gdk::font_load

gdk::font_load

GdkFont gdk::font_load (string font_name);

This method loads a font_name, which must be given in the form of an X Logical Font Description (XLFD).

The XLFD is a way of describing a font that is completely system-independant. It contains 14 fields, most of which can be represented by a wildcard * in order to allow flexibility when a match is being sought - the exceptions are addedstyle, which doesn't need one, and registry, which is the only mandatory field. The description opens with a hyphen, -, and each field is also separated by a hyphen.

If you need more information on fonts than is given here, the full XWindows definition is available online through the relevant XWindows documentation.

foundry xxx (where the font was created. 'unknown' is okay)
family xxx (e.g. Arial)
weight xxx (e.g. bold, medium)
slant x (r - roman, i = italic, o = oblique)
setwidth xxx (e.g. normal, condensed)
addedstyle xxx (e.g. serif, sans. Leave blank for none)
pixelsize N (set either this or pointsize, not both)
pointsize N (point size, e.g. 120)
resx N (x res the font was created for, in dots per inch)
resy N (y res the font was created for, in dots per inch)
space x (m = monospaced, p = proportional, c = cell)
averagewidth N (average character width in pixels. 0 if unknown)
registry xxx (e.g. utf, iso8859 or adobe)
encoding xxx (e.g. 1 or 2 (for iso8859) or fontspecific)

A typical font-load would look something like this: $font = gdk::font_load('-unknown-Arial-normal-r-normal--*-120-96-96-p-0-iso8859-1');

Font information in the XLFD format can be retrieved from any system by utilising the GtkFontSelection or GtkFontSelectionDialog widgets.

Note that there are sizing issues in GdkFont in the version of GTK+ currently used in PHP-GTK under win32. As a result, the point size should always be set in win32 - using the pixel size may give unexpected results.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.