|
Documentation
|
|||||||||||
|
CGapiBitmapFontOverviewCGapiBitmapFont is a bitmapped font class for drawing text to surfaces. RectanglesAll RECT structures are defined so that the right and bottom members are exclusive: right minus left equals the width of the rectangle, not one less than the width. This is to enable full compability with the DirectDraw coordinate system. This document has been updated for use with GapiDraw 4.0 or later.
CGapiBitmapFont::CreateFontThis method initializes the font.
Parameters
|
| Type | Description |
|---|---|
|
GDCREATEFONT_TRACKING |
Uses the tracking value in pGDFontFx->lTracking to specify the default spacing between characters. |
|
GDCREATEFONT_SIMPLEBITMAP |
Use a simple bitmap format to create the font (see notes below) |
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
GDERR_INVALIDBITMAP
GDERR_NOTINITIALIZED
GDERR_OUTOFMEMORY
GDERR_SURFACELOST
GapiDraw supports two font formats: an advanced format with kerning tables and a simple format with no fixed kerning. No matter what format you choose from, the steps involved to create a font are always:
THE ADVANCED FONT FORMAT
The advanced font format supports individual character kerning and can be useful to create extremely good looking bitmapped fonts. The advanced font format is illustrated in the picture below:
![]()
The first letters from one of the advanced bitmap fonts shipped with GapiDraw.
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. If the white kerning line is one pixel short to the left of the character, the character will always be closer to the character to the left. You can use this to create individual character kerning such as those used by the TrueType fonts. Italic fonts are also possible to create using this font format.
The easiest way to create new fonts using the advanced font format is to use the FontMaker application which is delivered with each GapiDraw installation.
THE SIMPLE FONT FORMAT
The simple font format comprises plain bitmap letters arranged in the standard ASCII format. Create a new image in Photoshop and just type in the letters as in one of the sample fonts. Make sure that the quotation marks: " do not have a space between them since this will cause GapiDraw to treat them as two characters. The number of pixels before the first letter in the font bitmap defines the width of the <space> character (" "). An example of a simple font bitmap is seen below:
![]()
The first letters from one of the simple bitmap fonts shipped with GapiDraw.
CREATING NEW FONTS
To create a new bitmap font, the easiest way is to either create a font using the simple font format, or to use the supplied FontMaker by MetalShard, inc. No matter what method you choose, the time involved to create a new fonts is usually just a matter of minutes.
Some caveats to watch out for:
This method adjusts font kerning for a bitmapped font.
|
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
GDERR_OUTOFMEMORY
In some cases it is not enough only being able to specify a fixed kerning
for each character. For certain character combinations such as "FJ",
"AV", and "LT" you might want to adjust the position
of the characters individually. If you for example would like the "V"
to move closer to the "A" if the string "AV" is being
written, you simply call:
SetKerning(TEXT("A"), TEXT("V"), -1);
This method returns the required width in pixels to draw a text string using the current font.
|
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
GDERR_INVALIDPARAMS
GDERR_NOTINITIALIZED
This method returns the width in pixels for a specific character using the current font.
|
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
GDERR_INVALIDPARAMS
GDERR_NOTINITIALIZED
This method returns the space in pixels between two characters using the current font.
|
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
GDERR_INVALIDPARAMS
GDERR_NOTINITIALIZED