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
textstringThe text to draw.
textFormatITextFormatAn object that describes formatting details of the text to draw, such as the font, the font size, and flow direction.
layoutRectRectFloatThe size and position of the area in which the text is drawn.
defaultFillBrushIDeviceBrushThe brush used to paint the text.
optionsDrawTextOptionsA 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.
measuringModeTextMeasuringModeA 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
textstringThe text to draw.
textFormatITextFormatAn object that describes formatting details of the text to draw, such as the font, the font size, and flow direction.
layoutRectRectFloatThe size and position of the area in which the text is drawn.
defaultFillBrushIDeviceBrushThe brush used to paint the text.
svgGlyphStyleISvgGlyphStyleValues for context-fill, context-stroke, and context-value that are used when rendering SVG glyphs.
colorPaletteIndexintThe index used to select a color palette within a color font.
optionsDrawTextOptionsA 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.
measuringModeTextMeasuringModeA value that indicates how glyph metrics are used to measure text when it is formatted.