Next Previous Contents

5. Content Generation

5.1 Generating AFM font metrics

AFM font metrics files are not required for display existing files with TrueType fonts, but they are necessary to create new files. The ghostscript program /usr/lib/ghostscript/5.50/printafm.ps could be used to generate these metric files, but I have found the ttf2afm program from the tetex-bin package to be easier to use.

The following script will generate an afm file for all TrueType fonts in a directory:


#!/bin/sh

set -e

for i in *.TTF
do
    /usr/bin/ttf2afm $i > ${i%TTF}afm
done

for i in *.ttf
do
    /usr/bin/ttf2afm $i > ${i%ttf}afm
done

One minor problem with ttf2afm is that some applications expect afm files to start with the StartFontMetrics tag, but files created by ttf2afm start with a comment. This "problem" is easily fixed by hitting each file with a text editor.

5.2 Generating font.map files

Once we have our afm files, we need to tell the system how to find them. This is often done via the font.map file.

I have been unable to find documentation on this file format, unlike fonts.dir, fonts.scale, and fonts.alias, all created by the mkfontdir program. However the minimum format appears to be quite simple:

Aliases appear to be implemented via multiple entries, and the filename extension must be in lowercase.

5.3 Image manipulation: GIMP

GIMP is the Gnu image manipulation and paint program. I did not have to make any additional changes to use TrueType fonts in gimp.

5.4 ASCII to PostScript conversion: enscript

Enscript is a program that converts ASCII to PostScript. Other programs which serve a similiar purpose are a2ps and mpage. Enscript allows two-up rotation, watermarks, headers, and keyword-based syntax coloring. It does not reformat text and is commonly used to print source listing.

To use TrueType fonts with enscript, you must do two things:

For details, see the enscript documentation.

Once I had made these changes, I had no problem using TrueType fonts.

5.5 Text Formatting and Typesetting: groff

Groff is the Gnu front end of the groff/troff document formatting system. The power of Groff is best seen with man pages.

user shell
$ zcat /usr/man/man1/groff.1.gz | groff -man | lpr

Besides man pages, an incredible amount of Unix documentation uses troff formatting with ms (and occasionally me) macros. The Debian xbooks package, for example, has 43 files using troff with ms macros. With groff, this material can be attractively printed.

Groff is a very powerful system, but it's the grandchild (or great-grandchild) of a program used to typeset 1960's era printing presses. Font support in groff reflects that heritage. Groff, in contrast to its predecessors, uses PostScript as the default output format so our earlier work with ghostscript takes care of half of the problem -- groff does not have to deal with reading TrueType font files. It does need to have accurate font metrics, and this section describes how to regenerate the necessary groff files:

Groff PostScript description files
/usr/share/groff/font/devps/DESC
    Device description file
/usr/share/groff/font/devps/text.enc
    Encoding used for text fonts
/usr/share/groff/font/devps/generate/textmap
    Standard mapping.
/usr/share/groff/font/devps/generate/Makefile
    Standard makefile

We must edit the Makefile,

/usr/share/groff/font/devps/generate/Makefile
- afmdir=/usr/local/afm
+ afmdir=/usr/share/fonts/truetype

change the name of the fonts to their TrueType equivalent (e.g., if we're using Microsoft's free TrueType fonts we would replace Helvetica with Arial), and change TEXTFONTS and the like to only include those fonts we are redefining.

We must also edit /usr/share/groff/font/devps/generate/afmname to use the TrueType font names and afm files, and to remove an "-e" flag from awk.

After all of this, we can rebuild the groff tables with

user shell
$ cd /usr/share/groff/font/devps
$ make -f generate/Makefile

As usual, the best way to verify the changes is to use a visually distinctive font. E.g., if you are using the Microsoft free TrueType fonts you can use Mistral for TR.

(I expect royalties from everyone who reconfigures their system to print manual pages in Old English fonts next April First!)

5.6 Text Formatting and Typesetting: TeX

TeX is the other common set of text formatting and typesetting programs on most GNU/Linux systems.

TeX fonts can created with mktexmf, but I have little information on the exact process. More details will be provided shortly.


Next Previous Contents

mirror server hosted at Truenetwork, Russian Federation.