FLTK 1.4.0
Loading...
Searching...
No Matches
Color & Font functions

fl global color, font functions. More...

Functions

Fl_Color fl_color ()
 Return the last fl_color() that was set.
 
void fl_color (Fl_Color c)
 Set the color for all subsequent drawing operations.
 
void fl_color (int c)
 for back compatibility - use fl_color(Fl_Color c) instead
 
void fl_color (uchar r, uchar g, uchar b)
 Set the color for all subsequent drawing operations.
 
Fl_Color fl_color_average (Fl_Color color1, Fl_Color color2, float weight)
 Returns the weighted average color between the two given colors.
 
Fl_Color fl_contrast (Fl_Color fg, Fl_Color bg, Fl_Fontsize fs, int context)
 Returns a color that contrasts with the background color.
 
void fl_contrast_function (Fl_Contrast_Function *f)
 Register a custom contrast function.
 
int fl_contrast_level ()
 Get the contrast level (sensitivity) of the fl_contrast() method.
 
void fl_contrast_level (int level)
 Set the contrast level (sensitivity) of the fl_contrast() method.
 
int fl_contrast_mode ()
 Return the current contrast algorithm (mode).
 
void fl_contrast_mode (int mode)
 Set the contrast algorithm (mode).
 
int fl_descent ()
 Return the recommended distance above the bottom of a fl_height() tall box to draw the text at so it looks centered vertically in that box.
 
Fl_Font fl_font ()
 Return the face set by the most recent call to fl_font().
 
void fl_font (Fl_Font face, Fl_Fontsize fsize)
 Sets the current font, which is then used in various drawing routines.
 
int fl_height ()
 Return the recommended minimum line spacing for the current font.
 
int fl_height (int font, int size)
 This function returns the actual height of the specified font and size.
 
Fl_Color fl_inactive (Fl_Color c)
 Returns the inactive, dimmed version of the given color.
 
const char * fl_latin1_to_local (const char *t, int n=-1)
 Convert text from Windows/X11 latin1 character set to local encoding.
 
double fl_lightness (Fl_Color color)
 Return the perceived lightness of a color.
 
const char * fl_local_to_latin1 (const char *t, int n=-1)
 Convert text from local encoding to Windows/X11 latin1 character set.
 
const char * fl_local_to_mac_roman (const char *t, int n=-1)
 Convert text from local encoding to Mac Roman character set.
 
double fl_luminance (Fl_Color color)
 Return the raw / physical luminance of a color.
 
const char * fl_mac_roman_to_local (const char *t, int n=-1)
 Convert text from Mac Roman character set to local encoding.
 
Fl_Color fl_show_colormap (Fl_Color oldcol)
 Pops up a window to let the user pick a colormap entry.
 
Fl_Fontsize fl_size ()
 Return the size set by the most recent call to fl_font().
 
void fl_text_extents (const char *, int &dx, int &dy, int &w, int &h)
 Determine the minimum pixel dimensions of a nul-terminated string using the current fl_font().
 
void fl_text_extents (const char *t, int n, int &dx, int &dy, int &w, int &h)
 Determine the minimum pixel dimensions of a sequence of n characters (bytes) using the current fl_font().
 
double fl_width (const char *txt)
 Return the typographical width of a nul-terminated string using the current font face and size.
 
double fl_width (const char *txt, int n)
 Return the typographical width of a sequence of n characters using the current font face and size.
 
double fl_width (unsigned int c)
 Return the typographical width of a single character using the current font face and size.
 
static void Fl::free_color (Fl_Color i, int overlay=0)
 Frees the specified color from the colormap, if applicable.
 
static unsigned Fl::get_color (Fl_Color i)
 Returns the RGB value(s) for the given FLTK color index.
 
static void Fl::get_color (Fl_Color i, uchar &red, uchar &green, uchar &blue)
 Returns the RGB value(s) for the given FLTK color index.
 
static void Fl::get_color (Fl_Color i, uchar &red, uchar &green, uchar &blue, uchar &alpha)
 Returns the RGBA value(s) for the given FLTK color index.
 
static const char * Fl::get_font (Fl_Font)
 Gets the string for this face.
 
static const char * Fl::get_font_name (Fl_Font, int *attributes=0)
 Get a human-readable string describing the family of this face.
 
static int Fl::get_font_sizes (Fl_Font, int *&sizep)
 Return an array of sizes in sizep.
 
static void Fl::set_color (Fl_Color i, unsigned c)
 Sets an entry in the fl_color index table.
 
static void Fl::set_color (Fl_Color, uchar, uchar, uchar)
 Sets an entry in the fl_color index table.
 
static void Fl::set_color (Fl_Color, uchar, uchar, uchar, uchar)
 Sets an entry in the fl_color index table.
 
static void Fl::set_font (Fl_Font, const char *)
 Changes a face.
 
static void Fl::set_font (Fl_Font, Fl_Font)
 Copies one face to another.
 
static Fl_Font Fl::set_fonts (const char *=0)
 FLTK will open the display, and add every fonts on the server to the face table.
 

Detailed Description

fl global color, font functions.

These functions are declared in <FL/Fl.H> or <FL/fl_draw.H>.

Function Documentation

◆ fl_color() [1/3]

Fl_Color fl_color ( )
inline

Return the last fl_color() that was set.

This can be used for state save/restore.

◆ fl_color() [2/3]

void fl_color ( Fl_Color  c)
inline

Set the color for all subsequent drawing operations.

For color-mapped displays, a color cell will be allocated out of fl_colormap the first time you use a color. If the colormap fills up then a least-squares algorithm is used to find the closest color. If no valid graphical context (fl_gc) is available, the foreground is not set for the current window.

Parameters
[in]ccolor

◆ fl_color() [3/3]

void fl_color ( uchar  r,
uchar  g,
uchar  b 
)
inline

Set the color for all subsequent drawing operations.

The closest possible match to the RGB color is used. The RGB color is used directly on TrueColor displays. For colormap visuals the nearest index in the gray ramp or color cube is used. If no valid graphical context (fl_gc) is available, the foreground is not set for the current window.

Parameters
[in]r,g,bcolor components

◆ fl_color_average()

Fl_Color fl_color_average ( Fl_Color  color1,
Fl_Color  color2,
float  weight 
)

Returns the weighted average color between the two given colors.

The red, green and blue values are averages using the following formula:

color = color1 * weight + color2 * (1 - weight)

Thus, a weight value of 1.0 will return the first color, while a value of 0.0 will return the second color.

Parameters
[in]color1,color2boundary colors
[in]weightweighting factor

◆ fl_contrast()

Fl_Color fl_contrast ( Fl_Color  fg,
Fl_Color  bg,
Fl_Fontsize  fs,
int  context 
)

Returns a color that contrasts with the background color.

This will be the foreground color if it contrasts sufficiently with the background color. Otherwise, returns FL_WHITE or FL_BLACK depending on which color provides the best contrast.

FLTK 1.4.0 uses a different default contrast function than earlier releases (1.3.x) but you can use the old "legacy" contrast function by calling

@ FL_CONTRAST_LEGACY
legacy (FLTK 1.3.x) contrast function
Definition Enumerations.H:1183
int fl_contrast_mode()
Return the current contrast algorithm (mode).
Definition fl_contrast.cxx:251

early in your main program.

Note
It is a known issue that static initialization using fl_contrast() may already have been executed before you call this function in main(). You should be aware of this and, if necessary, write your own (static) contrast initialization function. This should rarely be necessary.

You can change the behavior of fl_contrast() in several ways:

  • Change the "level" (sensitivity) for contrast calculation, see fl_contrast_level(). Valid levels are 0 - 100, the default "medium" value is 50. If you raise the level above 50 the overall contrast will generally be higher, i.e. the required contrast to return the foreground color is raised and therefore the calculated color will switch "earlier" to either black or white. In other words, using the following values:

    • 0 will always use the foreground color
    • 50 will use the default, unmodified algorithm
    • 100 will always use black or white
    • values larger than 50 may yield slightly better results. Changing the level is particularly useful and intended for the "legacy mode" to improve the results partially. Values slightly above 50 (50 - 70) will likely return the best results (50 is the default, as used in FLTK 1.3.x).
    Note
    Different contrast modes (algorithms) can use their own values and defaults of fl_contrast_level().
  • Change the used contrast calculation function. You can either use the old (FLTK 1.3.x) function or use the better but slower function based on the CIELAB (L*a*b*) color model, or you can define your own custom contrast function if you need even better contrast results.

The following contrast functions are available:

  • FL_CONTRAST_LEGACY, the old FLTK 1.3.x compatible function. This is the fastest function (using integer arithmetic) but it provides worse results in border cases. You may want to use this on embedded or otherwise CPU constrained systems or if you need strict backwards compatibility. For slightly better results you may utilize the new fl_contrast_level(int) function (since 1.4.0) to increase the contrast sensitivity. This will provide slightly better results than FLTK 1.3.x and earlier but we recommend to use the new default function:
  • FL_CONTRAST_CIELAB, based on the CIELAB (L*a*b*) color model. This function is superior regarding the visual contrast perception but may be slower. This is the default since FLTK 1.4.0.
  • FL_CONTRAST_CUSTOM, your own contrast calculation function.

In the future we may provide even more (and superior) contrast algorithms.

The new parameters fs and context (since 1.4.0) are defined for future extensions and are currently not used. Default values are 0.

Note
These new optional parameters must be provided in the custom contrast function which is the reason why they are added now. In the future we may use the fontsize to adjust the calculated contrast, and users defining their own contrast functions may use them in their functions.
Parameters
[in]fgforeground (text) color
[in]bgbackground color
[in]fsfont size (optional, default = 0 == undefined)
[in]contextgraphical context (optional, default = 0 == text)
Returns
contrasting color: fg, FL_BLACK, or FL_WHITE
See also
fl_contrast_level(int)
fl_contrast_mode(int)
fl_contrast_function()

◆ fl_contrast_function()

void fl_contrast_function ( Fl_Contrast_Function f)

Register a custom contrast function.

Your custom contrast function will be called when fl_contrast() is called if and only if you previously registered your function and called fl_contrast_mode(FL_CONTRAST_CUSTOM) .

Your custom contrast function must provide the signature

Fl_Color my_contrast_function(Fl_Color fg, Fl_Color bg, Fl_Fontsize fs, int context)
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1073

The arguments are the same as for the full fl_contrast() function since FLTK 1.4. You can use the supplied fontsize fs to modify the result. Depending on the caller the fs parameter can be 0 (default) or a valid fontsize.

The context parameter is not yet used and will always be 0 unless included in a call to fl_contrast(). The value 0 should be interpreted as text. In the future the context argument will be used to supply a different context than text (small icons, large icons, etc.). The exact usage is not yet specified.

Your function may also use fl_contrast_level() to modify the result accordingly.

Since
1.4.0
See also
fl_contrast_mode(int)
fl_contrast_level(int)
fl_contrast()

◆ fl_contrast_level() [1/2]

int fl_contrast_level ( )

Get the contrast level (sensitivity) of the fl_contrast() method.

This returns the level of the currently selected contrast mode.

Returns
The current contrast level.
See also
fl_contrast_level(int level)
fl_contrast_mode(int mode)
Since
1.4.0

◆ fl_contrast_level() [2/2]

void fl_contrast_level ( int  level)

Set the contrast level (sensitivity) of the fl_contrast() method.

This can be used to tune the legacy fl_contrast() function to achieve slightly better results. The default value is defined per contrast mode (see below). Values between 50 and 70 are recommended but you can raise it up to 100. Lower values than 50 are probably not useful.

The contrast level affects not only the legacy (1.3.x) fl_contrast() function but also the new CIELAB contrast mode which is the default since FLTK 1.4.0.

Other contrast modes are currently not affected by the contrast level.

You may use the contrast level if you define your own custom contrast function in mode FL_CONTRAST_CUSTOM.

Note
All contrast modes store their own contrast level because the behavior is slightly different. You must change the contrast mode fl_contrast_mode() before you set or get the contrast level.

The default contrast level is

  • 50 in mode FL_CONTRAST_LEGACY (compatible with FLTK 1.3.x)
  • 55 in mode FL_CONTRAST_CIELAB
  • 0 (undefined) for all other modes

See the description of fl_contrast_mode(int mode) for more information about the contrast level per mode.

Example:

int fl_contrast_level()
Get the contrast level (sensitivity) of the fl_contrast() method.
Definition fl_contrast.cxx:192

A level greater than 50 (probably best in the range 50 to 70) may achieve better results of the legacy fl_contrast() function in some border cases of low contrast between foreground and background colors but we recommend to use the new default algorithm FL_CONTRAST_CIELAB unless you need strict backwards compatibility or use a CPU constrained embedded system.

Parameters
[in]levelvalid range is 0 to 100
Since
1.4.0

◆ fl_contrast_mode() [1/2]

int fl_contrast_mode ( )

Return the current contrast algorithm (mode).

Returns
Contrast algorithm (mode).
Since
1.4.0
See also
fl_contrast_mode(int)

◆ fl_contrast_mode() [2/2]

void fl_contrast_mode ( int  mode)

Set the contrast algorithm (mode).

You can use one of

  • FL_CONTRAST_NONE (not recommended: returns the foreground color)
  • FL_CONTRAST_LEGACY (same as in FLTK 1.3.x)
  • FL_CONTRAST_CIELAB (default since FLTK 1.4.0)
  • FL_CONTRAST_CUSTOM (you must define your own contrast algorithm)

If you set FL_CONTRAST_CUSTOM you must also register your custom contrast function by calling fl_contrast_function().

You may set the contrast level fl_contrast_level(int) after setting the contrast mode. This affects the contrast algorithm as described below:

  • FL_CONTRAST_LEGACY: default level is 50 which is compatible with FLTK 1.3.x and older. This mode is no longer the default and is not recommended because it doesn't take human contrast perception into account and doesn't properly handle sRGB color values. You may get better contrasts if you set the level higher than 50. Values in the range 50 to 70 may be useful. Higher values result in higher contrast, i.e. the algorithm switches "earlier" to black or white mode.
  • FL_CONTRAST_CIELAB: defaut level is 55 which appears to be a good value. The higher the level is, the more contrast is to be expected. Values in the range below 55 accept lower contrast and values above 55 switch "earlier" to black or white. Values between 45 and 65 may yield usable contrast experience.
Parameters
[in]modeif invalid, FL_CONTRAST_CIELAB will be selected
Since
1.4.0
See also
fl_contrast_function(Fl_Contrast_Function *)
fl_contrast_level(int)

◆ fl_font() [1/2]

Fl_Font fl_font ( )
inline

Return the face set by the most recent call to fl_font().

This can be used to save/restore the font.

◆ fl_font() [2/2]

void fl_font ( Fl_Font  face,
Fl_Fontsize  fsize 
)

Sets the current font, which is then used in various drawing routines.

You may call this outside a draw context if necessary to measure text, for instance by calling fl_width(), fl_measure(), or fl_text_extents(), but on X this will open the display.

The font is identified by a face and a size. The size of the font is measured in pixels and not "points". Lines should be spaced size pixels apart or more.

◆ fl_height() [1/2]

int fl_height ( )
inline

Return the recommended minimum line spacing for the current font.

You can also use the value of size passed to fl_font().

◆ fl_height() [2/2]

int fl_height ( int  font,
int  size 
)

This function returns the actual height of the specified font and size.

Normally the font height should always be 'size', but with the advent of XFT, there are (currently) complexities that seem to only be solved by asking the font what its actual font height is. (See STR#2115)

This function was originally undocumented in 1.1.x, and was used only by Fl_Text_Display. We're now documenting it in 1.3.x so that apps that need precise height info can get it with this function.

Returns
the height of the font in pixels.
Todo:
In the future, when the XFT issues are resolved, this function should simply return the 'size' value.

◆ fl_latin1_to_local()

const char * fl_latin1_to_local ( const char *  t,
int  n = -1 
)

Convert text from Windows/X11 latin1 character set to local encoding.

Parameters
[in]tcharacter string (latin1 encoding)
[in]noptional number of characters (bytes) to convert (default is all)
Returns
pointer to internal buffer containing converted characters

◆ fl_lightness()

double fl_lightness ( Fl_Color  color)

Return the perceived lightness of a color.

This function calculates the perceived lightness of Fl_Color color.

The returned lightness value Lstar according to the CIELAB (L*a*b*) color model is almost linear with respect to human perception. It is in the range 0 (black) to 100 (white).

The result values of two colors can be compared directly and the difference is their perceived contrast.

Parameters
[in]colorFl_Color value
Returns
perceived lightness (0 .. 100)
Since
1.4.0

◆ fl_local_to_latin1()

const char * fl_local_to_latin1 ( const char *  t,
int  n = -1 
)

Convert text from local encoding to Windows/X11 latin1 character set.

Parameters
[in]tcharacter string (local encoding)
[in]noptional number of characters (bytes) to convert (default is all)
Returns
pointer to internal buffer containing converted characters

◆ fl_local_to_mac_roman()

const char * fl_local_to_mac_roman ( const char *  t,
int  n = -1 
)

Convert text from local encoding to Mac Roman character set.

Parameters
[in]tcharacter string (local encoding)
[in]noptional number of characters to convert (default is all)
Returns
pointer to internal buffer containing converted characters

◆ fl_luminance()

double fl_luminance ( Fl_Color  color)

Return the raw / physical luminance of a color.

This function calculates the physical luminance of Fl_Color color.

The returned luminance value (aka Y) is the physical luminance of the Fl_Color color.

The result is in the range 0.0 (black) to 1.0 (white).

Note
This is probably not what you want if you are interested in perceived contrast or lightness calculation because the luminance Y is not linear with respect to human perception.

See fl_lightness(Fl_Color) for a function that returns the perceived lightness of a color which can be used directly for contrast calculation.

Parameters
[in]colorFl_Color value
Returns
Raw (physical) luminance (0.0 .. 1.0)
Since
1.4.0
See also
fl_lightness(Fl_Color)

◆ fl_mac_roman_to_local()

const char * fl_mac_roman_to_local ( const char *  t,
int  n = -1 
)

Convert text from Mac Roman character set to local encoding.

Parameters
[in]tcharacter string (Mac Roman encoding)
[in]noptional number of characters to convert (default is all)
Returns
pointer to internal buffer containing converted characters

◆ fl_show_colormap()

Fl_Color fl_show_colormap ( Fl_Color  oldcol)

Pops up a window to let the user pick a colormap entry.

Parameters
[in]oldcolcolor to be highlighted when grid is shown.
Return values
Fl_Colorvalue of the chosen colormap entry.
See also
Fl_Color_Chooser

◆ fl_size()

Fl_Fontsize fl_size ( )
inline

Return the size set by the most recent call to fl_font().

This can be used to save/restore the font.

◆ fl_text_extents() [1/2]

void fl_text_extents ( const char *  c,
int &  dx,
int &  dy,
int &  w,
int &  h 
)

Determine the minimum pixel dimensions of a nul-terminated string using the current fl_font().

Usage: given a string "txt" drawn using fl_draw(txt, x, y) you would determine its pixel extents on the display using fl_text_extents(txt, dx, dy, wo, ho) such that a bounding box that exactly fits around the text could be drawn with fl_rect(x+dx, y+dy, wo, ho). Note the dx, dy values hold the offset of the first "colored in" pixel of the string, from the draw origin.

Note the desired font and font size must be set with fl_font() before calling this function.

This differs slightly from fl_measure() in that the dx/dy values are also returned.

No FLTK symbol expansion will be performed.

Example use:

int dx,dy,W,H;
fl_font(FL_HELVETICA, 12); // set font face+size first
fl_text_extents("Some text", dx, dy, W, H); // get width and height of string
printf("text's width=%d, height=%d\n", W, H);
const Fl_Font FL_HELVETICA
Helvetica (or Arial) normal (0)
Definition Enumerations.H:1046
void fl_text_extents(const char *, int &dx, int &dy, int &w, int &h)
Determine the minimum pixel dimensions of a nul-terminated string using the current fl_font().
Definition fl_font.cxx:40
Fl_Font fl_font()
Return the face set by the most recent call to fl_font().
Definition fl_draw.H:796

◆ fl_text_extents() [2/2]

void fl_text_extents ( const char *  t,
int  n,
int &  dx,
int &  dy,
int &  w,
int &  h 
)
inline

Determine the minimum pixel dimensions of a sequence of n characters (bytes) using the current fl_font().

Note
The string length is measured in bytes, not (UTF-8) characters.
See also
fl_text_extents(const char*, int& dx, int& dy, int& w, int& h)

◆ fl_width()

double fl_width ( unsigned int  c)
inline

Return the typographical width of a single character using the current font face and size.

Note
If a valid fl_gc is NOT found then it uses the first window gc, or the screen gc if no fltk window is available when called.

◆ free_color()

void Fl::free_color ( Fl_Color  i,
int  overlay = 0 
)
static

Frees the specified color from the colormap, if applicable.

If overlay is non-zero then the color is freed from the overlay colormap.

◆ get_color() [1/3]

unsigned Fl::get_color ( Fl_Color  i)
static

Returns the RGB value(s) for the given FLTK color index.

This form returns the RGB values packed in a 32-bit unsigned integer with the red value in the upper 8 bits, the green value in the next 8 bits, and the blue value in bits 8-15. The lower 8 bits will always be 0.

◆ get_color() [2/3]

void Fl::get_color ( Fl_Color  i,
uchar red,
uchar green,
uchar blue 
)
static

Returns the RGB value(s) for the given FLTK color index.

This form returns the red, green, and blue values separately in referenced variables.

See also
unsigned get_color(Fl_Color c)

◆ get_color() [3/3]

void Fl::get_color ( Fl_Color  i,
uchar red,
uchar green,
uchar blue,
uchar alpha 
)
static

Returns the RGBA value(s) for the given FLTK color index.

This form returns the red, green, blue, and alpha values separately in referenced variables.

See also
unsigned get_color(Fl_Color c)

◆ get_font()

const char * Fl::get_font ( Fl_Font  fnum)
static

Gets the string for this face.

This string is different for each face. Under X this value is passed to XListFonts to get all the sizes of this face.

◆ get_font_name()

const char * Fl::get_font_name ( Fl_Font  fnum,
int *  attributes = 0 
)
static

Get a human-readable string describing the family of this face.

This is useful if you are presenting a choice to the user. There is no guarantee that each face has a different name. The return value points to a static buffer that is overwritten each call.

The integer pointed to by attributes (if the pointer is not zero) is set to zero, FL_BOLD or FL_ITALIC or FL_BOLD | FL_ITALIC. To locate a "family" of fonts, search forward and back for a set with non-zero attributes, these faces along with the face with a zero attribute before them constitute a family.

◆ get_font_sizes()

int Fl::get_font_sizes ( Fl_Font  fnum,
int *&  sizep 
)
static

Return an array of sizes in sizep.

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. Warning: the returned array points at a static buffer that is overwritten each call. Under X this will open the display.

◆ set_color() [1/3]

void Fl::set_color ( Fl_Color  i,
unsigned  c 
)
static

Sets an entry in the fl_color index table.

You can set it to any 8-bit RGB color. The color is not allocated until fl_color(i) is used.

◆ set_color() [2/3]

void Fl::set_color ( Fl_Color  i,
uchar  red,
uchar  green,
uchar  blue 
)
static

Sets an entry in the fl_color index table.

You can set it to any 8-bit RGB color. The color is not allocated until fl_color(i) is used.

◆ set_color() [3/3]

void Fl::set_color ( Fl_Color  i,
uchar  red,
uchar  green,
uchar  blue,
uchar  alpha 
)
static

Sets an entry in the fl_color index table.

You can set it to any 8-bit RGBA color.

Note
The color transparency is effective under the Wayland, hybrid Wayland/X11 and macOS platforms, whereas it has no effect under the X11 and Windows platforms. It's also effective for widgets added to an Fl_Gl_Window.
Version
1.4

◆ set_font()

void Fl::set_font ( Fl_Font  fnum,
const char *  name 
)
static

Changes a face.

Parameters
fnumThe font number to be assigned a new face
nameName of the font to assign. The string pointer is simply stored, the string is not copied, so the string must be in static memory. The exact name to be used depends on the platform :
  • Windows, X11, Xft: use the family name prefixed by one character to indicate the desired font variant. Characters ' ', 'I', 'B', 'P' denote plain, italic, bold, and bold-italic variants, respectively. For example, string "IGabriola" is to be used to denote the "Gabriola italic" font. The "Oblique" suffix, in whatever case, is to be treated as "italic", that is, prefix the family name with 'I'.
  • Other platforms, i.e., X11 + Pango, Wayland, macOS: use the full font name as returned by function Fl::get_font_name() or as listed by applications test/fonts or test/utf8. No prefix is to be added.

◆ set_fonts()

Fl_Font Fl::set_fonts ( const char *  xstarname = 0)
static

FLTK will open the display, and add every fonts on the server to the face table.

It will attempt to put "families" of faces together, so that the normal one is first, followed by bold, italic, and bold italic.

The only argument to this function is somewhat obsolete since FLTK and most underlying operating systems move to support Unicode. For completeness, following is the original documentation and a few updates:

On X11, the optional argument is a string to describe the set of fonts to add. Passing NULL will select only fonts that have the ISO8859-1 character set (and are thus usable by normal text). Passing "-*" will select all fonts with any encoding as long as they have normal X font names with dashes in them. Passing "*" will list every font that exists (on X this may produce some strange output). Other values may be useful but are system dependent.

With the Xft option on Linux, this parameter is ignored.

With Windows, NULL selects fonts with ANSI_CHARSET encoding and non-NULL selects all fonts.

On macOS, this parameter is ignored.

The return value is how many faces are in the table after this is done.