Faximum TechNote #217

Faximum TechNote #217


*** DRAFT *** DRAFT *** DRAFT *** DRAFT *** DRAFT *** DRAFT *** DRAFT ***

TITLE:    #217 - Notes on Adding Fonts to the X11 Font Server

KEYWORDS: X11 font server fontserver glyph adobe scalable type 1



PROBLEM:  This TN documents how to add a new scalable font to the
	  X11 font server so that the asciitiff utility that is part
	  of many Faximum Software packages can utilise fonts that
	  may not be available to it.


SOLUTION: Although Faximum's asciitiff conversion program has access
	  to all of the scalable fonts available from a server's X11
	  font server, it may be the case that the user wishes to 
	  generate faxes using fonts that are not available from the
	  font server.

	  This TN outlines the steps to add a new font. The general
	  procedure is to:

	  i)   obtain the necessary scalable fonts in Type 1 format;
	  ii)  convert (if necessary) .pfb files to .pfa files;
	  iii) edit your X11 font server configuration files and add
	       the new fonts;
	  iv)  restart the font server and test; and
	  v)   redefine (if desired) the default font(s) used by asciitiff.

	  I.   Finding Fonts

	  There are, broadly speaking, two methods for obtaining

	  1) purchase the necessary fonts from a type foundry; or
	  2) locate public domain or free fonts on the Internet.

	  In either case what you are looking for are fonts that
	  are in Adobe Type 1 format. The font files themselves
	  will have either a .pfb or .pfa extension.

	  For the purposes of this TechNote we will illustrate the
	  process by using as an example the need for Greek fonts.

	  If you wish to download the files that we used to add Greek
	  fonts to a Faximum fax server, please download:
	  (The first is a tar file, the second a gzip-compressed tar file.)

	  A search of the Internet revealed that the best source of
	  free Type 1 (scalable) Greek fonts was a package that was part
	  of the Debian Linux distribution (the package we used was
	  called "xfonts-greek-ph-scalable_1.1-2.deb").

	  After unpacking this archive file (using "ar" and "cpio")
	  we obtained 12 Type 1 font files:

	   along with the all-important font.dir file which contained
	   (all of the data between the ===== lines):
grkcurp.pfb -grinet-greek courier-medium-r-normal--0-0-0-0-m-0-iso8859-1
grkcurb.pfb -grinet-greek courier-bold-r-normal--0-0-0-0-m-0-iso8859-1
grkcuri.pfb -grinet-greek courier-medium-i-normal--0-0-0-0-m-0-iso8859-1
grkcurbi.pfb -grinet-greek courier-bold-i-normal--0-0-0-0-m-0-iso8859-1
grktimp.pfb -grinet-greek times-medium-r-normal--0-0-0-0-p-0-iso8859-1
grktimb.pfb -grinet-greek times-bold-r-normal--0-0-0-0-p-0-iso8859-1
grktimi.pfb -grinet-greek times-medium-i-normal--0-0-0-0-p-0-iso8859-1
grktimbi.pfb -grinet-greek times-bold-i-normal--0-0-0-0-p-0-iso8859-1
grkarip.pfb -grinet-greek arial-medium-r-normal--0-0-0-0-p-0-iso8859-1
grkarib.pfb -grinet-greek arial-bold-r-normal--0-0-0-0-p-0-iso8859-1
grkarii.pfb -grinet-greek arial-medium-i-normal--0-0-0-0-p-0-iso8859-1
grkaribi.pfb -grinet-greek arial-bold-i-normal--0-0-0-0-p-0-iso8859-1

	  II.  Converting the Font Files

	  Some X11 font servers can handle binary Type 1 font files 
	  (i.e. .pfb files) directly while others require the files to
	  be in ASCII (i.e. .pfa) format. If your font server can use
	  .pfb file you can skip to the next part of this TechNote.

	  If, on the otherhand, you need to convert your .pfb files to
	  .pfa format then you either need to have access to a copy of
	  the Adobe Acrobat Distiller or be a brave soul and try to
	  use GhostScript.

	  The tool we used to convert our .pfb files to .pfa is called
	  pfb2pfa.ps and was written by Don Lancaster. Free copies of
	  this utility are available from his website at www.tinaja.com

	  Since his utility is well documented we will not spend any
	  more time discussing how to use it other than to say that
	  the files it produces have the lines of each .pfa file
	  terminated with a carriage return character. Since UNIX and
	  Linux systems prefer lines terminated with a newline character
	  we found we had to run the "tr" utility on the resulting .pfa
	  files to make them digestible to the X11 font server.

	  For example:

		mv grkarib.pfa grkarib.cr
		tr '\015' '\012' < grkarib.cr > grkarib.pfa

	  III. Configuring the X11 Font Server

	  Now that you have your fonts you need to tell your X11
	  font server about them.

	  The first step is to find where on your system your X11
	  font server stores its configuration file. Looking at
	  the man pages for the "fs" or "xfs" utility may provide
	  some guidance. Otherwise look in the obvious places such

	  Once you have found the config file look in it to see where
	  the Type 1 fonts are stored. Once such config file we looked
	  at contained (in part):

catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled,

	  It is obvious that in this example the Type 1 fonts are
	  stored in /usr/X11R6/lib/X11/fonts/Type1.

	  So we copied all of our .pfa files into this directory.

	  Then we edited the fonts.dir file in the Type1 directory and 
	  added the contents of our fonts.dir file (see above in Part I), 
	  without the first line (containing the number of fonts in the 
	  directory, 12 in this case).

	  Then we updated the first line of the original fonts.dir file
	  in the Type1 directory to contain the new count of the number 
	  of fonts in the file.

	  Note that since we had converted our original .pfb format
	  fonts into .pfa format, we had to change both the names
	  of the files (from, for exampe, grkarib.pfb to grkarib.pfa)
	  and the names of the font files in the fonts.dir file.

	  IV.  Restarting the Font Server and Testing the Fonts

	  How you restart your font server will depend on the system
	  you are using. For example, on Red Hat Linux we used:
	  	/etc/rc.d/init.d/fs stop
	  	/etc/rc.d/init.d/fs start
	  Your mileage will vary and you will need to consult the 
	  documentation for your system. Or, you could just reboot :-)

	  To test the new font(s) you will need to create a file that
	  tells asciitiff to set a new font. For example, a simple
	  such as:
$[font "-grinet-greek times-medium-r-normal-*-*-100-200-200-p-0-iso8859-1"]
20   |21 ! |22 " |23 # |24 $ |25 % |26 & |27 ' |
28 ( |29 ) |2a * |2b + |2c , |2d - |2e . |2f / |
30 0 |31 1 |32 2 |33 3 |34 4 |35 5 |36 6 |37 7 |
38 8 |39 9 |3a : |3b ; |3c < |3d = |3e > |3f ? |
40 @ |41 A |42 B |43 C |44 D |45 E |46 F |47 G |
48 H |49 I |4a J |4b K |4c L |4d M |4e N |4f O |
50 P |51 Q |52 R |53 S |54 T |55 U |56 V |57 W |
58 X |59 Y |5a Z |5b [ |5c \ |5d ] |5e ^ |5f _ |
60 ` |61 a |62 b |63 c |64 d |65 e |66 f |67 g |
68 h |69 i |6a j |6b k |6c l |6d m |6e n |6f o |
70 p |71 q |72 r |73 s |74 t |75 u |76 v |77 w |
78 x |79 y |7a z |7b { |7c | |7d } |7e ~ |7f  |
a0  |a1  |a2  |a3  |a4  |a5  |a6  |a7  |
a8  |a9  |aa  |ab  |ac  |ad  |ae  |af  |
b0  |b1  |b2  |b3  |b4  |b5  |b6  |b7  |
b8  |b9  |ba  |bb  |bc  |bd  |be  |bf  |
c0  |c1  |c2  |c3  |c4  |c5  |c6  |c7  |
c8  |c9  |ca  |cb  |cc  |cd  |ce  |cf  |
d0  |d1  |d2  |d3  |d4  |d5  |d6  |d7  |
d8  |d9  |da  |db  |dc  |dd  |de  |df  |
e0  |e1  |e2  |e3  |e4  |e5  |e6  |e7  |
e8  |e9  |ea  |eb  |ec  |ed  |ee  |ef  |
f0  |f1  |f2  |f3  |f4  |f5  |f6  |f7  |
f8  |f9  |fa  |fb  |fc  |fd  |fe  |ff  |

	  V.   Redefine the Default Font(s) for Asciitiff

	  For information on how to set the default fonts for asciitiff
	  please see TechNote 217 (http://www.faximum.com/technotes/217).

TechNote: 217 - Copyright 2000 Faximum Software Inc., All Rights Reserved.
Last Updated: Thu Jun 22 21:26:25 PDT 2000
The complete set of Faximum TechNotes are available on the Internet at 

Copyright 2001 Faximum Software Inc. All Rights Reserved.