fltk::Font Class Reference

List of all members.

Public Member Functions

Fontbold ()
int encodings (const char **&)
Fontitalic ()
const char * name (int *p)
const char * name () const
Fontplus (int attributes)
int sizes (int *&)
const char * system_name ()

Static Public Member Functions

static const char * current_name ()

Related Functions

(Note that these are not member functions.)
fltk::Fontfont (const char *name, int attributes)
fltk::Fontfont (int i)
int list_fonts (fltk::Font **&arrayp)

Detailed Description

Identifies a font. You can create these with fltk::font(name) or with fltk::list_fonts(). Do not attempt to create your instances or modify it.

This is a struct so that fltk can initialize a table internally with constants. Don't use the undocumented fields.

Member Function Documentation

fltk::Font * fltk::Font::bold ( ) [inline]

Same as plus(BOLD), returns a bold version of this font.

const char * fltk::Font::current_name ( ) [static]

Return the full X11 name for the currently selected font+size+encoding. This is mostly useful for debugging, though maybe you need to copy it to another program.

On non-X systems, and on modern X systems with Xft (antialiased fonts) this returns current_font()->system_name().

int fltk::Font::encodings ( const char **&  arrayp)

Return all the encodings for this font. These strings may be sent to fltk::set_encoding() before using the font.

The return value is the length of the list. The argument arrayp is set to point at the array, which is in static memory reused each time this call is done.

fltk::Font * fltk::Font::italic ( ) [inline]

Same as plus(ITALIC), returns an italic version of this font.

const char * fltk::Font::name ( int *  attributes) [inline]

Return a string name for this font, and put any attributes (BOLD, ITALIC) into the location pointed to by attributes. Using the returned string and attributes as arguments to find() will return the same font.

const char * fltk::Font::name ( ) const

Return a single string that names this font. Passing this string and zero for the attributes to find() will return the same font.

If the font's attributes are non-zero, this is done by appending a space and "Bold" and/or "Italic" to the name. This allows a single string rather than a string+attribute pair to identify a font, which is really useful for saving them in a file. The return value is in a temporary buffer that will be overwritten on the next call in this case.

fltk::Font * fltk::Font::plus ( int  attributes)

Return a font from the same family with the extra attributes turned on. This may return the same font if the attributes are already on or there is no font with those attributes.

int fltk::Font::sizes ( int *&  sizep)

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::setfont() that will be matched exactly (fltk::setfont() 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 still 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.

The return value is the length of the list. The argument arrayp is set to point at the array, which is in static memory reused each time this call is done.

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

Returns the string actually passed to the operating system, which may be different than name(). For Xlib this is a pattern sent to XListFonts to find all the sizes. For most other systems this is the same as name() without any attributes.

Friends And Related Function Documentation

fltk::Font * font ( const char *  name,
int  attributes 
) [related]

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 of the returned list. This can make the first call pretty slow, especially on X. Directly calling the system has a problem in that we want the same structure returned for any call that names the same font. This is sufficiently painful that I have not done this yet.

fltk::Font * font ( int  i) [related]

Turn an fltk1 integer font id into a font.

int list_fonts ( fltk::Font **&  arrayp) [related]

Generate an array containing every font on the server. 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 will usually return the same array quickly, but if a signal comes in indicating a change it will probably delete the old array and return a new one.

The documentation for this class was generated from the following files: