Tcl Package for 'font'

These modules will be built:
font: Version 4.1
creates libfont4.1.so and libfont4.1.tsl

The following indices are available:

File Index

The following files have been documented:
font.tcl

Procedure Index

The following procedures have been documented:
sub Font
font management


File font.tcl


sub Font - font management

Synopsis

	sub Font { ?subcmd? args } {}

Description

We do an intermediate step at font management (until font objects are available from tk itself). We hide the intricacies of X logical font names XLFD and encapsulate the font handling in this routine, which has some subcommands.

The idea behind this routine: we define a logical font name (eg Times, or LabelFont) with the basic properties of the font (eg registry, foundry, charset, but also size and slant).

A definition looks like this:

        Font def LabelFont \
        -foundry adobe -family helvetica -charset iso8859 \ 
        -encoding 1 -spacing p -pixel 0 \ 
           -slant normal -width normal -weight normal  -size 14

As you can see I used the standard XLFD conventions (don't know enough about Windows or Mac). This defines a font named LabelFont for subsequent use.

I have added the possibility to give standard attribute values for many of the more complicated things of X font naming (there are different names to indicate slant on X fonts - i and o for example). You always say -slant italic, the font routines do the proper conversions if you have already given -foundry and -family.

All values not mentioned will be replaced by * in the output.

Logical fontnames make it easy to change fonts througout the source code as the use looks always something like this:

        button .b -text "huhu?" -font [Font get LabelFont]

To give the button a bold appearance you can define a new logical font or (if this is just a onetime change) do this

        button .b config -font [Font get LabelFont -weight bold]

Of course you can do more complicated things:

        button .b -font [Font get LabelFont -weight bold \
                 -slant italic -size 24]

Arguments

Font def name args
Define a new font with the name given by name. args is a list of var - value pairs, where var may be one of the following:
-foundry
-family
-weight
-slant
-width
-style
-pixel
-size
-xres
-yres
-spacing
-avgwidth
-charset
-encoding

See one of the X books (eg Oliver Jones Introduction To The X Window System) for a proper description of what they mean. this routine returns an empty string

Font get name args
return the font associated with a logical font name modified by additional attributes passed.
Font exists name
returns 1 if the logical font with the given name exists, otherwise returns 0. Note that this does not imply that an X font with this property may be available. Use Font check for this.
Font names
returns a list of all defined logical font names.
Font check name args
check if an X font is available that corresponds to the given logical font (which must already exist) which is first modified by the additional attributes. Returns 1 if such a font is available, 0 otherwise.

Return Value

depends on the subfunction.