The pixfont command is used to create, delete, and query fonts from
Tcl (Tk not required). Those font handles can be used to draw text inside
images using the pixane command. It is a Tcl
wrapper around the Pixane C library. It can take several
different forms, depending on the option argument. The legal forms are:
- pixfont create ?name? ?option value ...?
- Creates a new font handle and returns its name. name specifies the name for the
font; if it is omitted then Pixane picks a name of the form pixfontx, where x is an integer.
There may be any number of option-value pairs, which provide configuration options for the
new font. If a font already exists by the
given name then an error is returned. Supported options are :
- -builtin ?fontlabel?
- Create a font handle for one of the builtin fonts. fontlabel must of of
the form family ?bold? ?italic?, where family is one of
serif, sansserif, or monotype. Some
families are accepted for
compatibilities, and are considered as aliases:
- "times" and "times new roman" are equivalent to serif
- "sans-serif", "arial", "helvetica" and "verdana" are
equivalent to sansserif
- "mono", "courier new" and "courier" are aliases for
monotype
If no fontlabel is specified, it defaults to
serif. According to build options, support for some or
all builtin fonts may be removed.
- -file ?filename?
- filename gives the name of a file that is to be read to supply data for the
font.
- -data ?data?
- Specified the contents of the font as a binary string.
- pixfont delete ?fontHandle fontHandle ...?
- Deletes each of the named fonts and returns an empty string.
- pixfont measure fontHandle fontsize text
- Measure box required to render text using font mapped to
fontHandle, using font size fontsize. Returns
width, ascending and
descending properties, as a list of 3 integers.
- pixfont metrics font fontsize
- Get metrics for font fontHandle. Returns ascending and
descending
properties, as a list of 2 integers. Metrics is a property intrinsic
to a a font, and doesn't relies on any rendered text.
Pixfont uses the FreeType to handle
fonts, so it can handle fonts in any format supported by a freetype
module. By default, FreeType 2 supports the following font formats:
- TrueType fonts (and collections)
- Type 1 fonts
- CID-keyed Type 1 fonts
- CFF fonts
- OpenType fonts (both TrueType and CFF variants)
- SFNT-based bitmap fonts
- X11 PCF fonts
- Windows FNT fonts
- BDF fonts (including anti-aliased ones)
- PFR fonts
- Type42 fonts (limited support)