Struct solstice_glyph::ab_glyph::FontRef[]

pub struct FontRef<'font>(_);

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

impl<'font> FontRef<'font>

pub fn try_from_slice(data: &'font [u8]) -> Result<FontRef<'font>, InvalidFont>

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"))?;

pub fn try_from_slice_and_index(
    data: &'font [u8],
    index: u32
) -> Result<FontRef<'font>, InvalidFont>

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

impl<'font> Clone for FontRef<'font>

impl<'_> Debug for FontRef<'_>

impl<'_> Font for FontRef<'_>

impl From<FontRef<'static>> for FontArc

Auto Trait Implementations

impl<'font> RefUnwindSafe for FontRef<'font>

impl<'font> Send for FontRef<'font>

impl<'font> Sync for FontRef<'font>

impl<'font> Unpin for FontRef<'font>

impl<'font> UnwindSafe for FontRef<'font>

Blanket Implementations

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

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

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

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

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

impl<T> Pointable for T

type Init = T

The type for initializers.

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

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>,