Debian Codegraph @

texmf-dist/source/fontinst/base/fimapgen.dtx

raw
1 % \CheckSum{916}
2 % \iffalse meta-comment
3 %
4 % Copyright 1999 the fontinst maintenance team and any individual
5 % authors listed elsewhere in this file. All rights reserved.
6 %
7 % This file is part of the fontinst system version 1.9.
8 % -----------------------------------------------------
9 %
10 % It may be distributed under the terms of the LaTeX Project Public
11 % License, as described in lppl.txt in the base LaTeX distribution.
12 % Either version 1.0 or, at your option, any later version.
13 %
14 %%% From file: fimapgen.dtx
15 %
16 %<*driver>
17 \documentclass{ltxdoc}
18 \usepackage{fisource}
19
20 \title{\texttt{fimapgen.dtx}}
21 \author{Lars Hellstr\"om}
22 \begin{document}
23 \maketitle
24
25 \DocInput{fimapgen.dtx}
26
27 \end{document}
28 %</driver>
29 % \fi
30 %
31 %
32 % \section{Generating map file fragments}
33 % \label{Sec:Mapfiles}
34 % \changes{1.904}{1999/06/15}{Completed rudimentary map file fragment
35 % generator, made it part of \texttt{finstmsc.sty}. (LH)}
36 % \newcommand\OzTeX{O\kern-.03em z\kern-.15em\TeX}
37 %
38 % A \emph{map file} is a file which is used by some DVI driver to link
39 % various kinds of font information to each other, as is needed for the
40 % driver's operation. Examples of such files are the file
41 % \texttt{psfonts.map} used by \texttt{dvips} and the config files of
42 % \OzTeX. There are however many other such files around in the \TeX\
43 % world.
44 %
45 % Not all of a map file need to be related to linking specific kinds of
46 % font information to each other. \OzTeX\ config files can for example
47 % be used to set the values of \TeX\ implementation parameters\footnote
48 % {The kind of things that were Pascal constants in the original \Web\
49 % sources for \TeX.} and there need not be any font-related information
50 % at all in them. The important thing is however that there can be map
51 % information in them---that information could be automatically written
52 % by the routines described here.
53 %
54 % Since there may be other kinds of information in these files (and often
55 % enough need to be for everthing to work right), the routines described
56 % here will only generate map file \emph{fragments}. These fragments
57 % will then have to be inserted in the final map files somehow, usually
58 % through manual editing. The purpose of the routines described here is
59 % only to save the user a good deal of (often quite boring) typing, not
60 % to actually install everything where it needs to be.
61 %
62 % \StopEventually{}
63 %
64 % \begin{macro}{\mapfrags_subsystem}
65 % This macro holds the name of the automatic map file fragments
66 % writer subsystem of \package{fontinst}, as it appears in error
67 % messages.
68 % \begin{macrocode}
69 \def\mapfrags_subsystem{Map~fragments~writer}
70 % \end{macrocode}
71 % \end{macro}
72 %
73 % \subsection{Interface to main \package{fontinst}}
74 % \label{Ssec:interface}
75 %
76 % The automatic generation of map file fragments is based on the two
77 % commands |\storemapdata| and |\makemapentry|. Their respective
78 % syntaxes are
79 % \begin{quote}
80 % |\storemapdata|\marg{\TeX\ font name}\marg{source}^^A
81 % \marg{transforms}\\
82 % |\makemapentry|\marg{\TeX\ font name}
83 % \end{quote}
84 %
85 % \DescribeMacro{\storemapdata}|\storemapdata| commands are written when
86 % a metric file \meta{\TeX\ font name}|.mtx| is generated. The purpose
87 % of these commands is to record where the data for that file came from,
88 % and what was done to these data. The source of the data is specified
89 % in the \meta{source} argument, which can contain one of
90 % \begin{quote}
91 % |\fromafm|\marg{AFM name}\marg{PS name}\\
92 % |\frompl|\marg{PL name}\\
93 % |\frommtx|\marg{MTX name}\\
94 % |\fromvpl|
95 % \end{quote}
96 % The only real difference between |\fromafm| and |\frompl| at this
97 % stage is that the former specifies the PS name of the font, but the
98 % latter does not. If you write a |\store|\-|map|\-|data| command yourself
99 % and want to supply the PS name then you should use |\fromafm| even if
100 % you took the font metrics from a PL.
101 % There is an important difference between |\fromvpl| and the first three
102 % in that virtual fonts need no map file entry (and hence there should
103 % not be any either). Besides some error checking, |\fromvpl| causes a
104 % |\makemapentry| to do essentially nothing.
105 %
106 % What was done to the data is specified by the \meta{transforms}
107 % argument, which is a possibly empty sequence of commands, in which
108 % each item is one of
109 % \begin{isyntax}
110 % |\transformfont|\marg{x-scale}\marg{slant-scale}\\
111 % |\reencodefont|\marg{etx}\\
112 % |\reglyphfont|
113 % \end{isyntax}
114 % The order is interpreted so that the thing done first appear first in
115 % the sequence. In normal cases there is at most one of each, and then
116 % the order is not important. \meta{x-scale}, \meta{slant-scale}, and
117 % \meta{y-scale} are the values of these variables used for the
118 % transformation, as \TeX\ numbers. \meta{etx} is the name of the ETX
119 % file used for the font reencoding.
120 % |\reglyphfont| is an error marker. It will not be encountered (but
121 % it may well get stored in some table) unless a metric font transform
122 % is applied to a font that has been reglyphed, which is illegal.
123 %
124 % \changes{1.911}{1999/11/17}{\cs{storemapdata} commands are also
125 % written to metric files when they are generated. (LH)}
126 % In addition to being written to a transforms record file (if one is
127 % open), |\storemapdata| commands are also written to the actual metric
128 % file. This makes it possible to find out where the data for a file
129 % comes from even if the file was made on a previous \package{fontinst}
130 % run, but since it requires reading an additional file just to find one
131 % command, it will be slower than if the |\storemapdata| appeared in a
132 % transforms records file.
133 %
134 % \DescribeMacro{\makemapentry}|\makemapentry| commands are written when
135 % a VPL that uses or a ligfull PL for a font is generated. These
136 % commands are the ones which actually cause the map file fragment
137 % generator to write an entry, but entries are only written if they
138 % haven't been written before. |\makemapentry| uses information that
139 % was stored by a previous call to |\storemapdata|.
140 %
141 % |\storemapdata| stores its arguments in one of the control sequences
142 % \describecsfamily{Tf-\meta{font}}|\Tf-|\meta{font}, where \meta{font}
143 % is the same thing as \meta{\TeX\ font name} above. |Tf| stands for
144 % ``\TeX\ font''. The control sequences in this family are paramterless
145 % macros whose replacement texts have the following form:
146 % \changes{1.914}{2000/05/30}{Contents of \cs{Tf-\meta{font}} control
147 % sequences changed to allow processing the same file of recorded
148 % transformations several times on the same run. (LH)}
149 % \begin{quote}
150 % \marg{made}\marg{source}\marg{transforms}
151 % \end{quote}
152 % Here \meta{source} and \meta{transforms} are exactly as above.
153 % \meta{made} is a number which describes the current status of this font.
154 % If \meta{made} is even then the font has been defined but no entry for
155 % it has subsequently been written to the map file, whereas if it is odd
156 % then an entry for it has been written to the map file. If the value of
157 % \meta{made} is less than |\process_generation| then the data in the
158 % other two arguments is from a previous run and should be ignored.
159 % The |\Tf-|\meta{font} control sequences should always be set globally.
160 %
161 % \begin{macro}{\process_generation}
162 % \begin{macro}{\process_generation_succ}
163 % |\process_generation| is a counter which stores the number of the
164 % current ``entry generation''. It starts at 0 and is increased by
165 % two at each |\donedrivers|. |\process_generation_succ| is a macro
166 % which expands to a number one larger than that in |\process_generation|.
167 % \multchanges{\cs{process_generation}\cs{process_generation_succ}}
168 % {1.914}{2000/05/30}{Control sequences added. (LH)}
169 % \begin{macrocode}
170 %<*map>
171 \newcount\process_generation
172 \process_generation=0
173 \def\process_generation_succ{1}
174 %</map>
175 % \end{macrocode}
176 % \end{macro}\end{macro}
177 %
178 % \begin{macro}{\recordtransforms}
179 % \begin{macro}{\endrecordtransforms}
180 % \begin{macro}{\transform_record_file}
181 % In main \package{fontinst}, the command
182 % \begin{quote}
183 % |\recordtransforms|\marg{filename}
184 % \end{quote}
185 % starts a block of code within which font transforms will be recorded
186 % in the file \meta{filename}. |\endrecordtransforms| ends such a block.
187 % \begin{macrocode}
188 %<*pkg>
189 \def\recordtransforms#1{\open_pout\transform_record_file{#1}}
190 \def\endrecordtransforms{
191 \close_pout\transform_record_file{Font~transformation~records}
192 }
193 \chardef\transform_record_file=\closed_stream
194 %</pkg>
195 % \end{macrocode}
196 % \end{macro} \end{macro} \end{macro}
197 %
198 %
199 % \begin{macro}{\extract_font_generation}
200 % The |\extract_font_generation| macro takes the name of a font and
201 % returns the \meta{made} component from the |\Tf-|\meta{font} macro
202 % for that font, or minus one if that macro hasn't been defined.
203 % \changes{1.914}{2000/05/30}{Macro added. (LH)}
204 % \begin{macrocode}
205 %<*map>
206 \def\extract_font_generation#1{
207 \if_defined{Tf-#1}\then
208 \expandafter\expandafter \expandafter\first_of_three
209 \csname Tf-#1\endcsname
210 \else
211 \m@ne
212 \fi
213 }
214 % \end{macrocode}
215 % \end{macro}
216 %
217 % \begin{macro}{\storemapdata}
218 % There should not be two |\storemapdata| for the same font, hence
219 % the check below. (Note that a `font' in this case is an MTX file.
220 % It is quite possible (and legal) to generate the PL file for that
221 % MTX file more than once.)
222 % \changes{1.927}{2004/07/12}{Improved wording of warning message
223 % and downgraded it to an info in the case when the two
224 % definitions are the same. (LH)}
225 % \begin{macrocode}
226 \def\storemapdata#1#2#3{
227 \expandafter\def \expandafter\a_macro
228 \expandafter{ \expandafter{ \the\process_generation}{#2}{#3}}
229 \ifnum \extract_font_generation{#1}<\process_generation \else
230 \x_cs\ifx{Tf-#1}\a_macro
231 \fontinstinfo\mapfrags_subsystem
232 {Repeated~definition~of~font~#1}
233 \else
234 \fontinstwarning\mapfrags_subsystem
235 {Inconsistent~redefinition~of~font~#1}
236 \fi
237 \fi
238 \x_cs\let{Tf-#1}=\a_macro
239 }
240 %</map>
241 % \end{macrocode}
242 % In main \package{fontinst}, |\storemapdata| should be a noop so
243 % that it can appear in metric files.
244 % \begin{macrocode}
245 %<pkg>\let\storemapdata=\gobble_three
246 % \end{macrocode}
247 % \end{macro}
248 %
249 % \begin{macro}{\record_transform}
250 % \changes{1.911}{1999/11/18}{\cs{storemapdata} lines are optionally
251 % written to the main output file as well. (LH)}
252 % In main \package{fontinst}, the call
253 % \begin{quote}
254 % |\record_transform|\marg{TFM name}\marg{source}^^A
255 % \marg{transforms}\marg{if}
256 % \end{quote}
257 % writes
258 % \begin{quote}
259 % |\storemapdata|\marg{TFM name}\marg{source}\marg{transforms}
260 % \end{quote}
261 % to the transformation recordings file (if font transforms are being
262 % recorded) and to the main output file (if the \meta{if} evaluates
263 % to true). Note that the caller of |\record_transform| must see to
264 % that macros in \meta{source} and \meta{transforms} are written
265 % correctly to the file (this is usually accomplished by adding
266 % |\string| in suitable places of these arguments during their
267 % construction).
268 %
269 % \begin{macrocode}
270 %<*pkg>
271 \def\record_transform#1#2#3#4{
272 \ifnum \transform_record_file=\closed_stream \else
273 \pout_line\transform_record_file{\string\storemapdata{#1}{#2}{#3}}
274 \fi
275 #4 \out_line{\string\storemapdata{#1}{#2}{#3}} \fi
276 }
277 %</pkg>
278 % \end{macrocode}
279 % \end{macro}
280 %
281 %
282 % \begin{macro}{\transformfont}
283 % \changes{1.913}{2000/03/11}{Third argument removed, since it isn't
284 % used anymore. This change is harmless, since the worst thing
285 % that can happen to this argument is that it is typeset. (LH)}
286 % \begin{macro}{\reencodefont}
287 % \begin{macro}{\reglyphfont}
288 % These are initially |\relax|, so they can be |\edef|ed with safely.
289 % \begin{macrocode}
290 %<*map>
291 \let\transformfont\x_relax
292 \let\reencodefont\x_relax
293 \let\reglyphfont\x_relax
294 % \end{macrocode}
295 % \end{macro}\end{macro}\end{macro}
296 %
297 %
298 % \changes{1.914}{2000/05/30}{The total transform applied for a font is
299 % determined before the entry makers are called. (LH)}
300 % \begin{macro}{\makemapentry}
301 % |\makemapentry| sets |\TeX_font_name|, checks if any map data have
302 % been stored for the font in question, and passes them on to
303 % |\make_map_entry| if they have; otherwise it raises an error. There
304 % is also a group which is begun and ended by |\makemapentry|, to stop
305 % values deduced for one entry to interfere with the deduction of values
306 % in the following.
307 % \changes{1.911}{1999/11/20}{When map data are not known, try to
308 % get them from the MTX file before declaring the source unknown.
309 % (LH)}
310 % \begin{macrocode}
311 \def\makemapentry#1{\begingroup
312 \def\TeX_font_name{#1}
313 \ifnum \extract_font_generation{#1}<\process_generation
314 \if_file_exists{#1.mtx}\then
315 \inputmtx{#1}
316 \fi\fi
317 \ifnum \extract_font_generation{#1}<\process_generation
318 \from_unknown{#1}
319 \x_cs\xdef{Tf-#1}{
320 {\process_generation_succ}{\noexpand\from_unknown{#1}}{}
321 }
322 \else
323 \expandafter\expandafter \expandafter\make_map_entry
324 \csname Tf-#1\endcsname
325 \fi
326 \endgroup
327 }
328 % \end{macrocode}
329 %
330 % \begin{macro}{\make_map_entry}
331 % |\make_map_entry| oversees the interpretation of the
332 % \meta{source} part of the map data, something which sets
333 % |\source_font_TeX_name| and possibly |\PS_font_name|. It also
334 % collects the transforms applied in |\font_transforms|,
335 % concatenates them, and calls a list macro |\entry_makers_list| which
336 % causes the actual entries to be written, and records in
337 % |\Tf-|\meta{\TeX\ font name} that the entries have been written.
338 % \begin{macrocode}
339 \def\make_map_entry#1#2#3{
340 \ifnum #1=\process_generation
341 \def\font_transforms{#3}
342 #2
343 \_a_false
344 \let\transformfont\concat_transformfont
345 \let\reencodefont\concat_reencodefont
346 \let\reglyphfont\_a_true
347 \font_transforms
348 \if_a_
349 \fontinsterror\mapfrags_subsystem{
350 \string\makemapentry\space for~reglyphed~font
351 }{ No~entry~for~font~\TeX_font_name\space
352 can~be~written,\messagebreak
353 since~it~had~been~reglyphed!~\error_help_a
354 }
355 \else
356 \entry_makers_list
357 \fi
358 \expandafter\gdef \csname Tf-\TeX_font_name \expandafter\endcsname
359 \expandafter{\expandafter{\process_generation_succ}{#2}{#3}}
360 \fi
361 }
362 %</map>
363 % \end{macrocode}
364 % \end{macro}\end{macro}
365 %
366 %
367 % \begin{macro}{\record_usage}
368 % In main \package{fontinst}, the call
369 % \begin{quote}
370 % |\record_usage|\marg{TFM name}
371 % \end{quote}
372 % writes
373 % \begin{quote}
374 % |\makemapentry|\marg{TFM name}
375 % \end{quote}
376 % to the transformation recordings file, if font transforms are being
377 % recorded. The |\record_usage| command is, roughly speaking, only used
378 % by |\installfont| and |\installrawfont|.
379 % \begin{macrocode}
380 %<*pkg>
381 \def\record_usage#1{
382 \ifnum \transform_record_file=\closed_stream \else
383 \pout_line\transform_record_file{\string\makemapentry{#1}}
384 \fi
385 }
386 %</pkg>
387 % \end{macrocode}
388 % \end{macro}
389 %
390 %
391 % \begin{macro}{\fromafm}
392 % |\fromafm| saves its two arguments in the suitable string macros.
393 % \begin{macrocode}
394 %<*map>
395 \def\fromafm#1#2{
396 \def\source_font_TeX_name{#1}
397 \def\PS_font_name{#2}
398 }
399 % \end{macrocode}
400 % \end{macro}
401 %
402 % \begin{macro}{\frompl}
403 % |\frompl| saves its argument in the suitable string macro.
404 % \begin{macrocode}
405 \def\frompl#1{
406 \def\source_font_TeX_name{#1}
407 }
408 % \end{macrocode}
409 % \end{macro}
410 %
411 % \begin{macro}{\frommtx}
412 % This one is tricky, since it will have to work recursively,
413 % fetching data that were stored for some other font. If it cannot
414 % find those data in memory, then it tries to get them from the
415 % metric file itself.
416 % \changes{1.911}{1999/11/17}{When map data are not known, try to
417 % get them from the MTX file before declaring the source unknown.
418 % (LH)}
419 % \begin{macrocode}
420 \def\frommtx#1{%
421 \ifnum \extract_font_generation{#1}<\process_generation
422 \if_file_exists{#1.mtx}\then
423 \inputmtx{#1}
424 \fi\fi
425 \ifnum \extract_font_generation{#1}<\process_generation
426 \from_unknown{#1}
427 \x_cs\xdef{Tf-#1}{
428 {\the\process_generation}{\noexpand\from_unknown{#1}}{}
429 }
430 \else
431 \expandafter\expandafter \expandafter\from_mtx
432 \csname Tf-#1\endcsname
433 \fi
434 }
435 % \end{macrocode}
436 % \begin{macro}{\from_mtx}
437 % \begin{macrocode}
438 \def\from_mtx#1#2#3{
439 \edef\font_transforms{#3\font_transforms}
440 #2
441 }
442 % \end{macrocode}
443 % \end{macro}\end{macro}
444 %
445 % \begin{macro}{\fromvpl}
446 % The |\fromvpl| command checks if |\font_transforms| is empty. If it
447 % is then everything is fine, but no entry should be written for this
448 % font. If it isn't then someone has tried to make a transformation of
449 % a virtual font, which doesn't work.
450 % \begin{macrocode}
451 \def\fromvpl{
452 \ifx \empty_command\font_transforms \else
453 \fontinsterror\mapfrags_subsystem{
454 Font~is~virtual,~it~cannot~be~transformed}{
455 No~entry~for~font~\TeX_font_name\space can~be~written.
456 \messagebreak\error_help_a
457 }
458 \fi
459 \let\maker_do\gobble_one
460 }
461 % \end{macrocode}
462 % \end{macro}
463 %
464 % \begin{macro}{\AssumeMetafont}
465 % The |\AssumeMetafont| general settings command makes |\frompl|
466 % behave like |\fromvpl|.
467 % \begin{macrocode}
468 \def\AssumeMetafont{
469 \def\frompl{
470 \ifx \empty_command\font_transforms \else
471 \fontinsterror\mapfrags_subsystem{
472 A~Metafont~cannot~be~transformed}{
473 No~entry~for~font~\TeX_font_name\space can~be~written.
474 \messagebreak\error_help_a
475 }
476 \fi
477 \let\maker_do\gobble_one
478 }
479 }
480 % \end{macrocode}
481 % \end{macro}
482 %
483 % \begin{macro}{\from_unknown}
484 % This special value for \meta{source} is used for fonts that are
485 % referenced by some |\frommtx| but which have no |\storemapdata|
486 % themselves.
487 % \begin{macrocode}
488 \def\from_unknown#1{
489 \fontinstwarningnoline\mapfrags_subsystem{
490 No~map~data~stored~for~font~#1.\messagebreak
491 No~entry~for~\TeX_font_name\space will~be~written,\messagebreak
492 due~to~insufficient~information}
493 \includewarning\warn_unknown_source
494 \let\maker_do\gobble_one
495 }
496 % \end{macrocode}
497 % \end{macro}
498 %
499 %
500 % \begin{macro}{\font_transforms}
501 % This macro is used to collect all transformations that have been
502 % applied to a font in, before they are concatenated.
503 % \begin{macrocode}
504 \let\font_transforms\empty_command
505 % \end{macrocode}
506 % \end{macro}
507 %
508 % \begin{macro}{\xscale_factor}
509 % \begin{macro}{\slant_factor}
510 % \begin{macro}{\reencode_etx}
511 % |\xscale_factor| and |\slant_factor| are dimens which the entry
512 % makers can inspect to check the amount of horizontal scaling and
513 % slanting should be applied to the current font. 1\,pt equals the
514 % factor~1.
515 % \begin{quote}
516 % |\expandafter\lose_measure\the\xscale_factor|
517 % \end{quote}
518 % will produce the corresponding factor.
519 %
520 % |\reencode_etx| is a macro which contains the name of the (last)
521 % ETX file used to reencode the font; it is empty if the font hasn't
522 % been reencoded.
523 % \multchanges{\cs{xscale_factor}\cs{slant_factor}\cs{reencode_etx}}
524 % {1.914}{2000/05/30}{Control sequences added. (LH)}
525 % \begin{macrocode}
526 \newdimen\xscale_factor \newdimen\slant_factor
527 \xscale_factor=\p@ \slant_factor=\z@
528 \let\reencode_etx\empty_command
529 % \end{macrocode}
530 % \end{macro}\end{macro}\end{macro}
531 %
532 % \multchanges{\cs{concat_transformfont}\cs{concat_reencodefont}}
533 % {1.914}{2000/05/30}{Macros added. (LH)}
534 % \begin{macro}{\concat_transformfont}
535 % The |\concat_transformfont| macro is a definition of |\transformfont|
536 % which concatenates the transformation expressed by the arguments
537 % with the one in |\xscale_factor| and |\slant_factor|.
538 % Mathematically, it performs the multiplication
539 % $$
540 % \left( \begin{array}{cc} f(\#1)& f(\#2)\\ 0& 1 \end{array} \right)
541 % \left( \begin{array}{cc}
542 % \mbox{\cs{xscale_factor}}& \mbox{\cs{slant_factor}} \\
543 % 0& 1
544 % \end{array} \right)
545 % $$
546 % where $f$ stands for |\make_factor|.
547 % \begin{macrocode}
548 \def\concat_transformfont#1#2{
549 \edef\a_macro{\make_factor{#1}}
550 \xscale_factor=\a_macro\xscale_factor
551 \slant_factor=\a_macro\slant_factor
552 \advance \slant_factor \make_factor{#2}\p@
553 }
554 % \end{macrocode}
555 % \end{macro}
556 %
557 %
558 % \begin{macro}{\concat_reencodefont}
559 % The |\concat_reencodefont| macro is a definition of |\reencodefont|
560 % which concatenates the reencoding expressed by the argument with
561 % the one in |\reencode_etx|. Since reencoding ignores the previous
562 % encoding, concatenating is the same thing as remembering the last
563 % reencoding.
564 % \begin{macrocode}
565 \def\concat_reencodefont#1{\def\reencode_etx{#1}}
566 % \end{macrocode}
567 % \end{macro}
568 %
569 %
570 % \subsection{User interface}
571 %
572 % The basic usage of the automatic map file fragment generator consists
573 % of specifying for which driver(s) entries should be generated,
574 % |\input|ing a file of recorded transformations generated by main
575 % \package{fontinst}, and signaling that there isn't anything more to
576 % write. This can be done with the commands
577 % \begin{quote}
578 % |\adddriver|\marg{driver name}\marg{fragment file name}\\
579 % \meta{possible additional \cs{adddriver} commands}\\
580 % |\input |\meta{recorded transforms file}\\
581 % |\donedrivers|\\
582 % |\bye|
583 % \end{quote}
584 % It should however be noted that this is the \emph{basic} usage. The
585 % map fragments that work for one \TeX\ system need not work for
586 % another (even if the driver is the same), and therefore it is
587 % necessary to make the whole process of writing map file fragments
588 % configurable. A few examples of things you may have to inform the map
589 % fragment writer about are (and these are for \package{dvips} alone;
590 % that's the driver I know best):
591 % \begin{itemize}
592 % \item
593 % Is the font resident on the printer or must it be downloaded?
594 % \item
595 % If the font must be downloaded, what is the name of the file it
596 % is in? Here one must take into account not only the possibility
597 % that the font file might have to be shared with some other
598 % software (such as a GUI) and thus cannot be named according to
599 % the Berry scheme---even if it is named according to the Berry
600 % scheme one still has the question of its extension: \texttt{.pfa},
601 % \texttt{.pfb}, or something else? For instances of Multiple Master
602 % fonts, you (at least sometimes) have to download more than one file.
603 % \item
604 % Again if the font must be downloaded, can/should it be partially
605 % downloaded?
606 % \item
607 % In case the font has been reencoded, what is the name of the file
608 % which defines this encoding, and by what name does that file make
609 % the encoding known to the postscript interpreter?
610 % \end{itemize}
611 % The mechanisms available for such configuration are described in
612 % Subsection~\ref{Sssec:Config-interface}.
613 % Note that map files for DVI viewers are on average more likely to need
614 % various platform-specific information about the fonts than map files
615 % for DVI printer drivers are, and hence once can expect that
616 % generation of these will need more extensive configuration than that
617 % for the printer drivers.
618 %
619 %
620 % \subsubsection{Interface for basic usage}
621 %
622 % An \emph{entry maker} is a group of macros which write the entry for
623 % the font currently under consideration to a map fragments file each
624 % time they are called. The macro to call must have a name of the form
625 % \describecsfamily{make_\meta{driver}}|\make_|\meta{driver} for
626 % |\adddriver| to recognise it. Each entry maker has a separate output
627 % file (opened using |\open_pout|) and the identifier connected to that
628 % file is called \describecsfamily{output_\meta{driver}}\relax
629 % |\output_|\meta{driver}.
630 %
631 % A list of all entry makers currently active is maintined in the macro
632 % |\entry_makers_list|. Each item in this list has the form
633 % \begin{quote}
634 % |\maker_do|\,|\make_|\meta{driver}
635 % \end{quote}
636 % |\maker_do| is usually |\relax|, but it does occationally get set to
637 % other values.
638 % \par\bigskip
639 %
640 %
641 % \begin{macro}{\adddriver}
642 % The |\adddriver| command adds the named driver to the list of
643 % drivers to write entries for and opens an output file where the
644 % entries for that particular driver will go. Repeated calls to
645 % |\adddriver| for the same driver have no effect.
646 % \begin{macrocode}
647 \def\adddriver#1#2{
648 \x_cs\ifx{make_#1}\x_relax
649 \fontinsterror\mapfrags_subsystem
650 {There~is~no~entry~maker~for~#1}\error_help_a
651 \else
652 \x_cs\ifx{output_#1}\x_relax \_a_true \else
653 \x_cs\ifx{output_#1}\closed_stream \_a_true \else
654 \_a_false
655 \fi\fi
656 \if_a_
657 \x_cs\open_pout{output_#1}{#2}
658 \expandafter\add_to \expandafter\entry_makers_list
659 \expandafter{ \expandafter\maker_do
660 \csname make_#1\endcsname}
661 \fi
662 \fi
663 }
664 % \end{macrocode}
665 % \end{macro}
666 %
667 % \begin{macro}{\entry_makers_list}
668 % \begin{macro}{\maker_do}
669 % \begin{macrocode}
670 \let\entry_makers_list\empty_command
671 \let\maker_do\x_relax
672 % \end{macrocode}
673 % \end{macro}\end{macro}
674 %
675 % \begin{macro}{\donedrivers}
676 % The main function performed by the |\donedrivers| command is to
677 % close all the open output files. It might also print some warning
678 % messages.
679 % \begin{macrocode}
680 \def\donedrivers{
681 \def\maker_do##1{
682 \x_cs\close_pout{output\expandafter\gobble_five\string##1}
683 {Map~file~fragments}
684 }
685 \entry_makers_list
686 \let\maker_do\x_relax
687 \let\entry_makers_list\empty_command
688 \errorstopmode
689 \reportwarnings
690 \advance \process_generation \thr@@
691 \edef\process_generation_succ{\the\process_generation}
692 \advance \process_generation \m@ne
693 }
694 % \end{macrocode}
695 % \end{macro}
696 %
697 % \begin{macro}{\gobble_five}
698 % \begin{macrocode}
699 \def\gobble_five#1#2#3#4#5{}
700 % \end{macrocode}
701 % \end{macro}
702 %
703 %
704 % It is appropriate that the map file writer writes a summary of the
705 % kinds of risky things which happened when it is done writing data to
706 % files. To simplify implementing such things, there is a command
707 % \DescribeMacro{\includewarning}|\includewarning| that takes care of
708 % the bookkeeping involved. After the call
709 % \begin{quote}
710 % |\includewarning|\meta{command}
711 % \end{quote}
712 % the \meta{command} will be executed exactly once the next time
713 % |\reportwarnings| is executed. The \meta{command} usually expands to
714 % something like
715 % \begin{quote}
716 % \small|\fontinstwarningnoline\mapfrags_subsystem{|\\
717 % | Check~the~output~file(s)--some~data~was~considered~uncertain}|
718 % \end{quote}
719 %
720 % \begin{macro}{\warnings_list}
721 % The |\warnings_list| macro contains a list of all warnings that
722 % should be made. It expands to a sequence of
723 % \begin{quote}
724 % |\warning_do|\meta{command}
725 % \end{quote}
726 % |\warnings_list| is always assigned globally.
727 % \begin{macrocode}
728 \g_let\warnings_list=\empty_command
729 % \end{macrocode}
730 % \end{macro}
731 %
732 % \begin{macro}{\includewarning}
733 % \begin{macro}{\warning_do}
734 % The |\includewarning| command adds an entry for its argument to the
735 % |\warnings_list| list, provided there wasn't already such an entry.
736 % |\includewarning| is based on the macro |\warning_do|, which does
737 % most of the bookkeeping for making sure the list contains at most
738 % one entry of each kind. |\warning_do| normally expects to be
739 % expanded in the context
740 % \begin{quote}
741 % |\warning_do|\meta{new command}\meta{old command}\meta{next}
742 % \end{quote}
743 % The \meta{new command} is the command that is being added to the
744 % list, and the \meta{old command} is a command that is already in the
745 % list. \meta{next} is the first token in the next item in the
746 % list---in most cases another |\warning_do|. If \meta{new command}
747 % and \meta{old command} are not equal, this should expand to
748 % \begin{quote}
749 % |\noexpand\warning_do|\,|\noexpand|\meta{old command}\,^^A
750 % \meta{next}\,\meta{new command}
751 % \end{quote}
752 % If on the other hand they are equal, this should expand to
753 % \begin{quote}
754 % |\noexpand\warning_do|\,|\noexpand|\meta{old command}\,^^A
755 % \meta{next}\,|\x_relax|
756 % \end{quote}
757 % The reason for this is that the last \meta{next} will not be a
758 % |\warning_do|, but an |\ifx| which tests whether a new item should
759 % be added to the list.
760 % \begin{macrocode}
761 \def\warning_do#1#2#3{
762 \noexpand\warning_do \noexpand#2
763 \ifx #1#2
764 \expandafter#3 \expandafter\x_relax
765 \else
766 \expandafter#3 \expandafter#1
767 \fi
768 }
769 \def\includewarning#1{
770 \xdef\warnings_list{
771 \expandafter\swap_two \expandafter#1 \warnings_list
772 \if_equal\x_relax\then \else
773 \noexpand\warning_do \noexpand#1
774 \fi
775 }
776 }
777 % \end{macrocode}
778 % \end{macro}\end{macro}
779 %
780 % \begin{macro}{\reportwarnings}
781 % The |\reportwarnings| command reports all the warnings and empties
782 % the |\warnings_list|.
783 % \begin{macrocode}
784 \def\reportwarnings{
785 \begingroup
786 \let\warning_do=\x_relax
787 \warnings_list
788 \endgroup
789 \g_let\warnings_list=\empty_command
790 }
791 % \end{macrocode}
792 % \end{macro}
793 %
794 % \begin{macro}{\warn_unknown_source}
795 % \begin{macro}{\warn_undecided_data}
796 % \begin{macro}{\warn_uncertain_data}
797 % These macros are used to output warnings at the |\reportwarnings| at
798 % the end of |\donedrivers|.
799 % \begin{macrocode}
800 \def\warn_unknown_source{
801 \fontinstwarningnoline\mapfrags_subsystem{
802 Some~font~is~missing~from~the~output~file(s),\messagebreak
803 since~its~source~is~unknown}
804 }
805 \def\warn_undecided_data{
806 \fontinstwarningnoline\mapfrags_subsystem{
807 Check~the~output~file(s)--some~data~could~not~be~determined}
808 }
809 \def\warn_uncertain_data{
810 \fontinstwarningnoline\mapfrags_subsystem{
811 Check~the~output~file(s)--some~data~was~considered~uncertain}
812 }
813 % \end{macrocode}
814 % \end{macro}\end{macro}\end{macro}
815 %
816 %
817 %
818 % \subsubsection{Configuration interface}
819 % \label{Sssec:Config-interface}
820 %
821 % To correctly format reencodings, the map file writer must know what
822 % the ETX encodings correspond to. In the case of drivers which
823 % generate postscript output, this information is stored in the
824 % \describecsfamily{pse-\meta{etx}}|\pse-|\meta{etx} family of macros.
825 % \meta{etx} is the name (suffix excluded) of the ETX file that the
826 % information pertains to. The expansion of these macros are of the form
827 % \begin{quote}
828 % \marg{postscript name}\marg{action}
829 % \end{quote}
830 % \meta{postscript name} is the name by which the encoding is known to
831 % the postscript interpreter, and \meta{action} lists any additional
832 % action that must be taken before the encoding can be used.
833 % ^^A So far the only actions known is
834 % ^^A \DescribeMacro{\download}|\download|\marg{file},
835 % ^^A which will cause code for downloading the file by the name
836 % ^^A \meta{file} (suffix included) to be inserted in the output.
837 %
838 % \begin{macro}{\declarepsencoding}
839 % Data is entered in a |\pse-|\meta{etx} macro using the
840 % |\declare|\-|ps|\-|encoding| command. Its syntax is
841 % \begin{quote}
842 % |\declarepsencoding|\marg{etx}\marg{postscript name}\marg{action}
843 % \end{quote}
844 % \begin{macrocode}
845 \def\declarepsencoding#1#2#3{\x_cs\gdef{pse-#1}{{#2}{#3}}}
846 %</map>
847 % \end{macrocode}
848 % In main \package{fontinst}, |\declarepsencoding| should be a noop so
849 % that it can appear in encoding files. It's probably a good idea to
850 % show it when typesetting as well.
851 % \changes{1.931}{2005/05/13}{Added main \package{fontinst} and
852 % \package{fontdoc} definitions. (LH)}
853 % \begin{macrocode}
854 %<pkg>\let\declarepsencoding=\gobble_three
855 %<*doc>
856 \def\declarepsencoding#1#2#3{\comment{%
857 This file corresponds to the \FD@typeset@string{#2} encoding vector.}}
858 %</doc>
859 % \end{macrocode}
860 % \end{macro}
861 %
862 % \begin{macro}{\providepsencoding}
863 % This command is basically the same as |\declarepsencoding|, but it
864 % checks whether the encoding has already been set and does nothing
865 % if that is the case. It is used for autogenerated declarations, to
866 % allow the user to override the setting.
867 % \changes{1.931}{2005/05/13}{Command added. (LH)}
868 % \begin{macrocode}
869 %<*map>
870 \def\providepsencoding#1#2#3{
871 \if_undefined{pse-#1}\then
872 \declarepsencoding{#1}{#2}{#3}
873 \fi
874 }
875 %</map>
876 %<pkg>\let\providepsencoding=\gobble_three
877 %<doc>\newcommand\providepsencoding[3]{}
878 % \end{macrocode}
879 % \end{macro}
880 %
881 % \begin{macro}{\download}
882 % By default |\download| gobbles its argument. It should be redefined
883 % when that is not the desired effect.
884 % \begin{macrocode}
885 %<*map>
886 \let\download=\gobble_one
887 % \end{macrocode}
888 % \end{macro}
889 %
890 % \begin{macro}{\fulldownload}
891 % By default this defaults to being a synonym of |\download|, to
892 % simplify matters for drivers where the distinction is not relevant.
893 % They should be redefined when that is not the desired effect.
894 % \changes{1.928}{2004/12/13}{Command added. (LH)}
895 % \begin{macrocode}
896 \def\fulldownload#1{\download{#1}}
897 % \end{macrocode}
898 % \end{macro}
899 %
900 % \begin{macro}{\encodingdownload}
901 % By default this defaults to being a synonym of |\download|, to
902 % simplify matters for drivers where the distinction is not relevant.
903 % They should be redefined when that is not the desired effect.
904 % \changes{1.931}{2005/05/04}{Command added. (LH)}
905 % \begin{macrocode}
906 \def\encodingdownload#1{\download{#1}}
907 % \end{macrocode}
908 % \end{macro}
909 %
910 % Some encodings seem to always be present, so they can be declared here.
911 % \begin{macrocode}
912 \declarepsencoding{8r}{TeXBase1Encoding}{\encodingdownload{8r.enc}}
913 \declarepsencoding{8a}{StandardEncoding}{}
914 % \end{macrocode}
915 % \package{fontinst} must be told about other postscript encodings (if you
916 % have them installed). The \texttt{finstmsc.rc} file is the right place
917 % for these declarations.\relax
918 % \SortIndex{finstmsc.rc file}{\texttt{finstmsc.rc} file}
919 %
920 % Next we have the cofiguration for fonts, which works in a similar
921 % fashion. The main problem here seems to be to determine which files (if
922 % any) should be downloaded to the printer, and this can be specified
923 % using |\download| commands as for the encodings. The family
924 % \describecsfamily{psf-\meta{PS font name}}|\psf-|\meta{PS font name}
925 % of macros expand to a sequence of \meta{actions} as for the encodings.
926 % If there is such a macro for a font then the instructions found there
927 % should be followed.
928 %
929 % It is recommended that the contents of a |\psf-|\meta{PS font name}
930 % macro is executed before the map file entry is written, and that
931 % commands like |\download| are temporarily redefined to build the text
932 % for the entry, rather than having the |\write| in |\pout_line| expand
933 % the contents of |\psf-|\meta{PS font name}.
934 %
935 % \begin{macro}{\specifypsfont}
936 % The |\specifypsfont| command is used as
937 % \begin{quote}
938 % |\specifypsfont|\marg{PS font name}\marg{actions}
939 % \end{quote}
940 % It can be used to specify the actions that should be done to make a
941 % Postscript font known to the printer, when the automatic guessing
942 % would not be right.
943 % \begin{macrocode}
944 \def\specifypsfont#1#2{\x_cs\def{psf-#1}{#2}}
945 % \end{macrocode}
946 % \end{macro}
947 %
948 % Examples of cases where |\specifypsfont| would be needed are:
949 % \begin{itemize}
950 % \item Fonts which are resident on the printer. In this case the
951 % \meta{actions} argument should be empty, e.g.
952 % \begin{quote}
953 % |\specifypsfont{Times-Roman}{}|
954 % \end{quote}
955 % \item Instances of multiple master fonts. In this case one must
956 % download both the multiple master font and the stub file that
957 % defines the instance.
958 %
959 % Subsection~10.6.1 in The \LaTeX\ graphics companion~\cite
960 % {LaTeX-graph-comp} contains an example with an instance of the
961 % \texttt{MinionMM} multiple master font. Both the \TeX\ and
962 % (what is of interest here) the PS name for this instance is
963 % \texttt{zmnl8ac6}, the base multiple master font is stored in the
964 % file \texttt{MinionMM.pfb}, and the stub file is called
965 % \texttt{zmnl8ac6.pro}. The |\specifypsfont| command for this is
966 % \begin{quote}
967 % |\specifypsfont{zmnl8ac6}{%|\\
968 % | \download{MinionMM.pfb}\download{zmnl8ac6.pro}%|\\
969 % |}|
970 % \end{quote}
971 % (It should probably be remarked that the most common method of
972 % defining a multiple master font instance is not to explicitly
973 % create it as in this example, but to simply use it as any ordinary
974 % PS font and then rely on the PS \textsf{findfont} operator to
975 % automagically create it for you. This requires using a special
976 % naming scheme for instances of multiple master fonts.)
977 % \item Fonts which do not fit any of the general naming schemes.
978 % \end{itemize}
979 %
980 %
981 % \begin{macro}{\AssumeLWFN}
982 % This command makes \mbox{MacOS} \texttt{LWFN} style abbreviated
983 % Postscript font names the default for fonts that have no
984 % |\psf-| entry.
985 % \begin{macrocode}
986 \def\AssumeLWFN{\let\get_PS_font_file\LWFN_get_PS_font_file}
987 % \end{macrocode}
988 % \end{macro}
989 %
990 %
991 %
992 % \subsection{Deducing values for the map file entries}
993 %
994 %
995 % \subsubsection{Basic principles}
996 %
997 % The automatic generation of map file fragments mainly consists of
998 % determining various text strings and writing these to a file as the
999 % format of the map file being written requires. The complicated part is
1000 % usually to determine what these text strings should be, since the only
1001 % restriction imposed by the output format often is that the strings
1002 % should be written in the right order and with separating whitespace.
1003 %
1004 % It is furthermore the case that some of these text strings seem to be
1005 % hard to deduce from the information primarily given in the command to
1006 % write the entry, but somewhat easier to deduce from some other deduced
1007 % text string.
1008 %
1009 % Therefore the following model seems appropriate. For each text string
1010 % that may need to be deduced, there is one macro which is used to store
1011 % the string (if it has been deduced) and one macro which can be called
1012 % to set the former macro to an appropriate value. Thus there is one
1013 % macro |\PS_font_name| which stores the postscript name for the font
1014 % currently in question and one macro
1015 % \describecsfamily{get_\meta{string name}}|\get_PS_font_name| which
1016 % determines the proper value for |\PS_font_name|. There is also a macro
1017 % \DescribeMacro{\unknown_str}|\unknown_str| to which all the
1018 % string storing macros should initially be |\let|, so that it can be
1019 % easily tested whether a string storing macro has been given its proper
1020 % value or not.
1021 %
1022 % Typically, if |\PS_font_name| is used somewhere, one would first have
1023 % a piece of code that says
1024 % \begin{quote}
1025 % \small
1026 % |\ifx\PS_font_name\unknown_str|\\
1027 % | \get_PS_font_name|\\
1028 % |\fi|
1029 % \end{quote}
1030 % to ensure that it is known when it is used.
1031 %
1032 % \begin{macro}{\unknown_str}
1033 % A suitable value for this macro seems to be |?????|.
1034 % \begin{macrocode}
1035 \def\unknown_str{?????}
1036 % \end{macrocode}
1037 % \end{macro}
1038 %
1039 % \begin{macro}{\clueless_str}
1040 % To further support this model, there is also a macro |\clueless_str|
1041 % which a string storing macro should be |\let| equal to if its proper
1042 % value could not be determined. This distinction is useful for the
1043 % |\get_|\textellipsis\ macros, since if |\get_|$A$ can determine the
1044 % correct value of $A$ from $B$, but also from $C$, then it helps if
1045 % |\get_|$A$ can easily check whether it has previously turned out to
1046 % be impossible to determine the value of $B$, because then it can
1047 % simply deduce $A$ from $C$ instead.
1048 %
1049 % \begin{macrocode}
1050 \edef\clueless_str{\unknown_str ?}
1051 % \end{macrocode}
1052 % \end{macro}
1053 %
1054 % An example of how |\clueless_str| should be used is the following
1055 % skeleton of a |\get_|$A$ macro:
1056 % \begin{quote}\small
1057 % |\def\get_|$A$|{|\\
1058 % | \ifx\unknown_str\|$B$| \get_|$B$| \fi|\\
1059 % | \ifx\clueless_str\|$B$\\
1060 % | \ifx\unknown_str\|$C$| \get_|$C$| \fi|\\
1061 % | \ifx\clueless_str\|$C$\\
1062 % | \let\|$A$|\clueless_str|\\
1063 % | \else|\\
1064 % | |\meta{Deduce $A$ from $C$}\\
1065 % | \fi|\\
1066 % | \else|\\
1067 % | |\meta{Deduce $A$ from $B$}\\
1068 % | \fi|\\
1069 % |}|
1070 % \end{quote}
1071 %
1072 %
1073 % \subsubsection{Implementation}
1074 %
1075 % \begin{macro}{\TeX_font_name}
1076 % This is the name (as appearing in a DVI or VF file) of the font for
1077 % which an entry should be made. It is set by |\makemapentry|, so no
1078 % |\get_|\textellipsis\ macro is needed.
1079 % \begin{macrocode}
1080 \let\TeX_font_name\unknown_str
1081 % \end{macrocode}
1082 % \end{macro}
1083 %
1084 % \begin{macro}{\source_font_TeX_name}
1085 % This is the name (as AFM or PL) of the font whose metrics were
1086 % used by \package{fontinst}. It is set by |\fromafm| or |\frompl|,
1087 % so no |\get_|\textellipsis\ macro is needed.
1088 % \begin{macrocode}
1089 \let\source_font_TeX_name\unknown_str
1090 % \end{macrocode}
1091 % \end{macro}
1092 %
1093 % \begin{macro}{\PS_font_name}
1094 % This is the name (as FontName entry in an AFM or correspondingly) of
1095 % the font in question.
1096 % \begin{macrocode}
1097 \let\PS_font_name\unknown_str
1098 % \end{macrocode}
1099 % \begin{macro}{\get_PS_font_name}
1100 % I expect this to become one of the central macros in the map file
1101 % generation (at least when entries are generated for postscript
1102 % fonts), but for the moment it does the closest thing to nothing a
1103 % |\get_|\textellipsis\ macro is allowed to do; it admits it hasn't
1104 % got a clue about what the proper value is.
1105 % \begin{macrocode}
1106 \def\get_PS_font_name{\let\PS_font_name\clueless_str}
1107 % \end{macrocode}
1108 % \end{macro}\end{macro}
1109 %
1110 % \begin{macro}{\AssumeAMSBSYY}
1111 % \begin{macro}{\AssumeBaKoMa}
1112 % These commands redefine |\get_PS_font_name| so that it returns the
1113 % PS name this font would have if it was part of the AMS\slash
1114 % Blue~Sky\slash Y\&Y and BaKoMa respectively distribution of the
1115 % Computer Modern fonts---the \TeX\ font name in all upper case and
1116 % all lower case respectively.
1117 % \begin{macrocode}
1118 \def\AssumeAMSBSYY{\def\get_PS_font_name{
1119 \uppercase \expandafter{ \expandafter\def
1120 \expandafter\PS_font_name \expandafter{ \source_font_TeX_name}
1121 }
1122 }}
1123 % \end{macrocode}
1124 % \begin{macrocode}
1125 \def\AssumeBaKoMa{\def\get_PS_font_name{
1126 \lowercase \expandafter{ \expandafter\def
1127 \expandafter\PS_font_name \expandafter{ \source_font_TeX_name}
1128 }
1129 }}
1130 % \end{macrocode}
1131 % \end{macro}\end{macro}
1132 %
1133 %
1134 % \begin{macro}{\PS_font_file}
1135 % This is the name of the file (suffix included) in which the PS font
1136 % is expected to be found.
1137 % \begin{macrocode}
1138 \let\PS_font_file\unknown_str
1139 % \end{macrocode}
1140 % \end{macro}
1141 %
1142 % \begin{macro}{\get_PS_font_file}
1143 % \begin{macro}{\normal_get_PS_font_file}
1144 % \begin{fistring}{PSfontsuffix}
1145 % The macro |\normal_get_PS_font_file| is (hardly surprisingly) the
1146 % normal |\get_PS_font_file|. It simply uses |\source_font_TeX_name|
1147 % plus the suffix specified by the |PSfontsuffix| string.
1148 % \begin{macrocode}
1149 \resetstr{PSfontsuffix}{.pfa}
1150 \def\normal_get_PS_font_file{
1151 \edef\PS_font_file{\source_font_TeX_name\str{PSfontsuffix}}
1152 }
1153 \let\get_PS_font_file=\normal_get_PS_font_file
1154 % \end{macrocode}
1155 % \end{fistring}\end{macro}\end{macro}
1156 %
1157 % \begin{macro}{\LWFN_get_PS_font_file}
1158 % \begin{macro}{\abbreviate_PS_font_name}
1159 % In MacOS, Postscript fonts file names are usually abbreviated forms of
1160 % the Postscript font names, formed using the so called
1161 % \(5+3+3+\cdots\) rule---keep the first five letters of the first
1162 % subword, keep the first three letters of all following subwords. The
1163 % |\LWFN_get_PS_font_file| macro uses this scheme if the Postscript
1164 % name for the font is known, otherwise it calls the
1165 % |\normal_get_PS_font_file|. The LWFN in the macro name is the type
1166 % code for such files.
1167 %
1168 % The algorithm is based on using |\aftergroup| to construct the
1169 % wanted |\def| statement, only |\aftergroup|ing the letters that are
1170 % not to be removed in the abbreviation. |\a_count| is used as a
1171 % counter of how many more letters in the current subword should be
1172 % kept.
1173 % \begin{macrocode}
1174 \def\LWFN_get_PS_font_file{
1175 \ifx \PS_font_name\unknown_str \get_PS_font_name \fi
1176 \ifx \PS_font_name\clueless_str
1177 \normal_get_PS_font_file
1178 \includewarning\warn_uncertain_data
1179 \else
1180 \begingroup
1181 \aftergroup\def \aftergroup\PS_font_file
1182 \aftergroup{
1183 \a_count=4~
1184 \expandafter\expandafter \expandafter\aftergroup
1185 \expandafter\swap_two \expandafter\abbreviate_PS_font_name
1186 \PS_font_name \x_relax
1187 \aftergroup}
1188 \endgroup
1189 \fi
1190 }
1191 % \end{macrocode}
1192 % \begin{macrocode}
1193 \def\abbreviate_PS_font_name#1{
1194 \ifx \x_relax#1 \else
1195 \ifnum \uccode`#1=`#1
1196 \a_count=2
1197 \aftergroup#1
1198 \else\ifx -#1
1199 \a_count=\z@
1200 \else\ifnum \a_count>\z@
1201 \advance \a_count \m@ne
1202 \aftergroup#1
1203 \fi\fi\fi
1204 \expandafter\abbreviate_PS_font_name
1205 \fi
1206 }
1207 % \end{macrocode}
1208 % \end{macro}\end{macro}
1209 %
1210 %
1211 %
1212 % \subsection{Driver makers}
1213 %
1214 % This subsection contains the definitions of macros that makes up the
1215 % driver makers.
1216 %
1217 %
1218 % \subsubsection{The \texttt{debug} driver}
1219 %
1220 % The \texttt{debug} driver maker doesn't really generate entries for
1221 % any DVI driver map file, it just prints the data that was available.
1222 % It is mainly intended for debugging purposes, but it might also serve
1223 % as a basic model for other driver makers.
1224 %
1225 % \begin{macro}{\make_debug}
1226 % \begin{macrocode}
1227 \def\make_debug{
1228 \pout_line\output_debug{Driver~data~for~font~\TeX_font_name:}
1229 \pout_lline\output_debug{Source~font~TeX~name:~\source_font_TeX_name}
1230 \ifx \reencode_etx\empty_command \else
1231 \pout_lline\output_debug{Font~reencoded~using~\reencode_etx.etx.}
1232 \fi
1233 \ifdim \xscale_factor=\p@ \else
1234 \pout_lline\output_debug{Font~x-scaled~by~
1235 \expandafter\lose_measure\the\xscale_factor.
1236 }
1237 \fi
1238 \ifdim \slant_factor=\z@ \else
1239 \pout_lline\output_debug{Font~slanted~by~
1240 \expandafter\lose_measure\the\slant_factor.
1241 }
1242 \fi
1243 \debug_values_hook
1244 }
1245 % \end{macrocode}
1246 % \end{macro}
1247 %
1248 %
1249 % \begin{macro}{\debug_value}
1250 % The |\debug_value| macro can be used to print the name and contents
1251 % of an arbitrary value macro in the |debug| driver. It is called with
1252 % the value macro as argument, e.g.
1253 % \begin{quote}
1254 % |\debug_value\PS_font_name|
1255 % \end{quote}
1256 %
1257 % \begin{macrocode}
1258 \def\debug_value#1{
1259 \ifx #1\unknown_str
1260 \csname get_ \expandafter\gobble_one \string#1 \endcsname
1261 \fi
1262 \pout_lline\output_debug{\string#1:~#1}
1263 \ifx #1\clueless_str \includewarning\warn_undecided_data \fi
1264 }
1265 % \end{macrocode}
1266 % \end{macro}
1267 %
1268 % \begin{macro}{\debugvalue}
1269 % \begin{macro}{\debug_values_hook}
1270 % The |\debugvalue| command is a user level interface for adding
1271 % value macros to the list of those that are displayed by the
1272 % \texttt{debug} driver. The argument is the name of the value in
1273 % question, e.g.
1274 % \begin{quote}
1275 % |\debugvalue{PS_font_name}|
1276 % \end{quote}
1277 % Note that the name given to |\debugvalue| is not the control
1278 % sequence in which the name is stored.
1279 % \begin{macrocode}
1280 \def\debugvalue#1{
1281 \expandafter\add_to \expandafter\debug_values_hook
1282 \expandafter{ \expandafter\debug_value \csname#1\endcsname}
1283 }
1284 % \end{macrocode}
1285 % \begin{macrocode}
1286 \let\debug_values_hook\empty_command
1287 \debugvalue{PS_font_name}
1288 % \end{macrocode}
1289 % \end{macro}\end{macro}
1290 %
1291 %
1292 % \subsubsection{The \texttt{dvips} driver}
1293 %
1294 % \changes{1.912}{2000/02/19}{\texttt{dvips} mapfile fragments writer
1295 % added. (LH)}
1296 % Before constructing an entry for a \package{dvips} mapfile, it should
1297 % be sorted out how such an entry should look. The \package{dvips}
1298 % manual says
1299 % \begin{quotation}
1300 % The parsing of the \texttt{psfonts.map} file should be explained to
1301 % eliminate all confusion. If a line is empty or begins with a space,
1302 % asterisk, semicolon, or hash mark, it is ignored. Each remaining
1303 % line is separated into words, where words are separated by spaces or
1304 % tabs. If a word begins with a double quote, it extends until the
1305 % next double quote or the end of the line. If a word starts with a
1306 % less than character, it is treated as a font header file (or a
1307 % downloaded PostScript font). There can be more than one such header
1308 % for a given font. If a word starts with a double quote, it is a
1309 % special instruction for generating that font. Otherwise it is a
1310 % name. The first such name is always the name \TeX\ uses for the
1311 % font and is also the name of the raw \texttt{tfm} file. If there is
1312 % another name word, that name is used as the PostScript name; if
1313 % there is only one name word, it is used for both the \TeX\ name and
1314 % the PostScript name.
1315 % \end{quotation}
1316 %
1317 % A \package{fontinst}-generated map file entry for the \texttt{dvips}
1318 % driver has the following structure:
1319 % \begin{isyntax}
1320 % \meta{\TeX{} font name} \meta{PS font name} \meta{downloads}
1321 % \meta{font transformations}
1322 % \end{isyntax}
1323 % \meta{\TeX{} font name} is simply the value of |\TeX_font_name| and
1324 % \meta{PS font name} is simply the value of |\PS_font_name|.
1325 % \meta{downloads} is a possibly empty sequence in which each item
1326 % has the form
1327 % \begin{quote}
1328 % \meta{prefix}\meta{filename}
1329 % \end{quote}
1330 % The \meta{prefix} values I've came across are empty,\footnote{I think
1331 % this is only used for files that \package{dvips} should ignore, but
1332 % which certain other programs that read the same \texttt{psfonts.map}
1333 % need.} |<|, |<<|, and |<[|. Currently |<| is always used.
1334 % \meta{filename} is a filename with suffix. \meta{font transformations}
1335 % is either empty or has the form
1336 % \begin{quote}
1337 % |"| \meta{Postscript code} |"|
1338 % \end{quote}
1339 %
1340 % Should support for the |<<| or |<[| prefixes be needed, then this
1341 % should be done by adding some new variant of the |\download|
1342 % command---|\fullldownload|, maybe---rather than adding the extra
1343 % character to the \meta{filename}. To simplify matters for other drivers,
1344 % such new variants should by default expand to |\download|, rather than
1345 % |\gobble_one|.
1346 %
1347 %
1348 % \begin{macro}{\downloads_list}
1349 % \begin{macro}{\append_download}
1350 % The |\downloads_list| is a token list register which is especially
1351 % used for accumulating |\download| commands. Each driver maker which
1352 % uses it should begin by emptying it. The command
1353 % \begin{quote}
1354 % |\append_download|\marg{cseq}\marg{string expression}
1355 % \end{quote}
1356 % \changes{1.931}{2005/05/10}{New syntax (two arguments)! The second
1357 % is expanded, whereas the first is protected by a \cs{noexpand}.
1358 % (LH)}
1359 % appends
1360 % \begin{quote}
1361 % \meta{cseq}\marg{expanded string expression}
1362 % \end{quote}
1363 % to |\downloads_list|. It overwrites |\a_macro|.
1364 % \begin{macrocode}
1365 \newtoks\downloads_list
1366 \def\append_download#1#2{
1367 \edef\a_macro{
1368 \downloads_list =
1369 \noexpand\expandafter{ \noexpand\the \downloads_list
1370 \noexpand#1 {#2} }
1371 }
1372 \a_macro
1373 }
1374 % \end{macrocode}
1375 % \end{macro}\end{macro}
1376 %
1377 %
1378 % \begin{macro}{\make_dvips}
1379 % This macro gathers the information for a \texttt{dvips} driver entry
1380 % and writes it to the corresponding output file. As a \texttt{dvips}
1381 % mapfile entry is on one line, the entire entry is written at once.
1382 % The \meta{font transformations} is collected as explicit text in the
1383 % macro |\postscript_code|. The \meta{downloads} is collected as a
1384 % sequence of |\|\dots|download| commands in the |\downloads_list|
1385 % token register.
1386 % \changes{1.931}{2005/05/10}{Supporting \cs{fulldownload} and
1387 % \cs{encodingdownload}. (LH)}
1388 % \begin{macrocode}
1389 \def\make_dvips{
1390 \downloads_list={}
1391 \let\postscript_code\empty_command
1392 \def\download{\append_download\download}
1393 \def\fulldownload{\append_download\fulldownload}
1394 \def\encodingdownload{\append_download\encodingdownload}
1395 \ifx \reencode_etx\empty_command \else
1396 \if_undefined{pse-\reencode_etx}\then
1397 \etxtoenc{\reencode_etx}{\reencode_etx}
1398 \fi
1399 \expandafter\expandafter \expandafter\second_of_two
1400 \csname pse-\reencode_etx\endcsname
1401 \edef\postscript_code{\postscript_code\space
1402 \expandafter\expandafter \expandafter\first_of_two
1403 \csname pse-\reencode_etx\endcsname
1404 \space ReEncodeFont
1405 }
1406 \fi
1407 \ifdim \xscale_factor=\p@ \else
1408 \edef\postscript_code{\postscript_code
1409 \space\expandafter\lose_measure\the\xscale_factor
1410 \space ExtendFont
1411 }
1412 \fi
1413 \ifdim \slant_factor=\z@ \else
1414 \edef\postscript_code{\postscript_code
1415 \space\expandafter\lose_measure\the\slant_factor
1416 \space SlantFont
1417 }
1418 \fi
1419 % \end{macrocode}
1420 % After constructing the \meta{Postscript code} and having appended
1421 % the necessary download (if any) for that code, the next problem is
1422 % to determine the actual \meta{PS font name} and append the downloads
1423 % needed to actually define the font to the Postscript interpreter. If
1424 % there is no special entry for this font in the |\psf-|\meta{PS font
1425 % name} table, or if its \meta{PS font name} is unknown, then it is
1426 % assumed that exactly one file should be downloaded. As the name of
1427 % that file is taken the value of |\PS_font_file|.
1428 % \begin{macrocode}
1429 \ifx \PS_font_name\unknown_str \get_PS_font_name \fi
1430 \ifx \PS_font_name\clueless_str
1431 \includewarning\warn_undecided_data
1432 \_a_true
1433 \else
1434 \if_undefined{psf-\PS_font_name}\then
1435 \_a_true
1436 \else
1437 \csname psf-\PS_font_name \endcsname
1438 \_a_false
1439 \fi\fi
1440 \if_a_
1441 \ifx \PS_font_file\unknown_str \get_PS_font_file \fi
1442 \append_download\download{\PS_font_file}
1443 \ifx \PS_font_file\clueless_str
1444 \includewarning\warn_undecided_data
1445 \fi
1446 \fi
1447 % \end{macrocode}
1448 % Finally, the entire entry is written to the file. The point with
1449 % expanding past an empty command is that \TeX\ in a |\write| normally
1450 % jumps past the expansion of a |\the|\meta{token list register}
1451 % without expanding it further, but this effect can be prevented by
1452 % expanding the |\the| with an |\expandafter|.
1453 % \begin{macrocode}
1454 \def\download##1{~<##1}
1455 \def\fulldownload##1{~<<##1}
1456 \def\encodingdownload##1{~<[##1}
1457 \pout_line\output_dvips{
1458 \TeX_font_name\space\PS_font_name
1459 \expandafter\empty_command \the\downloads_list
1460 \ifx \postscript_code\empty_command \else
1461 \space"\postscript_code\space"
1462 \fi
1463 }
1464 }
1465 % \end{macrocode}
1466 % \end{macro}
1467 %
1468 %
1469 %
1470 % \subsubsection{The \texttt{dvipdfm} driver}
1471 %
1472 % \changes{1.912}{2000/02/22}{\texttt{dvipdfm} mapfile fragments writer
1473 % added. (LH)}
1474 %
1475 % A mapfile entry for the \texttt{dvipdfm} driver has the following
1476 % structure:
1477 % \begin{isyntax}
1478 % \meta{\TeX{} font name} \meta{encoding} \meta{PS font}
1479 % \meta{options}
1480 % \end{isyntax}
1481 % \meta{\TeX{} font name} is simply the value of |\TeX_font_name|.
1482 % \meta{encoding} is the name of the encoding file which should be used
1483 % to reencode the font, or \texttt{default} if there is none. \meta{PS
1484 % font} is the value of |\PS_font_name| for the standard 35 fonts
1485 % (i.e., fonts which will not be included in the PDF generated), but for
1486 % other fonts it is the name of the file which contains the
1487 % font.\footnote{The documentation seems to say that \texttt{dvipdfm}
1488 % can only understand fonts in PFB format; I have chosen to ignore this
1489 % potential problem.} \meta{options}, finally, is a possibly empty
1490 % sequence of space-separated options. Each option is one of the
1491 % following
1492 % \begin{quote}
1493 % |-e |\meta{number}\\
1494 % |-s |\meta{number}\\
1495 % |-r|
1496 % \end{quote}
1497 % The |-e| and |-s| options extend and slant by the given amounts. The
1498 % |-r| option is a workaround for some Acrobat bugs; it is currently not
1499 % generated by \package{fontinst}.
1500 %
1501 % \begin{macro}{\make_dvipdfm}
1502 % This macro gathers the information for a \texttt{dvipdfm} driver entry
1503 % and writes it to the corresponding output file. As a \texttt{dvipdfm}
1504 % mapfile entry is on one line, the entire entry is written at once.
1505 % The \meta{options} text is collected as explicit text in the
1506 % macro |\options_text|. The \meta{downloads} is collected as a
1507 % sequence of |\download| commands in the |\downloads_list| token
1508 % register.
1509 % \begin{macrocode}
1510 \def\make_dvipdfm{
1511 \def\font_encoding{default}
1512 \ifx \reencode_etx\empty_command \else
1513 \if_undefined{pse-\reencode_etx}\then
1514 \etxtoenc{\reencode_etx}{\reencode_etx}
1515 \fi
1516 \def\download##1{\def\font_encoding{##1}}
1517 \expandafter\expandafter \expandafter\second_of_two
1518 \csname pse-\reencode_etx\endcsname
1519 \fi
1520 \let\options_text\empty_command
1521 \ifdim \xscale_factor=\p@ \else
1522 \edef\options_text{\options_text\space
1523 -e~\expandafter\lose_measure\the\xscale_factor
1524 }
1525 \fi
1526 \ifdim \slant_factor=\z@ \else
1527 \edef\options_text{\options_text\space
1528 -s~\expandafter\lose_measure\the\slant_factor
1529 }
1530 \fi
1531 % \end{macrocode}
1532 % After constructing the \meta{options} and having determined
1533 % \meta{encoding}, the next problem is to determine the actual
1534 % \meta{PS font}, which will be put in |\a_macro|. If there is no
1535 % special entry for this font in the |\psf-|\meta{PS font name} table,
1536 % or if its \meta{PS font name} is unknown, then it is assumed that
1537 % exactly one file should be downloaded. As the name of that file is
1538 % taken the value of |\PS_font_file|.
1539 % \begin{macrocode}
1540 \ifx \PS_font_name\unknown_str \get_PS_font_name \fi
1541 \if_or \if_equal\PS_font_name\clueless_str \or_else
1542 \if_undefined{psf-\PS_font_name}
1543 \then
1544 \ifx \PS_font_file\unknown_str \get_PS_font_file \fi
1545 \ifx \PS_font_file\clueless_str
1546 \includewarning\warn_undecided_data
1547 \fi
1548 \let\a_macro=\PS_font_file
1549 \else
1550 \let\a_macro=\PS_font_name
1551 \def\download##1{\def\a_macro{##1}}
1552 \csname psf-\PS_font_name \endcsname
1553 \fi
1554 % \end{macrocode}
1555 % Finally, the entire entry is written to the file.
1556 % \begin{macrocode}
1557 \pout_line\output_dvipdfm{
1558 \TeX_font_name\space\font_encoding\space\a_macro
1559 \options_text
1560 }
1561 }
1562 % \end{macrocode}
1563 % \end{macro}
1564 %
1565 %
1566 % \subsubsection{The \texttt{pltotf} ``driver''}
1567 % \changes{1.915}{2000/06/27}{\texttt{pltotf} ``driver'' support
1568 % added. (LH)}
1569 %
1570 % It can sometimes be hard to determine which of all the PL files that
1571 % \package{fontinst} creates need to be converted to TFM files. In most
1572 % cases no \texttt{8a}-encoded PLs need to be converted as they aren't
1573 % used as base fonts or installed in an FD file, but to automatically
1574 % exclude them isn't a trivial task (even though it probably could be
1575 % done by a regular expression filter for fonts named according to the
1576 % \texttt{fontname} scheme). There furthermore seems to be some systems
1577 % on which it for various reasons isn't easy to convert all PLs in a
1578 % directory. The \texttt{pltotf} ``driver'' support is meant to help with
1579 % both these problems, as the ``map file'' it creates really is a shell
1580 % script (batch file) for converting precisely those PL files that need
1581 % a map file entry to TFM format. I believe the shell script will work
1582 % both for UNIX and DOS systems.
1583 %
1584 % \begin{macro}{\make_pltotf}
1585 % \begin{fistring}{TFMfileprefix}
1586 % |\make_pltotf| writes a \package{PLtoTF} command for converting the
1587 % current font's PL file to a TFM file. If set, the string
1588 % \texttt{TFMfileprefix} will be prepended to the TFM file name---this
1589 % could be used for putting the TFMs in some directory other than the
1590 % current.
1591 % \begin{macrocode}
1592 \def\make_pltotf{
1593 \pout_line\output_pltotf{pltotf~\TeX_font_name.pl~
1594 \ifisstr{TFMfileprefix}\then \str{TFMfileprefix}\fi
1595 \TeX_font_name.tfm
1596 }
1597 }
1598 % \end{macrocode}
1599 % \end{fistring}\end{macro}
1600 %
1601 %
1602 % \begin{macrocode}
1603 %</map>
1604 % \end{macrocode}
1605 % \Finale
1606 \endinput
1607