summaryrefslogtreecommitdiff
path: root/fonts/korean/pk/lj_han/bzrsetup.mf
blob: 2f2bf1c19c7618067bebe5512600fc3e582ca840 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
% bzrsetup.mf: interesting and/or necessary things for bzrto's Metafont output.
%
% Copyright (C) 1992 Free Software Foundation, Inc.
%
% modified by Werner Lemberg 8-Nov-93
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


% |true_design_size| must be set before this file is input.  It is
% supposed to be the design size of the original font.  If the user does
% not set |designsize| on the command line, we default to the following.
default_design_size# := 10pt#;
if designsize = 0: designsize := default_design_size#; fi;

% It's pointless to actually produce different TFM files for different
% design sizes: we have only one set of outlines, after all.  So we
% adjust the resolution to account for different sizes, by setting
% |mag|.  Then we reset |designsize| to the default.
if unknown mag: mag := 1; fi;
mag := mag * designsize / default_design_size#;

% So we can produce output at varying sizes, all our dimensions are
% output in terms of the ad hoc parameter |u|.
%
u# := default_design_size# / true_design_size#;

designsize := default_design_size#;

% Macros from page 289 of {\sl The Metafontbook} for short-circuit evaluation.
%
def cand (text q) = startif true q else: false fi enddef;
def cor (text q) = startif true true else: q fi enddef;
tertiarydef p startif true = if p: enddef;

% The proof resolution of 2601.72 pixels per inch established by plain
% \MF\ does not always work, because the characters might be too large
% (or small, for that matter) for the paper size.  So, here we change
% the proof resolution to fit the design size of the font into
% |proof_size| inches.  To do this, we must know the resolution of the
% device the proof output will be printed on; we make |proof_resolution|
% default to 300.
%
if unknown mode cor ((mode = proof) or (mode = smoke)):
  % Given in inches:
  if unknown proof_size: proof_size := 7; fi;

  % Given in pixels per inch:
  if unknown proof_resolution: proof_resolution := 300; fi;

  % Set up the new mode to be the same as the old one, except for the
  % resolution.
  original_mode := if known mode: mode else: proof fi;
  mode_def bzr_proof_mode =
    if original_mode = proof:
      proof_;
    else:
      smoke_;
    fi;
    pixels_per_inch
      := (proof_size * proof_resolution)
         * (72.27 / proof_resolution)
         * (72.27 / designsize);
  enddef;
  mode := bzr_proof_mode;
fi;

% Set up the device values for this run.  Since we allow a nonstandard
% value of |proofing| (see below), we must save its value, if it has
% already been assigned.
%
if (known proofing) cand (proofing > 2):
  save_proofing := proofing;
fi

mode_setup;

if known save_proofing:
  proofing := save_proofing;
fi;


% We can't define the pixel-oriented version of |u| until after
% |mode_setup| has been called.
define_pixels (u);


% Use a font that blends better with the \MF\ logo for the title line.
%
if proofing > 0:
    special "titlefont cmss8";
fi;

% If we are doing smoke proofs, put the character at its actual size on
% the output; if we're doing gray proofs, use a smaller font for the
% labels.
%
if proofing = 1:
  special "labelfont " & jobname;
  extra_beginchar := extra_beginchar &
    "makelabel.lft.nodot (decimal charcode, (w + 1in#, 0));";
fi;
if proofing = 2:
  special "labelfont cmtt8";
fi;

% Produce a |makelabel| command for each |z| point in |point_list| and
% each suffix in |suffixes|.
%
def general_label (text point_list, suffixes) =
  forsuffixes point_suffix = ,suffixes:
    forsuffixes point = point_list:
      % Unfortunately, the way in which the |str| operator formats its
      % argument (which is an arbitrary suffix) cannot be changed, so
      % the proofsheets end up showing "0 0" for the variable |z[0][0]|.
      makelabel (str point.point_suffix, z.point.point_suffix);
    endfor
  endfor
enddef;

% Define our labels for the proofsheets.  The person running Metafont
% can also see the control points on each spline, by setting
% |proofing>2| at the beginning.  (The {\tt plain.mf} macros only
% distinguish between |proofing=0|, |proofing>0| and |proofing>1|, so we
% are not disturbing them.)
%
def proof_labels (text t) =
  % We need to delimit the arguments here, so \MF\ knows where the
  % second |text| argument begins.  Our output uses the suffix |"s"| for
  % startpoints of segments, and the suffixes |"c1"| and |"c2"| for
  % control points.
  if proofing > 1: general_label (t) (s); fi;
  if proofing > 2: general_label (t) (c1,c2); fi;
enddef;


% We define our characters as filled outlines; page 206 of {\sl The
% Metafontbook} suggests disabling \MF's |autorounding| and
% |smoothing| features in that case.
%
autorounding := 0;
smoothing := 0;

% Sometimes we want to fill our paths, other times unfill them,
% depending on whether the winding number is positive or negative.  We
% could be absolutely safe here, and declare |temp_path| inside a group,
% at every invocation of |fill_or_unfill|; but this would waste time and
% space to no advantage, since we know exactly what kind of \MF\
% programs we output, and the variable |temp_path| is not used in them.
%
% Incidentally, we need a variable in the first place only because it is more
% efficient to avoid evaluating long paths more than once.
%
path temp_path;

def fill_or_unfill expr p =
  temp_path := p;
  if turningnumber temp_path > 0: fill else: unfill fi temp_path;
enddef;

% Since we can assume the font fills all cycles counterclockwise
% (because PostScript requires this), we want to disable the
% |turningnumber| checking which generates the `Strange path' errors.
% See p.112 and p.119 of the Metafontbook.
%
% (By the way, setting |turningcheck := 0| makes Metafont always use the
% filling rule for positive turning number, i.e., always |fill| and
% never |unfill|.  When would this be useful?)
%
turningcheck := 1;

% When we don't know the dimensions of the character we're defining
% before we define it, we have to use these to begin it:
def begin_no_dimen_char (expr c) =
  begingroup
  transform save_currenttransform;
  save_currenttransform := currenttransform;
  charcode:=if known c: byte c else: 0 fi;
  charic:=0; clearxy; clearit; clearpen; scantokens extra_beginchar;
enddef;

def end_no_dimen_char =
  currenttransform := save_currenttransform;
  endchar;
enddef;

% When use the above to start a character, must call this before `endchar'.
%
def set_char_dimens (expr w_sharp,h_sharp,d_sharp) =
 charwd:=w_sharp;      charht:=h_sharp;       chardp:=d_sharp;
 w:=hround(charwd*hppp); h:=vround(charht*hppp); d:=vround(chardp*hppp);
enddef;

% Move by shifting the current transform matrix.
%
def move (expr h_amount, v_amount) =
  currenttransform := currenttransform shifted (h_amount, v_amount);
enddef;

def hmove (expr amount) = move (amount, 0); enddef;
def vmove (expr amount) = move (0, amount); enddef;