This chapter describes how to work with fonts on Silicon Graphics computers. It begins with an introduction to fonts and digital typography. Then it explains which fonts are available and how to install additional fonts. It also covers how to download outline fonts in the Type 1 format to a PostScript printer.
This chapter contains these sections:
“Font Basics” defines fonts and provides some general background information.
“Using Fonts with the X Window System” discusses some of the X Window System's most useful font utilities.
“Installing and Adding Font and Font Metric Files” explains how to install and add font files and font metric files for system-wide use.
“Downloading a Type 1 Font to a PostScript Printer” explains how to download a Type 1 font to a PostScript® printer.
Fonts are collections of characters. A font contains the information about the shape, size, and position of each character in a character set. That information is needed by those programs which process characters, such as editing, word-processing, desktop-publishing, multimedia, titling, and pre-press application programs. Almost all software components in a computer system use fonts to display messages, prompts, titles, and so forth.
Computers from Silicon Graphics are called digital computers, because discrete voltage levels are used to represent the binary digits 0 and 1. Binary digits are used to represent all other information stored in a digital computer, including fonts. Digital typography deals with the style, arrangement, and appearance of typeset matter in digital systems. If you want to use font and font metric files to correctly typeset text on a digital computer, you need to know some basics about digital typography. This section contains a brief introduction to fonts and digital typography. You may want to read a book on typography for more in-depth information.
This section covers the following topics:
“Terminology” introduces a few basic terms.
“How Resolution Affects Font Size” describes horizontal and vertical resolution, pixels, and bitmap fonts.
“Font Names” explains the 14-part font name.
“Writing Programs That Need to Use Fonts” covers X programs, DPS programs, and IRIS GL and IRIS GL/X programs.
Before discussing how to use fonts, consider these few terms.
The images on some output devices, such as laser printers and some types of video monitors, are created by drawing small dots or pixels (picture elements). The number of dots or pixels that can be drawn per unit of length in a horizontal direction is called the horizontal resolution, while the number of dots or pixels that can be drawn per unit of length in a vertical direction is called the vertical resolution. The most commonly used unit of measure for resolution is the number of dots per inch (dpi). The size of each dot or pixel decreases as the resolution of the output device increases and vice versa; therefore, dots and pixels are device-dependent units of measure.
To display the resolution of your video monitor, enter this command:
xdpyinfo | grep resol |
You should get a response similar to this:
resolution: 96x96 dots per inch |
If you draw all of the characters in a font in the same place (without advancing), you will get a composite image of those characters. If you then draw smallest rectangle that encloses that image, you will get the bounding box for that font. The size of a font is usually measured in the vertical direction. That size is usually not smaller than the height of a font bounding box, but it can be greater than that height. It may include additional vertical spacing that is considered part of the font design.
Typographers use small units of measure called points to specify font size. A point is approximately equal to 1/72 of an inch. The exact value is 1/72.27 (0.013837) of an inch or 0.351 mm.
A point is a device-independent unit of measure. Its size does not depend on the resolution of an output device. A 12-point font should have approximately the same size on different output devices, regardless of the resolution of those devices.
If the resolution of an output device is equal to 72 dots per inch (dpi), the size of a dot or pixel is approximately equal to the size of a point. If the resolution of an output device is greater than 72 dpi, the size of a dot or pixel is smaller than the size of a point, and vice versa. You can use the following formula to calculate a pixel size from a point size:
pixel-size = point-size x device-resolution / 72.27 |
A bitmap font is usually designed for a particular resolution. That font has the point size specified by its designer only when it is used on an output device whose resolution matches the resolution for which that font was designed. This is because a font designer specifies a fixed bitmap for each character. If a pixel is smaller than a point, characters will be smaller than intended, and vice versa.
When a font is designed, it is assigned a name such as Courier Oblique. This font belongs to a font family called Courier, which includes:
Courier
Courier Bold
Courier Bold Oblique
Courier Oblique
The size of a font is usually not specified for scalable fonts, because they can be scaled to any specified size. Bitmap fonts are usually designed in specific sizes. They are referred to by names such as 12-point Courier or 10-pixel Courier Bold.
When the PostScript page description software language was developed by Adobe Systems, the spaces embedded in font names were replaced with dashes. PostScript font names look like this:
Courier Courier-Bold Courier-BoldOblique |
The X Consortium specified 14-part font names for the X Window System.
Figure 3-1 shows an example 14-part name for a bitmap font, with each part labeled. In this Point sizes in X font names are specified in decipoints (tenths of a point).
For a detailed description of X font names, see the recommended X Window System documentation.
You can write different types of programs for Silicon Graphics computers, for example, X, Display PostScript (DPS), IRIS GL, OpenGL, and mixed-model programs. Some of your programs need fonts.
How a program accesses font files depends on the program type:
X programs access fonts by calling X font functions, such as XListFonts() and XLoadFont().
DPS programs access fonts by calling X and DPS functions, or by using PostScript.
IRIS GL and IRIS GL/X mixed-model programs usually access fonts by calling font management (fm) functions from the IRIS GL Font Manager library (fmenumerate() and fmfindfont() for example).
Most fonts are installed when you install the X Window System (X11 Execution Environment). Some fonts are installed with other software components, such as DPS, Impressario™ and IRIS Showcase™. Japanese fonts are installed when you install the Japanese Language System. However, most fonts are shared by the X Window System, DPS (which is an extension of the X Window System), IRIS GL Font Manager, and other software components.
To maintain compatibility and portability, it is best not to access font files directly from an application program because font formats, font names, font contents, and the location of font directories may change. Your program should use the Application Programming Interfaces (APIs) specified for the X Window System, DPS, and IRIS GL Font Manager, or call even higher level functions for the 2D and 3D text available from toolkits such as Inventor™ and Performer.
This section describes how to use fonts with the X Window System. The X Window System has several font utilities. This section covers a few of the most useful utilities and includes:
“Getting a List of Font Names and Font Aliases”explains using the xlsfonts command.
“Viewing Fonts” describes the xfd command.
“Getting the Current X Font Path” covers the xset command.
“Changing the X Font Path” explains the xset fp command.
For a complete description of the utilities, refer to your X Window System documentation.
To find out which font names and font aliases are known to the X Window System, enter this command:
xlsfonts > /tmp/fontlist |
The resulting file, fontlist, contains entries such as:
-adobe-courier-bold-o-normal--0-0-0-0-m-0-iso8859-1 -adobe-courier-bold-o-normal--14-100-100-100-m-90-iso8859-1 -sgi-screen-medium-r-normal--14-140-72-72-m-70-iso8859-1 screen14 |
The first entry is an example of a 14-part X name for an outline (scalable) font. Numeric parts of font names are set to zero for outline fonts, because those fonts can be scaled to various sizes. The second and third entries are examples of 14-part X font names for bitmap fonts, while the last entry is an alias for the third entry. An X or DPS program can get a list of available fonts by calling XListFonts() or the function XListFontsWithInfo().
To see what a particular font looks like, use the command xfd, and specify a font name or font alias from the file fontlist by using the option -fn. For example, to display the 14-point Adobe Courier Bold font, enter:
xfd -fn -adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1
|
To request a Utopia Regular font scaled to the size of 28 points, enter:
xfd -fn -adobe-utopia-medium-r-normal--0-280-0-0-p-0-iso8859-1 |
You can use wild cards (*) to indicate that any value is acceptable for parts of an X font name. For example, enter:
xfd -fn "-*-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1" |
to indicate that xfd can use a Courier Bold font from any foundry. Enclose the X font name on a command line in single or double quotes when that name contains wild cards or embedded space characters.
The xfd command displays all characters in the specified font, as shown in Figure 3-2.
To open a shell window that uses a certain font, enter:
xwsh -fn font-name |
To display the current X font path, enter this command:
xset q |
In addition to other information, the xset utility displays font path information that may look like this:
Font Path: /usr/lib/X11/fonts/100dpi/,/usr/lib/X11/fonts/75dpi/, /usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/Type1/, /usr/lib/X11/fonts/Speedo |
The X Window System checks the resolution of your video monitor. If that resolution is closer to 75 dpi than 100 dpi, it puts the directory 75dpi ahead of the directory 100dpi in the X font path.
This section explains where the various types of font and font metric files are installed by default, and how you can add one of your font or font metric files to the IRIX operating system.
This section describes the following topics:
“Installing Font and Font Metric Files” covers getting and changing the current X font path.
“Adding Font and Font Metric Files” details adding a bitmap and outline font, and adding a font metric file.
By default, bitmap font files are installed in these directories: /usr/lib/X11/fonts/100dpi, /usr/lib/X11/fonts/75dpi, and /usr/lib/X11/fonts/misc . The 100dpi directory contains bitmap fonts designed for the screen resolution of 100 dpi. The 75dpi directory contains bitmap fonts designed for the screen resolution of 75 dpi. The misc directory contains miscellaneous other fonts.
By default, outline font files in the Type 1 format are installed in the directory /usr/lib/DPS/outline/base.
By default, font files in the directories listed above are used by the X Window System, DPS, IRIS GL Font Manager, and other software components.
The X Window System accesses Type 1 font files with symbolic links in the directory /usr/lib/X11/fonts/Type1.
By default, outline font files in the Speedo™ format are installed in the directory /usr/lib/X11/fonts/Speedo. Font files in this directory are currently used only by the X Window System.
By default, Adobe Font Metric (AFM) files are installed in the directory /usr/lib/DPS/AFM.
There is one font metric file per typeface. Font metric files are primarily used by text-processing and desktop-publishing programs to, for example, generate PostScript code for a specified document.
When you purchase fonts or obtain a font that is in the public domain, you may need to add that font to your system or printer in order to use it. Adobe Systems donated bitmap, outline, and font metric files for the Utopia font family to the X Consortium. This section shows how the font and font metric files for Utopia Regular were added to the IRIX operating system. Other font and font metric files can be added in a similar way.
You must log in as root to make any changes to X font directories. Before you make any changes to any IRIX directory, you should make a copy of its contents so that you can restore that directory if anything goes wrong. For example, your font files may not be in the right format, and they may interfere with the access of Silicon Graphics font files. You should keep a log of the changes you make, and mention those changes when you report a problem with font files to Silicon Graphics; otherwise, it may be very difficult or impossible for other people to reproduce any problems that you might report.
As an example, we show how Utopia Regular bitmap fonts were added to IRIX. Other fonts can be added in a similar way.
To add the Utopia bitmap fonts to the X Window System, Display PostScript, and IRIS GL Font Manager, follow the steps below.
Log in as root.
Look at the names of existing bitmap font files and try to match these names when you specify new font names. For example, Adobe provided two sets of Utopia Regular bitmap font files that were designed for the resolutions of 100 and 75 dpi. These files were in the extended Bitmap BDF 2.1 format.
The names of the bitmap files were:
UTRG_10.bdf through UTRG_24.bdf |
When these fonts were added to IRIX, the names were changed to:
utopiaR10.bdf through utopiaR24.bdf |
to match the names of other X bitmap font files.
Convert the BDF font files to Portable Compiled Format (PCF) font files.
BDF font files are text (ASCII) files. You can think of them as source font files. You could put BDF font files into an X font directory, but people usually use binary font formats such as the PCF (.pcf) or compressed PCF format (.pcf.Z), so you should covert new fonts to one of these formats.
To convert a BDF font file to a PCF font file, enter a command such as:
bdftopcf -o file-name.pcf file-name.bdf |
![]() | Note: If you have used the bdftopcf command before, you may not have specified the name of the output file, but the command now requires that you enter the name of the output file. |
You can compress a PCF file by entering a command such as:
compress file-name.pcf |
That should give you a file called:
file-name.pcf.Z |
Most bitmap font files shipped by Silicon Graphics are in the compressed PCF format to save on disk space.
Put the bitmap font files for 100 dpi in the directory: /usr/lib/X11/fonts/100dpi.
You can tell the resolution for which a font was designed by the name of the directory in which the font designer stored the font files, or by the information in the header of a bitmap font file. In a BDF 2.1 font file, the horizontal (x) and vertical (y) resolution are specified in the X font name. They are also specified after the point size as the second and third numeric values in a SIZE entry. For example, the entry:
SIZE 8 100 100 |
indicates an 8-point font that was designed for the horizontal and vertical resolution of 100 dpi.
For example, when 100-dpi Utopia Regular bitmap font files were added to IRIX, they were moved to the directory /usr/lib/X11/fonts/100dpi.
Similarly, put the bitmap font files for 75 dpi in the directory /usr/lib/X11/fonts/75dpi, and put other bitmap fonts into the directory /usr/lib/X11/fonts/misc.
For example, when 75-dpi Utopia Regular bitmap font files were added to IRIX, they were placed in the directory /usr/lib/X11/fonts/75dpi.
For most font families shipped by Silicon Graphics, there is one entry per font family in the file:
/usr/lib/X11/fonts/ps2xlfd_map |
The same entry is used for both bitmap and outline fonts. A typical entry in this file looks like this:
Utopia-Regular -adobe-utopia-medium-r-normal--0-0-0-0-p-0-iso8859-1
For each Japanese font family shipped by Silicon Graphics, there is an entry in the file:
/usr/lib/X11/fonts/ps2xlfd_map.japanese |
The entries are used by the IRIS Font Manager to map PostScript and other short font names to corresponding X font names. The IRIS Font Manager does not use any bitmap fonts that do not have an entry in those files.
If you add your own (local) bitmap or outline fonts, you should put an entry for each font family in a file called:
/usr/lib/X11/fonts/ps2xlfd_map.local |
If that file does not exist, log in as root, and create it. That way your entries will not disappear when you upgrade the system software on your machine.
Enter the command:
mkfontdir |
to create a new fonts.dir (fonts directory) file in that directory. For example, when Utopia Regular fonts were added to the directories 100dpi and 75dpi, the command mkfontdir was executed in both of those directories.
Enter:
xset fp rehash |
to tell the X Window System that it should check again which fonts are available.
To check whether the fonts you added are known to the X Window System, enter:
xlsfonts > /tmp/fontlist |
The names of the fonts you added should appear on the list of font names and aliases produced by xlsfonts.
Bitmap fonts should now be added to the X Window System and the IRIS GL Font Manager. Since DPS needs both outline and bitmap fonts for each supported typeface, it first checks which outline fonts are stored in the directory /usr/lib/DPS/outline/base. Then it looks for the corresponding bitmap fonts in other X font directories. It ignores all other bitmap fonts. Therefore, DPS ignores the bitmap fonts you added, until you add the corresponding outline fonts.
Make sure that there is no overlap between your entries and the entries in other ps2xlfd_map* files.
If you do not want to use long X font names, you can specify short aliases for those names. Silicon Graphics software engineers use a file called fonts.alias to specify aliases for their fonts. There may be a fonts.alias file in an X font directory. For example, see the file fonts.alias in the directory:
/usr/lib/X11/fonts/100dpi
A typical font alias looks like this:
fixed -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1 |
If you want to specify your own (local) font aliases in a font directory, you should specify them in a file called fonts.alias.local in that directory. If that file does not exist, log in as root, and create it. That way your entries will not disappear when you upgrade the system software on your machine.
AFM files are primarily used by application programs—for example, to generate PostScript code for a specified document. Follow these steps to add a font metric file, follow the steps below.
Log in as root.
Put Adobe Font Metric files in the directory /usr/lib/DPS/AFM.
For example, Adobe provided the Utopia Regular font metric file UTRG____.AFM.
The name of an AFM file should also match the PostScript font name. When this font was added to IRIX, the name of the file UTRG____.AFM was changed to Utopia-Regular, and it was put in the directory /usr/lib/DPS/AFM.
To add the Utopia Regular outline font to the X Window System, Display PostScript, and the IRIS GL Font Manager, follow the steps below.
Log in as root.
Look at the names of existing outline font files in the directory /usr/lib/DPS/outline/base. Display PostScript requires that the name of each outline font file match the PostScript font name specified in the /FontName entry in the header of that outline font file. For example, if you enter:
grep /FontName Courier-Bold |
in the directory /usr/lib/DPS/outline/base, you get:
/FontName /Courier-Bold def |
You should put only Adobe text (ASCII) Type 1 font files or compatibles into that directory, not binary Type 1 font files or Type 3 font files. Display PostScript can handle Type 3 font files, but the X Window System and IRIS GL Font Manager cannot. You should put into that directory only those outline font files that look like the font files that are already in that directory.
If you have a binary Type 1 font file (a .pfb file), you must convert it into a text (ASCII) Type 1 font file before you can use it on a Silicon Graphics system. To convert .pfb files to .pfa files, you can use the program pfb2pfa from the subsystem print.sw.desktop (shipped with IRIX operating system version 5.3 and higher).
For example, Adobe provided the Utopia Regular outline font file UTRG____.pfa, which is an outline font file in the Type 1 format, a special PostScript program that specifies a scalable outline font.
To find the PostScript font name for this font, enter:
grep /FontName UTRG____.pfa |
You should get the response:
/FontName Utopia-Regular def |
This response tells you that the PostScript font name for this font is Utopia-Regular.
When this font was added to IRIX, the name of the file UTRG____.pfa was changed to Utopia-Regular.
Put the file Utopia-Regular in the directory /usr/lib/DPS/outline/base, because that outline font is in the Type 1 format. If you have an outline font in the Speedo format, put it in the directory:
/usr/lib/X11/fonts/Speedo |
To add the Utopia Regular font and font metric files to Display PostScript, enter:
/usr/bin/X11/makepsres -o /usr/lib/DPS/DPSFonts.upr /usr/lib/DPS/outline/base /usr/lib/DPS/AFM |
You should now be able to access the font file you added via Display PostScript.
For most font families shipped by Silicon Graphics, there is one entry per font family in the file:
/usr/lib/X11/fonts/ps2xlfd_map |
as described in “Adding a Bitmap Font.” The same entry is used for both bitmap and outline fonts.
If you add your own (local) bitmap or outline fonts, you should put an entry for each font family in the file called:
/usr/lib/X11/fonts/ps2xlfd_map.local |
You can use entries in the file ps2xlfd_map as templates for entries in the file ps2xlfd_map.local.
If the file ps2xlfd_map.local does not exist, log in as root, and create it.
You should now be able to access the font you added via the IRIS GL Font Manager.
Display PostScript is an extension of the X Window System. To add an outline font in the Type 1 format to the rest of the X Window System, in any directory, enter the commands:
type1xfonts xset fp rehash |
This recreates symbolic links in the directory /usr/lib/X11/fonts/Type1 that point to outline font files in the directory /usr/lib/DPS/outline/base, and instructs the X Window System to check which fonts are available.
To check whether the outline fonts you added are known to the X Window System, enter:
xlsfonts > /tmp/fontlist |
The entries for the outline fonts you added should appear on the list of font names and aliases produced by xlsfonts.
Some outline fonts are usually built into a PostScript printer. You can find out which fonts are known to the PostScript interpreter in your printer by sending the following file to that printer:
%!
% Produce a list of available fonts
/f 100 string def
/Times-Roman findfont 12 scalefont setfont
/y 700 def
72 y moveto
FontDirectory {
pop f cvs show 72 /y y 13 sub def y moveto
} forall
showpage
|
Utopia fonts are not usually built into PS printers. If you try to print a document that requires a Utopia font on a PS printer that does not have that font, a warning message about the replacement of a missing font with a Courier font is sent to the file /usr/spool/lp/log on the machine to which that PS printer is attached.
You can download a Type 1 font to a PS printer in either of the following two ways:
You can insert a Type 1 font file at the beginning of the PostScript file that needs that font. You should have a statement that starts with:
%! |
Put this statement at the beginning of your PS file. If you have two such lines, delete the second one.
When you download a font this way, the font is available only while your print job is being processed.
You can make a copy of a Type 1 font file, and then insert the statement:
serverdict begin 0 exitserver |
after the first group of comment statements (lines that start with %) if no password has been specified for your printer; otherwise, you should replace 0 in the above statement with the password for your printer. Then you should send the edited file to your printer.
When you download a font this way, the warning message:
%%[ exitserver: permanent state may be changed ]%% |
is sent to the file /usr/spool/lp/log on the machine to which the printer is attached.
The permanent state of the printer is not really changed. Downloaded fonts disappear when you reset the printer by switching its power off and on. If there is not enough memory for additional fonts, you receive a message about a Virtual Memory (VM) error, and the font is not downloaded.
If you again send the program that produces a list of available fonts to your printer, you should see the PostScript names of the fonts you downloaded on that list.