pub struct ShaperFont<'a, 'f> {
font: &'a Font,
ot: OtData<'a>,
aat: AatData<'a>,
units_per_em: u16,
apply_trak: bool,
charmap: Charmap<'a>,
glyph_metrics: OnceLock<GlyphMetrics<'a>>,
cmap_cache: Option<&'a CacheCore<KEY_BITS, VALUE_BITS, CACHE_SIZE, <() as SelectAtomic<STORAGE_BITS>>::Type>>,
symbol_font_page: OnceLock<u16>,
pub(crate) scale: Scale,
funcs: Option<&'f dyn FontFuncs>,
}Expand description
Fields§
§font: &'a Font§ot: OtData<'a>§aat: AatData<'a>§units_per_em: u16§apply_trak: bool§charmap: Charmap<'a>§glyph_metrics: OnceLock<GlyphMetrics<'a>>§cmap_cache: Option<&'a CacheCore<KEY_BITS, VALUE_BITS, CACHE_SIZE, <() as SelectAtomic<STORAGE_BITS>>::Type>>§symbol_font_page: OnceLock<u16>§scale: Scale§funcs: Option<&'f dyn FontFuncs>Implementations§
Source§impl<'a, 'f> ShaperFont<'a, 'f>
impl<'a, 'f> ShaperFont<'a, 'f>
Sourcepub fn new(font: &'a Font) -> Self
pub fn new(font: &'a Font) -> Self
Prepares a font for shaping, reusing its cached layout data.
Sourcepub fn normalized_coords(&self) -> &[NormalizedCoord] ⓘ
pub fn normalized_coords(&self) -> &[NormalizedCoord] ⓘ
Returns the currently active normalized coordinates.
Sourcepub fn with_scale(self, scale: i32) -> Self
pub fn with_scale(self, scale: i32) -> Self
Returns a new shaping font with the same scale applied to both axes.
Sourcepub fn set_scale_separate(&mut self, x_scale: i32, y_scale: i32)
pub fn set_scale_separate(&mut self, x_scale: i32, y_scale: i32)
Sets independent horizontal and vertical scales.
Sourcepub fn with_scale_separate(self, x_scale: i32, y_scale: i32) -> Self
pub fn with_scale_separate(self, x_scale: i32, y_scale: i32) -> Self
Returns a new shaping font with independent horizontal and vertical scales applied.
Sourcepub fn set_font_funcs(&mut self, funcs: Option<&'f dyn FontFuncs>)
pub fn set_font_funcs(&mut self, funcs: Option<&'f dyn FontFuncs>)
Replaces the callbacks used for effective font queries.
Sourcepub fn with_font_funcs(self, funcs: Option<&'f dyn FontFuncs>) -> Self
pub fn with_font_funcs(self, funcs: Option<&'f dyn FontFuncs>) -> Self
Returns a new shaping font with the specified font function callbacks.
Sourcepub fn glyph_name(&self, glyph: GlyphId) -> Option<GlyphName>
pub fn glyph_name(&self, glyph: GlyphId) -> Option<GlyphName>
Returns the name stored for a glyph in the font, if any.
Sourcepub fn nominal_glyph(&self, codepoint: u32) -> Option<GlyphId>
pub fn nominal_glyph(&self, codepoint: u32) -> Option<GlyphId>
Maps a character through the configured callbacks.
Sourcepub fn default_nominal_glyph(&self, codepoint: u32) -> Option<GlyphId>
pub fn default_nominal_glyph(&self, codepoint: u32) -> Option<GlyphId>
Maps a character using the font’s own charmap.
Sourcepub fn nominal_glyphs(&self, glyphs: NominalGlyphs<'_>) -> usize
pub fn nominal_glyphs(&self, glyphs: NominalGlyphs<'_>) -> usize
Maps a batch of codepoints through the configured callbacks.
Sourcepub fn default_nominal_glyphs(&self, glyphs: NominalGlyphs<'_>) -> usize
pub fn default_nominal_glyphs(&self, glyphs: NominalGlyphs<'_>) -> usize
Maps a batch of codepoints using the font’s own charmap.
Sourcepub fn variation_glyph(&self, codepoint: u32, selector: u32) -> Option<GlyphId>
pub fn variation_glyph(&self, codepoint: u32, selector: u32) -> Option<GlyphId>
Maps a character and variation selector through the configured callbacks.
Sourcepub fn default_variation_glyph(
&self,
codepoint: u32,
selector: u32,
) -> Option<GlyphId>
pub fn default_variation_glyph( &self, codepoint: u32, selector: u32, ) -> Option<GlyphId>
Maps a variation sequence using the font’s own charmap.
Sourcepub fn glyph_h_advance(&self, glyph: GlyphId) -> i32
pub fn glyph_h_advance(&self, glyph: GlyphId) -> i32
Returns the effective horizontal advance.
Sourcepub fn default_glyph_h_advance(&self, glyph: GlyphId) -> i32
pub fn default_glyph_h_advance(&self, glyph: GlyphId) -> i32
Returns the scaled horizontal advance from the font’s own tables.
Sourcepub fn glyph_h_advances(&self, advances: Advances<'_>)
pub fn glyph_h_advances(&self, advances: Advances<'_>)
Writes effective horizontal advances for a batch of glyphs.
Sourcepub fn default_glyph_h_advances(&self, advances: Advances<'_>)
pub fn default_glyph_h_advances(&self, advances: Advances<'_>)
Writes scaled horizontal advances from the font’s own tables.
Sourcepub fn glyph_v_advance(&self, glyph: GlyphId) -> i32
pub fn glyph_v_advance(&self, glyph: GlyphId) -> i32
Returns the effective vertical advance.
Sourcepub fn default_glyph_v_advance(&self, glyph: GlyphId) -> i32
pub fn default_glyph_v_advance(&self, glyph: GlyphId) -> i32
Returns the scaled vertical advance from the font’s own tables.
Sourcepub fn glyph_v_origin(&self, glyph: GlyphId) -> (i32, i32)
pub fn glyph_v_origin(&self, glyph: GlyphId) -> (i32, i32)
Returns the effective vertical origin.
Sourcepub fn default_glyph_v_origin(&self, glyph: GlyphId) -> (i32, i32)
pub fn default_glyph_v_origin(&self, glyph: GlyphId) -> (i32, i32)
Returns the scaled vertical origin from the font’s own tables.
Sourcepub fn glyph_extents(&self, glyph: GlyphId) -> Option<GlyphExtents>
pub fn glyph_extents(&self, glyph: GlyphId) -> Option<GlyphExtents>
Returns the effective glyph extents.
Sourcepub fn default_glyph_extents(&self, glyph: GlyphId) -> Option<GlyphExtents>
pub fn default_glyph_extents(&self, glyph: GlyphId) -> Option<GlyphExtents>
Returns the scaled glyph extents from the font’s own tables.
Source§impl<'a> ShaperFont<'a, '_>
impl<'a> ShaperFont<'a, '_>
pub(crate) fn layout(&self) -> LayoutData<'_>
pub(crate) fn has_glyph(&self, codepoint: u32) -> bool
fn cmap_cache( &self, ) -> Option<&CacheCore<KEY_BITS, VALUE_BITS, CACHE_SIZE, <() as SelectAtomic<STORAGE_BITS>>::Type>>
fn symbol_font_page(&self) -> u16
fn glyph_metrics(&self) -> ScaledGlyphMetrics<'a, 'static, Scale>
fn map_unicode(&self, codepoint: u32) -> Option<GlyphId>
Methods from Deref<Target = Font>§
Sourcepub fn axes(&self) -> Axes<'_>
pub fn axes(&self) -> Axes<'_>
Returns the font’s variation axes, which are empty if the font is not variable.
Sourcepub fn named_instances(&self) -> NamedInstances<'_>
pub fn named_instances(&self) -> NamedInstances<'_>
Returns the named instances defined by the font.
Sourcepub fn instance_builder(&self) -> InstanceBuilder
pub fn instance_builder(&self) -> InstanceBuilder
Returns a builder for another instance of the same font.
The two share everything the location does not change, so deriving one instance from another costs no more than reading the tables once.
Sourcepub fn default_instance(&self) -> Font
pub fn default_instance(&self) -> Font
Returns this font at its default location.
Sourcepub fn normalized_coords(&self) -> &[F2Dot14]
pub fn normalized_coords(&self) -> &[F2Dot14]
Returns the normalized variation coordinates for this font instance.
Sourcepub fn feature_variations(&self) -> SelectedFeatureVariations
pub fn feature_variations(&self) -> SelectedFeatureVariations
Returns the layout feature variations this instance selects.
Sourcepub fn num_glyphs(&self) -> u32
pub fn num_glyphs(&self) -> u32
Returns the number of glyphs in the font.
Fixed for the font: no location varies it.
Sourcepub fn units_per_em(&self) -> u16
pub fn units_per_em(&self) -> u16
Returns the size of the em square, in font units.
Fixed for the font: no location varies it.
Sourcepub fn default_attributes(&self) -> Attributes
pub fn default_attributes(&self) -> Attributes
Returns the width, style and weight of the default instance.
For an SFNT font, these come from the OS/2 table, with the post
italic angle for an oblique style. If there is no OS/2 table, they
come from head. These tables do not vary, so every instance of a
variable font returns the same values. To get the attributes at a
location, use Attributes::from_variations.
For a Type 1 or standalone CFF font, these come from the Weight name
and ItalicAngle.
Sourcepub fn is_hint_reliant(&self) -> bool
pub fn is_hint_reliant(&self) -> bool
Returns true if the font needs its TrueType instructions to draw
correct contours.
Such fonts are often called “tricky”. They are recognized by family name
or by the checksums of the cvt, fpgm and prep tables, and only
fonts with glyf outlines qualify. The result is computed once and
cached. See is_hint_reliant.
Sourcepub fn glyph_name(&self, glyph: GlyphId) -> Option<GlyphName>
pub fn glyph_name(&self, glyph: GlyphId) -> Option<GlyphName>
Returns the name of a glyph, synthesizing gidNNN if none is stored.
Returns None for a glyph outside the font.
Sourcepub fn glyph_names(&self) -> impl Iterator<Item = (GlyphId, GlyphName)>
pub fn glyph_names(&self) -> impl Iterator<Item = (GlyphId, GlyphName)>
Returns the identifier and name of every glyph in the font.
Names come from post, then CFF, or from Type 1 charstrings. A
missing name is synthesized as gidNNN.
Sourcepub fn glyph_by_name(&self, name: &str) -> Option<GlyphId>
pub fn glyph_by_name(&self, name: &str) -> Option<GlyphId>
Returns the glyph named name.
Names come from the same sources as glyph_names,
but a synthesized gidNNN name matches nothing. Where several glyphs
share a name, the first is returned.
The first call sorts the font’s names, and later calls search them.
Sourcepub fn is_cid_keyed(&self) -> bool
pub fn is_cid_keyed(&self) -> bool
Returns true if the font is a standalone CID-keyed CFF font, whose
glyphs are identified by CID.
A CFF table in an SFNT font may be CID-keyed too, but its glyphs
are identified by glyph index, as in any SFNT font.
Sourcepub fn max_cid(&self) -> Option<u32>
pub fn max_cid(&self) -> Option<u32>
Returns the largest CID that a CID-keyed font maps to a glyph.
Glyphs in a CID-keyed font can be addressed by CID, so one more than
this value is the number of addressable glyph IDs. Returns None if the
font is not CID-keyed.
Sourcepub fn glyph_by_cid(&self, cid: u32) -> Option<GlyphId>
pub fn glyph_by_cid(&self, cid: u32) -> Option<GlyphId>
Returns the glyph for cid in a CID-keyed font.
Where several glyphs have the same CID, the first is returned. Returns
None if the font is not CID-keyed or no glyph has cid.
The first call builds a table from each CID to its glyph.
Sourcepub fn metrics(&self) -> &Metrics
pub fn metrics(&self) -> &Metrics
Returns the metrics describing the font as a whole, at this instance’s location.
Sourcepub fn style_metrics(&self) -> &StyleMetrics
pub fn style_metrics(&self) -> &StyleMetrics
Returns the font’s style measurements at this instance’s location.
This reads post when requested; metrics does not.
Sourcepub fn glyph_metrics(&self) -> GlyphMetrics<'_>
pub fn glyph_metrics(&self) -> GlyphMetrics<'_>
Returns measurements of individual glyphs, at this instance’s location.
Sourcepub fn outline_glyphs(&self) -> OutlineGlyphs<'_>
pub fn outline_glyphs(&self) -> OutlineGlyphs<'_>
Returns the font’s outlines, using the source order in
GlyphSourceOrder::DEFAULT.
Sourcepub fn outline_glyphs_with(&self, order: GlyphSourceOrder) -> OutlineGlyphs<'_>
pub fn outline_glyphs_with(&self, order: GlyphSourceOrder) -> OutlineGlyphs<'_>
Returns the font’s outlines, using the source order in order.
The first of Glyf, Cff2, Cff and Type1 that the font has
becomes the base source for every glyph. If Varc comes before the
base source, it applies to the glyphs it covers, and their components
are drawn from the base source. Sources that are not outlines are
ignored.
Sourcepub fn bitmap_strikes(&self) -> BitmapStrikes<'_>
pub fn bitmap_strikes(&self) -> BitmapStrikes<'_>
Returns the font’s bitmaps, from the first of sbix, CBDT and
EBDT that the font has.
Sourcepub fn bitmap_strikes_with(&self, order: GlyphSourceOrder) -> BitmapStrikes<'_>
pub fn bitmap_strikes_with(&self, order: GlyphSourceOrder) -> BitmapStrikes<'_>
Returns the font’s bitmaps, using the source order in order.
The bitmaps come from the first of Sbix, Cbdt and Ebdt in
order that the font has. Sources that are not bitmaps are ignored.
Sourcepub fn color_glyphs(&self) -> ColorGlyphs<'_>
pub fn color_glyphs(&self) -> ColorGlyphs<'_>
Returns the font’s color glyphs.
Trait Implementations§
Source§impl<'a, 'f> Clone for ShaperFont<'a, 'f>
impl<'a, 'f> Clone for ShaperFont<'a, 'f>
Source§fn clone(&self) -> ShaperFont<'a, 'f>
fn clone(&self) -> ShaperFont<'a, 'f>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more