Wrapping, work and publication¶
ParagraphOptions supplies finite positive width/line height and physical
left/center/right alignment. Unicode 15 line opportunities are filtered through
Unicode 17 grapheme boundaries. Greedy fitting stops at the first overflowing
candidate, retains whitespace and its advance, and preserves an oversized first
unbreakable unit with overflows() == true. Width, alignment and overflow include
retained trailing whitespace advance, even when visible ink would fit. There is no forced split, clipping,
dictionary break, discretionary hyphen insertion or justification. Empty input
and adjacent/trailing hard separators retain empty lines and original separator
ranges. Lines expose logical source range, separator range, width, aligned
physical X/downward-Y baseline and visual runs. Runs expose script/level/direction,
actual face and stack index, shape and line-local X.
One construction shares at most 8192 coverage probes,16384 total backend shape
calls and 1024 measured candidate lines, including validations, discarded
candidates and empty lines. A bounded per-grapheme/direction choice cache avoids
repeated coverage probes. Successful work() reports exact admitted counts;
these counters do not measure CPU time. Candidate search can revisit a growing
prefix, so admitted work is width-dependent and not monotonic: wider geometry
can exhaust the whole-call budget even when narrower geometry succeeds. A
resize failure therefore preserves the consumer's prior image and publishes a
diagnostic; no automatic complexity-reducing fallback is applied. Each candidate and complete retained
output caps at 512 runs/16384 glyphs; output caps at 256 lines. Source/style/finite
arithmetic and caps validate before a complete immutable output is published.
Errors publish no partial layout. Font parser/shaper/bidi/line-break temporary
memory, allocation failure and latency are outside these counters; prepare on
UI/worker threads, never the audio callback.
SvgDrawing::fallback_paragraph consumes the exact faces and line/run origins,
with baseline/color, rolling back both document bytes and path-command counts
on any failure. With raster, RasterText::from_fallback_paragraph preflights
one owned geometry object under the aggregate 65536-command/device bounds before
publication. It can outlive fonts/layout. Existing draw_text then preflights
whole pixel work before touching the canvas. Selected TrueType glyf instances
remain exact; unsupported CFF/bitmap/color/hinting/ICC/display profiles are
separate. Existing renderer geometry limits can reject a valid layout.