DrawColorText
Text, Fonts, Color
Description
Draw text with authored COLR v0/v1 color vectors, gradient shadings, CPAL palettes, bitmap emojis and fallback fonts while retaining extractable text
Syntax
Delphi
Function TPDFlib.DrawColorText(XPos, YPos: Double; Const Text: WideString; Const VariationCoords: WideString= ''): Integer;Parameters
| XPos | Horizontal baseline origin in current page units |
|---|---|
| YPos | Vertical baseline origin in current page units |
| Text | Unicode text string including base characters and multi-codepoint emoji clusters |
| VariationCoords | Optional variable-font axis coordinates such as 'wght=900' for COLRv1 variation tables |
Return values
Returns 1 when text is drawn on the selected page, or 0 when no page is selected or input cannot be authored. Updates GetLastColorGlyphDiagnostics.
Remarks
Resolves color glyphs from the active font using CPAL palettes selected by SetColorGlyphPalette, tracking 0xFFFF foreground palette entries against the active text color set via SetTextColor.
Emits COLR v0 flat paths, COLR v1 transformed paths with affine transforms, linear and radial PDF shadings (/ShadingType 2 and 3), variable-font delta offsets, CBDT/sbix bitmap image XObjects, and automatic emoji fallback when enabled via SetColorGlyphMode.
Wraps each authored color cluster with an invisible Identity-H ToUnicode extract glyph and a /Span << /ActualText ... >> BDC ... EMC marked-content span so text extraction and copy-paste preserve the original Unicode sequence.
See also
SetColorGlyphPalette, GetColorGlyphPalette, GetFontColorPaletteCount, SetColorGlyphMode, SetColorEmojiFallbackFont, GetLastColorGlyphDiagnostics, DrawText