Solaris X Window System Developer's Guide
  Search only this book
Download this book in PDF

Font Support

4

This chapter provides information on font support in the Solaris X server. The chapter includes information on the following topics:
  • Available font formats
  • Outline and bitmap fonts
  • Location of fonts and changing the default font path

Font Support in the Solaris X Server

The Solaris X server provides 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 Solaris environment provides 55 Latin fonts for European text and two symbol fonts. Other fonts can also be added to the system.
The Solaris X server can also be a client of the font server fs. The font server renders fonts for the X server. fs can be started manually or automatically. For more information on this command, see the fs(1) man page.

Available Font Formats

Fonts from different vendors come in different formats. Table 4-1 and Table 4-2 list the various font formats, their vendors, and the associated file types supported by the Solaris environment. Table 4-1 lists outline fonts; Table 4-2 lists bitmap fonts.
Table 4-1
Font FormatVendorFile Type
F3SunSoft.f3b
Type1 (ASCII)Adobe and various foundries.pfa
Type1 (binary)Adobe and various foundries.pfb
Type 3Adobe and various foundries.ps
SpeedoBitstream.spd
Table 4-2
Font FormatVendorFile Type
Portable compiled formatMIT.pcf
Bitmap distribution formatAdobe.bdf
Big Endian prebuilt formatAdobe.bepf
Little Endian prebuilt formatAdobe (for x86 only).lepf
The fonts provided by the Solaris X server are located in the /usr/openwin/lib/X11/fonts directory. For more information on the directory structure, see "Locating Fonts" on page 48.
The Solaris environment is configured so that most X11 fonts are also available in DPS (see Table 4-3). DPS supports a slightly different set of fonts than those supported by X11.
Table 4-3
Font FormatAvailable in X11 Available in DPS
F3
YesYes
Type1 outline fonts-ASCII
YesYes
Type1 outline fonts-binary
YesYes
Type 3
YesYes
Speedo
YesNo
Portable compiled format
YesYes
Bitmap distribution format
YesNo
Big Endian prebuilt format
NoYes
Little Endian prebuilt format
NoYes

Associated Files

The Solaris 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

Outline and Bitmap Fonts

Solaris supports two types of font representation: outline fonts and bitmap fonts. In the X server, outline fonts can be scaled to any size; in Display PostScript 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 frequently, they are also kept in separate files in prerendered bitmap form. This saves the server from having to scale and render them. However, the resulting bitmap fonts can be displayed in only 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 fonts between the outline and bitmap font representation, 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 a font from .bdf format to portable compiled format (.pcf)
As illustrated in Table 4-4, 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 4-4
Font FormatBinaryArchitecture-Specific
Bitmap distribution formatNoNo
Portable compiled formatYesNo
Little Endian prebuilt formatYesYes (x86)
Big Endian prebuilt formatYesYes (SPARC)
The Solaris 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. Leave the files compressed if you want to conserve disk space.

Replacing Outline Fonts With Bitmap Fonts

The Solaris environment automatically replaces some outline fonts with 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.

Replacement Conditions

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 50 for details.)

Locating Fonts

By default, the Solaris server looks for fonts in directories under the /usr/openwin/lib/X11/fonts directory. Table 4-5 shows the complete font directory structure. The directory names are preceded by /usr/openwin/lib/X11/fonts.
Table 4-5
DirectorySubdirectoryFile SuffixesContents
/100dpi
.pcfBitmap fonts
/75dpi
.pcfBitmap fonts
/F3/afm.f3bF3 format outline fonts
/map.mapF3 character set specifications
/F3bitmaps.pcfBitmap fonts
/Speedo.spdBitstream Speedo format outline fonts
/Type1.pfa, .pfbType1 outline fonts
/afm.afmAdobe font metrics
/outline.pfa, .pfbType1 outline fonts
/prebuilt.bepf, .lepfBitmaps for SPARC Solaris and x86
/Xt+.pcfBitmap fonts
/Type3.psPostScript outline fonts
/encodings.encEncodings
/misc.pcfBitmap 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 the default font path either at startup or after the server has been started. At startup, use the following command to change the font path. In this command, 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.

  example% openwin -fp /<user-defined-directory-list>  

After the server has started, you can change the font path using either the xset command or the Xlib function 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  

The xset +fp command prepends /dir1/dir2/fonts to the X11 font path.

  example% xset +fp /dir1/dir2/fonts  

The xset fp+ command appends /dir1/dir2/fonts to the X11 font path. The xset fp- command removes /dir1/dir2/fonts from the X11 font path.

  example% xset fp- /dir1/dir2/fonts  


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 information on 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.

As shown in "Changing the Default Font Path in X11" on page 48, use xset +fp to prepend /dir1/dir2/fonts to the font path, and use xset 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 following command removes /dir1/dir2/fonts from the X11 font path, but does not alter the DPS resource path.

  example% xset fp- /dir1/dir2/fonts  

The following openwin command appends /dir1/dir2/fonts to the DPS resource path.

  example% openwin -fp /dir1/dir2/fonts  

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 - To clear the X11 font path and the DPS resource path, exit OpenWindows and then restart.

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 one byte fonts, such as the ISO Latin-1 fonts for English and European character sets. Multibyte fonts, such as Kanji fonts, might require additional files from the font supplier.
  1. 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.


  example% mkdir /newfonts  

  1. 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 53.

Adding Bitmap Fonts

Follow these steps if you are installing any of the bitmap font formats (pcf, snf, bdf, or fb).
  1. 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.
  1. If you want to define font "aliases," create a fonts.alias file. Use this file to map the long internal XLFD font names to shorter names that are easier to enter on a command line. A sample fonts.alias file is shown below.


  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.
  1. 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.
  1. Use xlsfonts to determine whether the server recognizes the new fonts. xlsfonts lists all the names of all fonts that are accessible to the window server.

Adding Outline Fonts

Follow these steps to install outline fonts. The Solaris 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.
  1. If you are installing Type1 (pfa or pfb) fonts or Type 3 (ps) 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 in X or DPS client applications.

  2. If you are installing F3 fonts, create a .upr file. Use the template below for the .upr file. Replace the example values 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  

  1. If you are installing Type1 (pfa or pfb), Type 3 (ps), or Speedo (spd) fonts, create a fonts.scale file.

    The fonts.scale file contains the mapping of an internal X11 font name to a known font name. The fonts.scale file is 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  

See the mkfontdir(1) man page for more information on the fonts.scale file.

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 information on the XLFD font naming convention.

  1. 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.


  example% cd /newfonts  
  example% /usr/openwin/bin/mkfontdir  

See the mkfontdir(1) man page for further details.
  1. 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 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
  1. 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.

  2. Use xset to add the /newfonts directory to your font path.


  example% xset fp+ /newfonts  

See the xset(1) man page for more information.
  1. Use xlsfonts to determine whether the server recognizes your new fonts.

    xlsfonts lists the names of all fonts that are accessible to the window server.

For DPS, you can determine whether the server recognizes your fonts using the following commands:

  example% dpsexec  
  PostScript(r) Version 2015.103  
  (c) Copyright 1984-1994 Adobe Systems Incorporated.  
  Typefaces (c) Copyright 1981 Linotype-Hell AG and/or its subsidiaries.  
  All Rights Reserved.  
  PS> /fontname findfont  

You can now use the fonts in the /newfonts directry in your applications. In X11, you do not need to restart the Solaris X server since xset dynamically changes the font path. See "Changing the Default Font Path in X11" on page 48 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.