pub trait OutlineContext<'a> {
// Required methods
fn glyph(&self, glyph: GlyphId) -> Option<LocaGlyph<'a>>;
fn glyph_variation_data(
&self,
glyph: GlyphId,
) -> Option<GlyphVariationData<'a>>;
fn has_gvar(&self) -> bool;
fn phantom_point_deltas(&self, glyph: GlyphId) -> Option<[Point<Fixed>; 4]>;
fn units_per_em(&self) -> u16;
fn h_metrics(&self, glyph: GlyphId) -> (i32, i32);
fn h_line_metrics(&self) -> (i32, i32);
// Provided methods
fn coords(&self) -> &[F2Dot14] { ... }
fn gvar_scalars(&self) -> &[Fixed] { ... }
fn v_metrics(&self, glyph: GlyphId) -> Option<(i32, i32)> { ... }
fn has_hvar(&self) -> bool { ... }
}Expand description
Everything OutlinePlan::load needs from a
font: glyphs, variation data, and the metrics behind the phantom points.
A caller that already holds these tables implements this trait and hands
them over. OutlineTables reads them from a font instead.
'a is the lifetime of the font data rather than of the context, so
glyphs outlive any borrow of the implementor.
Required Methods§
Sourcefn glyph(&self, glyph: GlyphId) -> Option<LocaGlyph<'a>>
fn glyph(&self, glyph: GlyphId) -> Option<LocaGlyph<'a>>
Returns the glyph with the given identifier, or None if it is empty.
Sourcefn glyph_variation_data(&self, glyph: GlyphId) -> Option<GlyphVariationData<'a>>
fn glyph_variation_data(&self, glyph: GlyphId) -> Option<GlyphVariationData<'a>>
Variation data for a glyph, or None if the font does not vary or the
glyph has none.
Sourcefn has_gvar(&self) -> bool
fn has_gvar(&self) -> bool
True if the font has a gvar table, whatever any one glyph has in it.
Answers for the font rather than per glyph, since it decides whether the delta buffers are needed at all.
Sourcefn phantom_point_deltas(&self, glyph: GlyphId) -> Option<[Point<Fixed>; 4]>
fn phantom_point_deltas(&self, glyph: GlyphId) -> Option<[Point<Fixed>; 4]>
Variation deltas for a glyph’s four phantom points.
SelectedGvar::phantom_point_deltas computes these from glyf/GLYF and loca/LOCA,
including which glyph of a composite tree supplies the metrics.
Sourcefn units_per_em(&self) -> u16
fn units_per_em(&self) -> u16
Design units per em.
Sourcefn h_metrics(&self, glyph: GlyphId) -> (i32, i32)
fn h_metrics(&self, glyph: GlyphId) -> (i32, i32)
Left side bearing and advance width, in font units.
These must be unvaried, straight out of hmtx and never adjusted by
HVAR. The loader applies gvar phantom point deltas to whatever this
returns, so varied metrics would be varied twice.
The phantom deltas arrive in the tuple accumulation the outline needs
anyway, which makes them cheaper than an HVAR lookup per glyph.
Sourcefn h_line_metrics(&self) -> (i32, i32)
fn h_line_metrics(&self) -> (i32, i32)
The ascender and descender of the line horizontal text sits on, in font units.
Only read when Self::v_metrics returns None, to derive that
glyph’s vertical metrics.
Provided Methods§
Sourcefn coords(&self) -> &[F2Dot14]
fn coords(&self) -> &[F2Dot14]
Normalized variation coordinates, empty for the default instance.
The context states the location so an implementor that holds one is never handed a different one.
Sourcefn gvar_scalars(&self) -> &[Fixed]
fn gvar_scalars(&self) -> &[Fixed]
Scalars for gvar’s shared tuples at Self::coords, as
SelectedGvar::compute_scalars fills them.
A scalar depends on the location and the tuple but never on the glyph, so an implementor reading many glyphs at one location computes these once. An empty or short slice is always correct; whatever is missing is computed per glyph.
These must be the scalars for Self::coords. Scalars from another
location produce wrong deltas and cannot be detected.
Sourcefn v_metrics(&self, glyph: GlyphId) -> Option<(i32, i32)>
fn v_metrics(&self, glyph: GlyphId) -> Option<(i32, i32)>
Top side bearing and vertical advance for a glyph, in font units.
None, the default, means the font states no per glyph vertical
metrics. They are then derived from Self::h_line_metrics and the
glyph’s bounding box, as FreeType does for a font without vmtx.
Like Self::h_metrics, these must be unvaried. The vertical phantom
points take their variation from gvar deltas.
Sourcefn has_hvar(&self) -> bool
fn has_hvar(&self) -> bool
True if the font has an HVAR table.
Phantom point deltas apply either way, per Self::h_metrics. This
only tells Scale26Dot6 to round them as
FreeType rounds HVAR metric deltas, so the output matches a FreeType
build that reads HVAR.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".