5. Using type 1 fonts with X11

X11 can use either the .pfa or the .pfb format fonts. The X11 fonts are located in various subdirectories under /usr/X11R6/lib/X11/fonts. Each font file is cross referenced to its X11 name by the contents of the fonts.dir file in each directory.

There is already a directory named Type1. The most straight forward way to add a new font is to put it into this directory. A better way is to keep all new fonts in a separate directory and use a symbolic link to the additional font. This allows one to more easily keep track of ones fonts without confusing them with the fonts that were originally provided. For example:

Create a directory to contain the font files
% mkdir -p /usr/local/share/fonts/type1
% cd /usr/local/share/fonts/type1

Place the .pfa, .pfb and .afm files here
One might want to keep readme files, and other documentation
for the fonts here also
% cp /cdrom/fonts/atm/showboat/showboat.pfb .
% cp /cdrom/fonts/atm/showboat/showboat.afm .

Maintain an index to cross reference the fonts
% echo showboat - InfoMagic CICA, Dec 1994, /fonts/atm/showboat >>INDEX

Now, to use a new font with X11, one must make the font file available and update the font name files. The X11 font names look like:

-bitstream-charter-medium-r-normal-xxx-0-0-0-0-p-0-iso8859-1
     |        |      |    |   |     |  | | | | | |    \    \
     |        |      |    |   |     \  \ \ \ \ \ \     +----+- character set
     |        |      |    |   \      \  \ \ \ \ \ +- average width
     |        |      |    |    \      \  \ \ \ \ +- spacing
     |        |      |    \	\      \  \ \ \ +- vertical res.
     |        |      |     \	 \	\  \ \ +- horizontal res.
     |        |      |      \	  \	 \  \ +- points
     |        |      |       \     \	  \  +- pixels
     |        |      |        \     \	   \
  foundry  family  weight   slant  width  additional style

A new name needs to be created for each new font. If you have some information from the documentation that accompanied the font, then it could serve as the basis for creating the name. If there is no information, then you can get some idea by using strings(1) on the font file. For example:

% strings showboat.pfb | more
%!FontType1-1.0: Showboat 001.001
%%CreationDate: 1/15/91 5:16:03 PM
%%VMusage: 1024 45747
% Generated by Fontographer 3.1
% Showboat
 1991 by David Rakowski.  Alle Rechte Vorbehalten.
FontDirectory/Showboat known{/Showboat findfont dup/UniqueID known{dup
/UniqueID get 4962377 eq exch/FontType get 1 eq and}{pop false}ifelse
{save true}{false}ifelse}{false}ifelse
12 dict begin
/FontInfo 9 dict dup begin
 /version (001.001) readonly def
 /FullName (Showboat) readonly def
 /FamilyName (Showboat) readonly def
 /Weight (Medium) readonly def
 /ItalicAngle 0 def
 /isFixedPitch false def
 /UnderlinePosition -106 def
 /UnderlineThickness 16 def
 /Notice (Showboat
 1991 by David Rakowski.  Alle Rechte Vorbehalten.) readonly def
end readonly def
/FontName /Showboat def
--stdin--

Using this information, a possible name might be:

-type1-Showboat-medium-r-normal-decorative-0-0-0-0-p-0-iso8859-1

The components of our name are:

Foundry

Lets just name all the new fonts type1.

Family

The name of the font.

Weight

Normal, bold, medium, semibold, etc. From the strings(1) output above, it appears that this font has a weight of medium.

Slant

roman, italic, oblique, etc. Since the ItalicAngle is zero, roman will be used.

Width

Normal, wide, condensed, extended, etc. Until it can be examined, the assumption will be normal.

Additional style

Usually omitted, but this will indicate that the font contains decorative capital letters.

Spacing

proportional or monospaced. Proportional is used since isFixedPitch is false.

All of these names are arbitrary, but one should strive to be compatible with the existing conventions. A font is referenced by name with possible wild cards by an X11 program, so the name chosen should make some sense. One might begin by simply using

…-normal-r-normal-…-p-…
	

as the name, and then use xfontsel(1) to examine it and adjust the name based on the appearance of the font.

So, to complete our example:

Make the font accessible to X11
% cd /usr/X11R6/lib/X11/fonts/Type1
% ln -s /usr/local/share/fonts/type1/showboat.pfb .

Edit fonts.dir and fonts.scale, adding the line describing the font
and incrementing the number of fonts which is found on the first line.
% ex fonts.dir
:1p
25
:1c
26
.
:$a
showboat.pfb -type1-showboat-medium-r-normal-decorative-0-0-0-0-p-0-iso8859-1
.
:wq

fonts.scale seems to be identical to fonts.dir…
% cp fonts.dir fonts.scale

Tell X11 that things have changed
% xset fp rehash

Examine the new font
% xfontsel -pattern -type1-*

References: xfontsel(1), xset(1), The X Windows System in a Nutshell, O'Reilly & Associates.

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <[email protected]>.
Send questions about this document to <[email protected]>.