function AddCidType2Text(const FontData: TBytes; const Glyphs: TPdfCidGlyphs; FontSize: Single; X, Y: Double; const Options: TPdfCidFontOptions; out Report: TPdfCidFontReport; Color: TColor = clBlack; Alpha: Byte = $FF): Boolean;
Loads caller-supplied TrueType or TrueType Collection data through PDFium's native CID Type 2 font loader and appends one or more positioned text objects to the active page
Each TPdfCidGlyph supplies a source glyph identifier, Unicode text, advance, and optional horizontal or vertical offset
Sequential CIDs isolate repeated glyph instances so the same glyph identifier can carry different Unicode cluster mappings
pcfemFull embeds the complete selected font, pcfemSubsetPreferred attempts a glyph-list subset and falls back to the complete font, and pcfemSubsetRequired rejects the operation if a safe subset cannot be produced
Subsetting always retains glyph zero, rejects output that would grow the font, and verifies that every requested original GID still exists before the data reaches PDFium
Native Free Pascal Linux and macOS targets use the optional HarfBuzz subsetting library while retaining glyph IDs; a missing library or unsafe subset is reported in SubsetErrorCode, and the embedding mode determines whether full-font fallback is permitted
TTCIndex selects a member of a TrueType Collection and must remain zero for a standalone font
A generated ToUnicode CMap maps every sequential CID to the supplied UnicodeText, including multi-code-unit ligature and supplementary-plane mappings
An empty mapping becomes U+200B so every CID remains extractable and observable
When VerifyExtraction is enabled, the method reopens the page text model, reads only the inserted objects, compares the result with ExpectedText, and rolls back all inserted objects on mismatch
TPdfCidFontOptions.Default picks pcfemSubsetPreferred as the EmbeddingMode, verifies extraction, limits font data to 64 MiB, glyph instances to 65,534, and MaxUnicodeCharacters to 1,048,576 mapped Unicode code units
TPdfCidFontReport records total glyph count and UniqueGlyphCount, OriginalFontBytes and EmbeddedFontBytes, SubsetAttempted, SubsetApplied, UsedFullFontFallback, SubsetErrorCode, FontEmbedded, expected and extracted text, and ExtractionMatches
Glyph positions are generated in linear time and glyphs sharing one baseline are emitted as one native text object
Differing vertical offsets use isolated text objects whilst preserving logical object order
Validation and subsetting finish before insertion, and any later native failure removes every object added by the call before page content is regenerated