A bitmap font. This is a font which is defined by a binary bit map. Each bit in the bitmap defines one pixel. Bits may be arranged in various common patterns. More...
#include <gui_tk.h>
Public Member Functions | |
BitmapFont (const unsigned char *data, int height, int ascent, bool owner=false, int width=8, bool background_set=false, int col_step=-1, int row_step=8, int character_step=0, Char last=256, const int *widths=NULL, const int *ascents=NULL, const unsigned char *const *char_position=NULL, const SpecialChar *special=NULL) | |
Constructor. | |
virtual int | getHeight () const |
Retrieve total height of font in pixels. | |
virtual int | getAscent () const |
Retrieve the ascent, i.e. the number of pixels above the base line. | |
virtual int | getWidth (Char c= 'M') const |
Retrieve width of a character. | |
virtual SpecialChar | toSpecial (Char c) const |
Convert a character to an equivalent SpecialChar. See Font::toSpecial(Char c) | |
virtual Char | fromSpecial (SpecialChar c) const |
Convert a character to an equivalent character. See Font::fromSpecial(SpecialChar c). | |
Protected Member Functions | |
virtual void | drawChar (Drawable *d, const Char c) const |
Draw character to a drawable at the current position. | |
Protected Attributes | |
const unsigned char *const | bitmap |
The actual font data. | |
const int | width |
Width of a character cell. | |
const int | height |
Height of all characters. | |
const int | ascent |
Ascent of all characters. | |
const int *const | widths |
Array of character widths. If font is fixed-width, this is NULL and width is used. | |
const int *const | ascents |
Array of character ascents. If this is NULL, ascent is used for all characters. | |
const bool | background_set |
True if set bits are background, false otherwise. | |
const int | col_step |
Number of bits added to get from a column to the next column. | |
const int | row_step |
Distance between 2 rows of a character, or 0 for variable-width rows. | |
const int | character_step |
Distance of two characters in the bitmap in bits. | |
const unsigned char *const *const | char_position |
Array of pointers to font data. If set, neither bitmap nor character_step are used. | |
const SpecialChar *const | special |
Array of SpecialChar equivalents. | |
const bool | owner |
If true , then all arrays are freed on destruction. | |
const Char | last |
Last defined character. Characters above this will be ignored. |
A bitmap font. This is a font which is defined by a binary bit map. Each bit in the bitmap defines one pixel. Bits may be arranged in various common patterns.
Encoding free, character size depends on number of characters in the font.
GUI::BitmapFont::BitmapFont | ( | const unsigned char * | data, |
int | height, | ||
int | ascent, | ||
bool | owner = false , |
||
int | width = 8 , |
||
bool | background_set = false , |
||
int | col_step = -1 , |
||
int | row_step = 8 , |
||
int | character_step = 0 , |
||
Char | last = 256 , |
||
const int * | widths = NULL , |
||
const int * | ascents = NULL , |
||
const unsigned char *const * | char_position = NULL , |
||
const SpecialChar * | special = NULL |
||
) |
Constructor.
The default values provide an 8 bit wide fixed-width pixel layout with each byte a row, arranged top-to-bottom just like a PC's VGA font. See the individual member documentation for details on the parameters.
Definition at line 571 of file gui_tk.cpp.
void GUI::BitmapFont::drawChar | ( | Drawable * | d, |
const Char | c | ||
) | const [protected, virtual] |
Draw character to a drawable at the current position.
d's
current position is advanced to the position of the next character. The y coordinate is located at the baseline before and after the call.
Implements GUI::Font.
Definition at line 482 of file gui_tk.cpp.
References ascent, ascents, background_set, bitmap, char_position, character_step, col_step, GUI::Drawable::getX(), GUI::Drawable::getY(), GUI::Drawable::gotoXY(), height, last, row_step, width, and widths.
const int* const GUI::BitmapFont::ascents [protected] |
Array of character ascents. If this is NULL, ascent is used for all characters.
This allows character data to be flush to the top or bottom of it's bitmap area.
Definition at line 1404 of file gui_tk.h.
Referenced by drawChar().
const int GUI::BitmapFont::character_step [protected] |
Distance of two characters in the bitmap in bits.
This is calculated as abs(row_step*height) unless explicitly specified.
Definition at line 1417 of file gui_tk.h.
Referenced by drawChar().
const SpecialChar* const GUI::BitmapFont::special [protected] |
Array of SpecialChar equivalents.
If unset, encoding is assumed ASCII-like for the first 32 characters
Definition at line 1424 of file gui_tk.h.
Referenced by fromSpecial(), and toSpecial().