Method DrawText
- Namespace
- PaintDotNet.Direct2D1
- Assembly
- PaintDotNet.Windows.dll
DrawText(string, ITextFormat, RectFloat, IDeviceBrush, DrawTextOptions, TextMeasuringMode)
Draws the specified text using the format information provided by an ITextFormat object.
void DrawText(string text, ITextFormat textFormat, RectFloat layoutRect, IDeviceBrush defaultFillBrush, DrawTextOptions options = DrawTextOptions.EnableColorFont, TextMeasuringMode measuringMode = TextMeasuringMode.Natural)
Parameters
text
stringThe text to draw.
textFormat
ITextFormatAn object that describes formatting details of the text to draw, such as the font, the font size, and flow direction.
layoutRect
RectFloatThe size and position of the area in which the text is drawn.
defaultFillBrush
IDeviceBrushThe brush used to paint the text.
options
DrawTextOptionsA value that indicates whether the text should be snapped to pixel boundaries, whether the text should be clipped to the layout rectangle, and whether colored glyphs are enabled.
measuringMode
TextMeasuringModeA value that indicates how glyph metrics are used to measure text when it is formatted.
Remarks
To create an ITextFormat object, retrieve an IDirectWriteFactory object and call its CreateTextFormat(string, IFontCollection?, FontWeight, FontStyle, FontStretch, float, string?) method.
DrawText(string, ITextFormat, RectFloat, IDeviceBrush?, ISvgGlyphStyle?, int, DrawTextOptions, TextMeasuringMode)
Draws the text within the given layout rectangle.
By default, this method performs baseline snapping and renders color versions of glyphs in color fonts.
void DrawText(string text, ITextFormat textFormat, RectFloat layoutRect, IDeviceBrush? defaultFillBrush, ISvgGlyphStyle? svgGlyphStyle, int colorPaletteIndex = 0, DrawTextOptions options = DrawTextOptions.EnableColorFont, TextMeasuringMode measuringMode = TextMeasuringMode.Natural)
Parameters
text
stringThe text to draw.
textFormat
ITextFormatAn object that describes formatting details of the text to draw, such as the font, the font size, and flow direction.
layoutRect
RectFloatThe size and position of the area in which the text is drawn.
defaultFillBrush
IDeviceBrushThe brush used to paint the text.
svgGlyphStyle
ISvgGlyphStyleValues for context-fill, context-stroke, and context-value that are used when rendering SVG glyphs.
colorPaletteIndex
intThe index used to select a color palette within a color font.
options
DrawTextOptionsA value that indicates whether the text should be snapped to pixel boundaries, whether the text should be clipped to the layout rectangle, and whether colored glyphs are enabled.
measuringMode
TextMeasuringModeA value that indicates how glyph metrics are used to measure text when it is formatted.