Back to Table of Contents |
<prefix>, in this section, refers
to the directory in which groff is installed, typically
/usr/share/groff/
(for distro-specific, pre-compiled groff packages) or
/usr/local/share/groff/
(if you’ve built groff from source).
<version> refers to the groff version number, which
can be found, if necessary, by typing
groff -v
at the command line.
Groff comes with a small library of
families
(see the
FAMILY
macro for a list). The families have four
fonts
associated with them. These fonts are a combination of
weight
and
shape:
R (Roman, usually Medium weight),
I (Italic, usually Medium weight),
B (Bold, usually Roman shape) and
BI (Bold Italic)
If you work with mom a lot, sooner or later you’ll find that these
families and their associated fonts aren’t sufficient. You’ll
want to supplement them, either with more fonts for the families
already provided—Damn! I need Helvetica Bold Condensed
Italic—or with entire new families.
The traditional approach to extending groff families has been
to create new families for non-default weights and shapes (e.g.
Light, which is a
weight,
or Condensed, which is a
shape),
then to associate them with groff’s predefined R,
I, B and BI font styles. An example of this
can be seen in the groff PostScript font library itself, which is
found in
<prefix>/<version>/font/devps/
There’s one “family” for Helvetica (HR,
HI, HB, HBI) and another for Helvetica Narrow
(HNR, HNI, HNB, HNBI).
The difficulty with this approach is that typographers tend to think of families as referring to the entire set of font weights and shapes associated with a family name. For example, when a typesetter says “the Helvetica family”, s/he is including the weights Helvetica Thin, Helvetica Light, Helvetica Regular, Helvetica Bold, Helvetica Heavy, etc, and all their associated shapes (Roman, Italic, Condensed, Narrow, Extended, Outline, etc).
Thus, intuitively, when a typesetter gives mom a .FAMILY H directive, s/he reasonably expects that any subsequent .FT directive will access the desired font from the Helvetica family—without the need to state explicitly both family and font to .FT, as it is explained one can do in the FAMILY and FT sections of these documents.
If one had, say, Helvetica Light Roman and Helvetica Light Italic
as well as Helvetica Light Condensed Roman and Helvetica Light
Condensed Italic, the established groff approach would require two
“partial” families, HL (for Helvetica Light)
and HLCD (for Helvetica Light Condensed), with R and
I fonts for both:
HLR
HLI
HLCDR
HLCDI
Accessing these family/font combos routinely
throughout a document would then require changing the family
(with .FAMILY) and selecting the desired font
(with .FT R or .FT I), or
passing .FT the lengthy family+fontname (.e.g.
.FT HLCDI).
Fortunately, groff provides a mechanism whereby it’s possible to extend the basic R, I, B, and BI fonts (“styles” in groff-speak) so that one can, in fact, create extensive type families, and access all the fonts in them with .ft (groff) or .FT (mom).
Mom uses this mechanism to offer, in addition to groff’s default font styles, the following:
Thus, with mom, if you’ve installed some extra
Helvetica fonts and named them according to the convention
<F><S> (where <F> means
family and <S> means font style), once having
entered
.FAMILY H
you can access any of the extra Helvetica fonts simply by passing
the correct argument to
FT
from the list, above. For example, if you were working in Medium
Roman (.FT R) and you needed Medium Condensed Italic
for a while (assuming it’s installed), you’d just type
.FT CDI
to access the Medium Condensed Italic font from the Helvetica
family.
Mom’s list of font styles doesn’t pretend to be exhaustive. The extension names are arbitrary and can be used in a flexible manner. For example, if you create a family that has a Demibold font (DB) but no Bold font (B), you might find it more convenient to give the Demibold font the extension “B”.
You may, at needs, want to add to mom’s list of font styles.
You can do this by editing the file, om.tmac (typical location:
<prefix>/<version>/tmac/om.tmac). Near the
top, you’ll see lines of the form
.sty \n[.fp] XL \" Extra Light
.sty \n[.fp] L \" Light Roman
.sty \n[.fp] LI \" Light Italic
.sty \n[.fp] LCD \" Light Condensed Roman
Simply add your new font style by imitating what you see, above,
and plugging in your new font style (having, of course,
added the font to groff, correctly named); see
Step-by-step instructions).
For example, if you already have some fonts from the Univers family
installed and have called the family Univers, you might decide at
some point to add the Bold Outline font (UniversBO). In which
case, you’d add
.sty \n[.fp] BO \" Bold Outline
to the .sty \n[.fp] <font style> list
in om.tmac.
Note: Mom’s font extensions are not “user-space” controllable via a macro. If you’ve been using groff for a long time, and have already rolled your own solution to adding families and fonts to groff, you may find that mom’s font extensions conflict with your own scheme. Should that be the case, comment out the .sty \n[.fp] <font style> lines found near the top of the om.tmac file.
Important: Be careful that any styles you add do not conflict with family names that already exist. “C”, for example, conflicts with the Courier family (CR, CI, CB, CI). Were you to create a font style “C”, thinking that .FT C would give you access to font style once you’d given a .FAMILY directive, you’d get a nasty surprise: your type would come out in Courier Roman!
There are a number of ways to approach making fonts available to groff. These instructions aren’t meant to cover all possibilities, merely one.
GNU/Linux distributions being what they are, directory locations may differ and the presence of some executable can’t be guaranteed. I run a Debian-based system. The instructions reflect that. Users of other distros may have to interpret them according to the way their distro operates.
The two most commonly available types of fonts are PostScript Type1 (extension .pfb) and TrueType (extension .ttf). Either can be made available to groff. There are many websites holding collections of both.
Change into the directory holding the new font.
For convenience in the next step, make a symbolic link to
the file 'textmap':
ln -s <prefix>/<version>/font/devps/generate/textmap .
See
here
for an explanation of <prefix>
and <version>.
In addition, unless you’re installing fonts from your home
directory, make links to the files 'generate-t42.pe' and
'generate-pfa.pe'.
ln -s $HOME/generate-t42.pe .
ln -s $HOME/generate-pfa.pe .
TrueType fonts (.ttf) need to be converted to .t42. Type 1 fonts (.pfa, .pfb) need to be converted to .pfa.
For .ttf fonts, run
fontforge -script generate-t42.pe <file>.ttf
This will create three new files with the extensions .t42, .pfa, and
.afm. Next, run
afmtodit <afm file> textmap <groff font>
This will create a groff font with the name you give. (See
here
for advice on naming groff fonts.)
Move the .t42 and groff font files to <prefix>/site-font/devps/.
If you’re running a recent version of groff that includes the native pdf device (gropdf), move the .pfa file to <prefix>/site-font/devpdf/. If not, you may safely remove it. You may also safely remove the .afm file.
For .pfb fonts, run
fontforge -script generate-pfa.pe <file>.pfb
This will create two new files with the extensions .pfa, and .afm.
Next, run
afmtodit <afm file> textmap <groff font>
Move the .pfa and groff font files to
<prefix>/<site-font>/devps/.
(See
here
for advice on naming groff fonts.)
If you’re running a recent version of groff that includes the native pdf device (gropdf), link the .pfa and groff font files, now in <prefix>/<site-font>/devps/, to the <prefix>/site-font/devpdf directory.
Start by changing into the
<prefix>/site-font/devpdf/
directory, then:
ln -s <prefix>/<site-font>/devps/<file>.pfa .
ln -s <prefix>/<site-font>/devps/<groff font> .
You may safely remove the .afm file.
Inspect your new groff font file. Near the top, you will see a line
of the form
internalname <name>
Usually, the internal name is helpfully descriptive, e.g.
internalname Optima-Bold
Make a note of the internal name.
If a file called ‘download’ is not already present in <prefix>/site-font/devps/, copy over the one found in <prefix>/<version>/font/devps/.
The download file maps the internal names used by groff to the actual fonts. To add your new font to the download file, append a line containing the internal name, followed by a tab (make sure your text editor is inserting the tab character, not spaces), followed by the .t42 or .pfa font to which the internal name refers.
For example, if the internal name is Optima-Bold and the font is a
.pfa file called Optima-Bold.pfa, your updated download file will
contain
Optima-Bold<tab>Optima-Bold.pfa
If you’re running a recent version of groff that includes the native pdf device (gropdf), you must update the <prefix>/site-font/devpdf/download file as well. If it does not exist, create it.
Note: Start with a blank ‘download’ file. Do not copy over the ‘download’ file from <prefix>/<version>/font/devpdf/.
The instructions for registering fonts in the
<prefix>/site-font/devpdf/ download
file are identical to those for PostScript fonts (see above), but
with one important difference: the lines must all begin with a tab
character. Thus, using our Optima example, your
<prefix>/site-font/devpdf/download
file download line for the same font is
<tab>Optima-Bold<tab>Optima-Bold.pfa
For convenience when using mom, and to keep your font collection
organized, choose meaningful groff font names following the scheme
<Family><FONT>, where Family is something
like Optima or Univers or Clarendon, and FONT is either
R (roman/regular)
I (italic)
B (bold)
BI (bold italic)
or one of the 1–5 character fontstyles listed
here.
Thus, for the fonts Optima Light Italic and Optima Extra Black, your font names would be
OptimaLI
OptimaXBL
This scheme allows you to enter .FAMILY Optima to make
Optima the current family, and .FT LI or .FT XBL
when you need the fonts Light Italic or Extra Black.
Groff font names are, in fact, arbitrary; you can call your fonts anything you like, provided the internal name in the download file matches the internal name found in the groff font file. When calling a font that does not follow the recommended naming convention, you must pass the full font name to .FT whenever you wish to use it.
For example, the font, Goudy Stout, isn’t really part of the Goudy family, and while "stout" describes it, Stout is not a recognized font style. Therefore, its groff name could simply be GoudyStout, and whenever you needed it, you could call it with .FT GoudyStout.
A bash script to make the entire process of installing fonts a painless no-brainer has been posted online at https://www.schaffter.ca/mom/bin/install-font.sh. Be sure to make the script executable (chmod 755 install-font) after you download it, then type ./install-font.sh -H for usage.
If, as Eric Raymond asserts, open source begins with a programmer scratching a personal itch, then mom can truly be called open source.
Mom had her origins in a library of groff routines I wrote over the years to handle various aspects of typesetting and document processing that weren’t adequately covered by ms, me, mm, and friends. Typically, I’d use the library to cobble together macro sets for new challenges as they came my way.
As a writer living in a perpetual state of penury, all the computers I’ve ever owned have been hand-me-downs—several generations out-of-date and resource challenged. Disk space has always been an issue, as has processor speed and available RAM. One of the reasons I run GNU/Linux rather than the offering from Redmond is that it has helped enormously to get the most out of my poor little boxes.
In Linux-land (all Unix variants, in fact), the choice of typesetting systems basically comes down to groff or TeX. Both are wonderful—monumental achievements if you ask me—and both have their own particular strengths. However, for people in my financial position (and there are millions of us around the globe, in both developed and developing countries), TeX and groff have one big difference: size. TeX is huge. Even its most ardent supporters agree it suffers from bloat, on top of being complex and unwieldy to manage. Groff is tiny by comparison, occupying minimal disk space and having only a small memory footprint while at the same time being flexible and powerful, typographically speaking. Back in the Jurassic Period, I ran it successfully on a 386 with 8 megs of RAM and a 250 meg hard disk.
However, groff has always had a liability: it’s incredibly geeky. Owing to its very long history, it—and its power users —seem to have remained stuck in a time warp. The canonical macro packages still look as they did back in those decades when memory was exorbitantly expensive and every byte mattered.
For some time now, groff users and macro writers have had the option to use “long” names for macros (i.e. longer than two letters, the original limit), yet have mostly chosen not to. With long names, it’s possible to create macro sets that are humanly readable and easy to interpret, encouraging development and evolution. What’s more, the macros themselves need not be terse, intimidating, and easily forgotten 1- or 2-letter commands inserted in the body of a document. They can be sensible and helpful to everyone, groff newbies and old hands alike.
Mom’s macro file, om.tmac, uses long names, aliases, and a host of other groff goodies that have become part of the whole groff picture. The function of nearly every macro, number register and string can be inferred simply from its name. The file is heavily commented. A consistent, if idiosyncratic, indenting style is used as well, significantly improving readability. Anyone wanting to futz around with mom’s macros should be able to do so with a minimum of head scratching.
If you have any questions or comments about mom, suggestions to
make, criticisms to offer, or bugs to report, use the groff mailing
list (subscription information available
here)
or contact me, Peter Schaffter, directly at the following
address:
peter@schaffter.ca
Please include the word “mom” or “groff” in
the Subject line of any message sent to my personal address or you
risk the wrath of my implacable spam filters.
If you want to visit mom’s website, you’ll find a link
to it at
https://www.schaffter.ca
The site contains links to some of my fiction, all of which was
typeset with mom and groff.
Back to Table of Contents | Top |