HPDFBuildHeadlessTextAppearance
function HPDFBuildHeadlessTextAppearance(const Text: UnicodeString;
const TrueTypeFont: SysUtils.TBytes; FirstObjectNumber: Integer;
const Options: THPDFHeadlessTextAppearanceOptions): THPDFHeadlessTextAppearance;
Builds a real Unicode Form XObject and its font objects using the shared HotPDF parser, object classes, cmap reader, actual TrueType advance and descriptor metadata, and optional HarfBuzz/FriBidi shaping
The returned bundle owns seven consecutive objects starting at a positive FirstObjectNumber; use the document appearance method for object registration, field links, encryption, and bounded incremental output
TrueType input requires named glyf/loca outlines, a consistent sfnt signature and head magic, ordered bounded glyph offsets, and a complete valid Unicode cmap contained inside its declared table extent; OpenType OTTO input can instead provide a bounded CFF 1 table with validated charset and collection metadata
Unicode lookup does not fall back to Symbol or MacRoman mappings; missing glyphs are rejected instead of replaced with a visually unrelated glyph
Direct horizontal text supports Latin, Greek, Cyrillic, simple CJK, precomposed Hangul, selected mathematical symbols, and isolated emoji when the supplied font contains each scalar
Multiline CR/LF layout, measured wrapping, comb cells, quarter-turn rotations, and rectangular or circular borders are controlled by the options record
With Multiline and WrapText enabled in direct unshaped layout, an ASCII space or TAB separator run consumed at a soft-wrap boundary does not create an extra separator-only blank line when its advance exceeds the remaining line width
Explicit CR/LF paragraph breaks retain their line structure, including intentional empty lines; whitespace that does not trigger a soft wrap retains its existing advances, and the source field value is not rewritten
With ShapeComplexText enabled, complex scripts, combining sequences, bidi, and ligatures use native HarfBuzz shaping and FriBidi run ordering; malformed surrogates, unsupported control characters, missing glyphs, invalid font permissions, and exhausted budgets remain errors
Complex glyphs receive individual positioning including shaping offsets, cluster-aware ToUnicode mappings, and marked-content ActualText retaining the logical source; extractors that ignore ActualText may return a different order or duplicate cluster text
Comb layout counts Unicode scalars rather than UTF-16 code units or output glyphs: a supplementary character uses one cell, and a shaped cluster covering k scalars occupies k cells in the complete text's bidi cell order
Glyphs within each comb cluster retain their relative HarfBuzz advances and offsets; the cluster is centred in its complete cell span using the combined horizontal extent of its natural advance, positioned glyph origins and glyph ink, with a shared baseline accounting for font metrics and ink extents
Automatic sizing fits shaped clusters to their cell spans and available height; fixed-size output retains widget clipping, CharacterSpacing and WordSpacing do not affect comb positioning, and separate clusters do not promise seamless cursive joins
Multiline text can combine TAB characters with complex shaping: TAB remains part of the complete paragraph's bidirectional context, while each physical line is reordered and reshaped before painting
A TAB advances the visual line cursor to the next stop on an eight-space grid measured from the supplied font at the effective size; it emits no glyph and receives no CharacterSpacing or WordSpacing addition
Wrapping respects shaped cluster and grapheme boundaries and recalculates tab stops on each line; the original field value and ActualText keep the logical source, including tabs and explicit paragraph breaks
Tabbed multiline shaping runs through the workspace-admitted HPDFShapeHeadlessTabbedTextWithWorkspace entry point, whose tab glyph records carry UnicodeText #9, GlyphID 0, and the measured advance; see headless workspace admission
Automatic font sizing recalculates shaping, fixed point spacing, wrapping and tab advances at each candidate size before checking the final logical width and metric height
Linux loads libharfbuzz.so.0 and libfribidi.so.0; Windows requires matching-architecture libharfbuzz-0.dll and libfribidi-0.dll, with optional explicit paths through HOTPDF_HARFBUZZ_LIBRARY and HOTPDF_FRIBIDI_LIBRARY
Full original font bytes are embedded with their actual PostScript name, bounds, ascent, descent, italic angle, and fixed-pitch flag; cap height uses OS/2 when available and otherwise the hhea ascender, while StemV uses a conservative fixed descriptor estimate
Installable or editable embedding is required; no-subsetting is honoured by full embedding, and restricted, preview-and-print, bitmap-only, absent, or unknown embedding permissions are rejected
The builder checks font bytes, glyph count, stream and dictionary sizes, scalar validity, and cancellation before returning an owned bundle
See THPDFHeadlessTextAppearanceOptions, THPDFHeadlessTextAppearance, and SetTextFieldValueWithAppearance
OpenType CFF 1 fonts are supported through the compact font appearance backend, preserving the full font, actual CID mapping, Unicode text, widths, and embedding policy