TextRenderer¶
This page describes the class TextRenderer
The class TextRenderer
provides nethods to render text in in an RGB array which
can be used ot create a PNG image or combine with other RGB arrays using AlphaComposer.
- Code:
Public Methods¶
constructor
¶
TextRenderer()
The constructor initalizes all members.
destructor
¶
~TextRenderer()
The dertructor frees allocate cairo resources.
init
¶
int init(int iW, int iH);
iW
Width of backgtoundd.
- `` iH``
Height of background
Creates a cairo surface sized iW
x iH
and a cairo context for it.
setFontSize
¶
void setFontSize(double dSize);
dSize
The new font size, in user space units.
Sets font size.
setColor
¶
void setColor(double dR, double dG, double dB, double dA);
dR
Red component of color.
dG
Green component of color.
dB
Blue component of color.
dA
Alpha component of color.
Sets the foreground color .. —————————————————————————–
addText
¶
void addText(const char *pText, double dX, double dY);
pText
Text to be written.
dX
X-coordinate of lower left corner of text rectangle.
dY
Y-coordinate of lower left corner of text rectangle.
Writes the given text into the cairo context at the spüecified position.
createData
¶
uchar **createData();
Creates an unsigned char RGB array with PNG-compatible structure. It is the caller’s responsability to delete this array properly (with deleteArray()).
writeToPNG
¶
int writeToPNG(const char *pOut);
pOut
Name of output PÜNG file.
Creates a PNG file from the data in the cairo context.
getExt
¶
void getExt(const char *pText, int &iExtW, int &iExtH);
pText
Text to get the extents of.
iExtW
Reference to integer for holding the width of the textrectangle.
iExtH
Reference to integer for holding the width of the textrectangle.
deleteArray()
¶
void deleteArray(uchar **ppData);
ppData
Array of unsigend char created by createData .
Properly deletes the specified array.