DrawColorText

Text, Fonts, Colour

Description

Draw text with authored COLR v0/v1 colour 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

XPosHorizontal baseline origin in current page units
YPosVertical baseline origin in current page units
TextUnicode text string including base characters and multi-codepoint emoji clusters
VariationCoordsOptional 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 colour glyphs from the active font using CPAL palettes selected by SetColorGlyphPalette, tracking 0xFFFF foreground palette entries against the active text colour 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 colour 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