pub struct Font {
pub handle: PlatformFont,
pub template: FontTemplateRef,
pub metrics: FontMetrics,
pub descriptor: FontDescriptor,
shaper: OnceLock<Shaper>,
cached_shape_data: RwLock<CachedShapeData>,
pub font_key: FontInstanceKey,
pub synthesized_small_caps: Option<FontRef>,
has_color_bitmap_or_colr_table: OnceLock<bool>,
}
Fields§
§handle: PlatformFont
§template: FontTemplateRef
§metrics: FontMetrics
§descriptor: FontDescriptor
§shaper: OnceLock<Shaper>
§cached_shape_data: RwLock<CachedShapeData>
§font_key: FontInstanceKey
§synthesized_small_caps: Option<FontRef>
If this is a synthesized small caps font, then this font reference is for the version of the font used to replace lowercase ASCII letters. It’s up to the consumer of this font to properly use this reference.
has_color_bitmap_or_colr_table: OnceLock<bool>
Whether or not this font supports color bitmaps or a COLR table. This is essentially equivalent to whether or not we use it for emoji presentation. This is cached, because getting table data is expensive.
Implementations§
source§impl Font
impl Font
pub fn new( template: FontTemplateRef, descriptor: FontDescriptor, synthesized_small_caps: Option<FontRef>, ) -> Result<Font, &'static str>
sourcepub fn identifier(&self) -> FontIdentifier
pub fn identifier(&self) -> FontIdentifier
A unique identifier for the font, allowing comparison.
pub fn webrender_font_instance_flags(&self) -> FontInstanceFlags
pub fn has_color_bitmap_or_colr_table(&self) -> bool
source§impl Font
impl Font
pub fn shape_text( &self, text: &str, options: &ShapingOptions, ) -> Arc<GlyphStore>
fn shape_text_harfbuzz( &self, text: &str, options: &ShapingOptions, glyphs: &mut GlyphStore, )
fn can_do_fast_shaping(&self, text: &str, options: &ShapingOptions) -> bool
sourcefn shape_text_fast(
&self,
text: &str,
options: &ShapingOptions,
glyphs: &mut GlyphStore,
)
fn shape_text_fast( &self, text: &str, options: &ShapingOptions, glyphs: &mut GlyphStore, )
Fast path for ASCII text that only needs simple horizontal LTR kerning.
pub fn table_for_tag(&self, tag: FontTableTag) -> Option<FontTable>
pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId>
pub fn has_glyph_for(&self, codepoint: char) -> bool
pub fn glyph_h_kerning( &self, first_glyph: GlyphId, second_glyph: GlyphId, ) -> FractionalPixel
pub fn glyph_h_advance(&self, glyph_id: GlyphId) -> FractionalPixel
pub fn typographic_bounds(&self, glyph_id: GlyphId) -> Rect<f32>
pub fn get_baseline(&self) -> Option<FontBaseline>
Trait Implementations§
source§impl MallocSizeOf for Font
impl MallocSizeOf for Font
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
Auto Trait Implementations§
impl !Freeze for Font
impl !RefUnwindSafe for Font
impl Send for Font
impl Sync for Font
impl Unpin for Font
impl !UnwindSafe for Font
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert