Struct owned_ttf_parser::PreParsedSubtables

source ·
pub struct PreParsedSubtables<'face, F> {
    pub face: F,
    pub(crate) subtables: FaceSubtables<'face>,
}
Expand description

A Face with cmap & kern subtables parsed once on initialization.

Provides much faster PreParsedSubtables::glyph_index & PreParsedSubtables::glyphs_hor_kerning methods compared to the .as_face_ref() equivalents that must parse their subtables on each call.

§Example

use owned_ttf_parser::{AsFaceRef, GlyphId, OwnedFace, PreParsedSubtables};

let owned_face = OwnedFace::from_vec(owned_font_data, 0).unwrap();
let faster_face = PreParsedSubtables::from(owned_face);

// Lookup a GlyphId using the pre-parsed cmap subtables
// this is much faster than doing: .as_face_ref().glyph_index('x')
assert_eq!(faster_face.glyph_index('x'), Some(GlyphId(91)));

// The rest of the methods are still available as normal
assert_eq!(faster_face.as_face_ref().ascender(), 2254);

Fields§

§face: F

Underlying face.

§subtables: FaceSubtables<'face>

Implementations§

source§

impl<F> PreParsedSubtables<'_, F>

source

pub fn glyph_index(&self, c: char) -> Option<GlyphId>

Maps a character to a GlyphId using pre-parsed unicode cmap subtables.

source

pub fn glyph_variation_index(&self, c: char, v: char) -> Option<GlyphId>

Maps a variation of a character to a GlyphId using pre-parsed unicode cmap subtables.

source

pub fn glyphs_hor_kerning(&self, first: GlyphId, second: GlyphId) -> Option<i16>

Returns horizontal kerning for a pair of glyphs using pre-parsed kern subtables.

Trait Implementations§

source§

impl<F> AsFaceRef for &PreParsedSubtables<'_, F>
where F: AsFaceRef,

source§

fn as_face_ref(&self) -> &Face<'_>

Convert to a Face reference.
source§

impl<F> AsFaceRef for PreParsedSubtables<'_, F>
where F: AsFaceRef,

source§

fn as_face_ref(&self) -> &Face<'_>

Convert to a Face reference.
source§

impl<'face, F: Clone> Clone for PreParsedSubtables<'face, F>

source§

fn clone(&self) -> PreParsedSubtables<'face, F>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<F> Debug for PreParsedSubtables<'_, F>

source§

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

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

impl<F> FaceMut for &mut PreParsedSubtables<'_, F>
where F: FaceMut,

source§

fn set_variation(&mut self, axis: Tag, value: f32) -> Option<()>

Sets a variation axis coordinate. Read more
source§

impl<F> FaceMut for PreParsedSubtables<'_, F>
where F: FaceMut,

source§

fn set_variation(&mut self, axis: Tag, value: f32) -> Option<()>

Sets a variation axis coordinate. Read more
source§

impl<'face> From<Face<'face>> for PreParsedSubtables<'face, Face<'face>>

source§

fn from(face: Face<'face>) -> Self

Converts to this type from the input type.
source§

impl From<OwnedFace> for PreParsedSubtables<'static, OwnedFace>

source§

fn from(face: OwnedFace) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'face, F> Freeze for PreParsedSubtables<'face, F>
where F: Freeze,

§

impl<'face, F> RefUnwindSafe for PreParsedSubtables<'face, F>
where F: RefUnwindSafe,

§

impl<'face, F> Send for PreParsedSubtables<'face, F>
where F: Send,

§

impl<'face, F> Sync for PreParsedSubtables<'face, F>
where F: Sync,

§

impl<'face, F> Unpin for PreParsedSubtables<'face, F>
where F: Unpin,

§

impl<'face, F> UnwindSafe for PreParsedSubtables<'face, F>
where F: UnwindSafe,

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> 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,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.