Skip to main content

HeadTable

Struct HeadTable 

Source
pub struct HeadTable<'a> { /* private fields */ }
Expand description

Zero-copy view over the head table.

Field offsets (OpenType 1.9): version 0, fontRevision 4, checkSumAdjustment 8, magicNumber 12, flags 16, unitsPerEm 18, created 20, modified 28, xMin 36, yMin 38, xMax 40, yMax 42, macStyle 44, lowestRecPPEM 46, fontDirectionHint 48, indexToLocFormat 50, glyphDataFormat 52.

Implementations§

Source§

impl<'a> HeadTable<'a>

Source

pub fn parse(data: &'a [u8]) -> Result<Self, ParseError>

Parse and validate the head table bytes.

§Errors

ParseError::TruncatedTable when the table is shorter than 54 bytes; ParseError::InvalidUnitsPerEm when unitsPerEm is zero or above 16384; ParseError::InvalidGlyphFormat when indexToLocFormat is neither 0 (short) nor 1 (long).

Source

pub fn as_bytes(&self) -> &'a [u8] ⓘ

Raw table bytes.

Source

pub fn version(&self) -> Result<Version16Dot16, ParseError>

Table version (typically 1.0).

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn font_revision(&self) -> Result<Fixed, ParseError>

Font revision set by the font manufacturer.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn check_sum_adjustment(&self) -> Result<u32, ParseError>

Checksum adjustment; computed over the whole font with this field zeroed (0xB1B0AFBA - sum).

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn magic_number(&self) -> Result<u32, ParseError>

Magic number (0x5F0F3CF5).

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn flags(&self) -> Result<u16, ParseError>

head.flags — font-wide behavior bits (bit 11 signals a losslessly-transformed font, e.g. after WOFF2 decoding).

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn units_per_em(&self) -> Result<u16, ParseError>

Units per em: 16..=16384, validated nonzero.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn created(&self) -> Result<i64, ParseError>

International date (seconds since 1904-01-01) the font was created.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn modified(&self) -> Result<i64, ParseError>

International date (seconds since 1904-01-01) the font was modified.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn x_min(&self) -> Result<i16, ParseError>

Glyph bounding box: xMin.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn y_min(&self) -> Result<i16, ParseError>

Glyph bounding box: yMin.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn x_max(&self) -> Result<i16, ParseError>

Glyph bounding box: xMax.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn y_max(&self) -> Result<i16, ParseError>

Glyph bounding box: yMax.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn mac_style(&self) -> Result<u16, ParseError>

macStyle — bold (bit 0), italic (bit 1) style flags.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn lowest_rec_ppem(&self) -> Result<u16, ParseError>

Smallest readable size in pixels.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn font_direction_hint(&self) -> Result<i16, ParseError>

Deprecated font direction hint.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn index_to_loc_format(&self) -> Result<i16, ParseError>

0 = short (u16, offsets/2), 1 = long (u32) loca entries. Validated to be one of the two in parse.

§Errors

Truncation (structurally impossible post-parse).

Source

pub fn glyph_data_format(&self) -> Result<i16, ParseError>

Always 0; reserved for future glyph data formats.

§Errors

Truncation (structurally impossible post-parse).

Trait Implementations§

Source§

impl<'a> Clone for HeadTable<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for HeadTable<'a>

Source§

impl<'a> Debug for HeadTable<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for HeadTable<'a>

Source§

impl<'a> PartialEq for HeadTable<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for HeadTable<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for HeadTable<'a>

§

impl<'a> RefUnwindSafe for HeadTable<'a>

§

impl<'a> Send for HeadTable<'a>

§

impl<'a> Sync for HeadTable<'a>

§

impl<'a> Unpin for HeadTable<'a>

§

impl<'a> UnsafeUnpin for HeadTable<'a>

§

impl<'a> UnwindSafe for HeadTable<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.