typedef Fl_Font

The font used by Fl_Widget::label_font() and other parts of fltk is a typedef for a ponter to the structure Fl_Font_.

The following Fl_Font values are predefined:

Methods

Fl_Font_* Fl_Font_::bold();
Fl_Font_* Fl_Font_::italic();

Pointers to the bold and italic versions of this font. If this font has no bold or italic version (usually because it aready is bold or italic, but possibly because the other font is missing from the server), then these are circular pointers to this.

const char* Fl_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* Fl_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, FL_BOLD or FL_ITALIC or FL_BOLD|FL_ITALIC. If this pointer is null then the attributes are indicated by adding "bold" or "italic" to the name.

int Fl_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 fl_font() to select what characters the first 256 codes print. If fltk cannot figure out the encodings it returns a zero-length array and setting the encoding will have no effect on what is drawn with this font.

int Fl_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 fl_font() that will be matched exactly (fl_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.

Fl_Font fl_find_font(const char* name, int attributes = 0);

Find a font with the given "nice" name. You can get bold and italic by either putting "Bold" or "Italic" in 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 fl_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 fl_list_fonts(Fl_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 the bold or italic pointers in them.

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.