[][src]Struct ttf_parser::Font

pub struct Font<'a> { /* fields omitted */ }

A font data handle.

Methods

impl<'a> Font<'a>[src]

pub fn glyph_index(&self, c: char) -> Result<u16, Error>[src]

Resolves Glyph ID for code point.

Returns Error::NoGlyph instead of 0 when glyph is not found.

impl<'a> Font<'a>[src]

pub fn glyph(&self, glyph_id: u16) -> Result<Glyph, Error>[src]

Returns a glyph handle.

impl<'a> Font<'a>[src]

pub fn glyph_hor_metrics(&self, glyph_id: u16) -> Option<HorizontalMetrics>[src]

Returns glyph's horizontal metrics.

Returns None when font doesn't have such glyph_id.

impl<'a> Font<'a>[src]

pub fn underline_metrics(&self) -> LineMetrics[src]

Parses font's underline metrics set in the post table.

impl<'a> Font<'a>[src]

pub fn units_per_em(&self) -> Option<u16>[src]

Returns font's units per EM set in the head table.

Returns None if value is not in a 16..16384 range.

impl<'a> Font<'a>[src]

pub fn ascender(&self) -> i16[src]

Returns font's ascender set in the hhea table.

pub fn descender(&self) -> i16[src]

Returns font's descender set in the hhea table.

pub fn height(&self) -> i16[src]

Returns font's height.

pub fn line_gap(&self) -> i16[src]

Returns font's line gap set in the hhea table.

impl<'a> Font<'a>[src]

pub fn from_data(data: &'a [u8], index: u32) -> Result<Self, Error>[src]

Creates a Font object from raw data.

You can set index in case of font collections. For simple ttf fonts set index to 0.

This function only parses font tables, so it's relatively light.

Required tables: cmap, glyp, head, hhea, hmtx, loca, post.

Optional tables: GDEF, name, OS/2

pub fn number_of_glyphs(&self) -> u16[src]

Returns a total number of glyphs in the font.

The value was already parsed, so this function doesn't involve any parsing.

pub fn is_valid(&self) -> Result<(), Error>[src]

Checks tables checksum.

Checks only used tables.

pub fn os2_table(&self) -> Option<Table>[src]

Returns a handle to a OS/2 table.

pub fn name_table(&self) -> Option<Table>[src]

Returns a handle to a name table.

pub fn gdef_table(&self) -> Option<Table>[src]

Returns a handle to a GDEF table.

Trait Implementations

impl<'a> Clone for Font<'a>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<'a> Send for Font<'a>

impl<'a> Sync for Font<'a>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]