Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
DWriteTextRenderer Class Reference

Internal helper class for rendering text using DirectWrite and Direct2D. More...

#include <DWriteTextRenderer.h>

Public Member Functions

bool drawText (std::string_view text, const FontDefinition &textDefinition, unsigned int align, bool &premultipliedAlpha, SIZE &extent, tlx::byte_buffer &outData)
 Render UTF-8 text into a WIC bitmap and return its pixel data.

Detailed Description

Internal helper class for rendering text using DirectWrite and Direct2D.

Member Function Documentation

◆ drawText()

bool drawText ( std::string_view text,
const FontDefinition & textDefinition,
unsigned int align,
bool & premultipliedAlpha,
SIZE & extent,
tlx::byte_buffer & outData )

Render UTF-8 text into a WIC bitmap and return its pixel data.

This function uses DirectWrite/Direct2D to draw text into a WIC bitmap, applying font settings, alignment, wrapping, overflow rules, stroke and shadow effects. The rendered bitmap is then copied into the provided output buffer in 32-bit BGRA format with premultiplied alpha.

Parameters
textUTF-8 encoded text string to render. Line breaks ('
') are supported.
textDefinitionFontDefinition structure specifying font family, size, color, stroke and shadow options, wrapping and overflow behavior.
alignAlignment flags (compatible with BitmapDC):
  • Horizontal: bits 0–3 (1 = left, 2 = right, 3 = center).
  • Vertical: bits 4–7 (1 = top, 2 = bottom, 3 = middle).
premultipliedAlphaOutput flag indicating whether the pixel data uses premultiplied alpha.
extentInput: maximum width/height constraints. Output: actual rendered text size in pixels.
outDataOutput buffer containing raw pixel data (BGRA, premultiplied alpha).
Note
'&' characters are escaped by doubling ('&&') to avoid mnemonic interpretation.
If overflow == 2, the font size may be reduced iteratively until the text fits.
When stroke is enabled, glyph outlines are converted into geometry and drawn with both stroke and fill.
Alignment is handled by DirectWrite layout; origin is adjusted only for bounding box placement.

The documentation for this class was generated from the following file:
  • DWriteTextRenderer.h