Debian Codegraph @

texmf-dist/fonts/source/public/otibet/bzrsetup.mf

raw
1 % bzrsetup.mf: interesting and/or necessary things for bzrto's Metafont output.
2 %
3 % Copyright (C) 1992 Free Software Foundation, Inc.
4 %
5 % This program is free software; you can redistribute it and/or modify
6 % it under the terms of the GNU General Public License as published by
7 % the Free Software Foundation; either version 2, or (at your option)
8 % any later version.
9 %
10 % This program is distributed in the hope that it will be useful,
11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 % GNU General Public License for more details.
14 %
15 % You should have received a copy of the GNU General Public License
16 % along with this program; if not, write to the Free Software
17 % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19
20 % |true_design_size| must be set before this file is input. It is
21 % supposed to be the design size of the original font. If the user does
22 % not set |designsize| on the command line, we default to the following.
23 default_design_size# := 10pt#;
24 if designsize = 0: designsize := default_design_size#; fi;
25
26 % It's pointless to actually produce different TFM files for different
27 % design sizes: we have only one set of outlines, after all. So we
28 % adjust the resolution to account for different sizes, by setting
29 % |mag|. Then we reset |designsize| to the default.
30 if unknown mag: mag := 1; fi;
31 mag := mag * designsize / default_design_size#;
32
33 % So we can produce output at varying sizes, all our dimensions are
34 % output in terms of the ad hoc parameter |u|.
35 %
36 u# := default_design_size# / true_design_size#;
37
38 designsize := default_design_size#;
39
40 % Macros from page 289 of {\sl The Metafontbook} for short-circuit evaluation.
41 %
42 def cand (text q) = startif true q else: false fi enddef;
43 def cor (text q) = startif true true else: q fi enddef;
44 tertiarydef p startif true = if p: enddef;
45
46 % The proof resolution of 2601.72 pixels per inch established by plain
47 % \MF\ does not always work, because the characters might be too large
48 % (or small, for that matter) for the paper size. So, here we change
49 % the proof resolution to fit the design size of the font into
50 % |proof_size| inches. To do this, we must know the resolution of the
51 % device the proof output will be printed on; we make |proof_resolution|
52 % default to 300.
53 %
54 if unknown mode cor ((mode = proof) or (mode = smoke)):
55 % Given in inches:
56 if unknown proof_size: proof_size := 7; fi;
57
58 % Given in pixels per inch:
59 if unknown proof_resolution: proof_resolution := 300; fi;
60
61 % Set up the new mode to be the same as the old one, except for the
62 % resolution.
63 original_mode := if known mode: mode else: proof fi;
64 mode_def bzr_proof_mode =
65 if original_mode = proof:
66 proof_;
67 else:
68 smoke_;
69 fi;
70 pixels_per_inch
71 := (proof_size * proof_resolution)
72 * (72.27 / proof_resolution)
73 * (72.27 / designsize);
74 enddef;
75 mode := bzr_proof_mode;
76 fi;
77
78 % Set up the device values for this run. Since we allow a nonstandard
79 % value of |proofing| (see below), we must save its value, if it has
80 % already been assigned.
81 %
82 if (known proofing) cand (proofing > 2):
83 save_proofing := proofing;
84 fi
85
86 mode_setup;
87
88 if known save_proofing:
89 proofing := save_proofing;
90 fi;
91
92
93 % We can't define the pixel-oriented version of |u| until after
94 % |mode_setup| has been called.
95 define_pixels (u);
96
97
98 % Use a font that blends better with the \MF\ logo for the title line.
99 %
100 special "titlefont cmss8";
101
102 % If we are doing smoke proofs, put the character at its actual size on
103 % the output; if we're doing gray proofs, use a smaller font for the
104 % labels.
105 %
106 if proofing <= 1:
107 special "labelfont " & jobname;
108 extra_beginchar := extra_beginchar &
109 "makelabel.lft.nodot (decimal charcode, (w + 1in#, 0));";
110 else:
111 special "labelfont cmtt8";
112 fi;
113
114 % Produce a |makelabel| command for each |z| point in |point_list| and
115 % each suffix in |suffixes|.
116 %
117 def general_label (text point_list, suffixes) =
118 forsuffixes point_suffix = ,suffixes:
119 forsuffixes point = point_list:
120 % Unfortunately, the way in which the |str| operator formats its
121 % argument (which is an arbitrary suffix) cannot be changed, so
122 % the proofsheets end up showing "0 0" for the variable |z[0][0]|.
123 makelabel (str point.point_suffix, z.point.point_suffix);
124 endfor
125 endfor
126 enddef;
127
128 % Define our labels for the proofsheets. The person running Metafont
129 % can also see the control points on each spline, by setting
130 % |proofing>2| at the beginning. (The {\tt plain.mf} macros only
131 % distinguish between |proofing=0|, |proofing>0| and |proofing>1|, so we
132 % are not disturbing them.)
133 %
134 def proof_labels (text t) =
135 % We need to delimit the arguments here, so \MF\ knows where the
136 % second |text| argument begins. Our output uses the suffix |"s"| for
137 % startpoints of segments, and the suffixes |"c1"| and |"c2"| for
138 % control points.
139 if proofing > 1: general_label (t) (s); fi;
140 if proofing > 2: general_label (t) (c1,c2); fi;
141 enddef;
142
143
144 % We define our characters as filled outlines; page 206 of {\sl The
145 % Metafontbook} suggests disabling \MF's |autorounding| and
146 % |smoothing| features in that case.
147 %
148 autorounding := 0;
149 smoothing := 0;
150
151 % Sometimes we want to fill our paths, other times unfill them,
152 % depending on whether the winding number is positive or negative. We
153 % could be absolutely safe here, and declare |temp_path| inside a group,
154 % at every invocation of |fill_or_unfill|; but this would waste time and
155 % space to no advantage, since we know exactly what kind of \MF\
156 % programs we output, and the variable |temp_path| is not used in them.
157 %
158 % Incidentally, we need a variable in the first place only because it is more
159 % efficient to avoid evaluating long paths more than once.
160 %
161 path temp_path;
162
163 def fill_or_unfill expr p =
164 temp_path := p;
165 if turningnumber temp_path > 0: fill else: unfill fi temp_path;
166 enddef;
167
168 % Since we can assume the font fills all cycles counterclockwise
169 % (because PostScript requires this), we want to disable the
170 % |turningnumber| checking which generates the `Strange path' errors.
171 % See p.112 and p.119 of the Metafontbook.
172 %
173 % (By the way, setting |turningcheck := 0| makes Metafont always use the
174 % filling rule for positive turning number, i.e., always |fill| and
175 % never |unfill|. When would this be useful?)
176 %
177 turningcheck := 1;
178
179 % When we don't know the dimensions of the character we're defining
180 % before we define it, we have to use these to begin it:
181 def begin_no_dimen_char (expr c) =
182 begingroup
183 transform save_currenttransform;
184 save_currenttransform := currenttransform;
185 charcode:=if known c: byte c else: 0 fi;
186 charic:=0; clearxy; clearit; clearpen; scantokens extra_beginchar;
187 enddef;
188
189 def end_no_dimen_char =
190 currenttransform := save_currenttransform;
191 endchar;
192 enddef;
193
194 % When use the above to start a character, must call this before `endchar'.
195 %
196 def set_char_dimens (expr w_sharp,h_sharp,d_sharp) =
197 charwd:=w_sharp; charht:=h_sharp; chardp:=d_sharp;
198 w:=hround(charwd*hppp); h:=vround(charht*hppp); d:=vround(chardp*hppp);
199 enddef;
200
201 % Move by shifting the current transform matrix.
202 %
203 def move (expr h_amount, v_amount) =
204 currenttransform := currenttransform shifted (h_amount, v_amount);
205 enddef;
206
207 def hmove (expr amount) = move (amount, 0); enddef;
208 def vmove (expr amount) = move (0, amount); enddef;