Skip to main content

FaceChain

Struct FaceChain 

Source
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

Source

pub fn new(primary: Face) -> Self

Build a chain from a single primary face. Use FaceChain::push_fallback (chainable) to append fallbacks.

Source

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).

Source

pub fn len(&self) -> usize

Number of faces in the chain (including the primary).

Source

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.

Source

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.

Source

pub fn primary(&self) -> &Face

Borrow the primary face — useful for size/metric queries.

Source

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().

Source

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).

Source

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.

Source

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.

Source

pub fn shape( &self, text: &str, size_px: f32, ) -> Result<Vec<PositionedGlyph>, Error>

Shape text with full chain fallback at default style (upright, regular).

Source

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).

Trait Implementations§

Source§

impl Debug for FaceChain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.