XFA Rich Text Wrapping

The rich text draw pipeline lays XHTML paragraph text into consecutive lines using the draw width, effective paragraph margins and the first-line textIndent

Words move together when their styled fragments fit a complete line, including words spanning adjacent span elements without an intervening space; words wider than a line split into measured prefixes, and UTF-16 surrogate pairs remain intact

Normal XHTML spaces, tabs and source line endings collapse to one space between words, and spaces at the beginning or end of a line are omitted; a br element forces a line break and consecutive breaks retain empty intermediate lines

Each line computes its own center or right alignment and common baseline; justified lines distribute spare width across actual word spaces after a soft wrap, while the final line and lines ended by br retain their natural spacing

The effective native para.lineHeight applies to every line and cannot reduce the line step below the text height; adjacent paragraph spacing is applied once around the complete paragraph

Inline font and color overrides survive line fragmentation, and nested styles inside a hyperlink remain effective; each positioned hyperlink fragment retains its destination and creates its own native PDF link rectangle

HPDFXFAFlatten uses the supplied TXFAMeasureTextFunc for fitting, with bounded prefix probes for oversized words; when no measurer is supplied, its fallback uses one half-em advance per Unicode scalar

THotPDF.ApplyXFAAsAcroForm uses the native font measurer and preserves runtime changes through XDP save and reload, including independent text, color and paragraph overrides on repeated instances

The current line breaker uses whitespace word boundaries and emergency scalar-safe splitting; full Unicode line-break and grapheme-cluster rules, additional CSS white-space modes, complete widget rich text editing and remaining decoration geometry continue as separate targets

Paragraph Geometry, Rich Text Property Overrides and ApplyXFAAsAcroForm