Main Page Class Hierarchy Compound List File List Compound Members
ZFont Class Reference
ZFont a bitmapped font class for drawing text to ZSurfaces.
More...
#include <ZFont.h>
Inheritance diagram for ZFont:
List of all members.
Detailed Description
ZFont a bitmapped font class for drawing text to ZSurfaces.
ZFont supports two font formats: an image based format ( custom font image) or default QFont based format.
When initialized with QImage , this class will used underlying ZSurface (which this class is derived from) as a source of character glyphs.
The QImage based font format is illustrated in the picture below:
Each character will always be drawn as it is presented in the bitmap. The white kerning lines above each character adjusts the distance between the character and the surrounding characters in a sentence.
This is the same format for fonts as used by GapiDraw game library available for Pocket PC devices.
This library (free) includes Windows based program for creating font images using TTF fonts as a source.
When initialized with QFont , the object will render all ASCII characters from that font on the underlying ZSurface object and use them as a source of character glyphs.
Usage:
You can prepare an external image with renderings for each character of your font ( this way you can create antialiased fonts etc ..) or you can simply initialize ZFont with an existing QFont object.
For example to create QT based (helvetica,bold,10 points) font use:
myZFontClass.create(QFont("helvetica",10,QFont::Bold),QColor(255,255,255),QColor(0,0,0));
After that you can simply call:
myZSurface.drawText(x,y,QString("text"),&myZFontClass);
Constructor & Destructor Documentation
|
|
Constructs an invalid (null) ZFont object. |
| ZFont::ZFont |
( |
const QImage & |
, |
|
|
QColor |
backColor |
|
) |
|
|
|
|
Constructs a ZFont out of a valid QImage object.
The backColor value indicates background color value (transparent pixel) used during ZSurface::drawText() methods. |
| ZFont::ZFont |
( |
const QPixmap & |
, |
|
|
QColor |
backColor |
|
) |
|
|
|
|
Constructs a ZFont out of a valid QPixmap object.
The backColor value indicates background color value (transparent pixel) used during ZSurface::drawText() methods. |
| ZFont::ZFont |
( |
const QFont & |
, |
|
|
QColor |
foreCol, |
|
|
QColor |
backCol |
|
) |
|
|
|
|
Constructs a ZFont out of a valid QFont object.
The foreColor value indicates the default color that will be associated with this font object. |
| ZFont::ZFont |
( |
const ZFont & |
|
) |
|
|
|
|
Constructs a deep copy of ZFont object. |
|
|
Destroys the object and cleans up |
Member Function Documentation
| QColor ZFont::backgroundColor |
( |
|
) |
const [inline] |
|
|
|
Returns the background color for this ZFont object ( this value will be used to indicate transparent pixels when drawing text on ZSurface.) |
| int ZFont::charWidth |
( |
char |
c |
) |
const [inline] |
|
|
|
Returns the width of character c in pixels. |
| bool ZFont::create |
( |
const QFont & |
, |
|
|
QColor |
foreColor, |
|
|
QColor |
backCol |
|
) |
|
|
|
|
Initializes an existing instance of ZFont object from a valid QFont object. The foreColor value indicates the default color that will be associated with this font object. Returns false if memory allocation failed. |
| bool ZFont::create |
( |
const QPixmap & |
, |
|
|
QColor |
backColor |
|
) |
|
|
|
|
Initializes an existing instance of ZFont object from a valid QPixmap. The backColor value indicates background color value (transparent pixel) used during ZSurface::drawText() methods. Returns false if memory allocation failed. |
| bool ZFont::create |
( |
const QImage & |
, |
|
|
QColor |
backColor |
|
) |
|
|
|
|
Initializes an existing instance of ZFont object from a valid QImage. The backColor value indicates background color value (transparent pixel) used during ZSurface::drawText() methods. Returns false if memory allocation failed or QImage depth is not 32. |
| int ZFont::height |
( |
|
) |
const [inline] |
|
|
|
Returns height of the font excluding white kerning line.
Reimplemented from ZSurface. |
| ZFont& ZFont::operator= |
( |
const ZFont & |
f |
) |
|
|
|
|
Assigns a deep copy of f to this ZFont object and returns a reference to it. |
| void ZFont::setSpacing |
( |
int |
s |
) |
[inline] |
|
|
|
Sets spacing in pixels to be used when drawing letters. |
| int ZFont::spacing |
( |
|
) |
const [inline] |
|
|
|
Returns current value of spacing between letters. |
| int ZFont::stringWidth |
( |
const QString & |
s |
) |
const |
|
|
|
Returns the width of string (distance where the next string should be drawn). |
| int ZFont::x |
( |
char |
c |
) |
const [inline] |
|
|
|
Returns offset x of character c in the underlying ZSurface image. |
| int ZFont::y |
( |
|
) |
const [inline] |
|
|
|
Returns offset y of the ZFont object in the underlying ZSurface image. |
The documentation for this class was generated from the following file:
Generated on Mon Feb 24 21:00:44 2003 for ZSurface by
1.2.14 written by Dimitri van Heesch,
© 1997-2002