Debian Codegraph @

texmf-dist/doc/support/mf2pt1/mf2pt1.texi

raw
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename mf2pt1.info
4 @settitle mf2pt1
5 @setchapternewpage off
6 @dircategory TeX
7 @direntry
8 * mf2pt1: (mf2pt1). PostScript Type 1 fonts from Metafont source.
9 @end direntry
10 @finalout
11 @c %**end of header
12
13 @copying
14 Copyright @copyright{} 2005--2024 Scott Pakin
15
16 @sp 2
17
18 This program may be distributed and/or modified under the conditions
19 of the @LaTeX{} Project Public License, either version 1.3c of this
20 license or (at your option) any later version.
21
22 @sp 1
23
24 The latest version of this license is in:
25 @sp 1
26 @center @uref{https://www.latex-project.org/lppl.txt}
27 @sp 1
28 and version 1.3c or later is part of all distributions of @LaTeX{}
29 version 2006/05/20 or later.
30
31 @end copying
32
33 @set VERSION 2.8
34 @set DATE 6 July 2024
35
36 @c Define some fonts we intend to use.
37 @iftex
38 @tex
39 @global@font@tenlogo=logo10 % font used for the METAFONT logo
40 @global@font@eightrm=cmr8 % needed for the "A" in "LaTeX"
41 @end tex
42 @end iftex
43
44 @c Define a macro for the Metafont logo.
45 @iftex
46 @macro MF {}
47 @tex
48 @tenlogo @leavevmode@hbox{METAFONT}@unskip
49 @end tex
50 @end macro
51 @end iftex
52 @ifnottex
53 @macro MF {}
54 Metafont
55 @end macro
56 @end ifnottex
57
58 @macro copt {option}
59 @w{@code{--\option\}}
60 @end macro
61
62 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63
64 @iftex
65 @tex
66 % If we're using pdfTeX in PDF-generating mode then include some
67 % document metadata.
68 \ifx\pdfoutput\undefined
69 \else
70 \ifx\pdfoutput\relax
71 \else
72 \ifcase\pdfoutput
73 \else
74 \pdfinfo {
75 /Title (mf2pt1)
76 /Subject (Produce PostScript Type 1 fonts from Metafont source)
77 /Author (Scott Pakin <scott+mf@@pakin.org>)
78 /Keywords (PostScript Type 1 fonts, Metafont, MetaPost, FontForge)
79 }
80 \fi
81 \fi
82 \fi
83 @end tex
84 @end iftex
85
86 @titlepage
87 @title mf2pt1
88 @subtitle Produce PostScript @w{Type 1} fonts from Metafont source
89 @author Scott Pakin, @email{scott+mf@@pakin.org}
90
91 @page
92
93 @vskip 0pt plus 2filll
94
95 This file documents @command{mf2pt1} version @value{VERSION}, dated
96 @value{DATE}.
97
98 @vskip 0pt plus 1filll
99
100 @insertcopying
101
102 @contents
103
104 @end titlepage
105
106 @ifnottex
107 @node Top, Introduction, (dir), (dir)
108 @top mf2pt1
109
110 @command{mf2pt1} is a tool that lets font designers design PostScript
111 @w{Type 1} fonts using the @MF{} language. The same source file can be
112 used to produce both @w{Type 1} (@file{.pfb}) and bitmap (@file{.pk})
113 fonts.
114 @end ifnottex
115
116 @menu
117 * Introduction:: Introduction to mf2pt1
118 * Usage:: How to use mf2pt1
119 * Future Work:: Features I may one day add to mf2pt1
120 * Acknowledgments:: People who helped with mf2pt1
121 @end menu
122
123
124 @node Introduction, Usage, Top, Top
125 @chapter Introduction
126
127 @MF{} is a high-level, mathematically oriented language for producing
128 fonts. The @MF{} interpreter produces device-dependent bitmaps, which
129 render well at the target resolution on the target device, but poorly
130 at other resolutions or on other devices. Adobe's PostScript @w{Type 1}
131 font format is the de facto font standard for printers these days. It
132 is a vector format, which implies that it scales better than bitmaps,
133 and it delegates the device- and resolution-dependent tweaking from
134 the font source to the target device's PostScript renderer. However,
135 @w{Type 1} fonts are extremely difficult to code by hand. Usually, one
136 uses a @acronym{WYSIWYG} program to design a @w{Type 1} font. @MF{}, with
137 its font-specific programming language, is an elegant alternative. A
138 font designer can write reusable subroutines for repeated features,
139 such as serifs and accents. He can define a font in terms of
140 arbitrary parameters, such as ``boldness'' or ``italicness'', making
141 it trivial to produce entire families of fonts from a single source
142 (hence the ``meta'' in the name ``@MF{}''). Ideally, we would like to
143 design a font using the @MF{} language, but produce PostScript @w{Type 1}
144 output instead of bitmaps.
145
146 @command{mf2pt1} helps bridge the gap between @MF{} and @w{Type 1} fonts.
147 @command{mf2pt1} facilitates producing PostScript @w{Type 1} fonts from a
148 @MF{} source file. It is @emph{not}, as the name may imply, an
149 automatic converter of arbitrary @MF{} fonts to @w{Type 1} format.
150 @command{mf2pt1} imposes a number of restrictions on the @MF{} input.
151 If these restrictions are met, @command{mf2pt1} will produce valid
152 @w{Type 1} output.
153
154 @menu
155 * Requirements:: Pre-installation checklist
156 * Installation:: How to install mf2pt1
157 @end menu
158
159
160 @node Requirements, Installation, Introduction, Introduction
161 @section Requirements
162
163 Before using @command{mf2pt1}, you will need to install the following
164 programs:
165
166 @table @asis
167 @item Perl
168 @command{mf2pt1} is written in Perl. You will need a Perl interpreter
169 to run it.
170
171 @item MetaPost
172 @command{mf2pt1} actually uses MetaPost, not @MF{}, to produce
173 PostScript output. Specifically, you will need the @command{mpost}
174 executable and the @file{mfplain.mp} base file.
175
176 @item @w{Type 1} Utilities
177 Producing properly encoded @w{Type 1} fonts is tricky.
178 @command{mf2pt1} delegates the effort to the @w{Type 1} Utilities,
179 specifically, to the @command{t1asm} program within that suite.
180
181 @item FontForge (optional)
182 FontForge is a @acronym{WYSIWYG}, but scriptable, @w{Type 1}
183 font-editing program. Although FontForge is not strictly required for
184 @command{mf2pt1} to produce a @w{Type 1} font, @command{mf2pt1} uses
185 FontForge when available to autohint the generated @w{Type 1} font,
186 thereby making it look better especially at lower resolutions.
187 @end table
188
189 Perl is available from @uref{https://www.cpan.org, the Comprehensive
190 Perl Archive Network}; MetaPost and the @w{Type 1} utilities are
191 available from @uref{https://www.ctan.org, the Comprehensive @TeX{}
192 Archive Network}; and FontForge is available from
193 @uref{https://fontforge.sourceforge.net/}. In addition, MetaPost's
194 home page is @uref{https://tug.org/metapost.html}, and the @w{Type 1}
195 utilities' home page is @uref{https://www.lcdf.org/type/}.
196
197 Besides being useful for autohinting fonts, FontForge enables a font
198 designer to hint fonts manually for additional fine-tuning and to
199 convert among a variety of font formats, such as PostScript, TrueType,
200 and @w{X Window} fonts. FontForge is strongly recommended as a
201 complement to @command{mf2pt1}.
202
203
204 @node Installation, , Requirements, Introduction
205 @section Installation
206
207 To install @command{mf2pt1}, move the @file{mf2pt1} executable
208 someplace where your operating system can find it. If you're running
209 Microsoft Windows, you should rename the program to @file{mf2pt1.pl},
210 so that Windows knows it's a Perl script. (Alternatively, if you have
211 @command{pl2bat}, use that to produce a @file{mf2pt1.bat} file, which
212 you can run as simply @file{mf2pt1}.)
213
214 The next step is to produce a @file{mf2pt1.mem} file from the supplied
215 @file{mf2pt1.mp}. The command to do this differs from system to
216 system but is usually something like the following:
217
218 @example
219 mpost -progname=mpost -ini mf2pt1 \\dump
220 @end example
221
222 Move the resulting @file{mf2pt1.mem} file someplace where MetaPost can
223 find it.
224
225 @sp 1
226
227 The @command{mf2pt1} documentation (what you're reading now) is written
228 in Texinfo and can therefore easily be converted to a variety of
229 formats:
230
231 @table @asis
232 @item PDF (@file{mf2pt1.pdf})
233 @example
234 texi2pdf mf2pt1.texi
235 @end example
236
237 @item PostScript (@file{mf2pt1.ps})
238 @example
239 texi2dvi mf2pt1.texi
240 dvips mf2pt1.dvi -o mf2pt1.ps
241 @end example
242
243 @item HTML (@file{mf2pt1.html})
244 @example
245 makeinfo --html mf2pt1.texi
246 @end example
247
248 @item Info (@file{mf2pt1.info})
249 @example
250 makeinfo mf2pt1.texi
251 @end example
252 @end table
253
254 @noindent
255 N.B@. The @command{install-info} command is a convenient way to install
256 @file{mf2pt1.info} on your system.
257
258 @sp 1
259
260 On Unix, you may also want to generate an @command{mf2pt1} man page.
261 The man page is embedded within the @file{mf2pt1} Perl script and can be
262 extracted with @command{pod2man}:
263
264 @example
265 pod2man --center="User Commands" --date="@value{DATE}" \
266 --release="v@value{VERSION}" mf2pt1 > mf2pt1.1
267 @end example
268
269 @noindent
270 You can then move @file{mf2pt1.1} into @file{/usr/man/man1} or any other
271 man page directory. Note that the @command{mf2pt1} man page is fairly
272 rudimentary. It is primarily a list of the command-line options
273 (@pxref{Font information}) and a pointer to the document that you're
274 reading now.
275
276
277 @node Usage, Future Work, Introduction, Top
278 @chapter Usage
279
280 @command{mf2pt1} is fairly straightforward to use. To process a
281 @MF{} source file, merely specify the filename:
282
283 @example
284 mf2pt1 myfont.mf
285 @end example
286
287 @noindent
288 That simple command automatically performs all of the following
289 operations:
290
291 @enumerate
292 @item
293 Read @file{myfont.mf}.
294
295 @item
296 Use @command{mpost} to convert each character to a separate
297 Encapsulated PostScript (@acronym{EPS}) file named
298 @file{myfont.@var{num}}.
299
300 @item
301 Process and merge the @acronym{EPS} files into a single
302 ``disassembled'' @w{Type 1} font called @file{myfont.pt1}.
303
304 @item
305 Run @command{t1asm} from the @w{Type 1} Utilities to convert the
306 disassembled font into a true, binary @w{Type 1} font called
307 @file{myfont.pfb}.
308
309 @item
310 Invoke @command{fontforge} to apply rendering hints to
311 @file{myfont.pfb} and to attempt to remove overlapping paths.
312 @end enumerate
313
314 The external programs launched by @command{mf2pt1}---@command{mpost},
315 @command{t1asm}, and @command{fontforge}---can be overridden by
316 setting the eponymous, uppercase environment variable. For example,
317 invoking FontForge's predecessor, PfaEdit, instead of FontForge is
318 simply a matter of setting the @samp{FONTFORGE} environment variable
319 to @samp{pfaedit} before invoking @command{mf2pt1}. As a corollary,
320 you can inhibit an @command{mf2pt1} external program from running by
321 setting the corresponding environment variable to the name of a
322 nonexistent program. Arguments can be included in the environment
323 variable's value. Hence, defining @samp{MPOST} to @samp{mpost
324 -recorder}, for instance, instructs @command{mf2pt1} to run
325 @command{mpost} with the @samp{-recorder} option.
326
327 @menu
328 * Restrictions:: Restrictions imposed on the font source code
329 * Font information:: Specifying PostScript font characteristics
330 * Additional command-line options:: Options unrelated to font characteristics
331 * Custom font encodings:: Altering the mapping from character name to number
332 * Restoring mfplain defaults:: Using the original (un)filldraw and pencircle
333 @end menu
334
335
336 @node Restrictions, Font information, Usage, Usage
337 @section Restrictions
338
339 If @command{mf2pt1} sounds too good to be true, it is---somewhat.
340 @command{mf2pt1} is not a general-purpose @MF{}-to-@w{Type 1}
341 converter. Rather, it can convert only certain @MF{} constructs.
342 This is not a showstopper for new fonts designed with @command{mf2pt1}
343 in mind, but it is unlikely that @command{mf2pt1} will work on an
344 arbitrary @MF{} source file.
345
346 @command{mf2pt1}'s biggest restriction is that each glyph must be
347 drawn entirely from closed paths, using @MF{}'s @strong{fill} and
348 @strong{unfill} commands. (@command{mf2pt1} has limited support for
349 @strong{draw} and @strong{undraw}, but their use is currently
350 discouraged. @strong{filldraw} and @strong{unfilldraw} issue a
351 warning message and invoke @strong{draw} and @strong{undraw},
352 respectively.) The @w{Type 1} format requires that these paths be
353 nonoverlapping. The following are some of the alternatives for
354 removing path overlaps:
355
356 @enumerate
357 @item
358 Install FontForge. As part of its final step in producing a @w{Type
359 1} font, @command{mf2pt1} instructs FontForge to replace overlapping
360 paths with nonoverlapping paths.
361
362 @item
363 Remove overlaps using @MF{} code within the font program itself. A
364 @file{.zip} file attachment to
365 @uref{https://tug.org/pipermail/metapost/2005-January/000080.html,
366 a @w{6 January} 2005 article} by
367 @iftex
368 @tex
369 Bogus\l{}aw
370 @end tex
371 @end iftex
372 @ifnottex
373 Boguslaw
374 @end ifnottex
375 Jackowski on the MetaPost mailing list (subject: ``Re: all
376 intersections between two paths'') includes a MetaPost library which
377 assists with that task. The library provides a @strong{find_outlines}
378 command which can be used to define a path as the union of two other
379 paths. A number of MetaPost example programs are also included in the
380 @file{.zip} file.
381
382 @item
383 Design your fonts from the beginning without using overlapping paths.
384 @end enumerate
385
386 A secondary restriction is that @command{mf2pt1} redefines a number of
387 Plain @MF{} commands, such as @strong{beginchar}, @strong{fill}, and
388 @strong{unfill}. @MF{} font programs which redefine or bypass these
389 (using @MF{} primitives) will not be convertible with
390 @command{mf2pt1}.
391
392 A far less severe restriction is due to @command{mf2pt1}'s utilizing
393 MetaPost's @MF{} interface instead of @MF{} itself. The implication
394 is that commands not defined by MetaPost's @file{mfplain.mp} cannot be
395 handled by @command{mf2pt1}, either. Very few fonts will have a
396 problem with this restriction but see the MetaPost manual for more
397 information.
398
399
400 @node Font information, Additional command-line options, Restrictions, Usage
401 @section Specifying font information
402
403 @iftex
404 @tex
405 @leavevmode
406 @end tex
407 @end iftex
408 @MF{} fonts normally specify a set of @strong{fontdimen}s which
409 provide information about a particular font that cannot otherwise be
410 inferred. These include features such as the font's x-height, quad
411 width, interword stretchability and shrinkability, and other design
412 characteristics that @TeX{} makes use of. PostScript fonts utilize a
413 largely different set of font parameters, such as the underline
414 position and thickness, font family name, and copyright notice.
415 @command{mf2pt1} provides @MF{} commands to define the PostScript font
416 parameters in the generated @w{Type 1} font. These parameters should
417 appear in the @MF{} source file as follows:
418
419 @display
420 @b{if} known @i{ps_output}:
421 @dots{}
422 @b{fi}
423 @end display
424
425 @noindent
426 @code{ps_output} is defined by @command{mf2pt1} but not by Plain
427 @MF{}. Checking if it is known is the recommended way to determine if
428 the font is being built under @command{mf2pt1}.
429
430 @ifnottex
431 @menu
432 * Parameters:: Font-information commands available to Metafont
433 * Command-line equivalents:: Specifying font features on the command line
434 * Default values:: Types and default values of each parameter
435 * Parameter example:: Metafont example which specifies all parameters
436 @end menu
437
438
439 @node Parameters, Command-line equivalents, Font information, Font information
440 @subsection Parameters
441 @end ifnottex
442
443 The following list presents all of the font-information commands
444 provided by @command{mf2pt1} and describes what each command means.
445 Commands marked with an asterisk are also defined by Plain @MF{} and
446 therefore do not need to be enveloped within a test for
447 @code{ps_output}.
448
449 @table @strong
450 @item font_coding_scheme
451 The mapping between character numbers and PostScript names. If this
452 is the name of a file, @command{mf2pt1} expects it to contain
453 PostScript code defining a font-encoding vector. @xref{Custom font
454 encodings}, for an example of such a file. If
455 @strong{font_coding_scheme} is not the name of a file,
456 @command{mf2pt1} expects it to be one of the literal strings
457 @code{standard} (Adobe standard encoding), @code{isolatin1} (ISO Latin
458 1 encoding), @code{ot1} (@TeX{} 7-bit encoding), @code{t1} (@TeX{}
459 8-bit encoding), or @code{asis} (encoding integrated with the
460 character programs using the @strong{glyph_name} command as described
461 in @ref{Custom font encodings}). Anything else will generate a
462 warning message and cause @command{mf2pt1} to use @code{standard}
463 instead.
464
465 @item font_comment
466 A textual comment that will appear within the generated font. This is
467 often used for copyright notices.
468
469 @item font_family
470 The family that this font belongs to. For example, ``Utopia Bold
471 Italic'' belongs to the @code{Utopia} family.
472
473 @item font_fixed_pitch
474 Whether the font is monospaced (if @strong{true}) or or proportionally
475 spaced (if @strong{false}).
476
477 @item font_identifier (*)
478 The full name of the font, e.g., @code{Utopia Bold Italic}.
479
480 @item font_name
481 The symbolic font name, used to load the font from a PostScript
482 document. Spaces are forbidden. Generally, the font name is of the
483 form @code{@var{family}-@var{modifiers}}. For example, the font name
484 of Utopia Bold Italic would be @code{Utopia-BoldItalic}.
485
486 @item font_size (*)
487 The font design size. This is specified in ``sharped'' units within
488 @MF{} code or as a point size on the command line.
489
490 @item font_slant (*)
491 When specified with @strong{font_slant}, the amount of slant per
492 point. When specified with @copt{italicangle}, the angle in
493 counterclockwise degrees from the vertical (i.e., zero for an upright
494 font, negative for a right-slanting italic font).
495
496 @item font_underline_position
497 The vertical position at which an underline should lie, specified in
498 ``sharped'' units within @MF{} code or as a number of points on the
499 command line.
500
501 @item font_underline_thickness
502 The thickness of an underline, specified in ``sharped'' units within
503 @MF{} code or as a number of points on the command line.
504
505 @item font_unique_id
506 The unique ID for this font. The ID should be between 0 and
507 16,777,215, with the ``open'' range being 4,000,000-4,999,999. All
508 IDs not in that range are allocated by contacting Adobe's UniqueID
509 Coordinator. (I don't believe a fee is involved, but I don't know for
510 sure.) If a unique ID is not specified, @command{mf2pt1} will not
511 write a unique ID to the file. Note that Adobe no longer recommends
512 including unique IDs in fonts.
513
514 @item font_version
515 The version number of the font. This should be of the form
516 @code{@var{MMM}.@var{mmm}}, where @var{MMM} is the major version
517 number and @var{mmm} is the minor version number.
518
519 @item font_weight
520 The font weight. For example, the font weight of Utopia Bold Italic
521 is @code{Bold}.
522 @end table
523
524
525 @ifnottex
526 @node Command-line equivalents, Default values, Parameters, Font information
527 @subsection Command-line equivalents
528 @end ifnottex
529
530 Each of the
531 @iftex
532 preceding font-information commands
533 @end iftex
534 @ifnottex
535 font-information commands listed in @ref{Parameters}
536 @end ifnottex
537 has a command-line equivalent. Their use is discouraged but they are
538 listed here for completeness:
539
540 @multitable {@strong{font_underline_thickness}} {@copt{fontversion}}
541 @item
542 @strong{font_coding_scheme}
543 @tab @copt{encoding}
544
545 @item
546 @strong{font_comment}
547 @tab @copt{comment}
548
549 @item
550 @strong{font_family}
551 @tab @copt{family}
552
553 @item
554 @strong{font_fixed_pitch}
555 @tab @copt{fixedpitch}
556
557 @item
558 @strong{font_identifier}
559 @tab @copt{fullname}
560
561 @item
562 @strong{font_name}
563 @tab @copt{name}
564
565 @item
566 @strong{font_size}
567 @tab @copt{designsize}
568
569 @item
570 @strong{font_slant}
571 @tab @copt{italicangle}
572
573 @item
574 @strong{font_underline_position}
575 @tab @copt{underpos}
576
577 @item
578 @strong{font_underline_thickness}
579 @tab @copt{underthick}
580
581 @item
582 @strong{font_unique_id}
583 @tab @copt{uniqueid}
584
585 @item
586 @strong{font_version}
587 @tab @copt{fontversion}
588
589 @item
590 @strong{font_weight}
591 @tab @copt{weight}
592 @end multitable
593
594 A special case is @copt{fixedpitch} which does not take an argument.
595 Rather, you should use @copt{fixedpitch} as the equivalent of
596 @samp{font_fixed_pitch true} and @copt{nofixedpitch} as the equivalent
597 of @samp{font_fixed_pitch false}.
598
599
600 @ifnottex
601 @node Default values, Parameter example, Command-line equivalents, Font information
602 @subsection Default values
603 @end ifnottex
604
605 The next table lists the @MF{} type and default value of each of the
606 parameters listed in
607 @ifnottex
608 @ref{Parameters}.
609 @end ifnottex
610 @ifnotinfo
611 the previous table.
612 @end ifnotinfo
613
614 @multitable {@strong{font_underline_thickness}} {@strong{numeric}} {MMMMMMMMMMMMMMMMMMMMMMMMM}
615 @item @strong{font_coding_scheme}
616 @tab @strong{string}
617 @tab @code{"standard"}
618
619 @item @strong{font_comment}
620 @tab @strong{string}
621 @tab @code{"Font converted to @w{Type 1} by mf2pt1, written by Scott Pakin."}
622
623 @item @strong{font_family}
624 @tab @strong{string}
625 @tab (The value of @strong{font_identifier})
626
627 @item @strong{font_fixed_pitch}
628 @tab @strong{boolean}
629 @tab @strong{false}
630
631 @item @strong{font_identifier}
632 @tab @strong{string}
633 @tab (The input filename, minus @file{.mf})
634
635 @item @strong{font_name}
636 @tab @strong{string}
637 @tab (The value of @strong{font_family}, plus an underscore, plus the
638 value of @strong{font_weight}, with all spaces removed)
639
640 @item @strong{font_size}
641 @tab @strong{numeric}
642 @tab (Must be specified or @command{mf2pt1} will abort with an error message)
643
644 @item @strong{font_slant}
645 @tab @strong{numeric}
646 @tab 0
647
648 @item @strong{font_underline_position}
649 @tab @strong{numeric}
650 @tab -1
651
652 @item @strong{font_underline_thickness}
653 @tab @strong{numeric}
654 @tab 0.5
655
656 @item @strong{font_unique_id}
657 @tab @strong{string}
658 @tab (Randomly generated in the range 4000000-4999999)
659
660 @item @strong{font_version}
661 @tab @strong{string}
662 @tab @code{"001.000"}
663
664 @item @strong{font_weight}
665 @tab @strong{string}
666 @tab @code{"Medium"}
667 @end multitable
668
669 @sp 1
670
671
672 @ifnottex
673 @node Parameter example, , Default values, Font information
674 @subsection Parameter example
675 @end ifnottex
676
677 As an example, the following @MF{} code shows the usage of all of the
678 parameters that @command{mf2pt1} accepts:
679
680 @noindent
681 @b{if} known @i{ps_output}:
682 @multitable {@b{if}} {@b{font_underline_thickness}} {@t{"Copyright (C) 2005-2024 Scott Pakin.";}}
683 @item @tab @b{font_coding_scheme} @tab @t{"ot1"};
684 @item @tab @b{font_comment} @tab @t{"Copyright (C) 2005-2024 Scott Pakin."};
685 @item @tab @b{font_family} @tab @t{"Kerplotz"};
686 @item @tab @b{font_fixed_pitch} @tab @b{false};
687 @item @tab @b{font_identifier} @tab @t{"Kerplotz Light Oblique"};
688 @item @tab @b{font_name} @tab @t{"Kerplotz-LightOblique"};
689 @item @tab @b{font_size} @tab 10@i{pt}#; @ @ @ @ @ % Important to include this.
690 @item @tab @b{font_slant} @tab 1/6;
691 @item @tab @b{font_underline_position} @tab -1@i{pt}#;
692 @item @tab @b{font_underline_thickness} @tab 1/2@i{pt}#;
693 @item @tab @b{font_unique_id} @tab @t{"4112233"}; @ @ @ @ @ % Better to omit this.
694 @item @tab @b{font_version} @tab @t{"002.005"};
695 @item @tab @b{font_weight} @tab @t{"Light"};
696 @end multitable
697 @noindent
698 @b{fi}
699
700 @noindent
701 In the above, the @strong{font_fixed_pitch} call could have been
702 omitted, as it defaults to @strong{false}. Also, unless you've
703 requested a unique ID from Adobe, it's generally better not to assign
704 @strong{font_unique_id}; let @command{mf2pt1} choose a random value
705 itself.
706
707 The same parameters can also be specified on the command line as
708 follows:
709
710 @example
711 mf2pt1 --encoding=ot1 --comment="Copyright (C) 2005-2024 Scott Pakin."
712 --family=Kerplotz --nofixedpitch --fullname="Kerplotz Light Oblique"
713 --name=Kerplotz-LightOblique --designsize=10 --italicangle=-9.5
714 --underpos=-100 --underthick=50 --uniqueid=4112233 --version=002.005
715 --weight=Light kerplotz.mf
716 @end example
717
718 @noindent
719 Note that a @MF{} font slant of 1/6 is equal to a PostScript italic
720 angle of approximately -9.5. The conversion formula is
721 @iftex
722 @tex
723 $s = -@tan @theta$, in which $s$ is the slant and $@theta$ is the
724 italic angle.
725 @end tex
726 @end iftex
727 @ifnottex
728 slant = -tan(angle).
729 @end ifnottex
730 In addition, the underline position and thickness must be multiplied by
731 1000/@strong{font_size} to convert from the @MF{} units that are used
732 within the @file{.mf} file to the PostScript units that are used on the
733 command line.
734
735
736 @node Additional command-line options, Custom font encodings, Font information, Usage
737 @section Additional command-line options
738
739 In addition to the command-line options for setting font parameters
740 that were presented in
741 @iftex
742 @ref{Font information},
743 @end iftex
744 @ifnottex
745 @ref{Parameters},
746 @end ifnottex
747 @command{mf2pt1} supports a @copt{rounding} option. While
748 @command{mf2pt1} normally rounds all font coordinates to the nearest
749 integer, @copt{rounding} increases coordinate precision by
750 instructing @command{mf2pt1} to round instead to the nearest multiple
751 of a given fractional number. For example, @samp{--rounding=0.25}
752 rounds the coordinate @math{(7.4, 10.3)} to @math{(7.5, 10.25)} while
753 it would otherwise be rounded to the less-precise @math{(7, 10)}.
754
755 Large glyphs can be problematic in MetaPost and therefore in
756 @command{mf2pt1}. Unlike @MF{}, MetaPost does not honor @samp{mag}
757 for magnifying dimensions. Rather, the number of PostScript
758 (a.k.a. ``big'') points per pixel---@samp{bpppix}---is hardwired @w{to
759 0.02} and all other dimensions (@samp{mm}, @samp{in}, @samp{pt},
760 etc.@:) are expressed in terms of that. Consequently, glyphs that
761 multiply a large number of font units by a dimension are likely to
762 exceed 4096, the largest value that MetaPost can represent in its
763 fixed-point format. If numerical overflow becomes a problem you can
764 use the @copt{bpppix} option to @command{mf2pt1} to change the value
765 of @samp{bpppix}. For example, specifying @samp{--bpppix=0.2} enables
766 a tenfold increase in maximum glyph size (with a corresponding
767 decrease in precision).
768
769 After generating a @w{Type 1} font, @command{mf2pt1} runs it through
770 FontForge to add hinting information, remove overlaps, and otherwise
771 clean up the generated font. The @copt{ffscript} option specifies
772 the filename of a FontForge script to use instead of the default
773 script, which is listed below:
774
775 @example
776 Open($1);
777 SelectAll();
778 RemoveOverlap();
779 AddExtrema();
780 Simplify(0, 2);
781 CorrectDirection();
782 Simplify(0, 2);
783 RoundToInt();
784 AutoHint();
785 Generate($1);
786 Quit(0);
787 @end example
788
789 @noindent
790 See the FontForge documentation for an explanation of each of those
791 commands and a description of other commands made available to
792 FontForge scripts. @command{mf2pt1} runs the script with one argument
793 (@code{$1}), which is the name of the generated @file{.pfb} file.
794
795 @command{mf2pt1} also supports a @copt{help} option which summarizes
796 all of the program's command-line options.
797
798 @c Improve formatting by keeping the large cartouche on the same
799 @c page as the text that introduces it.
800 @page
801
802 @node Custom font encodings, Restoring mfplain defaults, Additional command-line options, Usage
803 @section Custom font encodings
804
805 @iftex
806 @ref{Font information},
807 @end iftex
808 @ifnottex
809 @ref{Parameters},
810 @end ifnottex
811 lists the font encodings currently supported by @command{mf2pt1} and
812 mentions that an alternate encoding can be specified by providing the
813 name of an encoding file. To elaborate, the following example
814 represents the contents of an encoding file which defines a---largely
815 useless nowadays---@acronym{EBCDIC} font encoding:
816
817 @cartouche
818 @quotation
819 @code{% Sample encoding vector: @acronym{EBCDIC}@*
820 @*
821 % The encoding vector must have a name and be defined as a PostScript array.@*
822 /ebcdic_encoding [@*
823 /_a0 /_a1 /_a2 /_a3 /_a4 /_a5 /_a6 /_a7 /_a8 /_a9 /_a10 /_a11 /_a12
824 /_a13 /_a14 /_a15 /_a16 /_a17 /_a18 /_a19 /_a20 /_a21 /_a22 /_a23
825 /_a24 /_a25 /_a26 /_a27 /_a28 /_a29 /_a30 /_a31 /_a32 /_a33 /_a34
826 /_a35 /_a36 /_a37 /_a38 /_a39 /_a40 /_a41 /_a42 /_a43 /_a44 /_a45
827 /_a46 /_a47 /_a48 /_a49 /_a50 /_a51 /_a52 /_a53 /_a54 /_a55 /_a56
828 /_a57 /_a58 /_a59 /_a60 /_a61 /_a62 /_a63 /space /_a65 /_a66 /_a67
829 /_a68 /_a69 /_a70 /_a71 /_a72 /_a73 /bracketleft /period /less
830 /parenleft /plus /exclam /ampersand /_a81 /_a82 /_a83 /_a84 /_a85
831 /_a86 /_a87 /_a88 /_a89 /bracketright /dollar /asterisk /parenright
832 /semicolon /asciicircum /hyphen /slash /_a98 /_a99 /_a100 /_a101
833 /_a102 /_a103 /_a104 /_a105 /bar /comma /percent /underscore /greater
834 /question /_a112 /_a113 /_a114 /_a115 /_a116 /_a117 /_a118 /_a119
835 /_a120 /_a121 /colon /numbersign /at /quoteright /equal /quotedbl
836 /_a128 /a /b /c /d /e /f /g /h /i /_a138 /_a139 /_a140 /_a141 /_a142
837 /_a143 /_a144 /j /k /l /m /n /o /p /q /r /_a154 /_a155 /_a156 /_a157
838 /_a158 /_a159 /_a160 /asciitilde /s /t /u /v /w /x /y /z /_a170 /_a171
839 /_a172 /_a173 /_a174 /_a175 /_a176 /_a177 /_a178 /_a179 /_a180 /_a181
840 /_a182 /_a183 /_a184 /quoteleft /_a186 /_a187 /_a188 /_a189 /_a190
841 /_a191 /braceleft /A /B /C /D /E /F /G /H /I /_a202 /_a203 /_a204
842 /_a205 /_a206 /_a207 /braceright /J /K /L /M /N /O /P /Q /R /_a218
843 /_a219 /_a220 /_a221 /_a222 /_a223 /backslash /_a225 /S /T /U /V /W /X
844 /Y /Z /_a234 /_a235 /_a236 /_a237 /_a238 /_a239 /zero /one /two /three
845 /four /five /six /seven /eight /nine /_a250 /_a251 /_a252 /_a253
846 /_a254 /_a255@*
847 % Don't forget to end the array.@*
848 ] def}
849 @end quotation
850 @end cartouche
851
852 All entries in the encoding vector are PostScript ``names'' and
853 therefore must be prefixed with a slash. Unnamed characters such as
854 control characters are commonly named @samp{_a@var{number}}, where
855 @var{number} is the decimal offset into the character table.
856 Undefined characters are indicated by @samp{.notdef}. In the
857 @acronym{EBCDIC} example, the character at @w{position 0} in the font
858 will be named @samp{a0}; the character at @w{position 1} will be named
859 @samp{a1}; the character at @w{position 74} will be named
860 @samp{bracketleft}; the character at @w{position 129} will be named
861 @samp{a}; and so forth.
862
863 Individual characters can be mapped to an encoding either numerically
864 or by executing a @strong{glyph_name} command within a character
865 definition. For example, the following code overrides the character
866 position passed to @strong{beginchar} @w{(i.e., 123)} with whatever
867 character position the current encoding has designated for the
868 @samp{ohungarumlaut} glyph:
869
870 @display
871 @b{beginchar} (123, cap_height#-1/2pt#, cap_height#, 0);
872 @b{if} known @i{ps_output}:
873 @i{glyph_name} @t{"ohungarumlaut"};
874 @b{fi}
875 @dots{}
876 @b{endchar};
877 @end display
878
879
880 @node Restoring mfplain defaults, , Custom font encodings, Usage
881 @section Restoring @file{mfplain} defaults
882
883 @command{mf2pt1} normally redefines @strong{filldraw} as @strong{fill}
884 and @strong{unfilldraw} as @strong{unfill} because @w{Type 1} fonts
885 don't allow overlapping curves. Similarly, @command{mf2pt1} redefines
886 @strong{pencircle} as a 20-gon to coerce MetaPost into drawing it
887 using a filled instead of a stroked PostScript path.
888
889 If you know you'll be postprocessing your fonts using FontForge, which
890 can automatically convert overlapping paths to nonoverlapping paths,
891 then you can restore the original @file{mfplain.mp} definitions of
892 @strong{filldraw}, @strong{unfilldraw}, and @strong{pencircle} as
893 follows:
894
895 @display
896 @b{if} known @i{ps_output}:
897 @b{pencircle} := @i{mfplain_pencircle};
898 @b{let filldraw} := @i{mfplain_filldraw};
899 @b{let unfilldraw} := @i{mfplain_unfilldraw};
900 @b{fi}
901 @end display
902
903
904 @node Future Work, Acknowledgments, Usage, Top
905 @chapter Future Work
906
907 One avenue for future work is to enable the font designer to specify
908 @w{Type 1} font hints directly in the @MF{} font program. Hinting is
909 a way for a font designer to specify how a font should be rendered at
910 low resolutions, for example, at typical monitor resolutions. In
911 @MF{}, this is done by controlling the way that points are mapped to
912 pixel locations, using commands such as
913 @strong{define_corrected_pixels}, @strong{define_blacker_pixels}, and
914 @strong{lowres_fix}. @w{Type 1} fonts are hinted in a completely
915 different manner. @w{Type 1} hints distinguish key character
916 features, such as stems and dots, from decorations which can be
917 discarded at low resolutions. The PostScript interpreter uses that
918 information to determine how to map points to pixels. Although
919 @command{mf2pt1} employs FontForge to autohint the fonts it generates,
920 the approach is mechanical and unlikely to hint as well as a human can
921 do manually. It would be convenient for @command{mf2pt1} one day to
922 provide @MF{} commands for @strong{hstem}, @strong{vstem},
923 @strong{dotsection}, and the other @w{Type 1} hints. That way, hints
924 will no longer need to be re-added manually every time
925 @command{mf2pt1} regenerates a @w{Type 1} font.
926
927 Another future addition to @command{mf2pt1} is the addition of more
928 font encodings. The following are the encodings that @command{mf2pt1}
929 will most likely accept:
930
931 @table @code
932 @item TeXMathItalicEncoding
933 Upper- and lowercase Greek and Latin letters, old-style digits, and a
934 few symbols and accents.
935
936 @item TeXMathSymbolEncoding
937 A variety of symbols, as well as calligraphic Latin majuscules.
938
939 @item TeXMathExtensionEncoding
940 Variable-sized symbols, such as braces, integrals, and radicals.
941
942 @item AdobeExpert
943 Small caps, currency symbols, old-style digits, and various superior and
944 inferior letters and digits.
945 @end table
946
947
948 @node Acknowledgments, , Future Work, Top
949 @unnumbered Acknowledgments
950
951 Many thanks are owed to Werner Lemberg for writing the code underlying
952 the @copt{rounding} option; for introducing the @strong{glyph_name}
953 command and @code{asis} encoding vector; for providing the default
954 FontForge script listed in @ref{Additional command-line options}; for
955 fixing some code-generation bugs in @command{mf2pt1}; for finding a
956 more robust way to dump @file{mf2pt1.mem}; for directing me to the
957 overlap-removal code mentioned in @ref{Restrictions}; for supplying
958 the @emph{crossproduct}, @emph{makeline}, and @emph{is_clockwise}
959 functions used by @file{mf2pt1.mp}; for proposing the @copt{bpppix}
960 command-line option; and for suggesting numerous features and
961 improvements to @command{mf2pt1}. Thanks also go to Werner Lemberg
962 and
963 @iftex
964 @tex
965 Bogus\l{}aw
966 @end tex
967 @end iftex
968 @ifnottex
969 Boguslaw
970 @end ifnottex
971 Jackowski for updating the @strong{is_clockwise} function in
972 @file{mf2pt1.mp} to work around a bug in MetaPost which relates to the
973 @strong{turningnumber} command. Finally, thanks go to Ralf Stubner
974 for providing the T1 encoding vector and for pointing out a typo in
975 the generated font programs; to Michael Zedler for alerting me to
976 problems with @copt{encoding} and suggesting I modify that option to
977 accept PostScript @file{.enc} files; and to Michael Ummels for fixing
978 a couple of bugs that made character widths in the generated fonts
979 slightly too large.
980
981 @bye