Class ::tycho::FontManager


Inherits: ::tycho::Uninstantiable - Related constructs - Source File - Contents: public procs
Manage font selection. This is a "non-instantiable" class that manages selection of fonts. It simplifies the interface to the available fonts in aa number of ways:

Unfortunately, fonts are a major weak point in the X window system, since there is only one font that is guaranteed to be installed on all systems: "fixed". This font is the fallback font of the getFont procedure, which always returns a valid font.


Public constructs

Public Procs

size {proposed {}} {shift 0}
Return a legal font size or sizes. If no arguments are given, return a list of legal font sizes. If the first argument is given, return that size if it is legal or a similar size if it is not. If the second argument is also given, return the size shifted by that many legal font sizes.
checkXFont font
Return 0 if the specified font is not available on the current system, otherwise return 1.
getFont family {size 12} {style roman} {shift 0}
Find a font, given a partial specification of the font. This procedure always returns a legal X font name. The family name is compulsory, but everything else is optional. A font specification consists of three items, the family, point size, and style. Common families are "Times", "Courier", and "Helvetica". Reasonable point sizes are 12, 14, 18, and 24. If omitted, it defaults to 12. The style can be one of "Roman," "Italic," "Bold," or "Bold Italic." If the style is omitted, it defaults to "Roman". The final optional argument specifies the font size relative to the given size. This field must be an integer: it's value indicates the number of legal font sizes to move. For example, "-1" will return the next smaller size. (Note that this value is not in points!)

All arguments are case-insensitive.

In addition to the real font families, there is the psuedo-family "Screen," which is mapped to constant-width X screen fonts. Also, the font family can be one of "Serif," "Sans-serif," or "Constant-width," in which case the preferred font of the specified type is chosen.

If the font request is not found immediately, this procedure attempts to find a reasonable alternative:

  1. Try an alternate family name, such as "lucida bright" instead of "lucidabright."
  2. Try an alternate family. For example, if times is requested, try lucidabright and palatino.
  3. If the requested font is bold, try a non-bold version.
  4. If the requested font is italicised, try a roman version.
  5. Try the same thing with the next size up.
  6. Try the same thing with the next size down.
  7. Give up and return "fixed."
.
family {type {}} {family {}} args
Set or get the font manager's preferred font families. If no arguments are given, then return a list of preferred font families. If a single argument is given then it is the "type" of font family, and is one of "serif," "sansserif," or "constantwidth": the procedure return a list of font families of that particular type. If the two or more arguments are given, then the second argument is the family name which is added to the list of preferred fonts of a particular type. Following arguments are a list of alternative fonts to scan through if the font manager fails to satisfy a request for that family.

Warning: Use of this procedure with more than one argument is not for casual use. The facility is provided to allow customization of the font choices for particular Tycho installations, not to allow users (for example) to arbitrarily mess with the font setup.

A special value of the family argument is recognized: if "replace" then the list of fonts that particular type is set to following arguments Note again that this is only for customization to a particular installation.

getXFont family {size 12} {weight medium} {style r} {shift 0}
Find a font, given a symbolic specification of the font. This procedure always returns a legal X font name. A font specification consists of four items, the family, point size, weight, and style. Common families are "Times", "Courier", and "Helvetica". Reasonable point sizes are 12, 14, 18, and 24. The weight is typically either "medium" or "bold", and the style is either "r" or "i" for roman or italic. If the style is omitted, it defaults to "r". If the style and weight are omitted, they default to "medium" and "r". If the point size, style, and weight are omitted, they default to "14", "medium", and "r". The family is not optional.

Warning: This procedure is available publicly only because not all files have been updated to use getFont. Do not call it directly.

Index of classes



Author: Edward A. Lee, John Reekie
Version: @(#)FontManager.itcl 1.39 12/16/96
Copyright: Copyright (c) 1995-1996 The Regents of the University of California.