pub struct Ligatures { /* private fields */ }Expand description
Parsed GSUB liga standard ligatures for a font. Built once via
Font::gsub_ligatures; Ligatures::substitute applies them.
Implementations§
Source§impl Ligatures
impl Ligatures
Sourcepub fn rule_start_glyphs(&self) -> impl Iterator<Item = &u16>
pub fn rule_start_glyphs(&self) -> impl Iterator<Item = &u16>
Glyph ids that begin some ligature rule (the keys of the rule map).
Callers shaping ASCII text use this to prove substitute is an identity
for a given string: if no glyph in the string starts a rule, the
substitution is a no-op.
Sourcepub fn max_rule_len(&self) -> usize
pub fn max_rule_len(&self) -> usize
Total glyph length (first glyph + components) of the longest ligature rule. Incremental shapers use it as the settle window: an input suffix shorter than this cannot complete a rule that starts before it, so decisions before the window are final.
Sourcepub fn substitute(&self, gids: &[u16]) -> Vec<u16>
pub fn substitute(&self, gids: &[u16]) -> Vec<u16>
Apply ligature substitution to a glyph-id sequence (greedy longest match), returning the shaped sequence (which may contain ligature glyph ids that no single character maps to).
Sourcepub fn substitute_with_spans(&self, gids: &[u16]) -> Vec<(u16, usize)>
pub fn substitute_with_spans(&self, gids: &[u16]) -> Vec<(u16, usize)>
Like Ligatures::substitute but pairs each output glyph with the number
of input glyphs it consumed (1 for a pass-through, N for an N-component
ligature) — so callers can map a ligature back to its source characters
(e.g. to build a ToUnicode entry).
Sourcepub fn substitute_with_spans_into(
&self,
gids: &[u16],
out: &mut Vec<(u16, usize)>,
)
pub fn substitute_with_spans_into( &self, gids: &[u16], out: &mut Vec<(u16, usize)>, )
Into-scratch Ligatures::substitute_with_spans: identical decisions
and output, but appends into a caller-owned buffer (cleared first) so
repeat shapers reuse one allocation across runs instead of returning a
fresh Vec per call.