PeachDrawing.Core

PeachDrawing.Core.Canvas

Canvas.DrawString Method

Overloads  
DrawString(string, Font, PaintColor, PaintPoint, Size, double, FontPalette, Nullable<ShapeSettings>) Draw the given string using the given font and foreground color at given location.
DrawString(string, Font, PaintColor, PaintPoint, Size, double, FontPalette, Nullable<ShapeSettings>, string) Same as the other DrawString(string, Font, PaintColor, PaintPoint, Size, double, FontPalette, Nullable<ShapeSettings>) overload, plus logicalText: the true logical-order (pre-bidi-mirroring) source text str was derived from, when the two differ - null (the default) means they’re the same (the overwhelming common case: LTR text, or any word that was never reversed/mirrored for RTL display) and the real implementation should behave identically to the other overload. A word whose own Text WAS reversed/mirrored for RTL display (CssLayoutEngine.MirrorWordTextIfNeeded’s ordinary path - not an Arabic-family joining word, which never mutates its own text at all) passes its own stable PreMirrorText here, so the PDF’s ToUnicode CMap records each glyph’s true source character(s) rather than whichever reversed/mirrored character happens to occupy that glyph’s position in the *painted* string - see this overload’s own introduction for the real-world extraction corruption this fixes (a parenthesized RTL word extracting with its parentheses in the wrong position, confirmed against real MuPDF/PDFium output). A default (non-abstract) implementation forwarding to the other overload - ignoring logicalText - is deliberate: only a real PDF-writing backend needs to act on it; every other implementation (test mocks recording draw calls, measuring-only contexts) is unaffected by this overload’s mere existence and needs no changes to keep compiling/behaving identically.

Canvas.DrawString(string, Font, PaintColor, PaintPoint, Size, double, FontPalette, Nullable<ShapeSettings>) Method

Draw the given string using the given font and foreground color at given location.

public abstract void DrawString(string str, PeachDrawing.Core.Font font, PeachDrawing.Core.PaintColor color, PeachDrawing.Core.PaintPoint point, PeachDrawing.Core.Size size, double letterSpacing=0.0, PeachDrawing.Core.FontPalette? fontPalette=null, System.Nullable<PeachDrawing.Text.Shaping.ShapeSettings> features=null);

Parameters

str System.String

the string to draw

font Font

the font to use to draw the string

color PaintColor

the text color to set

point PaintPoint

the location to start string draw (top-left)

size Size

used to know the size of the rendered text for transparent text support

letterSpacing System.Double

extra space to add between each pair of adjacent characters (CSS letter-spacing), in the same units as point. 0 (the default/common case) must draw str as a single atomic string, identically to how this always worked before this parameter existed - implementations should only fall back to a slower per-character draw loop when this is non-zero.

fontPalette FontPalette

the resolved CSS font-palette selection (a CPAL palette index + per-entry color overrides) for a COLR/CPAL color font; null (the default/common case) selects palette 0 with no overrides, identical to how color-glyph drawing always worked before this parameter existed.

features System.Nullable<ShapeSettings>

which GSUB features (see ShapeSettings) to apply when shaping str - the resolved CSS font-variant-*/font-feature-settings values.

Canvas.DrawString(string, Font, PaintColor, PaintPoint, Size, double, FontPalette, Nullable<ShapeSettings>, string) Method

Same as the other DrawString(string, Font, PaintColor, PaintPoint, Size, double, FontPalette, Nullable<ShapeSettings>) overload, plus logicalText: the true logical-order (pre-bidi-mirroring) source text str was derived from, when the two differ - null (the default) means they’re the same (the overwhelming common case: LTR text, or any word that was never reversed/mirrored for RTL display) and the real implementation should behave identically to the other overload. A word whose own Text WAS reversed/mirrored for RTL display (CssLayoutEngine.MirrorWordTextIfNeeded’s ordinary path - not an Arabic-family joining word, which never mutates its own text at all) passes its own stable PreMirrorText here, so the PDF’s ToUnicode CMap records each glyph’s true source character(s) rather than whichever reversed/mirrored character happens to occupy that glyph’s position in the *painted* string - see this overload’s own introduction for the real-world extraction corruption this fixes (a parenthesized RTL word extracting with its parentheses in the wrong position, confirmed against real MuPDF/PDFium output).

A default (non-abstract) implementation forwarding to the other overload - ignoring logicalText - is deliberate: only a real PDF-writing backend needs to act on it; every other implementation (test mocks recording draw calls, measuring-only contexts) is unaffected by this overload’s mere existence and needs no changes to keep compiling/behaving identically.

public virtual void DrawString(string str, PeachDrawing.Core.Font font, PeachDrawing.Core.PaintColor color, PeachDrawing.Core.PaintPoint point, PeachDrawing.Core.Size size, double letterSpacing, PeachDrawing.Core.FontPalette? fontPalette, System.Nullable<PeachDrawing.Text.Shaping.ShapeSettings> features, string? logicalText);

Parameters

str System.String

font Font

color PaintColor

point PaintPoint

size Size

letterSpacing System.Double

fontPalette FontPalette

features System.Nullable<ShapeSettings>

logicalText System.String