typedef fltk::Font


The type passed to fltk::Widget::label_font() and other parts of fltk is a typedef defined like this, pointing at a structure fltk::Font_:
typedef fltk::Font_* fltk::Font;

To draw text in a font you use fltk::font(fltk::Font,size) to select a font and scale, and then fltk::draw(const char*) to draw letters. See the documentaion on drawing functions.

The following fltk::Font values are predefined. These names are historical, actually fltk::HELVETICA will give the system's sans-serif font, fltk::TIMES will give the system's serif font, and fltk::COURIER will give the system's fixed-pitch font. fltk::SCREEN will give a fixed-pitch font designed for computer i/o, it may match fltk::COURIER. Avoid fltk::SYMBOL and fltk::ZAPF_DINGBATS for compatability with future versions of fltk.

Methods

fltk::Font_* fltk::Font_::bold();
fltk::Font_* fltk::Font_::italic();

Pointers to the bold and italic versions of this font. fltk::HELVETICA->bold() is the same as fltk::HELVETICA_BOLD, fltk::TIMES->bold()->italic() is the same as fltk::TIMES_BOLD_ITALIC.

These are never null. If this font has no bold or italic version then these are circular pointers. Thus fltk::TIMES_BOLD->bold() is the same as fltk::TIMES_BOLD and fltk::SYMBOL->bold() is the same as fltk::SYMBOL.

const char* fltk::Font_::system_name()

Returns a string that identifies the font in a system-specific manner. About all that can be said about it is that it is different for every font (two different fonts may return the same name()). This string is not portable, even between different machines running the same operating system.

const char* fltk::Font_::name(int* attributes = 0)

Returns the name of the font. The return value points to a static buffer that is overwritten each call (so copy the string if you want to keep it).

The integer pointed to by attributes is set to zero, fltk::BOLD or fltk::ITALIC or fltk::BOLD|fltk::ITALIC. If this pointer is null then the attributes are indicated by adding a space and "bold" or "italic" to the name.

int fltk::Font_::encodings(const char** &array) const;

Sets array to point at a list of encoding names. The return value is the length of this array. Each string identifies an "encoding" that is supported by this font. These strings may be passed to the fltk::encoding() to select what characters the first 256 codes print. A zero length array may be returned, this indicates that the font will print the same no matter what encoding is set.

int fltk::Font_::sizes(int *&array) const;

Sets array to point at a list of sizes. The return value is the length of this array. The sizes are sorted from smallest to largest and indicate what sizes can be given to fltk::font() that will be matched exactly (fltk::font() will pick the closest size for other sizes). A zero in the first location of the array indicates a scalable font, where any size works, although the array may list sizes that work "better" than others. The returned array points at a static buffer that is overwritten each call, so you want to copy it if you plan to keep it.

fltk::Font fltk::find_font(const char* name, int attributes = 0);

Find a font with the given "nice" name. You can get bold and italic by adding a space and "bold" or "italic" (or both) to the name, or by passing them as the attributes. Case is ignored and fltk will accept some variations in the font name.

The current implementation calls fltk::list_fonts() and then does a binary search for the font in it. This can make the first call pretty slow, especially on X.

int fltk::list_fonts(fltk::Font*& arrayp);

This allocates and fills in an array containing every font on the server. The location arrayp is set to a pointer to this array, and the length of the array is the return value. Each entry is a "base" font, there may be bold, italic, and bold+italic version of each font pointed to by bold() or italic().

Subsequent calls to this function returns the same array again. Currently there is no way to update the list from any changes to the set of fonts on the server.