[texhax] How can I "condense" or "narrow" an existing font? -- solution

Niall Mansfield texhax at uit.co.uk
Tue Feb 12 17:54:00 CET 2008

On 22-Feb-2007, 17:30, Niall Mansfield wrote:
 > Subject: How can I "condense" or "narrow" an existing font?
   > I am typesetting material that contains many code examples
   > and program output listings, some of which are very wide.
   > I have to use a monospaced font.
   > If I just reduce the text size, it becomes almost unreadable,
   > and anyway the main problem is the width, not the length.
   > 1. Can I somehow transform the standard courier font so that it
   >    is say, X percent narrower, without reducing its height?

You *can* take an existing PostScript font, and define a
modified variant of it which is condensed (i.e. narrower)
or expanded (wider).

To do this, you install your modified font as a new one,
with two crucial changes:

1. When you run afm2tfm to produce the TeX font metric
    for your new file, specify argument -e 0.6 (to condense
    each character to 60% of its normal width).

2. In the .map file, specify the same value, followed by "ExtendFont".
    E.g. for a condensed version of OCR-B, we created
    the file pob.map, containing the single line:

	pobr OCRB  " TeXBase1Encoding ReEncodeFont 0.6 ExtendFont " <8r.enc <ob______.pfb

    (We used OCRB because it was the only not-part-of-a-distribution
    PostScript font that was to hand, so we could be sure it didn't
    interfere with anything else.)

(You can also slant an existing font -- by using SlantFont instead of
ExtendFont -- though that wasn't relevant for us.)

For full details of how to install a new PostScript font, see:

	Formatting information
	A beginner's introduction to typesetting with LATEX
	Chapter 8 — Fonts and layouts
	Peter Flynn

	See section "6 PostScript fonts" for a good overview
	of the various pieces steps and how they fit together.


More information about the texhax mailing list