pub trait FontFuncs {
// Provided methods
fn nominal_glyph(
&self,
font: &ShaperFont<'_, '_>,
c: u32,
) -> Option<GlyphId> { ... }
fn nominal_glyphs(
&self,
font: &ShaperFont<'_, '_>,
glyphs: NominalGlyphs<'_>,
) -> usize { ... }
fn variation_glyph(
&self,
font: &ShaperFont<'_, '_>,
c: u32,
vs: u32,
) -> Option<GlyphId> { ... }
fn glyph_h_advance(&self, font: &ShaperFont<'_, '_>, glyph: GlyphId) -> i32 { ... }
fn glyph_h_advances(
&self,
font: &ShaperFont<'_, '_>,
advances: Advances<'_>,
) { ... }
fn glyph_v_advance(&self, font: &ShaperFont<'_, '_>, glyph: GlyphId) -> i32 { ... }
fn glyph_v_origin(
&self,
font: &ShaperFont<'_, '_>,
glyph: GlyphId,
) -> (i32, i32) { ... }
fn glyph_extents(
&self,
font: &ShaperFont<'_, '_>,
glyph: GlyphId,
) -> Option<GlyphExtents> { ... }
}Expand description
Overrides character mapping and glyph metrics for a ShaperFont.
Scalar methods default to queries on the underlying font; batch methods
call their scalar counterparts. Implement only the callbacks that need
different behavior. Callbacks take &self; mutable state can be managed
by the implementation.
§Metrics scaling
All font metrics returned by these callbacks must be consistent with the
scale factor configured on ShaperFont.
If no scale is set, values must be in unscaled font units (i.e. the same
coordinate space as the font’s units_per_em). If a scale is set —
for example font_size * 64 for FreeType-style 26.6 — then all returned
values must already be in that scaled coordinate space.
Provided Methods§
Sourcefn nominal_glyph(&self, font: &ShaperFont<'_, '_>, c: u32) -> Option<GlyphId>
fn nominal_glyph(&self, font: &ShaperFont<'_, '_>, c: u32) -> Option<GlyphId>
Nominal character-to-glyph mapping callback.
Sourcefn nominal_glyphs(
&self,
font: &ShaperFont<'_, '_>,
glyphs: NominalGlyphs<'_>,
) -> usize
fn nominal_glyphs( &self, font: &ShaperFont<'_, '_>, glyphs: NominalGlyphs<'_>, ) -> usize
Batch nominal character-to-glyph mapping callback.
Maps a run of codepoints to glyphs, stopping at the first codepoint the font has no glyph for. Returns the number of consecutive codepoints mapped.
Sourcefn variation_glyph(
&self,
font: &ShaperFont<'_, '_>,
c: u32,
vs: u32,
) -> Option<GlyphId>
fn variation_glyph( &self, font: &ShaperFont<'_, '_>, c: u32, vs: u32, ) -> Option<GlyphId>
Variation-selector mapping callback.
Sourcefn glyph_h_advance(&self, font: &ShaperFont<'_, '_>, glyph: GlyphId) -> i32
fn glyph_h_advance(&self, font: &ShaperFont<'_, '_>, glyph: GlyphId) -> i32
Horizontal advance callback.
See “Metrics scaling” in the trait-level docs for details on what value this method should return.
Sourcefn glyph_h_advances(&self, font: &ShaperFont<'_, '_>, advances: Advances<'_>)
fn glyph_h_advances(&self, font: &ShaperFont<'_, '_>, advances: Advances<'_>)
Batch horizontal-advance callback.
See “Metrics scaling” in the trait-level docs for details on what value this method should return.
Sourcefn glyph_v_advance(&self, font: &ShaperFont<'_, '_>, glyph: GlyphId) -> i32
fn glyph_v_advance(&self, font: &ShaperFont<'_, '_>, glyph: GlyphId) -> i32
Vertical advance callback.
See “Metrics scaling” in the trait-level docs for details on what value this method should return.
Sourcefn glyph_v_origin(
&self,
font: &ShaperFont<'_, '_>,
glyph: GlyphId,
) -> (i32, i32)
fn glyph_v_origin( &self, font: &ShaperFont<'_, '_>, glyph: GlyphId, ) -> (i32, i32)
Vertical origin callback.
Returns the (x, y) coordinates of the vertical origin for the given glyph.
See “Metrics scaling” in the trait-level docs for details on what values this method should return.
Sourcefn glyph_extents(
&self,
font: &ShaperFont<'_, '_>,
glyph: GlyphId,
) -> Option<GlyphExtents>
fn glyph_extents( &self, font: &ShaperFont<'_, '_>, glyph: GlyphId, ) -> Option<GlyphExtents>
Glyph extents callback.
See “Metrics scaling” in the trait-level docs for details on what values this method should return.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".