summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/make-tex-work/html/ch11.html
blob: b75eb560ed127e75ec3c498a4a6345ba4755c02b (plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta name="generator"
    content="HTML Tidy for Linux/x86 (vers 1st March 2002), see www.w3.org" />
    <meta http-equiv="Content-Type"
    content="text/html; charset=ISO-8859-1" />

    <title>Chapter&#160;11.&#160;Introducing MetaFont</title>
    <link rel="stylesheet" href="mtw.css" type="text/css" />
    <meta name="generator"
    content="DocBook XSL Stylesheets V1.53.0" />
    <link rel="home" href="index.html" title="Making TeX Work" />
    <link rel="up" href="pt02.html"
    title="Part&#160;II.&#160;Elements of a Complex Document" />
    <link rel="previous" href="ch10.html"
    title="Chapter&#160;10.&#160;Online Documentation" />
    <link rel="next" href="ch12.html"
    title="Chapter&#160;12.&#160;Bibliographies, Indexes, and Glossaries" />
  </head>

  <body>
    <div class="navheader">
      <table border="0" cellpadding="0" cellspacing="0"
      width="100%" summary="Navigation table">
        <tr>
          <td align="left">&#160;<a title="Making TeX Work"
          href="index.html"><img src="figures/nav-home.png"
          alt="Home" border="0" /></a>&#160;<a
          title="Chapter&#160;10.&#160;Online Documentation"
          href="ch10.html"><img src="figures/nav-prev.png"
          alt="Prev" border="0" /></a>&#160;<a
          title="Part&#160;II.&#160;Elements of a Complex Document"
          href="pt02.html"><img src="figures/nav-up.png" alt="Up"
          border="0" /></a>&#160;<a
          title="Chapter&#160;12.&#160;Bibliographies, Indexes, and Glossaries"
           href="ch12.html"><img src="figures/nav-next.png"
          alt="Next" border="0" /></a></td>

          <td align="right"><i>Making TeX Work</i> Version 1.0.1
          <span class="alpha-version">(<a
          href="co01.html"><em>Alpha</em></a>)</span></td>
        </tr>
      </table>
    </div>

    <div class="chapter">
      <div class="titlepage">
        <div>
          <h2 class="title"><a id="chap.mf"
          name="chap.mf"></a>Chapter&#160;11.&#160;Introducing
          MetaFont</h2>
        </div>

        <div>
          <p class="releaseinfo">$Revision: 1.1 $</p>
        </div>

        <div>
          <p class="pubdate">$Date: 2002/08/23 14:31:13 $</p>
        </div>
        <hr class="component-separator" />
      </div>

      <p>TeX builds pages out of boxes<a id="id2915957"
      class="indexterm" name="id2915957"></a> and glue<a
      id="id2915971" class="indexterm" name="id2915971"></a>. The
      smallest boxes are usually individual characters. MetaFont<a
      id="id2915983" class="indexterm" name="id2915983"></a> is a
      tool that creates the actual characters.</p>

      <p>In the last few years, a real explosion has taken place in
      the number of readily available fonts<a id="id2916000"
      class="indexterm" name="id2916000"></a><a id="id2915858"
      class="indexterm" name="id2915858"></a><a id="id2915866"
      class="indexterm" name="id2915866"></a>. Today, many people
      have access to a large number of high quality typefaces. Not
      too long ago (before Adobe Type Manager (ATM)<a
      id="id2915883" class="indexterm" name="id2915883"></a> was
      available for the Macintosh and Microsoft Windows), fonts
      were too expensive to be generally available. In those days,
      a font building tool like MetaFont was essential if TeX was
      going to have a number of typefaces and a large number of
      mathematical symbols. Today, the role of MetaFont is
      diminishing. Many people choose to use PostScript fonts<a
      id="id2915891" class="indexterm" name="id2915891"></a> almost
      entirely. In fact, with PostScript alternatives to the
      Computer Modern Math fonts<a id="id2915912" class="indexterm"
      name="id2915912"></a><a id="id2915918" class="indexterm"
      name="id2915918"></a> now available, it's possible to use TeX
      without using MetaFont fonts at all.</p>

      <p>On the other hand, lots of people do still use the
      Computer Modern fonts, and there are many other MetaFont
      fonts (for non-English languages like Arabic and Japanese,
      for example), so MetaFont is still a useful tool. Also, it
      can be used to make nice portable diagrams.</p>

      <p>This chapter cannot teach you how to harness all of
      MetaFont's power. The only practical way to learn how to
      design your own images with MetaFont is to read <span
      class="emphasis"><em>The \MF{}book</em></span>&#160;[<a
      href="bi01.html#kn:mfbook">kn:mfbook</a>] (even if your
      images are nowhere near as complex as an entire font).</p>

      <p>What you will learn from this chapter is how to run
      MetaFont to create TeX <tt>PK</tt> fonts<a id="id2917710"
      class="indexterm" name="id2917710"></a> and <tt>TFM</tt>
      files<a id="id2917745" class="indexterm"
      name="id2917745"></a> from existing MetaFont programs. The
      Computer Modern fonts, the \AmS fonts, and the DC Fonts are
      all created with MetaFont. It is not unreasonable to imagine
      that you might someday want to create one of these fonts at a
      non-standard size or unusual magnification.</p>

      <p>Knowing how to run MetaFont will also help you set up a
      system for performing automatic font generation. This can
      save a lot of disk space. See the section called &#8220;<a
      href="ch05.html#sec.autofont"
      title="Automatic Font Generation by DVI Drivers">the section
      called &#8220;Automatic Font Generation by DVI
      Drivers&#8221;</a>&#8221; in Chapter&#160;<a href="ch05.html"
      title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a>, <span
      class="emphasis"><em><a href="ch05.html"
      title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a></em></span>,
      for more information about setting up automatic font
      generation.</p>

      <p>From many perspectives, TeX and MetaFont behave in
      analogous ways. Where TeX reads a plain text <tt>TEX</tt>
      document, processes it, and produces a <tt>DVI</tt> file,
      MetaFont reads a plain text <tt>MF</tt> program, processes
      it, and produces a generic bitmap font file as output.</p>

      <p>Because you probably aren't going to be writing your own
      font programs for MetaFont, you have to get them from
      somewhere. Many distributions of TeX include MetaFont and the
      font files for the Computer Modern fonts. This chapter will
      concentrate on just the Computer Modern font programs because
      those are the most likely to be available.</p>

      <p>Many MetaFont fonts can be retrieved from the CTAN
      archives. Table&#160;<a href="ch11.html#tab.mf.mfdistrib"
      title="Table&#160;11.1.&#160;Some Popular MetaFont Fonts on the CTAN Archives">
      Table&#160;11.1</a> lists some common fonts and their
      location in the CTAN archives. A collection of font samples
      is shown in Appendix&#160;<a href="apb.html"
      title="Appendix&#160;B.&#160;Font Samples">Appendix&#160;B</a>,
      <span class="emphasis"><em><a href="apb.html"
      title="Appendix&#160;B.&#160;Font Samples">Appendix&#160;B</a></em></span>.</p>

      <div class="table">
        <a id="tab.mf.mfdistrib" name="tab.mf.mfdistrib"></a>

        <p class="title"><b>Table&#160;11.1.&#160;Some Popular
        MetaFont Fonts on the CTAN Archives</b></p>

        <table
        summary="Some Popular MetaFont Fonts on the CTAN Archives"
        border="1">
          <colgroup>
            <col />
            <col />
          </colgroup>

          <thead>
            <tr>
              <th>Fonts</th>

              <th>Location</th>
            </tr>
          </thead>

          <tbody>
            <tr>
              <td>Standard Computer Modern</td>

              <td><tt>fonts/cm</tt></td>
            </tr>

            <tr>
              <td>Standard LaTeX</td>

              <td><tt>macros/latex/distribs/base/fonts</tt></td>
            </tr>

            <tr>
              <td>A<sub>m</sub>S Fonts</td>

              <td><tt>fonts/ams</tt></td>
            </tr>

            <tr>
              <td>DC Fonts</td>

              <td><tt>fonts/dc</tt></td>
            </tr>

            <tr>
              <td>Concrete</td>

              <td><tt>fonts/concrete</tt></td>
            </tr>

            <tr>
              <td>Pandora</td>

              <td><tt>fonts/pandora</tt></td>
            </tr>

            <tr>
              <td>Ralph Smith's Script Font</td>

              <td><tt>fonts/rsfs</tt></td>
            </tr>

            <tr>
              <td>St. Mary's Road</td>

              <td><tt>fonts/stmary</tt></td>
            </tr>
          </tbody>
        </table>
      </div>

      <div class="section">
        <div class="titlepage">
          <div>
            <h2 class="title" style="clear: both"><a
            id="sec.mf.gettingstarted"
            name="sec.mf.gettingstarted"></a>What to Run?</h2>
          </div>
        </div>

        <p>Like TeX itself, the actual MetaFont file you have to
        execute <a id="id2918084" class="indexterm"
        name="id2918084"></a> varies between platforms and
        implementations. If you have built and/or installed TeX,
        you probably already know what program to run. You'll have
        to ask your system administrator for help if you cannot
        figure out what the name of the MetaFont executable is on
        your computer. In the rest \linebreak</p>

        <p>of this chapter, I'll assume that the command <span
        class="emphasis"><em>mf</em></span> runs MetaFont. You
        should substitute the name of the executable program on
        your system for <span class="emphasis"><em>mf</em></span>
        in the examples that follow.</p>

        <p>MetaFont comes in big and small versions just like TeX.
        You will need the big MetaFont if you are building fonts
        for very high-resolution devices or at very large sizes.
        Most fonts can be built with a small MetaFont.</p>
      </div>

      <div class="section">
        <div class="titlepage">
          <div>
            <h2 class="title" style="clear: both"><a id="id2918131"
            name="id2918131"></a>What Files Does MetaFont
            Need?</h2>
          </div>
        </div>

        <p>In addition to the MetaFont programs, MetaFont<a
        id="id2918140" class="indexterm" name="id2918140"></a> must
        be able to find several other files. The files that are
        needed are normally created during the installation
        process. The sections that follow describe each of the
        files that MetaFont needs.</p>

        <div class="section">
          <div class="titlepage">
            <div>
              <h3 class="title"><a id="id2918156"
              name="id2918156"></a>Pool Files</h3>
            </div>
          </div>

          <p>The pool file<a id="id2918169" class="indexterm"
          name="id2918169"></a> for each version of MetaFont has
          the same purpose as the pool file created for TeX. It is
          created when MetaFont is compiled. If you don't have a
          pool file, there's nothing you can do about it. If you
          obtained precompiled programs (from the Internet, from a
          friend, or commercially) and you don't have the pool file
          needed by MetaFont, you received an incomplete
          distribution.</p>

          <p>If you did not install MetaFont, and the pool file is
          missing, contact the system administrator who performed
          the installation. Something was done incorrectly.</p>
        </div>

        <div class="section">
          <div class="titlepage">
            <div>
              <h3 class="title"><a id="id2918200"
              name="id2918200"></a>Base Files</h3>
            </div>
          </div>

          <p>Base files<a id="id2918209" class="indexterm"
          name="id2918209"></a> for MetaFont are analogous to
          format files for TeX. Unlike TeX, which has many
          different format files, there are relatively few base
          files for MetaFont.</p>

          <p>Base files are created by a special version of
          MetaFont, usually called \iniMF. However, some
          implementations combine MetaFont and \iniMF into one
          program, in which case you must select \iniMF with a
          special option when you run the program.</p>

          <p>Like iniTeX, \iniMF interprets all the control
          sequences in a set of base macros and builds the
          in-memory data structures that the MetaFont program
          needs. After loading all the files, \iniMF writes the
          memory image into a base file. When MetaFont loads the
          base file, it simply copies it into memory; no
          interpretation is necessary.</p>

          <p>Because MetaFont loads the base files without
          interpretation, they are not generally portable from one
          system to another, or even between different versions of
          MetaFont on the same system. Different versions of
          MetaFont load differently in memory, and this makes the
          base files incompatible. For example, you need a big
          \iniMF to make base files for big MetaFont and small
          \iniMF for a small MetaFont.</p>

          <p>The &#8220;<a href="ch11.html#sec.mf.gettingstarted"
          title="What to Run?">the section called &#8220;What to
          Run?&#8221;</a>&#8221; section later in this chapter
          describes how to build a base file, if you do not already
          have one.</p>
        </div>

        <div class="section">
          <div class="titlepage">
            <div>
              <h3 class="title"><a id="id2918279"
              name="id2918279"></a>MetaFont Programs</h3>
            </div>
          </div>

          <p>When you run MetaFont, you have to tell it what file
          (MetaFont program)<a id="id2918287" class="indexterm"
          name="id2918287"></a> to process. MetaFont programs are
          stored in files with the extension <tt>.mf</tt>. If you
          specify a complete pathname, MetaFont will load the
          specific file that you request. If you specify a simple
          filename without a path, MetaFont looks for the file in
          several user-defined and, possibly, system-defined
          locations. The most common way to specify user-defined
          locations is by setting the <tt>MFINPUTS</tt> environment
          variable to a list of subdirectories where MetaFont
          programs are kept. The format of the environment variable
          differs according to the platform you use. On unix
          systems, it is a list of directory names separated by
          colons. On MS-DOS and OS/2 systems, it is a list of
          directory names separated by semicolons. Consult the
          documentation for the particular implementation of
          MetaFont you use for more information about
          system-defined locations where MetaFont looks for input
          files.</p>
        </div>
      </div>

      <div class="section">
        <div class="titlepage">
          <div>
            <h2 class="title" style="clear: both"><a id="id2918336"
            name="id2918336"></a>Command-line Options</h2>
          </div>
        </div>

        <p>In addition to the name of the MetaFont program,
        MetaFont has very few command-line<a id="id2918345"
        class="indexterm" name="id2918345"></a><a id="id2918360"
        class="indexterm" name="id2918360"></a> options. The name
        of a base file is the only option regularly used. In this
        section, I'll explain what can go on the MetaFont command
        line.</p>

        <p>A formal specification of the MetaFont command line
        looks like this:</p>
<pre class="screen">
$ <span class="bold"><b>mf <span
class="emphasis"><em>switches</em></span> <span
class="bold"><b>&amp;</b></span><span
class="emphasis"><em>base</em></span> mf-program mf-commands</b></span>
</pre>

        <p>After the name of the MetaFont program, the first things
        that you can specify on the command line are
        implementation-dependent switches and options. For example,
        implementations of MetaFont that combine \iniMF and
        MetaFont into a single program may use the switch <span
        class="emphasis"><em>/I</em></span> to specify that \iniMF
        processing is desired. There are no system-independent
        switches for MetaFont. Consult the documentation that comes
        with your implementation for more information about
        system-dependent switches.</p>

        <p>After any system-dependent switches, you can specify the
        name of the base file to use. This option, if present, must
        come before any other options, and you must put an
        ampersand (&amp;) in front of the base file name. If you do
        not specify a base file, MetaFont will use a default
        base.</p>

        <p>After the base, MetaFont looks for the name of a
        MetaFont program file. If MetaFont finds a filename on the
        command line, it will process the program contained in that
        file before looking at any other options that may
        follow.</p>

        <p>Finally, you can insert arbitrary MetaFont commands on
        the command line by typing them just as you would in a
        program. In fact, this is frequently done to change the
        size or magnification of the font being created. Exactly
        how this is accomplished is described in the section called
        &#8220;<a href="ch11.html#sec.buildfont"
        title="Running MetaFont">the section called &#8220;Running
        MetaFont&#8221;</a>&#8221; later in this chapter.</p>

        <p>Please read the section called &#8220;<a
        href="ch03.html#sec.runtex.cmdcautions"
        title="Command-line Options">the section called
        &#8220;Command-line Options&#8221;</a>&#8221; in
        Chapter&#160;<a href="ch03.html"
        title="Chapter&#160;3.&#160;Running TeX">Chapter&#160;3</a>,
        <span class="emphasis"><em><a href="ch03.html"
        title="Chapter&#160;3.&#160;Running TeX">Chapter&#160;3</a></em></span>,
        for a detailed description of some common problems with
        MetaFont commands on the command line. They are exactly the
        same problems that can occur on the TeX command line.</p>

        <p>Also, the behavior of MetaFont when run without any
        options at all is the same as the behavior of TeX as
        described in the section called &#8220;<a
        href="ch03.html#sec.runtex.texwoopts"
        title="Filenames and TeX">the section called
        &#8220;Filenames and TeX&#8221;</a>&#8221; in
        Chapter&#160;<a href="ch03.html"
        title="Chapter&#160;3.&#160;Running TeX">Chapter&#160;3</a>.</p>
      </div>

      <div class="section">
        <div class="titlepage">
          <div>
            <h2 class="title" style="clear: both"><a id="id2918545"
            name="id2918545"></a>Building a Base File</h2>
          </div>
        </div>

        <p>Building a base file<a id="id2918553" class="indexterm"
        name="id2918553"></a> for MetaFont is exactly analogous to
        building a format file for TeX. Fortunately, there are far
        fewer base files. The two most common base files are the
        <span class="emphasis"><em>plain</em></span> <a
        id="id2918571" class="indexterm" name="id2918571"></a> base
        and the <span class="emphasis"><em>cmbase</em></span><a
        id="id2918583" class="indexterm" name="id2918583"></a> (the
        base used for the Computer Modern fonts). Use the \iniMF
        program<a id="id2918593" class="indexterm"
        name="id2918593"></a> to build a base file. For example, to
        build the plain base, use:</p>
<pre class="screen">
\$ <span class="bold"><b>inimf plain</b></span>
</pre>

        <p>Move the resulting files, <tt>plain.base</tt><a
        id="id2918627" class="indexterm" name="id2918627"></a> and
        <tt>plain.log</tt><a id="id2918646" class="indexterm"
        name="id2918646"></a>, into the directory where MetaFont
        looks for base files (typically in a <tt>bases</tt> or
        <tt>formats</tt> subdirectory under the standard TeX
        directory).</p>

        <p>The <span class="emphasis"><em>cmbase</em></span> is
        actually an extension of the plain base. To build it, use
        the command:</p>
<pre class="screen">
\$ <span class="bold"><b>inimf &amp;plain cmbase</b></span>
</pre>

        <p>Remember to use appropriate quotation or shell escape
        characters to prevent the ampersand from being
        misinterpreted.</p>
      </div>

      <div class="section">
        <div class="titlepage">
          <div>
            <h2 class="title" style="clear: both"><a
            id="sec.buildfont" name="sec.buildfont"></a>Running
            MetaFont</h2>
          </div>
        </div>

        <p><a id="id2918724" class="indexterm"
        name="id2918724"></a><a id="id2918736" class="indexterm"
        name="id2918736"></a>The sections that follow describe how
        to use MetaFont to make a font from an existing <tt>MF</tt>
        file. You should reread the sections &#8220;<a
        href="ch05.html#sec.issueofsize"
        title="What TeX Needs To Know">the section called
        &#8220;What TeX Needs To Know&#8221;</a>&#8221; from
        Chapter&#160;<a href="ch05.html"
        title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a>,
        <span class="emphasis"><em><a href="ch05.html"
        title="Chapter&#160;5.&#160;Fonts">Chapter&#160;5</a></em></span>,
        and &#8220;<a href="ch08.html#sec.bitfonts"
        title="Built-in Fonts">the section called &#8220;Built-in
        Fonts&#8221;</a>&#8221; from Chapter&#160;<a
        href="ch08.html"
        title="Chapter&#160;8.&#160;Printing">Chapter&#160;8</a>,
        <span class="emphasis"><em><a href="ch08.html"
        title="Chapter&#160;8.&#160;Printing">Chapter&#160;8</a></em></span>,
        if you are unfamiliar with the notions of bitmap and device
        resolution and magnification and design size in TeX
        fonts.</p>

        <div class="section">
          <div class="titlepage">
            <div>
              <h3 class="title"><a id="id2918826"
              name="id2918826"></a>Picking a Mode</h3>
            </div>
          </div>

          <p>The input to MetaFont<a id="id2918833"
          class="indexterm" name="id2918833"></a> is an
          &#8220;outline&#8221; description of a font. The output
          is a set of bitmaps that realize the outline on a
          particular device at a particular size.</p>

          <p>Output from MetaFont is naturally device-dependent
          because different printers have different resolutions.
          But even two printers with the same resolution sometimes
          produce different looking results from the same bit
          patterns. For example, some laser printers are
          &#8220;write white&#8221; printers, and some are
          &#8220;write black&#8221; printers---depending on whether
          the printer fills in the black (text) areas or the white
          (non-text) areas of the page. A small, intricate bitmap
          (like a character from a font) designed for a write-black
          printer may not look as good on a write-white printer and
          vice versa.</p>

          <p>There are several internal parameters that can be
          modified to produce optimal output on any given device.
          These parameters are grouped together in a <span
          class="emphasis"><em>mode</em></span>. Whenever you run
          MetaFont to create a new set of bitmaps, you must select
          a mode.</p>

          <p>There are no rules for determining what parameters
          produce the best mode for a particular printer; it's just
          done by trial and error (set some values, print a font,
          see if it looks good, adjust some values, print another
          font, etc.).</p>

          <p>Luckily, a large collection of predefined MetaFont
          modes is available in the CTAN archives. The file
          <tt>fonts/modes/modes.mf</tt> contains appropriate
          MetaFont modes for many printers.</p>

          <p>Each mode has a name<a id="id2918916"
          class="indexterm" name="id2918916"></a>. For example,
          <tt>laserwriter</tt> and <tt>LNOthree</tt> are two modes
          from <tt>modes.mf</tt>. See &#8220;<a
          href="ch11.html#sec.buildfont"
          title="Running MetaFont">the section called
          &#8220;Running MetaFont&#8221;</a>,&#8221; later in this
          chapter for how to select a mode when you run
          MetaFont.</p>

          <p>Internally, MetaFont has a variable called
          <tt>mode</tt> that it uses to keep track of the current
          mode. The examples in this chapter use the
          <tt>laserwriter</tt> mode because that is appropriate for
          my printer.</p>

          <div class="section">
            <div class="titlepage">
              <div>
                <h4 class="title"><a id="id2918994"
                name="id2918994"></a>Proofing mode</h4>
              </div>
            </div>

            <p>Proofing mode<a id="id2919003" class="indexterm"
            name="id2919003"></a> is the mode that MetaFont uses if
            you do not select another mode. In proofing mode,
            MetaFont displays each character on the screen. This
            mode does not usually produce a useful font because it
            sets the device resolution to 2601.72 dots per inch
            (dpi). That resolution is chosen so that there are
            exactly 36 pixels per point (one point is 1/72.27
            inches in TeX).</p>

            <p>Because font designers are going to want to look at
            a font on the screen far more often than they will want
            to print it, MetaFont uses proofing mode as the
            default.</p>

            <p>If you find that MetaFont is producing fonts with
            huge resolutions (thousands of dots per inch) or fonts
            without <tt>TFM</tt> files, you're probably running in
            proofing mode. Remember to use the mode-setting
            commands on the command line when you run MetaFont.
            These commands are described in &#8220;<a
            href="ch11.html#sec.buildfont"
            title="Running MetaFont">the section called
            &#8220;Running MetaFont&#8221;</a>,&#8221; later in
            this chapter.</p>
          </div>
        </div>

        <div class="section">
          <div class="titlepage">
            <div>
              <h3 class="title"><a id="id2919066"
              name="id2919066"></a>Selecting a Size</h3>
            </div>
          </div>

          <p>The design size<a id="id2919075" class="indexterm"
          name="id2919075"></a> of the font you are creating is
          determined by the <tt>MF</tt> file you use. For example,
          the design size of <tt>cmr10.mf</tt> is 10pt. The design
          size of <tt>cmr12.mf</tt> is 12pt, etc. To select how
          large you want the bitmaps to be, you must set the
          magnification. There is no other way to select the size
          when you are running MetaFont.</p>

          <p>If you know the design size of a font and the size of
          the bitmaps that you actually want to produce, it is easy
          to calculate the magnification required. The
          magnification is simply the ratio of the size you want to
          the design size.</p>

          <p>For example, suppose you need a 16pt version of
          Computer Modern Roman. First, pick the font that has a
          design size closest to the size you want---in this case,
          Computer Modern Roman 17pt (<tt>cmr17.mf</tt>). To
          calculate the magnification, simply divide 16 by 17; in
          other words, the desired magnification is 0.9412. To make
          a 13pt version of <tt>cmr12</tt>, use a magnification of
          1.0833. Remember, in order to use these fonts in TeX, you
          will have to use the <tt>at</tt> or <tt>scaled</tt>
          operators (for example, <tt>\font\cmrxvi=cmr17 at
          16pt</tt>).</p>
        </div>

        <div class="section">
          <div class="titlepage">
            <div>
              <h3 class="title"><a id="id2919175"
              name="id2919175"></a>Making a GF Font</h3>
            </div>
          </div>

          <p><a id="id2919183" class="indexterm"
          name="id2919183"></a><a id="id2919196" class="indexterm"
          name="id2919196"></a><a id="id2919208" class="indexterm"
          name="id2919208"></a>After you have selected a mode and a
          magnification, running MetaFont is easy. In general, you
          use a command line like the following:</p>
<pre class="screen">
\$ <span class="bold"><b>mf {\bs}mode=</b></span><span
class="emphasis"><em>selected-mode</em></span><span
class="bold"><b>; mag=</b></span><span
class="emphasis"><em>desired-magnification</em></span><span
class="bold"><b>; {\bs}input</b></span> <span
class="emphasis"><em>mf-file</em></span>
</pre>

          <p>For example, on a unix system, the following command
          line would make a GF file for the Computer Modern Roman
          12pt font at a size of 13pt:</p>
<pre class="screen">
\$ <span
class="bold"><b>mf '{\bs}mode=laserwriter; mag=1.0833; {\bs}input cmr12'</b></span>
</pre>

          <p>Note the use of quotation marks to avoid
          shell-expansion of the backslash characters.</p>

          <p>On an MS-DOS or OS/2 system, where the backslash is
          not a special character, the 13pt version of
          <tt>cmr12</tt> is made with the following command:</p>
<pre class="screen">
\$ <span
class="bold"><b>mf {\bs}mode=laserwriter; mag=1.0833; {\bs}input cmr12</b></span>
</pre>

          <p>As you can see, the semicolons are <span
          class="emphasis"><em>required</em></span> in both
          cases.</p>

          <p>Magnification<a id="id2919326" class="indexterm"
          name="id2919326"></a> can be expressed with the
          <tt>magstep()</tt> function if the font is being built at
          a standard magstep size. For example, the following
          command builds a 14.44pt version of <tt>cmr12</tt>:</p>
<pre class="screen">
  \$ <span
class="bold"><b>mf {\bs}mode=hplaser; mag=magstep(1); {\bs}input cmr12</b></span>
</pre>

          <p>This corresponds to \magstep1. This example also
          illustrates how a different mode can be selected. In this
          case, the font is being built for an HP LaserJet printer.
          The command is shown without quotations, but they are
          still necessary on unix systems.</p>
        </div>

        <div class="section">
          <div class="titlepage">
            <div>
              <h3 class="title"><a id="id2919378"
              name="id2919378"></a>Making a PK Font</h3>
            </div>
          </div>

          <p><a id="id2919390" class="indexterm"
          name="id2919390"></a><a id="id2919415" class="indexterm"
          name="id2919415"></a><a id="id2919427" class="indexterm"
          name="id2919427"></a>Running MetaFont, as shown above,
          produces a <tt>TFM</tt> file and a <tt>GF</tt> file. TeX
          only needs the <tt>TFM</tt> file, which can simply be
          copied to the appropriate directory. For the Computer
          Modern fonts, you probably already have copies of the
          <tt>TFM</tt> files, so the duplicates produced by
          MetaFont can be deleted. The <tt>TFM</tt> file does not
          change at different magnifications, so you do not need to
          save different <tt>TFM</tt> files for different
          sizes.</p>

          <p>The <tt>GF</tt> file contains a font in the
          &#8220;generic bitmap&#8221; format. Most DVI drivers use
          <tt>PK</tt> files. The <b>GFtoPK</b> program converts
          <tt>GF</tt> fonts into <tt>PK</tt> fonts. If MetaFont
          creates the file <tt>cmr12.gf</tt>, you can convert it
          into a <tt>PK</tt> file by issuing the command:</p>
<pre class="screen">
  \$ <span class="bold"><b>gftopk cmr12.gf cmr12.pk</b></span>
</pre>

          <p>After conversion, you should move the <tt>PK</tt> file
          to the appropriate directory for your DVI driver and
          delete the <tt>GF</tt> file. <tt>PK</tt> files are
          generally stored in one of two directory structures. On
          operating systems that support long filenames, it is most
          common to store all the <tt>PK</tt> files for a given
          font in the same directory, using the extension to
          identify the resolution. In this case, a 360dpi version
          of <tt>cmr10</tt> would be stored as
          <tt>cmr10.360pk</tt>. Under operating systems like
          MS-DOS, which do not support long filenames, different
          resolutions are stored in their own directories. In this
          case the 360dpi font just described would be stored as
          <tt>cmr10.pk</tt> in a directory called <tt>360dpi</tt>
          or <tt>dpi360</tt>.</p>
        </div>
      </div>

      <div class="section">
        <div class="titlepage">
          <div>
            <h2 class="title" style="clear: both"><a id="id2919679"
            name="id2919679"></a>What About Errors?</h2>
          </div>
        </div>

        <p>Because I'm operating under the assumption that you are
        not writing your own MetaFont programs, errors<a
        id="id2919688" class="indexterm" name="id2919688"></a> are
        far less likely. Nevertheless, there are a few things that
        can go wrong.</p>

        <p>Figure&#160;<a href="ch11.html#fig.eight"
        title="Figure&#160;11.1.&#160;A figure eight created with MetaFont">
        Figure&#160;11.1</a> shows a simple figure eight created
        with MetaFont. The code which creates this symbol is shown
        in Example&#160;<a href="ch11.html#ex.eightcode"
        title="Example&#160;11.1.&#160;The Code for the Figure Eight">
        Example&#160;11.1</a>.</p>

        <div class="figure">
          <a id="fig.eight" name="fig.eight"></a>

          <p class="title"><b>Figure&#160;11.1.&#160;A figure eight
          created with MetaFont</b></p>
<pre class="screen">
8
</pre>
        </div>

        <div class="example">
          <a id="ex.eightcode" name="ex.eightcode"></a>

          <p class="title"><b>Example&#160;11.1.&#160;The Code for
          the Figure Eight</b></p>
<pre class="screen">
mode_setup;
u# := 2mm#;
define_pixels(u);

beginchar("A", 8u#, 9u#, 5u#);
  z1 = ( 0u,  0u);
  z2 = ( 8u,  0u);
  z3 = ( 1u,  8u);
  z4 = ( 7u,  8u);
  pickup pencircle scaled 1u#;
  draw z4 ..  z1 .. z2 ..  z3 .. cycle;
  pickup pencircle scaled 3u#;
  drawdot z1;
  drawdot z2;
  drawdot z3;
  drawdot z4;
endchar;

\end
</pre>
        </div>

        <p>Let's look at some of the things that can go wrong. In
        the following examples, a unix implementation of MetaFont
        is being used. Quotation marks are used to prevent
        misinterpretation of the backslashes.</p>

        <div class="variablelist">
          <dl>
            <dt><span class="term"><tt>! I can't find file
            `mode=laserwriter.mf'.</tt></span></dt>

            <dd>
              <p>If you forget to put a backslash in front of the
              <tt>mode</tt> parameter, MetaFont thinks that mode
              specification is the name of the <tt>MF</tt> file.
              For example, <tt>mode=laserwriter</tt> is
              misinterpreted as the filename:</p>
<pre class="screen">
$ mf 'mode=laserwriter; \input eight'
This is METAFONT, Version 2.71 (C version 6.1)
! I can't find file `mode=laserwriter.mf'.
&lt;*&gt; mode=laserwriter
                    ; \input eight
Please type another input file name:
</pre>
            </dd>

            <dt><span class="term"><tt>! Value is too large
            (xxxx).</tt></span></dt>

            <dd>
              <p>This error occurs if some element of the image
              goes outside of the bounds allowed by MetaFont.
              Frequently, this occurs in proofing mode when the
              image is so large that it can't be rendered.<sup>[<a
              id="id2919870" name="id2919870"
              href="#ftn.id2919870">112</a>]</sup> In this example,
              MetaFont is in proofing mode because I forgot the
              \mode=laserwriter parameter on the command line:</p>
<pre class="screen">
$ mf '\input eight'
This is METAFONT, Version 2.71 (C version 6.1)
(eight.mf
! Value is too large (4097).
&lt;recently read&gt; ;
                 
beginchar-&gt;...rdp:=(EXPR3);w:=hround(charwd*hppp);
                                       h:=vround(charht*hppp);
l.5 beginchar("A", 8u#, 9u#, 5u#)
                                 ;
? 
</pre>

              <p>This doesn't mean that MetaFont can't render very
              large images; it just means that my design isn't
              robust enough to handle an extremely high
              resolution.</p>
            </dd>

            <dt><span class="term"><tt>! Curve out of
            range.</tt></span></dt>

            <dd>
              <p>This error is also caused by an image that is too
              large to be rendered.<sup>[<a id="id2919932"
              name="id2919932" href="#ftn.id2919932">113</a>]</sup>
              Again, MetaFont is trying to create the image at an
              extremely high resolution; it is in proofing mode
              because I forgot the \mode=laserwriter parameter on
              the command line:</p>
<pre class="screen">
$ mf '\input eight'
This is METAFONT, Version 2.71 (C version 6.1)
(eight.mf
! Curve out of range.
&lt;to be read again&gt; 
                   ;
l.11   draw z4 ..  z1 .. z2 ..  z3 .. cycle;
                                            
? 
</pre>
            </dd>

            <dt><span class="term"><tt>unknown
            string</tt></span></dt>

            <dd>
              <p>This is what happens if you forget the semicolon
              after the \mode parameter. In this example, MetaFont
              thinks that &#8220;<tt>laserwriter \input
              eight</tt>&#8221; is the mode, which doesn't make
              sense:</p>
<pre class="screen">
$ mf '\mode=laserwriter \input eight'
This is METAFONT, Version 2.71 (C version 6.1)
(eight.mf
&gt;&gt; unknown string mode_name0
! Not a string.
&lt;to be read again&gt; 
                   ;
mode_setup-&gt;...nput "&amp;mode)else:mode_name[mode]fi;
                                                  if.unknown.mag:...
l.1 mode_setup
              ;
? 
</pre>
            </dd>

            <dt><span class="term"><tt>! Extra tokens will be
            flushed.</tt></span></dt>

            <dd>
              <p>Oops, another missing semicolon:</p>
<pre class="screen">
$ mf '\mode=laserwriter; mag=magstep(1) \input eight'
This is METAFONT, Version 2.71 (C version 6.1)
(eight.mf
! Extra tokens will be flushed.
&lt;to be read again&gt; 
                   warningcheck
mode_setup-&gt;warningcheck
                        :=0;if.unknown.mode:mode=proof;fi...
l.1 mode_setup
? 
</pre>
            </dd>

            <dt><span class="term">Nothing
            happens&#8230;</span></dt>

            <dd>
              <p>MetaFont is sitting at the asterisk prompt waiting
              for you to do something. You forgot to \input the
              font:</p>
<pre class="screen">
$ mf '\mode=laserwriter; eight'
This is METAFONT, Version 2.71 (C version 6.1)

*
</pre>
            </dd>

            <dt><span class="term"><tt>Output written on
            eight.nnngf&#8230;</tt></span></dt>

            <dd>
              <p>Success! A 300dpi version of <tt>eight.mf</tt> has
              been created and stored in the file
              <tt>eight.300gf</tt>:</p>
<pre class="screen">
$ mf '\mode=laserwriter; \input eight'
This is METAFONT, Version 2.71 (C version 6.1)
(eight.mf [65] )
Font metrics written on eight.tfm.
Output written on eight.300gf (1 character, 1964 bytes).
Transcript written on eight.log.
</pre>

              <p>On systems that place restrictions on the length
              of a filename extension, it is abbreviated to
              <tt>eight.300</tt>. The next step is to run <span
              class="emphasis"><em>gftopk eight.300gf</em></span>.
              This will produce <tt>eight.300pk</tt>, which our DVI
              driver can use.</p>
            </dd>
          </dl>
        </div>

        <div class="section">
          <div class="titlepage">
            <div>
              <h3 class="title"><a id="id2920144"
              name="id2920144"></a>Other Errors</h3>
            </div>
          </div>

          <p>The list of errors in the preceding sections is hardly
          exhaustive. For example, the gothic fonts (see
          Appendix&#160;<a href="apb.html"
          title="Appendix&#160;B.&#160;Font Samples">Appendix&#160;B</a>,
          <span class="emphasis"><em><a href="apb.html"
          title="Appendix&#160;B.&#160;Font Samples">Appendix&#160;B</a></em></span>)
          produce two more errors when rendered at low resolutions:
          <span class="emphasis"><em>! inconsistent
          equation</em></span>, caused by apparently contradictory
          statements (probably due to rounding errors) and <span
          class="emphasis"><em>{! strange path}</em></span>, caused
          by a path that does not appear to run counter-clockwise
          (again probably caused by rounding errors, these are very
          complex fonts).<sup>[<a id="id2920188" name="id2920188"
          href="#ftn.id2920188">114</a>]</sup></p>

          <p>Most of the other errors that are encountered can be
          ignored (the preceding examples from the gothic fonts can
          certainly be ignored---at least at 300dpi). Entering
          <b>H</b> at MetaFont's question mark prompt will describe
          the cause of the error in more detail.</p>
        </div>
      </div>

      <div class="section">
        <div class="titlepage">
          <div>
            <h2 class="title" style="clear: both"><a id="id2920215"
            name="id2920215"></a>Output at Very High
            Resolutions</h2>
          </div>
        </div>

        <p>Producing MetaFont output for very high resolution <a
        id="id2920224" class="indexterm" name="id2920224"></a>
        devices like phototypesetters is sometimes difficult. This
        will frequently require a big MetaFont for the same reasons
        that processing a large document requires a big TeX.</p>

        <p>It is possible to construct examples that cannot be
        rendered at very high resolutions because they are simply
        too large and complex.</p>
      </div>

      <div class="section">
        <div class="titlepage">
          <div>
            <h2 class="title" style="clear: both"><a id="id2920252"
            name="id2920252"></a>Output at Very Low
            Resolutions</h2>
          </div>
        </div>

        <p><a id="id2920260" class="indexterm"
        name="id2920260"></a>The intricate detail of many
        characters is difficult to render at very low resolutions.
        Yet, it is sometimes desirable to produce output at low
        resolutions for on-screen previewers and dot matrix
        printers.</p>

        <p>Usually, errors like &#8220;<tt>strange turning
        path</tt>&#8221; that result from attempting to produce
        output at low resolutions can be ignored, but sometimes the
        resulting characters will be distorted.</p>
      </div>

      <div class="footnotes">
        <br />
        <hr width="100" align="left" />

        <div class="footnote">
          <p><sup>[<a id="ftn.id2919870" name="ftn.id2919870"
          href="#id2919870">112</a>]</sup> {Obtaining this error
          from <tt>eight.mf</tt> required changing unit size from
          2mm to 5mm.}</p>
        </div>

        <div class="footnote">
          <p><sup>[<a id="ftn.id2919932" name="ftn.id2919932"
          href="#id2919932">113</a>]</sup> {Obtaining this error
          from <tt>eight.mf</tt> required changing unit size from
          2mm to 4mm.}</p>
        </div>

        <div class="footnote">
          <p><sup>[<a id="ftn.id2920188" name="ftn.id2920188"
          href="#id2920188">114</a>]</sup> {There are very specific
          rules about which way paths must be drawn so that
          MetaFont's algorithms for filling in the character's
          outline can succeed.}</p>
        </div>
      </div>
    </div>

    <div class="navfooter">
      <table width="100%" summary="Navigation table">
        <tr>
          <td width="40%" align="left"><a
          title="Chapter&#160;10.&#160;Online Documentation"
          href="ch10.html"><img src="figures/nav-prev.png"
          alt="Prev" border="0" /></a>&#160;</td>

          <td width="20%" align="center"><a title="Making TeX Work"
          href="index.html"><img src="figures/nav-home.png"
          alt="Home" border="0" /></a></td>

          <td width="40%" align="right">&#160;<a
          title="Chapter&#160;12.&#160;Bibliographies, Indexes, and Glossaries"
           href="ch12.html"><img src="figures/nav-next.png"
          alt="Next" border="0" /></a></td>
        </tr>

        <tr>
          <td width="40%" align="left">Chapter&#160;10.&#160;Online
          Documentation&#160;</td>

          <td width="20%" align="center"><a
          title="Part&#160;II.&#160;Elements of a Complex Document"
          href="pt02.html"><img src="figures/nav-up.png" alt="Up"
          border="0" /></a></td>

          <td width="40%" align="right">
          &#160;Chapter&#160;12.&#160;Bibliographies, Indexes, and
          Glossaries</td>
        </tr>
      </table>
    </div>
  </body>
</html>