|
| 以 PDF 格式下载本书
Font Support
5
- The OpenWindows server provides robust font support in both the X11 server and the Display PostScript (DPS) extension. Font formats from numerous vendors can be used to display text in English or foreign languages, including Asian languages. Symbol fonts can be used to display mathematical equations. The OpenWindows environment provides 55 Latin fonts for European text and two symbol fonts. You can add other fonts to the system if you want.
Font Formats
- Fonts from different vendors come in different formats. Table 5-1 lists the various font formats, their vendors, and the associated file types supported by the OpenWindows environment.
-
Table 5-1
| Font Format | Vendor | File Types |
| F3 (Type 7) | SunSoft | .f3b |
| Type1 (ASCII) | Adobe and various foundries | .pfa |
| Type1 (binary) | Adobe and various foundries | .pfb |
| Type 3 | Adobe and various foundries | .ps |
| Speedo | Bitstream | .spd |
| Portable Compiled Format | MIT | .pcf |
| Bitmap Distribution Format | Adobe | .bdf |
-
Table 5-1
| Font Format | Vendor | File Types |
| Big Endian Prebuilt Format | Adobe | .bepf |
| Little Endian Prebuilt Format | Adobe (for x86 only) | .lepf |
| Server Natural Format | MIT | .snf |
| Old OpenWindows Bitmap | SunSoft | .fb |
- The fonts provided by the OpenWindows server are located in the /usr/openwin/lib/X11/fonts directory. For more information on the directory structure see "Font Directory Structure" on page 38.
Outline and Bitmap Fonts
- OpenWindows supports two types of font representation: outline fonts and bitmap fonts. In the X11 server, outline fonts can be scaled to any desired size; in Display PostScript (DPS) they can also be rotated and skewed. To display a letter from an outline font, the server scales and rotates only the outline of the character. This repositioned outline is then rendered into pixel form (bitmap) for display on the screen. This rendered bitmap is also stored in the glyph cache for reuse.
- Because certain font sizes occur very frequently, they are also kept in separate files in pre-rendered bitmap form. This saves the server from having to scale and render them. However, the resulting bitmap fonts can only be displayed in one size and orientation. Some of these fonts have also been hand-tuned to look better and be more readable. As they are encountered, these bitmaps are also placed in the glyph cache.
- The recommended bitmap format is the portable compiled format (.pcf).
- The /usr/openwin/bin directory contains the following tools to convert between outline and bitmap fonts, as well as between various bitmap formats. See the corresponding man pages for more detailed information.
-
-
makebdf Creates Bitmap Distribution Format files (.bdf) from outline font files (.f3b)
-
bdftopcf Converts font from .bdf format to Portable Compiled Format (.pcf)
-
-
bdftosnf Converts .bdf files to Server Natural Format (.snf) files
- As illustrated in Table 5-2, many bitmap font file formats are architecture-dependent binary files. They cannot be shared between machines of different architectures (for example, between SPARC and x86).
-
Table 5-2
| Font Format | File Extension | Binary | Architecture-specific |
| Bitmap Distribution | .bdf | No | No |
| Portable Compiled | .pcf | Yes | No |
| Server Natural Format | .snf | Yes | Yes |
| Old OpenWindows Bitmap | .fb | Yes | Yes |
| Little Endian Prebuilt Format | .lepf | Yes | Yes (x86) |
| Big Endian Prebuilt Format | .bepf | Yes | Yes (SPARC) |
- The OpenWindows environment contains compressed .pcf files (files with .pcf.Z extensions). You can uncompress these if you want. If you add fonts to your system, you can either compress the files or not. Use uncompressed files if you want the fonts to display somewhat faster.
Replacing Outline Fonts with Bitmap Fonts
- The OpenWindows environment automatically replaces some outline fonts by bitmap fonts when the size is appropriate. This improves performance, and in some cases improves the aesthetics and readability of the text. There may be several sizes at which replacement occurs for a given outline font.
When Replacement Occurs
- Currently in DPS, the .pcf bitmap format is substituted for F3 outline fonts and the .bepf (or .lepf) is substituted for Type1 fonts. Substitution occurs when there is no rotation, the requested pixel size is within one half of a pixel of the .pcf font size, and the .pcf font is an F3BitMap resource in a .upr (PostScript resource) file.
Using F3 Fonts in DPS
- F3 fonts behave exactly like Type1 fonts, except /FontType returns 7 instead of 1. For example, the following PostScript code works the same regardless of the kind of font.
- /Helvetica findfont 50 scalefont setfont 10 10 moveto (ABC) show
- But the following code yields 7 for an F3 font and 1 for a Type1 font.
- currentfont /FontType get ==
- The kind of font returned depends on the current DPS internal resource path. See "Changing the Resource Path in DPS" on page 40 for details.)
Locating Fonts
- By default, the OpenWindows server looks for fonts in directories under the /usr/openwin/lib/X11/fonts directory. See Table 5-3 for the complete font directory structure.
Font Directory Structure
- The directories below are preceded by /usr/openwin/lib/X11/fonts.
-
Table 5-3
| Directory | Subdirectory | File Suffixes | Contents |
| /100dpi |
| .pcf | Bitmap fonts |
| /75dpi |
| .pcf | Bitmap fonts |
| /F3 |
| .f3b | F3 format outline fonts |
| /map | .map | F3 character set specifications |
| /F3bitmaps | .pcf | Bitmap fonts |
| /Speedo | .spd | Bitstream Speedo format outline fonts |
-
Table 5-3
| Directory | Subdirectory | File Suffixes | Contents |
| /Type1 |
| .pfa, .pfb | Type1 outline fonts |
| /afm | .afm | Adobe font metrics |
| /outline | .pfa, .pfb | Type1 outline fonts |
| /prebuilt | .bepf, .lepf | Bitmaps for SPARC Solaris and x86 |
| /Xt+ | .pcf | Bitmap fonts |
| /Type3 | .ps | PostScript Outline fonts |
| /encodings | .enc | Encodings |
| /misc | .pcf | Bitmap fonts |
Changing the Default Font Path in X11
- In X11, the default font path is:
-
-
/usr/openwin/lib/X11/fonts/F3,
/usr/openwin/lib/X11/fonts/F3bitmaps,
/usr/openwin/lib/X11/fonts/Type1,
/usr/openwin/lib/X11/fonts/Speedo,
/usr/openwin/lib/X11/fonts/misc,
/usr/openwin/lib/X11/fonts/75dpi,
/usr/openwin/lib/X11/fonts/100dpi,
/usr/openwin/lib/X11/fonts/Xt+
- You can change this default either at start up or after the server has been started.
- At start up, use:
-
example% openwin -fp /<user-defined-directory-list>
|
- where the user-defined directory list is a comma separated list of directories for the server to search. Note that the directory paths must be absolute.
- After the server has started, you can use either the xset command or XSetFontPath. For xset, use only one of the following:
-
example% xset +fp /user-defined-directory-list
example% xset fp+ /user-defined-directory-list
example% xset fp- /user-defined-directory-list
|
-
Note - Since xset dynamically changes the font path, you do not need to restart the server to change the default font path.
- For more information on xset, see the xset man page; for XSetFontPath, see the Xlib Reference Manual.
Changing the Resource Path in DPS
- In DPS, fonts are considered resources in the font category. Their associated files are specified by resource (.upr) files. DPS resource files reside in directories specified by the resource (font) path. This path is a list of directories maintained internally by DPS. DPS uses the default resource path specified by the PSRESOURCEPATH environment variable to initialize itself. If PSRESOURCEPATH is not defined, DPS uses /usr/openwin/lib/X11. (See Programming the Display PostScript System with X for further information on resource database files.)
-
Warning - Because DPS maintains so many internal font caches, you cannot remove a path from the DPS resource path. DPS appends all paths subsequent to the default path to the resource path, regardless of where they end up in the X11 font path. Thus fonts available in X windows might be different from those available in DPS. However, the DPS resource path is dynamic. Fonts should be accessible after the xset command completes. Any change to the X font path is passed to DPS. If there are .upr files present, DPS appends the font files to its internal resource path.The examples in the remainder of this section illustrate some of the DPS and X11 font path behavior.
- The xset command:
-
example% xset +fp /dir1/dir2/fonts
|
- prepends /dir1/dir2/fonts to the X11 font path. (Use fp+ to append /dir1/dir2/fonts to the font path.) If there are any .upr files present, the xset command (with either fp+ or +fp) also appends /dir1/dir2/fonts to the DPS resource path.
- The command:
-
example% xset fp- /dir1/dir2/fonts
|
- removes /dir1/dir2/fonts from the X11 font path, but does not alter the DPS resource path.
- The following openwin command:
-
example% openwin -fp /dir1/dir2/fonts
|
- appends /dir1/dir2/fonts to the DPS resource path.
- Use the following xset command to set the X11 font path to /dir1/dir2/fonts and to append /dir1/dir2/fonts to the existing DPS resource path:
-
example% xset fp= /dir1/dir2/fonts
|
-
Note - A server reset clears both the X11 font path and the DPS resource path.
Font File Suffixes
- The OpenWindows environment is configured so that most X11 fonts are also available in DPS (see Table 5-4 below). DPS supports a slightly different set of fonts than those supported by X11.
-
Table 5-4
| Font Description | Font File Suffix | Available in X11 Available in DPS |
| Type1 outline fonts | .pfa (scaled) |
| Yes | Yes |
| Type1 outline fonts | .pfb (scaled) |
| No | Yes |
| Big Endian Prebuilt Format | .bepf |
| No | Yes |
| Little Endian Prebuilt Format | .lepf |
| No | Yes |
| F3 (Type 7) | .f3b (scaled) |
| Yes | Yes |
| Old OpenWindows Bitmap | .fb |
| Yes | No |
| Speedo | .spd (scaled) |
| Yes | No |
| Type 3 | .ps (scaled) |
| No | Yes |
| Portable compiled | .pcf |
| Yes | Yes |
| Bitmap Distribution | .bdf |
| Yes | No |
| Server Natural Format | .snf |
| Yes | No |
Associated Files
- The OpenWindows environment provides files with these extensions. They are not intended to be edited.
-
-
.afm Adobe Font Metrics files read by client for kerning information
-
.map F3 files read by X11 and DPS for encoding purposes
-
.trans F3 files read by DPS for composite font construction
-
.ps..PostScript Files for composite font and PostScript resource construction
-
.enc Encoding files used by X11 and DPS
-
-
.upr Display PostScript resource files
Adding New Fonts
- To add new bitmap and outline fonts to the OpenWindows Server, follow the steps outlined in the following sections. These instructions apply to eight-bit fonts. Multibyte fonts might require additional files from the font supplier.
-
-
Create a directory for the new fonts.
Do not add fonts to existing font directories--you might corrupt files in those directories, and you also must be superuser. For this example, /newfonts is the directory name.
-
-
-
Copy or move all fonts to the /newfonts directory.
- If you are installing bitmap fonts (pcf, snf, bdf, or fb), see additional steps in "Adding Bitmap Fonts." If you are installing outline fonts (f3b, pfa, pfb, or spd formats), see "Adding Outline Fonts" on page 44.
Adding Bitmap Fonts
- Follow these steps if you are installing any of the bitmap font formats (pcf, snf, bdf, or fb).
-
-
Use mkfontdir to create the fonts.dir file.
-
example% cd /newfonts
example% /usr/openwin/bin/mkfontdir
|
- See the mkfontdir(1) man page for further details.
-
-
If you want to define font "aliases," create a fonts.alias file. Use this to map the long internal XLFD font names to shorter names that are easier to enter on a command line.
Here is a sample fonts.alias file:
-
courier "-adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1"
courier-italic "-adobe-courier-medium-i-normal--0-0-0-0-m-0-iso8859-1
courier-bold "-adobe-courier-bold-r-normal--0-0-0-0-m-0-iso8859-1
courier-bolditalic "-adobe-courier-bold-i-normal--0-0-0-0-m-0-iso8859-1
|
- See the mkfontdir(1) man page for further details.
-
-
Use xset to add the /newfonts directory to the server font path.
-
example% xset fp+ /newfonts
|
- See the xset(1) man page for more information.
-
-
Use xlsfonts to check to see if the server recognizes your new fonts. xlsfonts lists all the names of all fonts that are accessible to the window server.
Adding Outline Fonts
- Follow the steps included in this section to install outline fonts. The OpenWindows environment supports Type1 (pfa), Speedo (spd), and F3 (f3b) outline fonts.
- Multibyte fonts might require additional files from the font supplier. For F3 format fonts, you need the .map and .trans files. The server also uses the .map file. It provides a mapping between the character name and its F3 code. The DPS extension uses the .trans file to support multiple byte encodings. It contains the definitions of these encodings.
-
-
If you are installing Type1 (pfa or pfb) fonts run makepsres in the /newfonts directory.
This creates a PSres.upr file. The system requires this file if you want to use these fonts within the DPS extension.
-
-
If you are installing F3 fonts, create a .upr file. Use the template below for the .upr file. Replace the example values given below with values that reflect the fonts you want to add. Follow the syntax used in the example. Include the // before the directory name you want to install into. Use the = in the lines where you include the map file and font file names.
If the .map file included with your font is not in /usr/openwin/lib/X11/F3/map, then include it in the .upr file.)
-
PS-Resources-1.0 #mandatory
F3MapFile #put this in if you are adding map files
FontOutline #put this in if you are installing F3 fonts
. #mandatory
//home/newfonts #name of directory to install fonts in:
#// required (this is an example)
F3MapFile #put this in if you are adding map files
latin=map/latin.map #name of the map file and where it is
located (this is an example)
. #put this in if you are adding map files
FontOutline #put this in if you are installing F3 fonts
Helvetica=Helvetica.f3b #put the font file name here (this is
an example)
Times-Roman=Times-Roman.f3b#put in as many font files as you want
. #mandatory
|
-
-
If you are installing Type1 (pfa or pfb) or Speedo (spd) fonts, create a fonts.scale file.
The fonts.scale file contains the mapping of an internal X11 font name to an easily understood font name. The fonts.scale file will be copied to the fonts.dir file automatically. Do not edit the fonts.dir file. Any changes you make are overwritten when you run mkfontdir. For example, here is a fonts.scale file for a directory containing four Type1 fonts:
-
cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1
couri.pfa -adobe-courier-medium-i-normal--0-0-0-0-m-0-iso8859-1
courb.pfa -adobe-courier-bold-r-normal--0-0-0-0-m-0-iso8859-1
courbi.pfa -adobe-courier-bold-i-normal--0-0-0-0-m-0-iso8859-1
|
-
Note - X11 names must follow the standard XLFD font naming convention, using 0's in appropriate fields to indicate outline fonts.
- See the X Protocol Reference Manual for additional information on the XLFD font naming convention.
- See the mkfontdir(1) man page for more information on the fonts.scale file.
-
-
Use mkfontdir to create the fonts.dir file. If you are installing Type1 or Speedo fonts, your fonts.scale file is copied to fonts.dir at this point.
-
example% cd /newfonts
example% /usr/openwin/bin/mkfontdir
|
- See the mkfontdir(1) man page for further details.
-
-
If you want to define font "aliases," create a fonts.alias file. Use this to map the long internal XLFD font names to shorter names which are easier to enter on the command line.
Here is an example fonts.alias file:
-
courier "-adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1"
courier-italic "-adobe-courier-medium-i-normal--0-0-0-0-m-0-iso8859-1"
courier-bold "-adobe-courier-bold-r-normal--0-0-0-0-m-0-iso8859-1"
courier-bolditalic "-adobe-courier-bold-i-normal--0-0-0-0-m-0-iso8859-1"
|
- See the mkfontdir(1) man page for further details.
- If you are installing an F3 font and the character set supported by this font is not one of the following, the font supplier must provide an encoding file (.enc file).
-
- iso8859-1
- iso8859-2
- symbol
- jisx0201.1976-0
- jisx0208.1983-0
-
-
Copy the .enc file described in Step 5 (if you have one) to /usr/openwin/lib/X11/fonts/encodings, and add an entry for it in the encodings.dir file in the same directory.
-
Use xset to add the /newfonts directory to your font path.
-
example% xset fp+ /newfonts
|
- See the xset(1) man page for more information.
-
-
Use xlsfonts to check if the server recognizes your new fonts. xlsfonts lists all the names of all fonts that are accessible to the window server.
- You can now use the fonts in the /newfonts directory in your applications. In X11, you do not need to restart the OpenWindows server since xset dynamically changes the font path. See "Changing the Default Font Path in X11" on page 39 for more information.
Using OPEN LOOK Fonts on X Terminals
- The /usr/openwin/share/src/fonts directory contains OPEN LOOK fonts in bdf format. Follow the instructions from your vendor on how to install the fonts.
|
|