summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/fontinst/base/fimapgen.dtx
blob: fccdf30b5e22f3561f73b228e3032ee8edb0eb94 (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
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
% \CheckSum{876}
% \iffalse meta-comment
%
% Copyright 1999 the fontinst maintenance team and any individual 
% authors listed elsewhere in this file.  All rights reserved.
% 
% This file is part of the fontinst system version 1.9.
% -----------------------------------------------------
% 
% It may be distributed under the terms of the LaTeX Project Public
% License, as described in lppl.txt in the base LaTeX distribution.
% Either version 1.0 or, at your option, any later version.
% 
%%% From file: fimapgen.dtx
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{fisource}

\title{\texttt{fimapgen.dtx}}
\author{Lars Hellstr\"om}
\begin{document}
\maketitle

\DocInput{fimapgen.dtx}

\end{document}
%</driver>
% \fi
% 
% 
% \section{Generating map file fragments}
% \label{Sec:Mapfiles}
% \changes{1.904}{1999/06/15}{Completed rudimentary map file fragment 
%    generator, made it part of \texttt{finstmsc.sty}. (LH)}
% \newcommand\OzTeX{O\kern-.03em z\kern-.15em\TeX}
% 
% A \emph{map file} is a file which is used by some DVI driver to link 
% various kinds of font information to each other, as is needed for the 
% driver's operation. Examples of such files are the file 
% \texttt{psfonts.map} used by \texttt{dvips} and the config files of 
% \OzTeX. There are however many other such files around in the \TeX\ 
% world.
% 
% Not all of a map file need to be related to linking specific kinds of 
% font information to each other. \OzTeX\ config files can for example 
% be used to set the values of \TeX\ implementation parameters\footnote
% {The kind of things that were Pascal constants in the original \Web\ 
% sources for \TeX.} and there need not be any font-related information 
% at all in them. The important thing is however that there can be map 
% information in them---that information could be automatically written 
% by the routines described here. 
% 
% Since there may be other kinds of information in these files (and often 
% enough need to be for everthing to work right), the routines described 
% here will only generate map file \emph{fragments}. These fragments 
% will then have to be inserted in the final map files somehow, usually 
% through manual editing. The purpose of the routines described here is 
% only to save the user a good deal of (often quite boring) typing, not 
% to actually install everything where it needs to be.
% 
% \StopEventually{}
% 
% \begin{macro}{\mapfrags_subsystem}
%   This macro holds the name of the automatic map file fragments 
%   writer subsystem of \package{fontinst}, as it appears in error 
%   messages.
%    \begin{macrocode}
\def\mapfrags_subsystem{Map~fragments~writer}
%    \end{macrocode}
% \end{macro}
% 
% \subsection{Interface to main \package{fontinst}}
% \label{Ssec:interface}
% 
% The automatic generation of map file fragments is based on the two 
% commands |\storemapdata| and |\makemapentry|. Their respective 
% syntaxes are
% \begin{quote}
%   |\storemapdata|\marg{\TeX\ font name}\marg{source}^^A
%     \marg{transforms}\\
%   |\makemapentry|\marg{\TeX\ font name}
% \end{quote}
% 
% \DescribeMacro{\storemapdata}|\storemapdata| commands are written when 
% a metric file \meta{\TeX\ font name}|.mtx| is generated. The purpose 
% of these commands is to record where the data for that file came from, 
% and what was done to these data. The source of the data is specified 
% in the \meta{source} argument, which can contain one of
% \begin{quote}
%   |\fromafm|\marg{AFM name}\marg{PS name}\\
%   |\frompl|\marg{PL name}\\
%   |\frommtx|\marg{MTX name}\\
%   |\fromvpl|
% \end{quote}
% The only real difference between |\fromafm| and |\frompl| at this 
% stage is that the former specifies the PS name of the font, but the 
% latter do not. If you write a |\store|\-|map|\-|data| command yourself 
% and want to supply the PS name then you should use |\fromafm| even if 
% you took the font metrics from a PL.
% There is a important difference between |\fromvpl| and the first three 
% in that virtual fonts need no map file entry (and hence there should 
% not be any either). Besides some error checking, |\fromvpl| causes a 
% |\makemapentry| to do essentially nothing.
% 
% What was done to the data is specified by the \meta{transforms} 
% argument, which is a possibly empty sequence of commands, in which 
% each item is one of
% \begin{isyntax}
%   |\transformfont|\marg{x-scale}\marg{slant-scale}\\
%   |\reencodefont|\marg{etx}\\
%   |\reglyphfont|
% \end{isyntax}
% The order is interpreted so that the thing done first appear first in 
% the sequence. In normal cases there is at most one of each, and then 
% the order is not important. \meta{x-scale}, \meta{slant-scale}, and 
% \meta{y-scale} are the values of these variables used for the 
% transformation, as \TeX\ numbers. \meta{etx} is the name of the ETX 
% file used for the font reencoding.
% |\reglyphfont| is an error marker. It will not be encountered (but 
% it may well get stored in some table) unless a metric font transform 
% is applied to a font that has been reglyphed, which is illegal.
% 
% \changes{1.911}{1999/11/17}{\cs{storemapdata} commands are also 
%    written to metric files when they are generated. (LH)}
% In addition to being written to a transforms record file (if one is 
% open), |\storemapdata| commands are also written to the actual metric 
% file. This makes it possible to find out where the data for a file 
% comes from even if the file was made on a previous \package{fontinst} 
% run, but since it requires reading an additional file just to find one 
% command, it will be slower than if the |\storemapdata| appeared in a 
% transforms records file.
% 
% \DescribeMacro{\makemapentry}|\makemapentry| commands are written when 
% a VPL that uses or a ligfull PL for a font is generated. These 
% commands are the ones which actually cause the map file fragment 
% generator to write an entry, but entries are only written if they 
% haven't been written before. |\makemapentry| uses information that 
% was stored by a previous call to |\storemapdata|.
% 
% |\storemapdata| stores its arguments in one of the control sequences 
% \describecsfamily{Tf-\meta{font}}|\Tf-|\meta{font}, where \meta{font} 
% is the same thing as \meta{\TeX\ font name} above. |Tf| stands for 
% ``\TeX\ font''. The control sequences in this family are paramterless 
% macros whose replacement texts have the following form:
% \changes{1.914}{2000/05/30}{Contents of \cs{Tf-\meta{font}} control 
%    sequences changed to allow processing the same file of recorded 
%    transformations several times on the same run. (LH)}
% \begin{quote}
%   \marg{made}\marg{source}\marg{transforms}
% \end{quote}
% Here \meta{source} and \meta{transforms} are exactly as above. 
% \meta{made} is a number which describes the current status of this font. 
% If \meta{made} is even then the font has been defined but no entry for 
% it has subsequently been written to the map file, whereas if it is odd 
% then an entry for it has been written to the map file. If the value of 
% \meta{made} is less than |\process_generation| then the data in the 
% other two arguments is from a previous run and should be ignored.
% The |\Tf-|\meta{font} control sequences should always be set globally.
% 
% \begin{macro}{\process_generation}
% \begin{macro}{\process_generation_succ}
%   |\process_generation| is a counter which stores the number of the 
%   current ``entry generation''. It starts at 0 and is increased by 
%   two at each |\donedrivers|. |\process_generation_succ| is a macro 
%   which expands to a number one larger than that in |\process_generation|.
%   \multchanges{\cs{process_generation}\cs{process_generation_succ}}
%      {1.914}{2000/05/30}{Control sequences added. (LH)}
%    \begin{macrocode}
%<*map>
\newcount\process_generation
\process_generation=0
\def\process_generation_succ{1}
%</map>
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% \begin{macro}{\recordtransforms}
% \begin{macro}{\endrecordtransforms}
% \begin{macro}{\transform_record_file}
%   In main \package{fontinst}, the command
%   \begin{quote}
%     |\recordtransforms|\marg{filename}
%   \end{quote}
%   starts a block of code within which font transforms will be recorded 
%   in the file \meta{filename}. |\endrecordtransforms| ends such a block.
%    \begin{macrocode}
%<*pkg>
\def\recordtransforms#1{\open_pout\transform_record_file{#1}}
\def\endrecordtransforms{
   \close_pout\transform_record_file{Font~transformation~records}
}
\chardef\transform_record_file=\closed_stream
%</pkg>
%    \end{macrocode}
% \end{macro} \end{macro} \end{macro}
% 
% 
% \begin{macro}{\extract_font_generation}
%   The |\extract_font_generation| macro takes the name of a font and 
%   returns the \meta{made} component from the |\Tf-|\meta{font} macro 
%   for that font, or minus one if that macro hasn't been defined.
%   \changes{1.914}{2000/05/30}{Macro added. (LH)}
%    \begin{macrocode}
%<*map>
\def\extract_font_generation#1{
   \if_defined{Tf-#1}\then
      \expandafter\expandafter \expandafter\first_of_three
         \csname Tf-#1\endcsname
   \else
      \m@ne
   \fi
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\storemapdata}
%   There should not be two |\storemapdata| for the same font, hence 
%   the check below. (Note that a `font' in this case is an MTX file. 
%   It is quite possible (and legal) to generate the PL file for that 
%   MTX file more than once.)
%   \changes{1.927}{2004/07/12}{Improved wording of warning message 
%      and downgraded it to an info in the case when the two 
%      definitions are the same. (LH)}
%    \begin{macrocode}
\def\storemapdata#1#2#3{
   \expandafter\def \expandafter\a_macro
      \expandafter{ \expandafter{ \the\process_generation}{#2}{#3}}
   \ifnum \extract_font_generation{#1}<\process_generation \else
      \x_cs\ifx{Tf-#1}\a_macro 
         \fontinstinfo\mapfrags_subsystem
            {Repeated~definition~of~font~#1}
      \else
         \fontinstwarning\mapfrags_subsystem
            {Inconsistent~redefinition~of~font~#1}
      \fi
   \fi
   \x_cs\let{Tf-#1}=\a_macro
}
%</map>
%    \end{macrocode}
%   In main \package{fontinst}, |\storemapdata| should be a noop so 
%   that it can appear in metric files.
%    \begin{macrocode}
%<pkg>\let\storemapdata=\gobble_three
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\record_transform}
%   \changes{1.911}{1999/11/18}{\cs{storemapdata} lines are optionally 
%      written to the main output file as well. (LH)}
%   In main \package{fontinst}, the call
%   \begin{quote}
%     |\record_transform|\marg{TFM name}\marg{source}^^A
%        \marg{transforms}\marg{if}
%   \end{quote}
%   writes
%   \begin{quote}
%     |\storemapdata|\marg{TFM name}\marg{source}\marg{transforms}
%   \end{quote}
%   to the transformation recordings file (if font transforms are being 
%   recorded) and to the main output file (if the \meta{if} evaluates 
%   to true). Note that the caller of |\record_transform| must see to 
%   that macros in \meta{source} and \meta{transforms} are written 
%   correctly to the file (this is usually accomplished by adding 
%   |\string| in suitable places of these arguments during their 
%   construction).
%   
%    \begin{macrocode}
%<*pkg>
\def\record_transform#1#2#3#4{
   \ifnum \transform_record_file=\closed_stream \else
      \pout_line\transform_record_file{\string\storemapdata{#1}{#2}{#3}}
   \fi
   #4 \out_line{\string\storemapdata{#1}{#2}{#3}} \fi
}
%</pkg>
%    \end{macrocode}
% \end{macro}
% 
% 
% \begin{macro}{\transformfont}
%   \changes{1.913}{2000/03/11}{Third argument removed, since it isn't 
%      used anymore. This change is harmless, since the worst thing 
%      that can happen to this argument is that it is typeset. (LH)}
% \begin{macro}{\reencodefont}
% \begin{macro}{\reglyphfont}
%   These are initially |\relax|, so they can be |\edef|ed with safely.
%    \begin{macrocode}
%<*map>
\let\transformfont\x_relax
\let\reencodefont\x_relax
\let\reglyphfont\x_relax
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% 
% 
% \changes{1.914}{2000/05/30}{The total transform applied for a font is 
%    determined before the entry makers are called. (LH)}
% \begin{macro}{\makemapentry}
%   |\makemapentry| sets |\TeX_font_name|, checks if any map data have 
%   been stored for the font in question, and passes them on to 
%   |\make_map_entry| if they have; otherwise it raises an error. There 
%   is also a group which is begun and ended by |\makemapentry|, to stop 
%   values deduced for one entry to interfere with the deduction of values 
%   in the following.
%   \changes{1.911}{1999/11/20}{When map data are not known, try to 
%      get them from the MTX file before declaring the source unknown. 
%      (LH)}
%    \begin{macrocode}
\def\makemapentry#1{\begingroup
   \def\TeX_font_name{#1}
   \ifnum \extract_font_generation{#1}<\process_generation
      \if_file_exists{#1.mtx}\then
         \inputmtx{#1}
   \fi\fi
   \ifnum \extract_font_generation{#1}<\process_generation
      \from_unknown{#1}
      \x_cs\xdef{Tf-#1}{
         {\process_generation_succ}{\noexpand\from_unknown{#1}}{}
      }
   \else
      \expandafter\expandafter \expandafter\make_map_entry 
         \csname Tf-#1\endcsname
   \fi
   \endgroup
}
%    \end{macrocode}
%   
%   \begin{macro}{\make_map_entry}
%     |\make_map_entry| oversees the interpretation of the 
%     \meta{source} part of the map data, something which sets 
%     |\source_font_TeX_name| and possibly |\PS_font_name|. It also 
%     collects the transforms applied in |\font_transforms|, 
%     concatenates them, and calls a list macro |\entry_makers_list| which 
%     causes the actual entries to be written, and records in 
%     |\Tf-|\meta{\TeX\ font name} that the entries have been written.
%    \begin{macrocode}
\def\make_map_entry#1#2#3{
   \ifnum #1=\process_generation
      \def\font_transforms{#3}
      #2
      \_a_false
      \let\transformfont\concat_transformfont
      \let\reencodefont\concat_reencodefont
      \let\reglyphfont\_a_true
      \font_transforms
      \if_a_
         \fontinsterror\mapfrags_subsystem{
            \string\makemapentry\space for~reglyphed~font
         }{ No~entry~for~font~\TeX_font_name\space 
            can~be~written,\messagebreak
            since~it~had~been~reglyphed!~\error_help_a
         }
      \else
         \entry_makers_list
      \fi
      \expandafter\gdef \csname Tf-\TeX_font_name \expandafter\endcsname
         \expandafter{\expandafter{\process_generation_succ}{#2}{#3}}
   \fi
}
%</map>
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% 
% \begin{macro}{\record_usage}
%   In main \package{fontinst}, the call
%   \begin{quote}
%     |\record_usage|\marg{TFM name}
%   \end{quote}
%   writes
%   \begin{quote}
%     |\makemapentry|\marg{TFM name}
%   \end{quote}
%   to the transformation recordings file, if font transforms are being 
%   recorded. The |\record_usage| command is, roughly speaking, only used 
%   by |\installfont| and |\installrawfont|.
%    \begin{macrocode}
%<*pkg>
\def\record_usage#1{
   \ifnum \transform_record_file=\closed_stream \else
      \pout_line\transform_record_file{\string\makemapentry{#1}}
   \fi
}
%</pkg>
%    \end{macrocode}
% \end{macro}
% 
% 
% \begin{macro}{\fromafm}
%   |\fromafm| saves its two arguments in the suitable string macros.
%    \begin{macrocode}
%<*map>
\def\fromafm#1#2{
   \def\source_font_TeX_name{#1}
   \def\PS_font_name{#2}
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\frompl}
%   |\frompl| saves its argument in the suitable string macro.
%    \begin{macrocode}
\def\frompl#1{
   \def\source_font_TeX_name{#1}
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\frommtx}
%   This one is tricky, since it will have to work recursively, 
%   fetching data that were stored for some other font. If it cannot 
%   find those data in memory, then it tries to get them from the 
%   metric file itself.
%   \changes{1.911}{1999/11/17}{When map data are not known, try to 
%      get them from the MTX file before declaring the source unknown. 
%      (LH)}
%    \begin{macrocode}
\def\frommtx#1{%
   \ifnum \extract_font_generation{#1}<\process_generation
      \if_file_exists{#1.mtx}\then
         \inputmtx{#1}
   \fi\fi
   \ifnum \extract_font_generation{#1}<\process_generation
      \from_unknown{#1}
      \x_cs\xdef{Tf-#1}{
         {\the\process_generation}{\noexpand\from_unknown{#1}}{}
      }
   \else
      \expandafter\expandafter \expandafter\from_mtx
         \csname Tf-#1\endcsname
   \fi
}
%    \end{macrocode}
% \begin{macro}{\from_mtx}
%    \begin{macrocode}
\def\from_mtx#1#2#3{
   \edef\font_transforms{#3\font_transforms}
   #2
}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% \begin{macro}{\fromvpl}
%   The |\fromvpl| command checks if |\font_transforms| is empty. If it 
%   is then everything is fine, but no entry should be written for this 
%   font. If it isn't then someone has tried to make a transformation of 
%   a virtual font, which doesn't work.
%    \begin{macrocode}
\def\fromvpl{
   \ifx \empty_command\font_transforms \else
      \fontinsterror\mapfrags_subsystem{
         Font~is~virtual,~it~cannot~be~transformed}{
         No~entry~for~font~\TeX_font_name\space can~be~written.
         \messagebreak\error_help_a
      }
   \fi
   \let\maker_do\gobble_one
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\AssumeMetafont}
%   The |\AssumeMetafont| general settings command makes |\frompl| 
%   behave like |\fromvpl|.
%    \begin{macrocode}
\def\AssumeMetafont{
   \def\frompl{
      \ifx \empty_command\font_transforms \else
         \fontinsterror\mapfrags_subsystem{
            A~Metafont~cannot~be~transformed}{
            No~entry~for~font~\TeX_font_name\space can~be~written.
            \messagebreak\error_help_a
         }
      \fi
      \let\maker_do\gobble_one
   }
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\from_unknown}
%   This special value for \meta{source} is used for fonts that are 
%   referenced by some |\frommtx| but which have no |\storemapdata| 
%   themselves.
%    \begin{macrocode}
\def\from_unknown#1{
   \fontinstwarningnoline\mapfrags_subsystem{
      No~map~data~stored~for~font~#1.\messagebreak
      No~entry~for~\TeX_font_name\space will~be~written,\messagebreak
      due~to~insufficient~information}
   \includewarning\warn_unknown_source
   \let\maker_do\gobble_one
}
%    \end{macrocode}
% \end{macro}
% 
% 
% \begin{macro}{\font_transforms}
%   This macro is used to collect all transformations that have been 
%   applied to a font in, before they are concatenated.
%    \begin{macrocode}
\let\font_transforms\empty_command
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\xscale_factor}
% \begin{macro}{\slant_factor}
% \begin{macro}{\reencode_etx}
%   |\xscale_factor| and |\slant_factor| are dimens which the entry 
%   makers can inspect to check the amount of horizontal scaling and 
%   slanting should be applied to the current font. 1\,pt equals the 
%   factor~1. 
%   \begin{quote}
%     |\expandafter\lose_measure\the\xscale_factor|
%   \end{quote}
%   will produce the corresponding factor.
%   
%   |\reencode_etx| is a macro which contains the name of the (last) 
%   ETX file used to reencode the font; it is empty if the font hasn't 
%   been reencoded.
%   \multchanges{\cs{xscale_factor}\cs{slant_factor}\cs{reencode_etx}}
%      {1.914}{2000/05/30}{Control sequences added. (LH)}
%    \begin{macrocode}
\newdimen\xscale_factor  \newdimen\slant_factor
\xscale_factor=\p@       \slant_factor=\z@
\let\reencode_etx\empty_command
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% 
% \multchanges{\cs{concat_transformfont}\cs{concat_reencodefont}}
%    {1.914}{2000/05/30}{Macros added. (LH)}
% \begin{macro}{\concat_transformfont}
%   The |\concat_transformfont| macro is a definition of |\transformfont| 
%   which concatenates the transformation expressed by the arguments 
%   with the one in |\xscale_factor| and |\slant_factor|. 
%   Mathematically, it performs the multiplication
%   $$
%     \left( \begin{array}{cc} f(\#1)& f(\#2)\\ 0& 1 \end{array} \right)
%     \left( \begin{array}{cc} 
%        \mbox{\cs{xscale_factor}}& \mbox{\cs{slant_factor}} \\ 
%        0& 1 
%     \end{array} \right)
%   $$
%   where $f$ stands for |\make_factor|.
%    \begin{macrocode}
\def\concat_transformfont#1#2{
   \edef\a_macro{\make_factor{#1}}
   \xscale_factor=\a_macro\xscale_factor
   \slant_factor=\a_macro\slant_factor
   \advance \slant_factor \make_factor{#2}\p@
}
%    \end{macrocode}
% \end{macro}
% 
% 
% \begin{macro}{\concat_reencodefont}
%   The |\concat_reencodefont| macro is a definition of |\reencodefont| 
%   which concatenates the reencoding expressed by the argument with 
%   the one in |\reencode_etx|. Since reencoding ignores the previous 
%   encoding, concatenating is the same thing as remembering the last 
%   reencoding.
%    \begin{macrocode}
\def\concat_reencodefont#1{\def\reencode_etx{#1}}
%    \end{macrocode}
% \end{macro}
% 
% 
% \subsection{User interface}
% 
% The basic usage of the automatic map file fragment generator consists 
% of specifying for which driver(s) entries should be generated, 
% |\input|ing a file of recorded transformations generated by main 
% \package{fontinst}, and signaling that there isn't anything more to 
% write. This can be done with the commands
% \begin{quote}
%   |\adddriver|\marg{driver name}\marg{fragment file name}\\
%   \meta{possible additional \cs{adddriver} commands}\\
%   |\input |\meta{recorded transforms file}\\
%   |\donedrivers|\\
%   |\bye|
% \end{quote}
% It should however be noted that this is the \emph{basic} usage. The 
% map fragments that work for one \TeX\ system need not work for 
% another (even if the driver is the same), and therefore it is 
% necessary to make the whole process of writing map file fragments 
% configurable. A few examples of things you may have to inform the map 
% fragment writer about are (and these are for \package{dvips} alone; 
% that's the driver I know best):
% \begin{itemize}
%   \item
%     Is the font resident on the printer or must it be downloaded?
%   \item
%     If the font must be downloaded, what is the name of the file it 
%     is in? Here one must take into account not only the possibility 
%     that the font file might have to be shared with some other 
%     software (such as a GUI) and thus cannot be named according to 
%     the Berry scheme---even if it is named according to the Berry 
%     scheme one still has the question of its extension: \texttt{.pfa}, 
%     \texttt{.pfb}, or something else? For instances of Multiple Master 
%     fonts, you (at least sometimes) have to download more than one file.
%   \item
%     Again if the font must be downloaded, can/should it be partially 
%     downloaded?
%   \item
%     In case the font has been reencoded, what is the name of the file 
%     which defines this encoding, and by what name does that file make 
%     the encoding known to the postscript interpreter?
% \end{itemize}
% The mechanisms available for such configuration are described in 
% Subsection~\ref{Sssec:Config-interface}. 
% Note that map files for DVI viewers are on average more likely to need 
% various platform-specific information about the fonts than map files 
% for DVI printer drivers are, and hence once can expect that 
% generation of these will need more extensive configuration than that 
% for the printer drivers.
% 
% 
% \subsubsection{Interface for basic usage}
% 
% An \emph{entry maker} is a group of macros which write the entry for 
% the font currently under consideration to a map fragments file each 
% time they are called. The macro to call must have a name of the form 
% \describecsfamily{make_\meta{driver}}|\make_|\meta{driver} for 
% |\adddriver| to recognise it. Each entry maker has a separate output 
% file (opened using |\open_pout|) and the identifier connected to that 
% file is called \describecsfamily{output_\meta{driver}}\relax
% |\output_|\meta{driver}.
% 
% A list of all entry makers currently active is maintined in the macro 
% |\entry_makers_list|. Each item in this list has the form
% \begin{quote}
%   |\maker_do|\,|\make_|\meta{driver}
% \end{quote}
% |\maker_do| is usually |\relax|, but it does occationally get set to 
% other values.
% \par\bigskip
% 
% 
% \begin{macro}{\adddriver}
%   The |\adddriver| command adds the named driver to the list of 
%   drivers to write entries for and opens an output file where the 
%   entries for that particular driver will go. Repeated calls to 
%   |\adddriver| for the same driver have no effect.
%    \begin{macrocode}
\def\adddriver#1#2{
   \x_cs\ifx{make_#1}\x_relax
      \fontinsterror\mapfrags_subsystem
         {There~is~no~entry~maker~for~#1}\error_help_a
   \else
      \x_cs\ifx{output_#1}\x_relax \_a_true \else
         \x_cs\ifx{output_#1}\closed_stream \_a_true \else
            \_a_false
      \fi\fi
      \if_a_
         \x_cs\open_pout{output_#1}{#2}
         \expandafter\add_to \expandafter\entry_makers_list 
            \expandafter{ \expandafter\maker_do 
            \csname make_#1\endcsname}
      \fi
   \fi
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\entry_makers_list}
% \begin{macro}{\maker_do}
%    \begin{macrocode}
\let\entry_makers_list\empty_command
\let\maker_do\x_relax
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% \begin{macro}{\donedrivers}
%   The main function performed by the |\donedrivers| command is to 
%   close all the open output files. It might also print some warning 
%   messages.
%    \begin{macrocode}
\def\donedrivers{
   \def\maker_do##1{
      \x_cs\close_pout{output\expandafter\gobble_five\string##1}
         {Map~file~fragments}
   }
   \entry_makers_list
   \let\maker_do\x_relax
   \let\entry_makers_list\empty_command
   \errorstopmode
   \reportwarnings
   \advance \process_generation \thr@@
   \edef\process_generation_succ{\the\process_generation}
   \advance \process_generation \m@ne
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\gobble_five}
%    \begin{macrocode}
\def\gobble_five#1#2#3#4#5{}
%    \end{macrocode}
% \end{macro}
% 
% 
% It is appropriate that the map file writer writes a summary of the 
% kinds of risky things which happened when it is done writing data to 
% files. To simplify implementing such things, there is a command 
% \DescribeMacro{\includewarning}|\includewarning| that takes care of 
% the bookkeeping involved. After the call
% \begin{quote}
%   |\includewarning|\meta{command}
% \end{quote}
% the \meta{command} will be executed exactly once the next time 
% |\reportwarnings| is executed. The \meta{command} usually expands to 
% something like
% \begin{quote}
%   \small|\fontinstwarningnoline\mapfrags_subsystem{|\\
%   |   Check~the~output~file(s)--some~data~was~considered~uncertain}|
% \end{quote}
% 
% \begin{macro}{\warnings_list}
%   The |\warnings_list| macro contains a list of all warnings that 
%   should be made. It expands to a sequence of
%   \begin{quote}
%     |\warning_do|\meta{command}
%   \end{quote}
%   |\warnings_list| is always assigned globally.
%    \begin{macrocode}
\g_let\warnings_list=\empty_command
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\includewarning}
% \begin{macro}{\warning_do}
%   The |\includewarning| command adds an entry for its argument to the 
%   |\warnings_list| list, provided there wasn't already such an entry. 
%   |\includewarning| is based on the macro |\warning_do|, which does 
%   most of the bookkeeping for making sure the list contains at most 
%   one entry of each kind. |\warning_do| normally expects to be 
%   expanded in the context
%   \begin{quote}
%     |\warning_do|\meta{new command}\meta{old command}\meta{next}
%   \end{quote}
%   The \meta{new command} is the command that is being added to the 
%   list, and the \meta{old command} is a command that is already in the 
%   list. \meta{next} is the first token in the next item in the 
%   list---in most cases another |\warning_do|. If \meta{new command} 
%   and \meta{old command} are not equal, this should expand to
%   \begin{quote}
%     |\noexpand\warning_do|\,|\noexpand|\meta{old command}\,^^A
%     \meta{next}\,\meta{new command}
%   \end{quote}
%   If on the other hand they are equal, this should expand to
%   \begin{quote}
%     |\noexpand\warning_do|\,|\noexpand|\meta{old command}\,^^A
%     \meta{next}\,|\x_relax|
%   \end{quote}
%   The reason for this is that the last \meta{next} will not be a 
%   |\warning_do|, but an |\ifx| which tests whether a new item should 
%   be added to the list.
%    \begin{macrocode}
\def\warning_do#1#2#3{
   \noexpand\warning_do \noexpand#2
   \ifx #1#2
      \expandafter#3 \expandafter\x_relax
   \else
      \expandafter#3 \expandafter#1
   \fi
}
\def\includewarning#1{
   \xdef\warnings_list{
      \expandafter\swap_two \expandafter#1 \warnings_list
      \if_equal\x_relax\then \else
         \noexpand\warning_do \noexpand#1
      \fi
   }
}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% \begin{macro}{\reportwarnings}
%   The |\reportwarnings| command reports all the warnings and empties 
%   the |\warnings_list|.
%    \begin{macrocode}
\def\reportwarnings{
   \begingroup
      \let\warning_do=\x_relax
      \warnings_list
   \endgroup
   \g_let\warnings_list=\empty_command
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\warn_unknown_source}
% \begin{macro}{\warn_undecided_data}
% \begin{macro}{\warn_uncertain_data}
%   These macros are used to output warnings at the |\reportwarnings| at 
%   the end of |\donedrivers|.
%    \begin{macrocode}
\def\warn_unknown_source{
   \fontinstwarningnoline\mapfrags_subsystem{
      Some~font~is~missing~from~the~output~file(s),\messagebreak
      since~its~source~is~unknown}
}
\def\warn_undecided_data{
   \fontinstwarningnoline\mapfrags_subsystem{
      Check~the~output~file(s)--some~data~could~not~be~determined}
}
\def\warn_uncertain_data{
   \fontinstwarningnoline\mapfrags_subsystem{
      Check~the~output~file(s)--some~data~was~considered~uncertain}
}
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% 
% 
% 
% \subsubsection{Configuration interface}
% \label{Sssec:Config-interface}
% 
% To correctly format reencodings, the map file writer must know what 
% the ETX encodings correspond to. In the case of drivers which 
% generate postscript output, this information is stored in the 
% \describecsfamily{pse-\meta{etx}}|\pse-|\meta{etx} family of macros. 
% \meta{etx} is the name (suffix excluded) of the ETX file that the 
% information pertains to. The expansion of these macros are of the form
% \begin{quote}
%   \marg{postscript name}\marg{action}
% \end{quote}
% \meta{postscript name} is the name by which the encoding is known to 
% the postscript interpreter, and \meta{action} lists any additional 
% action that must be taken before the encoding can be used. So far the 
% only action known is \DescribeMacro{\download}|\download|\marg{file}, 
% which will cause code for downloading the file by the name \meta{file} 
% (suffix included) to be inserted in the output.
% 
% \begin{macro}{\declarepsencoding}
%   Data is entered in a |\pse-|\meta{etx} macro using the 
%   |\declare|\-|ps|\-|encoding| command. Its syntax is
%   \begin{quote}
%     |\declarepsencoding|\marg{etx}\marg{postscript name}\marg{action}
%   \end{quote}
%    \begin{macrocode}
\def\declarepsencoding#1#2#3{\x_cs\gdef{pse-#1}{{#2}{#3}}}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\download}
%   By default |\download| gobbles its argument. It should be redefined 
%   when that is not the desired effect.
%    \begin{macrocode}
\let\download=\gobble_one
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\fulldownload}
%   By default this defaults to being a synonym of |\download|, to 
%   simplify matters for drivers where the distinction is not relevant. 
%   They should be redefined when that is not the desired effect.
%   \changes{1.928}{2004/12/13}{Command added. (LH)}
%    \begin{macrocode}
\def\fulldownload#1{\download{#1}}
%    \end{macrocode}
% \end{macro}
% 
% Some encodings seem to always be present, so they can be declared here.
%    \begin{macrocode}
\declarepsencoding{8r}{TeXBase1Encoding}{\download{8r.enc}}
\declarepsencoding{8a}{StandardEncoding}{}
%    \end{macrocode}
% \package{fontinst} must be told about other postscript encodings (if you 
% have them installed). The \texttt{finstmsc.rc} file is the right place 
% for these declarations.\relax
% \SortIndex{finstmsc.rc file}{\texttt{finstmsc.rc} file}
% 
% Next we have the cofiguration for fonts, which works in a similar 
% fashion. The main problem here seems to be to determine which files (if 
% any) should be downloaded to the printer, and this can be specified 
% using |\download| commands as for the encodings. The family 
% \describecsfamily{psf-\meta{PS font name}}|\psf-|\meta{PS font name} 
% of macros expand to a sequence of \meta{actions} as for the encodings. 
% If there is such a macro for a font then the instructions found there 
% should be followed.
% 
% It is recommended that the contents of a |\psf-|\meta{PS font name} 
% macro is executed before the map file entry is written, and that 
% commands like |\download| are temporarily redefined to build the text 
% for the entry, rather than having the |\write| in |\pout_line| expand 
% the contents of |\psf-|\meta{PS font name}.
% 
% \begin{macro}{\specifypsfont}
%   The |\specifypsfont| command is used as
%   \begin{quote}
%     |\specifypsfont|\marg{PS font name}\marg{actions}
%   \end{quote}
%   It can be used to specify the actions that should be done to make a 
%   Postscript font known to the printer, when the automatic guessing 
%   would not be right.
%    \begin{macrocode}
\def\specifypsfont#1#2{\x_cs\def{psf-#1}{#2}}
%    \end{macrocode}
% \end{macro}
% 
% Examples of cases where |\specifypsfont| would be needed are:
% \begin{itemize}
%   \item Fonts which are resident on the printer. In this case the 
%     \meta{actions} argument should be empty, e.g.
%     \begin{quote}
%       |\specifypsfont{Times-Roman}{}|
%     \end{quote}
%   \item Instances of multiple master fonts. In this case one must 
%     download both the multiple master font and the stub file that 
%     defines the instance.
%     
%     Subsection~10.6.1 in The \LaTeX\ graphics companion~\cite
%     {LaTeX-graph-comp} contains an example with an instance of the 
%     \texttt{MinionMM} multiple master font. Both the \TeX\ and 
%     (what is of interest here) the PS name for this instance is 
%     \texttt{zmnl8ac6}, the base multiple master font is stored in the 
%     file \texttt{MinionMM.pfb}, and the stub file is called 
%     \texttt{zmnl8ac6.pro}. The |\specifypsfont| command for this is
%     \begin{quote}
%       |\specifypsfont{zmnl8ac6}{%|\\
%       |   \download{MinionMM.pfb}\download{zmnl8ac6.pro}%|\\
%       |}|
%     \end{quote}
%   \item Fonts which do not fit any of the general naming schemes.
% \end{itemize}
% 
% 
% \begin{macro}{\AssumeLWFN}
%   This command makes \mbox{MacOS} \texttt{LWFN} style abbreviated 
%   Postscript font names the default for fonts that have no 
%   |\psf-| entry.
%    \begin{macrocode}
\def\AssumeLWFN{\let\get_PS_font_file\LWFN_get_PS_font_file}
%    \end{macrocode}
% \end{macro}
% 
% 
% 
% \subsection{Deducing values for the map file entries}
% 
% 
% \subsubsection{Basic principles}
% 
% The automatic generation of map file fragments mainly consists of 
% determining various text strings and writing these to a file as the 
% format of the map file being written requires. The complicated part is 
% usually to determine what these text strings should be, since the only 
% restriction imposed by the output format often is that the strings 
% should be written in the right order and with separating whitespace.
% 
% It is furthermore the case that some of these text strings seem to be 
% hard to deduce from the information primarily given in the command to 
% write the entry, but somewhat easier to deduce from some other deduced 
% text string. 
% 
% Therefore the following model seems appropriate. For each text string 
% that may need to be deduced, there is one macro which is used to store 
% the string (if it has been deduced) and one macro which can be called 
% to set the former macro to an appropriate value. Thus there is one 
% macro |\PS_font_name| which stores the postscript name for the font 
% currently in question and one macro 
% \describecsfamily{get_\meta{string name}}|\get_PS_font_name| which 
% determines the proper value for |\PS_font_name|. There is also a macro 
% \DescribeMacro{\unknown_str}|\unknown_str| to which all the 
% string storing macros should initially be |\let|, so that it can be 
% easily tested whether a string storing macro has been given its proper 
% value or not.
% 
% Typically, if |\PS_font_name| is used somewhere, one would first have 
% a piece of code that says
% \begin{quote}
%   \small
%   |\ifx\PS_font_name\unknown_str|\\
%   |   \get_PS_font_name|\\
%   |\fi|
% \end{quote}
% to ensure that it is known when it is used.
% 
% \begin{macro}{\unknown_str}
%   A suitable value for this macro seems to be |?????|.
%    \begin{macrocode}
\def\unknown_str{?????}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\clueless_str}
%   To further support this model, there is also a macro |\clueless_str| 
%   which a string storing macro should be |\let| equal to if its proper 
%   value could not be determined. This distinction is useful for the 
%   |\get_|\textellipsis\ macros, since if |\get_|$A$ can determine the 
%   correct value of $A$ from $B$, but also from $C$, then it helps if 
%   |\get_|$A$ can easily check whether it has previously turned out to 
%   be impossible to determine the value of $B$, because then it can 
%   simply deduce $A$ from $C$ instead.
%   
%    \begin{macrocode}
\edef\clueless_str{\unknown_str ?}
%    \end{macrocode}
% \end{macro}
% 
% An example of how |\clueless_str| should be used is the following 
% skeleton of a |\get_|$A$ macro:
% \begin{quote}\small
%   |\def\get_|$A$|{|\\
%   |   \ifx\unknown_str\|$B$| \get_|$B$| \fi|\\
%   |   \ifx\clueless_str\|$B$\\
%   |      \ifx\unknown_str\|$C$| \get_|$C$| \fi|\\
%   |      \ifx\clueless_str\|$C$\\
%   |         \let\|$A$|\clueless_str|\\
%   |      \else|\\
%   |         |\meta{Deduce $A$ from $C$}\\
%   |      \fi|\\
%   |   \else|\\
%   |      |\meta{Deduce $A$ from $B$}\\
%   |   \fi|\\
%   |}|
% \end{quote}
% 
% 
% \subsubsection{Implementation}
% 
% \begin{macro}{\TeX_font_name}
%   This is the name (as appearing in a DVI or VF file) of the font for 
%   which an entry should be made. It is set by |\makemapentry|, so no 
%   |\get_|\textellipsis\ macro is needed.
%    \begin{macrocode}
\let\TeX_font_name\unknown_str
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\source_font_TeX_name}
%   This is the name (as AFM or PL) of the font whose metrics were 
%   used by \package{fontinst}. It is set by |\fromafm| or |\frompl|, 
%   so no |\get_|\textellipsis\ macro is needed.
%    \begin{macrocode}
\let\source_font_TeX_name\unknown_str
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\PS_font_name}
%   This is the name (as FontName entry in an AFM or correspondingly) of 
%   the font in question.
%    \begin{macrocode}
\let\PS_font_name\unknown_str
%    \end{macrocode}
%   \begin{macro}{\get_PS_font_name}
%     I expect this to become one of the central macros in the map file 
%     generation (at least when entries are generated for postscript 
%     fonts), but for the moment it does the closest thing to nothing a 
%     |\get_|\textellipsis\ macro is allowed to do; it admits it hasn't 
%     got a clue about what the proper value is. 
%    \begin{macrocode}
\def\get_PS_font_name{\let\PS_font_name\clueless_str}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% \begin{macro}{\AssumeAMSBSYY}
% \begin{macro}{\AssumeBaKoMa}
%   These commands redefine |\get_PS_font_name| so that it returns the 
%   PS name this font would have if it was part of the AMS\slash 
%   Blue~Sky\slash Y\&Y and BaKoMa respectively distribution of the 
%   Computer Modern fonts---the \TeX\ font name in all upper case and 
%   all lower case respectively.
%    \begin{macrocode}
\def\AssumeAMSBSYY{\def\get_PS_font_name{
   \uppercase \expandafter{ \expandafter\def 
      \expandafter\PS_font_name \expandafter{ \source_font_TeX_name}
   }
}}
%    \end{macrocode}
%    \begin{macrocode}
\def\AssumeBaKoMa{\def\get_PS_font_name{
   \lowercase \expandafter{ \expandafter\def 
      \expandafter\PS_font_name \expandafter{ \source_font_TeX_name}
   }
}}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% 
% \begin{macro}{\PS_font_file}
%   This is the name of the file (suffix included) in which the PS font 
%   is expected to be found.
%    \begin{macrocode}
\let\PS_font_file\unknown_str
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\get_PS_font_file}
% \begin{macro}{\normal_get_PS_font_file}
% \begin{fistring}{PSfontsuffix}
%   The macro |\normal_get_PS_font_file| is (hardly surprisingly) the 
%   normal |\get_PS_font_file|. It simply uses |\source_font_TeX_name| 
%   plus the suffix specified by the |PSfontsuffix| string.
%    \begin{macrocode}
\resetstr{PSfontsuffix}{.pfa}
\def\normal_get_PS_font_file{
   \edef\PS_font_file{\source_font_TeX_name\str{PSfontsuffix}}
}
\let\get_PS_font_file=\normal_get_PS_font_file
%    \end{macrocode}
% \end{fistring}\end{macro}\end{macro}
% 
% \begin{macro}{\LWFN_get_PS_font_file}
% \begin{macro}{\abbreviate_PS_font_name}
%   In MacOS, Postscript fonts file names are usually abbreviated forms of 
%   the Postscript font names, formed using the so called 
%   \(5+3+3+\cdots\) rule---keep the first five letters of the first 
%   subword, keep the first three letters of all following subwords. The 
%   |\LWFN_get_PS_font_file| macro uses this scheme if the Postscript 
%   name for the font is known, otherwise it calls the 
%   |\normal_get_PS_font_file|. The LWFN in the macro name is the type 
%   code for such files.
%   
%   The algorithm is based on using |\aftergroup| to construct the 
%   wanted |\def| statement, only |\aftergroup|ing the letters that are 
%   not to be removed in the abbreviation. |\a_count| is used as a 
%   counter of how many more letters in the current subword should be 
%   kept.
%    \begin{macrocode}
\def\LWFN_get_PS_font_file{
   \ifx \PS_font_name\unknown_str \get_PS_font_name \fi
   \ifx \PS_font_name\clueless_str
      \normal_get_PS_font_file
      \includewarning\warn_uncertain_data
   \else
      \begingroup
         \aftergroup\def \aftergroup\PS_font_file
         \aftergroup{
         \a_count=4~
         \expandafter\expandafter \expandafter\aftergroup
            \expandafter\swap_two \expandafter\abbreviate_PS_font_name 
            \PS_font_name \x_relax
         \aftergroup}
      \endgroup
   \fi
}
%    \end{macrocode}
%    \begin{macrocode}
\def\abbreviate_PS_font_name#1{
   \ifx \x_relax#1 \else
      \ifnum \uccode`#1=`#1
         \a_count=2
         \aftergroup#1
      \else\ifx -#1
         \a_count=\z@
      \else\ifnum \a_count>\z@
         \advance \a_count \m@ne
         \aftergroup#1
      \fi\fi\fi
      \expandafter\abbreviate_PS_font_name
   \fi
}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% 
% 
% \subsection{Driver makers}
% 
% This subsection contains the definitions of macros that makes up the 
% driver makers.
% 
% 
% \subsubsection{The \texttt{debug} driver}
% 
% The \texttt{debug} driver maker doesn't really generate entries for 
% any DVI driver map file, it just prints the data that was available. 
% It is mainly intended for debugging purposes, but it might also serve 
% as a basic model for other driver makers.
% 
% \begin{macro}{\make_debug}
%    \begin{macrocode}
\def\make_debug{
   \pout_line\output_debug{Driver~data~for~font~\TeX_font_name:}
   \pout_lline\output_debug{Source~font~TeX~name:~\source_font_TeX_name}
   \ifx \reencode_etx\empty_command \else
      \pout_lline\output_debug{Font~reencoded~using~\reencode_etx.etx.}
   \fi
   \ifdim \xscale_factor=\p@ \else
      \pout_lline\output_debug{Font~x-scaled~by~
         \expandafter\lose_measure\the\xscale_factor.
      }
   \fi
   \ifdim \slant_factor=\z@ \else
      \pout_lline\output_debug{Font~slanted~by~
         \expandafter\lose_measure\the\slant_factor.
      }
   \fi
   \debug_values_hook
}
%    \end{macrocode}
% \end{macro}
% 
% 
% \begin{macro}{\debug_value}
%   The |\debug_value| macro can be used to print the name and contents 
%   of an arbitrary value macro in the |debug| driver. It is called with 
%   the value macro as argument, e.g.
%   \begin{quote}
%      |\debug_value\PS_font_name|
%   \end{quote}
%   
%    \begin{macrocode}
\def\debug_value#1{
   \ifx #1\unknown_str
      \csname get_ \expandafter\gobble_one \string#1 \endcsname
   \fi
   \pout_lline\output_debug{\string#1:~#1}
   \ifx #1\clueless_str \includewarning\warn_undecided_data \fi
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\debugvalue}
% \begin{macro}{\debug_values_hook}
%   The |\debugvalue| command is a user level interface for adding 
%   value macros to the list of those that are displayed by the 
%   \texttt{debug} driver. The argument is the name of the value in 
%   question, e.g.
%   \begin{quote}
%      |\debugvalue{PS_font_name}|
%   \end{quote}
%   Note that the name given to |\debugvalue| is not the control 
%   sequence in which the name is stored.
%    \begin{macrocode}
\def\debugvalue#1{
   \expandafter\add_to \expandafter\debug_values_hook
   \expandafter{ \expandafter\debug_value \csname#1\endcsname}
}
%    \end{macrocode}
%    \begin{macrocode}
\let\debug_values_hook\empty_command
\debugvalue{PS_font_name}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% 
% \subsubsection{The \texttt{dvips} driver}
% 
% \changes{1.912}{2000/02/19}{\texttt{dvips} mapfile fragments writer 
%    added. (LH)}
% Before constructing an entry for a \package{dvips} mapfile, it should 
% be sorted out how such an entry should look. The \package{dvips} 
% manual says
% \begin{quotation}
%   The parsing of the \texttt{psfonts.map} file should be explained to 
%   eliminate all confusion.  If a line is empty or begins with a space, 
%   asterisk, semicolon, or hash mark, it is ignored.  Each remaining 
%   line is separated into words, where words are separated by spaces or 
%   tabs.  If a word begins with a double quote, it extends until the 
%   next double quote or the end of the line.  If a word starts with a 
%   less than character, it is treated as a font header file (or a 
%   downloaded PostScript font).  There can be more than one such header 
%   for a given font.  If a word starts with a double quote, it is a 
%   special instruction for generating that font.  Otherwise it is a 
%   name.  The first such name is always the name \TeX\ uses for the 
%   font and is also the name of the raw \texttt{tfm} file.  If there is 
%   another name word, that name is used as the PostScript name; if 
%   there is only one name word, it is used for both the \TeX\ name and 
%   the PostScript name.
% \end{quotation}
% 
% A \package{fontinst}-generated map file entry for the \texttt{dvips} 
% driver has the following structure:
% \begin{isyntax}
%   \meta{\TeX{} font name} \meta{PS font name} \meta{downloads}
%     \meta{font transformations}
% \end{isyntax}
% \meta{\TeX{} font name} is simply the value of |\TeX_font_name| and 
% \meta{PS font name} is simply the value of |\PS_font_name|. 
% \meta{downloads} is a possibly empty sequence in which each item 
% has the form
% \begin{quote}
%   \meta{prefix}\meta{filename}
% \end{quote}
% The \meta{prefix} values I've came across are empty,\footnote{I think 
% this is only used for files that \package{dvips} should ignore, but 
% which certain other programs that read the same \texttt{psfonts.map} 
% need.} |<|, |<<|, and |<[|. Currently |<| is always used. 
% \meta{filename} is a filename with suffix. \meta{font transformations} 
% is either empty or has the form
% \begin{quote}
%   |"| \meta{Postscript code} |"|
% \end{quote}
% 
% Should support for the |<<| or |<[| prefixes be needed, then this 
% should be done by adding some new variant of the |\download| 
% command---|\fullldownload|, maybe---rather than adding the extra 
% character to the \meta{filename}. To simplify matters for other drivers, 
% such new variants should by default expand to |\download|, rather than 
% |\gobble_one|.
% 
% 
% \begin{macro}{\downloads_list}
% \begin{macro}{\append_download}
%   The |\downloads_list| is a token list register which is especially 
%   used for accumulating |\download| commands. Each driver maker which 
%   uses it should begin by emptying it.
%   \begin{quote}
%     |\append_download|\marg{arg}
%   \end{quote}
%   appends
%   \begin{quote}
%     |\download|\marg{arg}
%   \end{quote}
%   to |\downloads_list|.
%    \begin{macrocode}
\newtoks\downloads_list
\def\append_download#1{
   \downloads_list=\expandafter{ \the\downloads_list \download{#1} }
}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% 
% \begin{macro}{\make_dvips}
%   This macro gathers the information for a \texttt{dvips} driver entry 
%   and writes it to the corresponding output file. As a \texttt{dvips} 
%   mapfile entry is on one line, the entire entry is written at once. 
%   The \meta{font transformations} is collected as explicit text in the 
%   macro |\postscript_code|. The \meta{downloads} is collected as a 
%   sequence of |\download| commands in the |\downloads_list| token 
%   register.
%    \begin{macrocode}
\def\make_dvips{
   \downloads_list={}
   \let\postscript_code\empty_command
   \let\download\append_download
   \ifx \reencode_etx\empty_command \else
      \if_undefined{pse-\reencode_etx}\then
         \etxtoenc{\reencode_etx}{\reencode_etx}
      \fi
      \expandafter\expandafter \expandafter\second_of_two
         \csname pse-\reencode_etx\endcsname
      \edef\postscript_code{\postscript_code\space
         \expandafter\expandafter \expandafter\first_of_two
            \csname pse-\reencode_etx\endcsname
         \space ReEncodeFont
      }
   \fi
   \ifdim \xscale_factor=\p@ \else
      \edef\postscript_code{\postscript_code
         \space\expandafter\lose_measure\the\xscale_factor
         \space ExtendFont
      }
   \fi
   \ifdim \slant_factor=\z@ \else
      \edef\postscript_code{\postscript_code
         \space\expandafter\lose_measure\the\slant_factor
         \space SlantFont
      }
   \fi
%    \end{macrocode}
%   After constructing the \meta{Postscript code} and having appended 
%   the necessary download (if any) for that code, the next problem is 
%   to determine the actual \meta{PS font name} and append the downloads 
%   needed to actually define the font to the Postscript interpreter. If 
%   there is no special entry for this font in the |\psf-|\meta{PS font 
%   name} table, or if its \meta{PS font name} is unknown, then it is 
%   assumed that exactly one file should be downloaded. As the name of 
%   that file is taken the value of |\PS_font_file|.
%    \begin{macrocode}
   \ifx \PS_font_name\unknown_str \get_PS_font_name \fi
   \ifx \PS_font_name\clueless_str
      \includewarning\warn_undecided_data
      \_a_true
   \else
      \if_undefined{psf-\PS_font_name}\then
         \_a_true
      \else
         \csname psf-\PS_font_name \endcsname
         \_a_false
   \fi\fi
   \if_a_
      \ifx \PS_font_file\unknown_str \get_PS_font_file \fi
      \append_download{\PS_font_file}
      \ifx \PS_font_file\clueless_str
         \includewarning\warn_undecided_data
      \fi
   \fi
%    \end{macrocode}
%   Finally, the entire entry is written to the file. The point with 
%   expanding past an empty command is that \TeX\ in a |\write| normally 
%   jumps past the expansion of a |\the|\meta{token list register} 
%   without expanding it further, but this effect can be prevented by 
%   expanding the |\the| with an |\expandafter|.
%    \begin{macrocode}
   \def\download##1{~<##1}
   \pout_line\output_dvips{
      \TeX_font_name\space\PS_font_name
      \expandafter\empty_command \the\downloads_list
      \ifx \postscript_code\empty_command \else
         \space"\postscript_code\space"
      \fi
   }
}
%    \end{macrocode}
% \end{macro}
% 
% 
% 
% \subsubsection{The \texttt{dvipdfm} driver}
% 
% \changes{1.912}{2000/02/22}{\texttt{dvipdfm} mapfile fragments writer 
%    added. (LH)}
% 
% A mapfile entry for the \texttt{dvipdfm} driver has the following 
% structure:
% \begin{isyntax}
%   \meta{\TeX{} font name} \meta{encoding} \meta{PS font}
%     \meta{options}
% \end{isyntax}
% \meta{\TeX{} font name} is simply the value of |\TeX_font_name|. 
% \meta{encoding} is the name of the encoding file which should be used 
% to reencode the font, or \texttt{default} if there is none. \meta{PS 
% font} is the value of |\PS_font_name| for the standard 35 fonts 
% (i.e., fonts which will not be included in the PDF generated), but for 
% other fonts it is the name of the file which contains the 
% font.\footnote{The documentation seems to say that \texttt{dvipdfm} 
% can only understand fonts in PFB format; I have chosen to ignore this 
% potential problem.} \meta{options}, finally, is a possibly empty 
% sequence of space-separated options. Each option is one of the 
% following
% \begin{quote}
%   |-e |\meta{number}\\
%   |-s |\meta{number}\\
%   |-r|
% \end{quote}
% The |-e| and |-s| options extend and slant by the given amounts. The 
% |-r| option is a workaround for some Acrobat bugs; it is currently not 
% generated by \package{fontinst}.
% 
% \begin{macro}{\make_dvipdfm}
%   This macro gathers the information for a \texttt{dvipdfm} driver entry 
%   and writes it to the corresponding output file. As a \texttt{dvipdfm} 
%   mapfile entry is on one line, the entire entry is written at once. 
%   The \meta{options} text is collected as explicit text in the 
%   macro |\options_text|. The \meta{downloads} is collected as a 
%   sequence of |\download| commands in the |\downloads_list| token 
%   register.
%    \begin{macrocode}
\def\make_dvipdfm{
   \def\font_encoding{default}
   \ifx \reencode_etx\empty_command \else
      \if_undefined{pse-\reencode_etx}\then
         \etxtoenc{\reencode_etx}{\reencode_etx}
      \fi
      \def\download##1{\def\font_encoding{##1}}
      \expandafter\expandafter \expandafter\second_of_two
         \csname pse-\reencode_etx\endcsname
   \fi
   \let\options_text\empty_command
   \ifdim \xscale_factor=\p@ \else
      \edef\options_text{\options_text\space 
         -e~\expandafter\lose_measure\the\xscale_factor
      }
   \fi
   \ifdim \slant_factor=\z@ \else
      \edef\options_text{\options_text\space 
         -s~\expandafter\lose_measure\the\slant_factor
      }
   \fi
%    \end{macrocode}
%   After constructing the \meta{options} and having determined 
%   \meta{encoding}, the next problem is to determine the actual 
%   \meta{PS font}, which will be put in |\a_macro|. If there is no 
%   special entry for this font in the |\psf-|\meta{PS font name} table, 
%   or if its \meta{PS font name} is unknown, then it is assumed that 
%   exactly one file should be downloaded. As the name of that file is 
%   taken the value of |\PS_font_file|.
%    \begin{macrocode}
   \ifx \PS_font_name\unknown_str \get_PS_font_name \fi
   \if_or \if_equal\PS_font_name\clueless_str \or_else
      \if_undefined{psf-\PS_font_name}
   \then
      \ifx \PS_font_file\unknown_str \get_PS_font_file \fi
      \ifx \PS_font_file\clueless_str
         \includewarning\warn_undecided_data
      \fi
      \let\a_macro=\PS_font_file
   \else
      \let\a_macro=\PS_font_name
      \def\download##1{\def\a_macro{##1}}
      \csname psf-\PS_font_name \endcsname
   \fi
%    \end{macrocode}
%   Finally, the entire entry is written to the file.
%    \begin{macrocode}
   \pout_line\output_dvipdfm{
      \TeX_font_name\space\font_encoding\space\a_macro
      \options_text
   }
}
%    \end{macrocode}
% \end{macro}
% 
% 
% \subsubsection{The \texttt{pltotf} ``driver''}
% \changes{1.915}{2000/06/27}{\texttt{pltotf} ``driver'' support 
%    added. (LH)}
% 
% It can sometimes be hard to determine which of all the PL files that 
% \package{fontinst} creates need to be converted to TFM files. In most 
% cases no \texttt{8a}-encoded PLs need to be converted as they aren't 
% used as base fonts or installed in an FD file, but to automatically 
% exclude them isn't a trivial task (even though it probably could be 
% done by a regular expression filter for fonts named according to the 
% \texttt{fontname} scheme). There furthermore seems to be some systems 
% on which it for various reasons isn't easy to convert all PLs in a 
% directory. The \texttt{pltotf} ``driver'' support is meant to help with 
% both these problems, as the ``map file'' it creates really is a shell 
% script (batch file) for converting precisely those PL files that need 
% a map file entry to TFM format. I believe the shell script will work 
% both for UNIX and DOS systems.
% 
% \begin{macro}{\make_pltotf}
% \begin{fistring}{TFMfileprefix}
%   |\make_pltotf| writes a \package{PLtoTF} command for converting the 
%   current font's PL file to a TFM file. If set, the string 
%   \texttt{TFMfileprefix} will be prepended to the TFM file name---this 
%   could be used for putting the TFMs in some directory other than the 
%   current.
%    \begin{macrocode}
\def\make_pltotf{
   \pout_line\output_pltotf{pltotf~\TeX_font_name.pl~
      \ifisstr{TFMfileprefix}\then \str{TFMfileprefix}\fi
      \TeX_font_name.tfm
   }
}
%    \end{macrocode}
% \end{fistring}\end{macro}
% 
% 
%    \begin{macrocode}
%</map>
%    \end{macrocode}
% \Finale
\endinput