Font Struct Reference

List of all members.

Public Member Functions

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

Static Public Member Functions

const char * current_name ()

Public Attributes

const char * name_
int attributes_

Related Functions

(Note that these are not member functions.)

int list_fonts (Font **&arrayp)
Fontfont (const char *name, int attributes)
Fontfont (int i)

Detailed Description

Identifies a font. You can create these with font(name) or with 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

Font * Font::bold  )  [inline]
 

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

const char * 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 Font::encodings const char **&  arrayp  ) 
 

Return all the encodings for this font. These strings may be sent to 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.

Font * Font::italic  )  [inline]
 

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

const char * 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 * 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.

Font * Font::plus int  x  ) 
 

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 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 setfont() that will be matched exactly (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 * 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

Font * font int  i  )  [related]
 

Turn an fltk1 integer font id into a font.

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 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.

int list_fonts 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 struct was generated from the following files:
Sun Jan 7 00:55:17 2007. FLTK ©2006 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.