pub enum FontOrRef<T> {
Font(T),
Ref(FontRef),
}Expand description
Enum that wraps either a fontconfig-resolved font (T) or a direct FontRef.
This allows the shaping code to handle both fontconfig-resolved fonts and embedded fonts (FontRef) uniformly through the ParsedFontTrait interface.
Variants§
Font(T)
A font loaded via fontconfig
Ref(FontRef)
A direct FontRef (embedded font, bypasses fontconfig)
Trait Implementations§
Source§impl<T: ParsedFontTrait> ParsedFontTrait for FontOrRef<T>
impl<T: ParsedFontTrait> ParsedFontTrait for FontOrRef<T>
Source§fn shape_text(
&self,
text: &str,
script: Script,
language: Language,
direction: BidiDirection,
style: &StyleProperties,
) -> Result<Vec<Glyph>, LayoutError>
fn shape_text( &self, text: &str, script: Script, language: Language, direction: BidiDirection, style: &StyleProperties, ) -> Result<Vec<Glyph>, LayoutError>
Shape the given text into a sequence of glyphs using the font’s shaping tables.
Source§fn get_hash(&self) -> u64
fn get_hash(&self) -> u64
Hash of the font, necessary for breaking layouted glyphs into glyph runs
Source§fn get_glyph_size(&self, glyph_id: u16, font_size: f32) -> Option<LogicalSize>
fn get_glyph_size(&self, glyph_id: u16, font_size: f32) -> Option<LogicalSize>
Returns the size of a glyph at the given font size, or
None if the glyph is missing.Source§fn get_hyphen_glyph_and_advance(&self, font_size: f32) -> Option<(u16, f32)>
fn get_hyphen_glyph_and_advance(&self, font_size: f32) -> Option<(u16, f32)>
Returns the glyph ID and horizontal advance of the hyphen character at the given font size.
Source§fn get_kashida_glyph_and_advance(&self, font_size: f32) -> Option<(u16, f32)>
fn get_kashida_glyph_and_advance(&self, font_size: f32) -> Option<(u16, f32)>
Returns the glyph ID and horizontal advance of the kashida (tatweel) character.
Source§fn has_glyph(&self, codepoint: u32) -> bool
fn has_glyph(&self, codepoint: u32) -> bool
Returns whether the font contains a glyph for the given Unicode codepoint.
Source§fn get_vertical_metrics(&self, glyph_id: u16) -> Option<VerticalMetrics>
fn get_vertical_metrics(&self, glyph_id: u16) -> Option<VerticalMetrics>
Returns vertical metrics (ascent, descent, line gap) for a specific glyph.
Source§fn get_font_metrics(&self) -> LayoutFontMetrics
fn get_font_metrics(&self) -> LayoutFontMetrics
Returns the global font metrics (ascent, descent, units per em, etc.).
Source§fn num_glyphs(&self) -> u16
fn num_glyphs(&self) -> u16
Returns the total number of glyphs in the font.
Source§fn get_space_width(&self) -> Option<usize>
fn get_space_width(&self) -> Option<usize>
Returns the advance width of the space character (U+0020) in font units,
or None if the font doesn’t have a space glyph.
Source§impl<T: ParsedFontTrait> ShallowClone for FontOrRef<T>
impl<T: ParsedFontTrait> ShallowClone for FontOrRef<T>
Source§fn shallow_clone(&self) -> Self
fn shallow_clone(&self) -> Self
Create a shallow clone (increment reference count, don’t copy data)
Auto Trait Implementations§
impl<T> Freeze for FontOrRef<T>where
T: Freeze,
impl<T> RefUnwindSafe for FontOrRef<T>where
T: RefUnwindSafe,
impl<T> Send for FontOrRef<T>where
T: Send,
impl<T> Sync for FontOrRef<T>where
T: Sync,
impl<T> Unpin for FontOrRef<T>where
T: Unpin,
impl<T> UnsafeUnpin for FontOrRef<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for FontOrRef<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more