One face’s slice of a per-glyph-fallback shaping result. A word
shaped through shape_with_fallback produces a Vec<WordSubRun>;
each sub-run is self-contained: its text is the source UTF-8 slice
covered by exactly this sub-run, its glyphs’ cluster offsets are
rebased to the sub-run’s local text (so plan_embedded can
build /ToUnicode without knowing about the parent word), and its
advance_pt is the sum of per-glyph advances at the requested
point size.
Convert a (font, byte_range, parent-relative glyphs) triple into
a fully-baked WordSubRun: slices parent_text to the sub-run’s
local string, rebases glyph clusters to that local string, sums
the advance.
Walk a rustybuzz-ordered LTR glyph stream and group consecutive
glyphs sharing the same cluster value. Each group’s byte range is
[c..c_next) where c_next is the next cluster’s start (or
text_len for the last cluster). The shaper currently forces LTR;
RTL support must revisit this monotonic-cluster assumption.
Single-sub-run packaging when no fallback retry was needed. Skips
the rebasing branch: the input glyphs already have cluster offsets
relative to local_text (which is the full parent text).
Shape text against font and return both the glyph stream and
the advance widths in user-space points. Callers that need only the
width can use text_width; callers that will also emit glyphs
downstream should use this to avoid shaping twice.
Shape text against primary with per-glyph fallback. Walks each
HarfBuzz cluster in the primary’s shaped output; clusters that
contain any .notdef (GID 0) glyph are re-shaped against each
embedded face in fallbacks in order. The first fallback to produce a
glyph stream with no .notdef wins the whole cluster (cluster-
granular replacement, never partial: partial replacement would
duplicate bases, drop marks, break ligatures).