[Tex/LaTex] Metafont Book – problems with gray.tfm and displaying “experiment 2”

metafont

I'm working through Knuth's Metafont Book as preparation for learning Metapost and I'm running into some problems working through his "experiments". I've installed the latest TeX Live 2013 distribution on my system but I'm having problems.

Here's the code (contained in file io.mf as recommended by Knuth):

mode_setup;
 em#:=10pt#; cap#:=7pt#;
 thin#:=1/3pt#; thick#:=5/6pt#;
 o#:=1/5pt#;
define_pixels(em,cap);
define_blacker_pixels(thin,thick);
define_corrected_pixels(o);
 curve_sidebar=round 1/18em;
beginchar("O", 0.8em#, cap#, 0); "The letter O";
 penpos1(thick,10); penpos2(.1[thin,thick],90-10);
 penpos3(thick,180+10); penpos4(thin,270-10);
 x1l=w-x3l=curve_sidebar; x2=x4=.5w;
 y1=.49h; y2l=-o; y3=.51h; y4l=h+o;
 penstroke z1e{down}..z2e{right}
            ..z3e{up}..z4e{left}..cycle;
 penlabels(1,2,3,4); endchar;

Now, when running the mf command and loading this file, I get a window that is unfortunately empty. Supposedly a large letter "O" should appear.

$ mf
This is METAFONT, Version 2.718281 (TeX Live 2013)
**io
(io.mf
The letter O [79])
*end
Output written on io.2602gf (1 character, 1724 bytes).
Transcript written on io.log.

$ gftodvi io.2602gf 
gftodvi: fatal: tfm file `gray.tfm' not found.

Then, when trying to use the gftodvi command I get the above error.

  1. Any ideas why my "window" that should display the letter "O" is blank/empty?
  2. How do I resolve the gray.tfm error?
  3. Are the two related?

Note: I'm using Ubuntu 14.04, but the TeXLive installation is NOT from the Ubuntu repository. I used the installer from http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz and created a local "portable" installation.

Best Answer

TeX Live can generate the missing TFM files automatically:

mktextfm gray
mktextfm black

Documentation: kpathsea, section "2.2.9 mktex scripts".


TeX and friends are using the kpathsea library for the file lookup business. Depending on the configuration, the library runs help programs mktex* to create missing files. For example, mktextfm is triggered, if a .tfm file is not found.

The following older version of this answer uses this indirect triggering.

Older version

The following TeX file test.tex loads the fonts:

\font\gray=gray \gray
\font\black=black \black
\csname @@end\endcsname\end

Run it through tex or latex:

$ tex test
This is TeX, Version 3.14159265 (TeX Live 2014) (preloaded format=tex)
(./test.tex
kpathsea: Running mktextfm gray
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input gray
This is METAFONT, Version 2.7182818 (TeX Live 2014) (preloaded base=mf)

([TEXMFDIST]/fonts/source/public/knuth-local/gray.mf
([TEXMFDIST]/fonts/source/public/knuth-local/graylj.mf
([TEXMFDIST]/fonts/source/public/knuth-lib/grayf.mf
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
[17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31]
[32] [33] [34] [35] [36] [37] [38] [39] [40] [41] [42] [43] [44] [45] [46]
[47] [48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61]
[62] [63] [64] [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76]
[77] [78] [79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90] [91]
[92] [93] [94] [95] [96] [97] [98] [99] [100] [101] [102] [103] [104] [105]
[106] [107] [108] [109] [110] [111] [112] [113] [114] [115] [116] [117]
[118] [119] [120] [121] [122] ) ) )
Font metrics written on gray.tfm.
Output written on gray.600gf (123 characters, 13144 bytes).
Transcript written on gray.log.
mktextfm: [TEXMFVAR]/fonts/tfm/public/knuth-local/gray.tfm: successfully generated.
 )
No pages of output.
Transcript written on test.log.

(I have omitted the generation of black.tfm and have replaced the paths with the name of the search path variable.)

Then gftodvi finds gray.tfm.

Related Question