pub struct FaceChain { /* private fields */ }Expand description
Ordered chain of faces. Index 0 is the primary; index N is consulted
only if 0..N all returned .notdef for a codepoint.
Implementations§
Source§impl FaceChain
impl FaceChain
Sourcepub fn new(primary: Face) -> Self
pub fn new(primary: Face) -> Self
Build a chain from a single primary face. Use
FaceChain::push_fallback (chainable) to append fallbacks.
Sourcepub fn push_fallback(self, face: Face) -> Self
pub fn push_fallback(self, face: Face) -> Self
Append a fallback face to the end of the chain. Builder-style:
FaceChain::new(latin).push_fallback(cjk).push_fallback(emoji).
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True if the chain has no faces — never the case for chains
constructed via FaceChain::new, present only because clippy
rightly complains when len() exists alone.
Sourcepub fn face(&self, idx: u16) -> &Face
pub fn face(&self, idx: u16) -> &Face
Borrow face at idx. Panics if idx >= len() — the rasterizer
always reads face_idx from a PositionedGlyph produced by
this chain so the index is bounded by construction.
Sourcepub fn face_mut(&mut self, idx: usize) -> &mut Face
pub fn face_mut(&mut self, idx: usize) -> &mut Face
Mutably borrow face at idx. Used to flip per-face state like
variation coordinates without rebuilding the chain. Panics if
idx >= len().
Sourcepub fn set_variation_coords(&mut self, coords: &[f32]) -> Result<(), Error>
pub fn set_variation_coords(&mut self, coords: &[f32]) -> Result<(), Error>
Set the variation coordinates on the primary face (index 0).
Convenience wrapper around Face::set_variation_coords for
the common case of “shape this run at wght=600 / wdth=125”.
Mirrors Face::set_variation_coords’s clamp + length cap and
returns its error variant unchanged.
Fallback faces in the chain are NOT touched — call
FaceChain::face_mut explicitly if a fallback also needs
variation coords (rare in practice; fallback faces typically
cover a different script and are loaded from a static cut).
Sourcepub fn named_instances(&self, face_index: usize) -> Vec<NamedInstance>
pub fn named_instances(&self, face_index: usize) -> Vec<NamedInstance>
Named instances published by the face at face_index. Empty
vec when the face is static / OTF, or when the index is out of
range. Mirrors Face::named_instances for the chosen face.
Sourcepub fn variation_axes(&self, face_index: usize) -> Vec<VariationAxis>
pub fn variation_axes(&self, face_index: usize) -> Vec<VariationAxis>
Variation axes published by the face at face_index. Empty vec
when the face is static / OTF, or when the index is out of
range. Mirrors Face::variation_axes for the chosen face.
Sourcepub fn shape(
&self,
text: &str,
size_px: f32,
) -> Result<Vec<PositionedGlyph>, Error>
pub fn shape( &self, text: &str, size_px: f32, ) -> Result<Vec<PositionedGlyph>, Error>
Shape text with full chain fallback at default style (upright,
regular).
Sourcepub fn shape_styled(
&self,
text: &str,
size_px: f32,
_style: Style,
) -> Result<Vec<PositionedGlyph>, Error>
pub fn shape_styled( &self, text: &str, size_px: f32, _style: Style, ) -> Result<Vec<PositionedGlyph>, Error>
Shape text honouring style (italic / weight). The shear
derived from style is applied at rasterise-time, not at
shape-time — so glyph positions / advances stay identical
regardless of italic. This matches what desktop shapers do
(synthesised italic doesn’t change the metrics).