pub struct FontRef<'font>(_);
Expand description

Font data handle stored as a &[u8] + parsed data. See Font for more methods.

Also see the owned version FontVec.

Example

use ab_glyph::{Font, FontRef};

let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?;

assert_eq!(font.glyph_id('s'), ab_glyph::GlyphId(56));

Implementations

Creates an FontRef from a byte-slice.

For font collections see FontRef::try_from_slice_and_index.

Example
let font = FontRef::try_from_slice(include_bytes!("../../dev/fonts/Exo2-Light.otf"))?;

Creates an FontRef from byte-slice.

You can set index for font collections. For simple fonts use 0 or FontRef::try_from_slice.

Example
let font =
    FontRef::try_from_slice_and_index(include_bytes!("../../dev/fonts/Exo2-Light.otf"), 0)?;

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Get the size of the font unit Read more
Unscaled glyph ascent. Read more
Unscaled glyph descent. Read more
Unscaled line gap. Read more
Lookup a GlyphId matching a given char. Read more
Unscaled horizontal advance for a given glyph id. Read more
Unscaled horizontal side bearing for a given glyph id. Read more
Unscaled vertical advance for a given glyph id. Read more
Unscaled vertical side bearing for a given glyph id. Read more
Returns additional unscaled kerning to apply for a particular pair of glyph ids. Read more
Compute unscaled glyph outline curves & bounding box.
The number of glyphs present in this font. Glyph identifiers for this font will always be in the range 0..self.glyph_count() Read more
Returns an iterator of all distinct (GlyphId, char) pairs. Not ordered. Read more
Returns a pre-rendered image of the glyph. Read more
Converts pt units into PxScale. Read more
Unscaled height ascent - descent. Read more
Returns the layout bounds of this glyph. These are different to the outline px_bounds(). Read more
Compute glyph outline ready for drawing.
Construct a PxScaleFontRef by associating with the given pixel scale. Read more
Move into a PxScaleFont associated with the given pixel scale. Read more
Converts to this type from the input type.
Sets a variation axis coordinate value by it’s tag. Read more
Returns variation axes. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.