Product Home Class IndexDownload

CK_FixedBitmapFont

CK_Font
    |
    +----CK_FixedBitmapFont

This is a font created from a specially formatted bitmap containing the character set. An example of the first part of a font bitmap is shown below:

The bitmap should contain each character of the font in a vertical column, starting with the space character. (The first 32 non-printable characters are not used.) The bitmap should be wide enough to for the widest character in the font. It doesn't matter if the bitmap is wider, as long as the extra space is on the right side. The left side of each character should be either flush with the left edge of the bitmap, or indented as much as desired. The extra indentation will be used when spacing characters.Each character in the bitmap should be positioned vertically in a fixed-height cell. For example, in the example above, each character occupies a cell that is 38 pixels high and 42 pixels wide. You'll notice that the double-quote character is positioned higher in its cell.

Easy way to create a font bitmap in this format:

The reason this font bitmap format exists is because there is a very easy way to create it. Using a paint program, such as Photoshop, create a new image with the proper dimensions (height can be very large relative to width). Select the text tool, select a font and size, and type each character in the font. Each character should be followed by a carriage return. The paint program will vertically and horizontally position each character properly.


Constructors

CK_FixedBitmapFont(const CK_StaticBitmap &bitmap, int spacing, int cellHeight)
Construct a CK_FixedBitmapFont from a bitmap containing the character set.

Parameters

bitmap
The bitmap containing the characters in the font.
spacing
The number of pixels to separate each character when drawing text.
cellHeight
The height in pixels of each cell in the bitmap. Each character should be positioned properly within its cell.

The constructor will analyze the bitmap and determine the width of each character in the font. When drawing text, each character will be separated by the number of pixels specified by the spacing parameter.

The constructor does not own the bitmap. This means that it holds a reference to the bitmap, but it is not responsible for deleting it when the CK_FixedBitmapFont is destructed. If a CK_FixedBitmapFont is created from a bitmap, the bitmap should not be deleted as long as the font is in use.