Skip to main content

Module shape

Module shape 

Source

Structs§

ClusterGroup 🔒
Internal: one HarfBuzz cluster’s worth of primary-shaped glyphs plus the cluster’s source byte range.
ClusterResolution 🔒
Internal: one cluster’s resolution after fallback retry. glyphs carry cluster offsets into the parent word text.
ShapedRun
Output of shape_text: the shaped glyph stream and the total advance width at the requested point size.
WordSubRun
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 glyphscluster 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.

Functions§

embedded_upem 🔒
units_per_em for an embedded face.
finalize_subrun 🔒
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.
group_clusters 🔒
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.
into_subrun 🔒
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
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_with_fallback
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).