libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
FontPainter Class Reference

Renders text into an image using a TrueType font. More...

#include <fontpainter.h>

Public Member Functions

 FontPainter ()
 Constructs a FontPainter with no paint engine or font set.
 
 ~FontPainter ()
 Destroys the FontPainter and releases font resources.
 
void setPaintEngine (const PaintEngine &val)
 Sets the paint engine used for rendering.
 
void setFontFilename (const String &val)
 Sets the path to the TrueType font file.
 
bool drawText (const String &text, int x, int y, int pointSize=12) const
 Draws text at the specified position.
 
int measureText (const String &text, int pointSize=12) const
 Measures the pixel width of a text string without drawing it.
 

Detailed Description

Renders text into an image using a TrueType font.

Uses a PaintEngine to draw glyphs loaded from a TrueType font file. Set the paint engine and font filename before calling drawText().

Member Function Documentation

◆ drawText()

bool FontPainter::drawText ( const String text,
int  x,
int  y,
int  pointSize = 12 
) const

Draws text at the specified position.

Parameters
textThe text string to render.
xThe x coordinate of the text origin.
yThe y coordinate of the text origin (baseline).
pointSizeThe font size in points (default 12).
Returns
True if the text was drawn successfully.

◆ measureText()

int FontPainter::measureText ( const String text,
int  pointSize = 12 
) const

Measures the pixel width of a text string without drawing it.

Parameters
textThe text string to measure.
pointSizeThe font size in points (default 12).
Returns
The width in pixels, or 0 on error.

◆ setFontFilename()

void FontPainter::setFontFilename ( const String val)
inline

Sets the path to the TrueType font file.

Parameters
valThe filename or path of the font to load.

◆ setPaintEngine()

void FontPainter::setPaintEngine ( const PaintEngine val)
inline

Sets the paint engine used for rendering.

Parameters
valThe PaintEngine to use for drawing operations.

The documentation for this class was generated from the following file: