Debian Codegraph @

texmf-dist/fonts/source/public/cmbright/ebbase.mf

raw
1 % ebbase.mf
2 % [=exbase.mf, changed by Walter Schmidt, see (CMBR)]
3 %
4 % (c) Copyright 1995, 1996, 1997 J"org Knappen
5 % (c) Copyright 1990, 1992 Norbert Schwarz
6 %
7 % This file is part of EC Bright v1.0
8 %
9 % Content:
10 %
11 % The base file needed for generation of the EC Bright fonts
12
13 ebbase:=1; % if |ebbase| is known, this file has been input
14
15 ec_maj_version:=1; ec_min_version:=0; % version identification
16
17 def version_check(expr e,f)=
18 if e=ec_maj_version:
19 if f=ec_min_version:
20 message " Ok";
21 elseif: f>ec_min_version:
22 message "ec font warning: Obsolete base";
23 elseif: f<ec_min_version:
24 message "ec font warning: File from old release found";
25 fi
26 elseif: e>ec_maj_version:
27 message "ec font warning: Obsolete base";
28 elseif: e<ec_maj_version:
29 message "ec font warning: File from old release found";
30 fi
31 enddef;
32
33 let stop_eventually=relax;
34
35 % The following checks require, that |bye| is an |inner| command.
36 % This is usually set by |local.mf| or |modes.mf|, however we cannot
37 % rely on this feature, therefore we do it here again.
38
39 inner bye;
40
41 % Check for existence of |boundarychar|
42 if unknown boundarychar:
43 message "You are using out-of-date METAFONT 1.*,";
44 message "please update to METFONT 2.718 or newer.";
45 let stop_eventually=bye;
46 fi
47
48 % Check for old version of |plain.mf| (2.0 or older)
49 if known begingroup killtext whatever endgroup:
50 relax;
51 else:
52 message "You are using plain.mf 2.0 or older";
53 message "please update to plain.mf 2.71 or newer";
54 let stop_eventually=bye;
55 fi
56
57 % Check for |cmbase|
58 if known cmbase:
59 message "You are using METAFONT with cmbase preloaded,";
60 message "please use only plain METAFONT to generate the ec fonts.";
61 let stop_eventually=bye;
62 fi
63
64 stop_eventually;
65
66 boolean slitex; slitex := false; % |true| simulates behaviour of |sroman|
67 boolean one_serif; one_serif:=true; % |false| suppresses base serif on `1'
68 boolean classic_serif; classic_serif := false;
69 boolean suppress_i_dot; suppress_i_dot :=false;
70 boolean hach_sharp; hach_sharp:=false;
71 boolean classic_sharp_s; classic_sharp_s:=true; % (CMBR)
72 boolean true_mono; true_mono:=false; % |true| forces ligatures to monowidth
73 boolean knuthian_ae; knuthian_ae:=false; % |true| reproduces cm italic \ae
74 boolean fancy_thorn; fancy_thorn:=false; % |true| produces \th with fancier bulb
75 boolean is_small_cap; is_small_cap:=false;
76 tracingstats:=1; % Print statistics at the end of run
77
78 let ecchar=\; % `|ecchar|' should precede each character
79 let generate=input; % `|generate|' should follow the parameters
80
81 autorounding:=0; smoothing:=0; % we do our own rounding
82 def autorounded = interim autorounding:=2 enddef;
83
84 newinternal slant,fudge,math_spread,superness,superpull,beak_darkness;
85 boolean square_dots,hefty,serifs,
86 monospace,variant_g,low_asterisk,math_fitting;
87
88 boolean dark,dark.dark,skewed,skewed.skewed; % for fast option testing
89 dark=skewed=false; dark.dark=skewed.skewed=true;
90
91 vardef Vround primary y = y_:=vround y;
92 if y_<min_Vround: min_Vround else: y_ fi enddef;
93 newinternal y_,min_Vround;
94
95 vardef serif(suffix $,$$,@) % serif at |z$| for stroke from |z$$|
96 (expr darkness,jut) suffix modifier =
97 pickup crisp.nib; numeric bracket_height; pair downward;
98 bracket_height=if dark.modifier: 1.5 fi\\ bracket;
99 if y$<y$$: y@2=min(y$+bracket_height,y$$);
100 top y@1-slab=bot y@0+eps=tiny.bot y$; downward=z$-z$$;
101 if y@1>y@2: y@2:=y@1; fi
102 else: y@2=max(y$-bracket_height,y$$);
103 bot y@1+slab=top y@0-eps=tiny.top y$; downward=z$$-z$;
104 if y@1<y@2: y@2:=y@1; fi fi
105 y@3=y@2; z@3=whatever[z$,z$$];
106 if jut<0: z@2+penoffset downward of currentpen =
107 z$l+penoffset downward of pen_[tiny.nib]+whatever*downward;
108 lft x@0=lft x@1=tiny.lft x$l+jut;
109 if x@3<x@2+eps: x@3:=x@2+eps; fi
110 else: z@2-penoffset downward of currentpen =
111 z$r-penoffset downward of pen_[tiny.nib]+whatever*downward;
112 rt x@0=rt x@1=tiny.rt x$r+jut;
113 if x@3>x@2-eps: x@3:=x@2-eps; fi fi
114 pair corner; ypart corner=y@1; corner=z@2+whatever*downward;
115 filldraw z@2{z$-z$$}
116 ...darkness[corner,.5[z@1,z@2] ]{z@1-z@2}
117 ...{jut,0}z@1--z@0--(x$,y@0)--z@3--cycle; % the serif
118 labels (@1,@2); enddef;
119
120 def dish_serif(suffix $,$$,@)(expr left_darkness,left_jut)
121 (suffix @@)(expr right_darkness,right_jut) suffix modifier =
122 serif($,$$,@,left_darkness,-left_jut) modifier;
123 serif($,$$,@@,right_darkness,right_jut) modifier;
124 if dish>0: pickup tiny.nib; numeric dish_out,dish_in;
125 if y$<y$$: dish_out=bot y$; dish_in=dish_out+dish; let rev_=reverse;
126 else: dish_out=top y$; dish_in=dish_out-dish; let rev_=relax; fi
127 erase fill rev_
128 ((x@1,dish_out)..(x$,dish_in){right}..(x@@1,dish_out)--cycle);
129 fi enddef;
130
131 def nodish_serif(suffix $,$$,@)(expr left_darkness,left_jut)
132 (suffix @@)(expr right_darkness,right_jut) suffix modifier =
133 serif($,$$,@,left_darkness,-left_jut) modifier;
134 serif($,$$,@@,right_darkness,right_jut) modifier; enddef;
135
136 vardef sloped_serif.l(suffix $,$$,@)(expr darkness,jut,drop) =
137 pickup crisp.nib; pos@2(slab,90);
138 lft x@0=tiny.lft x$l; rt x@1=tiny.rt x$r; top y@1=tiny.top y$r;
139 lft x@2=lft x@0-jut; y@2r=y@1-drop;
140 y@0=max(y@2l-bracket,y$$)-eps;
141 if drop>0: erase fill z@1--top z@1
142 --(x@2r,top y@1)--z@2r--cycle; fi % erase excess at top
143 filldraw z@1--z@2r--z@2l{right}
144 ...darkness[(x@0,y@2l),.5[z@2l,z@0] ]{z@0-z@2l}
145 ...{down}z@0--(x@1,y@0)--cycle; % sloped serif
146 labels(@0,@1,@2); enddef;
147
148 vardef sloped_serif.r(suffix $,$$,@)(expr darkness,jut,drop) =
149 pickup crisp.nib; pos@2(slab,-90);
150 rt x@0=tiny.rt x$r; lft x@1=tiny.lft x$l; bot y@1=tiny.bot y$l;
151 rt x@2=rt x@0+jut; y@2r=y@1+drop;
152 y@0=min(y@2l+bracket,y$$)+eps;
153 if drop>0: erase fill z@1--bot z@1
154 --(x@2r,bot y@1)--z@2r--cycle; fi % erase excess at bottom
155 filldraw z@1--z@2r--z@2l{left}
156 ...darkness[(x@0,y@2l),.5[z@2l,z@0] ]{z@0-z@2l}
157 ...{up}z@0--(x@1,y@0)--cycle; % sloped serif
158 labels(@0,@1,@2); enddef;
159
160 vardef term.l(suffix $,$$)(expr d,t,s)= % ``robust'' sans-serif terminal
161 path p_; p_=z$l{d}..tension t..z$$l;
162 pair d_; d_=(x$$l-x$l,s*(y$$l-y$l));
163 if (abs angle direction 1 of p_ < abs angle d_)<>(x$l<x$$l):
164 p_:=z$l{d}..tension atleast t..{d_}z$$l; fi
165 p_ enddef;
166 vardef term.r(suffix $,$$)(expr d,t,s)=
167 path p_; p_=z$r{d}..tension t..z$$r;
168 pair d_; d_=(x$$r-x$r,s*(y$$r-y$r));
169 if (abs angle direction 1 of p_ < abs angle d_)<>(x$r<x$$r):
170 p_:=z$r{d}..tension atleast t..{d_}z$$r; fi
171 p_ enddef;
172 def rterm=reverse term enddef;
173
174 vardef arm(suffix $,$$,@)(expr darkness,jut) = % arm from |z$| to |z$$|
175 x@0=good.x(x$$r-jut); y@0=y$r;
176 if serifs: y@1=y$l; z@1=z$$l+whatever*(z$$r-z@0);
177 z@2=.5[z$l,z@1];
178 filldraw z$$l{z@1-z$$l}...darkness[z@1,.5[z@2,z$$l] ]...z@2
179 ---z$l--z$r--z@0--z$$r--cycle; % arm and beak
180 else: filldraw z$l--z$r--z@0--z$$r--cycle; fi % sans-serif arm
181 penlabels(@0,@1,@2); enddef;
182
183 def bulb(suffix $,$$,$$$) =
184 z$$$r=z$$r;
185 path_.l:=z$l{x$$r-x$r,0}...{0,y$$r-y$r}z$$l;
186 filldraw path_.l--z$$r{0,y$r-y$$r}...{x$r-x$$r,0}z$r--cycle; % link
187 path_.r:=z$$$l{0,y$r-y$$r}..z$$$r{0,y$$r-y$r}; % near-circle
188 filldraw subpath(0,xpart(path_.r intersectiontimes path_.l)) of path_.r
189 --z$$r{0,y$$r-y$r}..cycle; % bulb
190 enddef;
191
192 def v_bulb(suffix $,$$)= % |pos$| is known
193 y$$+.5curve=x_height+oo; x$$+.5curve=w-u;
194 numeric theta; theta=angle(4(x$-x$$),y$-y$$); pos$$(curve,theta+90);
195 filldraw z$$l{dir theta}..tension atleast 1 and 1..{down}z$l
196 --z$r{up}...{-dir theta}z$$r..cycle; % bulb
197 enddef;
198
199 def dot(suffix $,$$) =
200 filldraw if square_dots: (x$l,y$$l)--(x$r,y$$l)
201 --(x$r,y$$r)--(x$l,y$$r)--cycle % squarish dot
202 else: z$l...z$$l...z$r...z$$r...cycle fi % roundish dot
203 enddef;
204
205 def comma(suffix $,@)(expr dot_size,jut,depth) =
206 pickup fine.nib; pos$(dot_size,90);
207 if square_dots: pos$'(dot_size,0); z$'=z$; dot($',$); % squarish dot
208 comma_join_:=max(fine.breadth,floor .7dot_size);
209 comma_bot_:=max(fine.breadth,floor .5dot_size);
210 pos@0(comma_join_,0); pos@1(comma_join_,0);
211 pos@2(comma_bot_,0); y@0=y$; y@1=y$l; y@2=y@1-depth;
212 x@0r=x@1r=x$'r; rt x@2r=good.x(x$-eps);
213 filldraw stroke z@[email protected]@2e; % tail
214 else: pos@1(vair,90); pos@2(vair,0); pos@3(vair,-45);
215 z@1r=z$r; rt x@2r=hround(x$+.5dot_size+jut)+2eps; x@3=x$-.5u;
216 y@2=1/3[y@1,y@3]; bot y@3r=vround(y$-.5dot_size-depth);
217 y_:=ypart((z@1{right}...z@2{down}...z@3)
218 intersectiontimes (z$l{right}..{left}z$r)); if y_<0: y_:=1; fi
219 filldraw z$r{left}..subpath (0,y_) of (z$l{right}..{left}z$r)--cycle; % dot
220 filldraw stroke z@1e{right}...z@2e{down}...z@3e; fi % tail
221 penlabels(@1,@2,@3); enddef;
222
223 def ammoc(suffix $,@)(expr dot_size,jut,depth) = % reversed comma
224 pickup fine.nib; pos$(dot_size,90);
225 if square_dots: pos$'(dot_size,0); z$'=z$; dot($',$); % squarish dot
226 comma_join_:=max(fine.breadth,floor .7dot_size);
227 comma_top_:=max(fine.breadth,floor .5dot_size);
228 pos@0(comma_join_,0); pos@1(comma_join_,0);
229 pos@2(comma_top_,0); y@0=y$; y@1=y$r; y@2=y@1+depth;
230 x@0l=x@1l=x$'l; lft x@2l=good.x(x$+eps);
231 filldraw stroke z@[email protected]@2e; % tail
232 else: pos@1(vair,90); pos@2(vair,0); pos@3(vair,-45);
233 z@1l=z$l; lft x@2l=hround(x$-.5dot_size-jut)-2eps; x@3=x$+.5u;
234 y@2=1/3[y@1,y@3]; top y@3l=vround(y$+.5dot_size+depth);
235 y_:=ypart((z@1{left}...z@2{up}...z@3)
236 intersectiontimes (z$r{left}..{right}z$l)); if y_<0: y_:=1; fi
237 filldraw z$l{right}..subpath (0,y_) of (z$r{left}..{right}z$l)--cycle; % dot
238 filldraw stroke z@1e{left}...z@2e{up}...z@3e; fi % tail
239 penlabels(@1,@2,@3); enddef;
240
241 %%% @ from to %%%% temporary formatting change
242 vardef diag_in(suffix from,$)(expr sharpness)(suffix $$) =
243 pickup tiny.nib; save from_x,y_;
244 if y.from>y$: bot else: top fi\\ y_=y$;
245 (from_x,y_)=whatever[z.from,z$];
246 sharpness[z$,(from_x,y_)]{z$-z.from}
247 ...{z$$-z$}z$+sharpness*length(z$-(from_x,y_))*unitvector(z$$-z$) enddef;
248
249 vardef diag_out(suffix $)(expr sharpness)(suffix $$,to) =
250 pickup tiny.nib; save to_x,y_;
251 if y.to>y$: bot else: top fi\\ y_=y$;
252 (to_x,y_)=whatever[z$$,z.to];
253 z$$-sharpness*length(z$$-(to_x,y_))*unitvector(z$$-z$){z$$-z$}
254 ...{z.to-z$$}sharpness[z$$,(to_x,y_)] enddef;
255
256 vardef diag_end(suffix from,$)(expr sharpness_in,sharpness_out)(suffix $$,to)=
257 save from_x,to_x,y_,x_,xx_;
258 if y.from>y$: tiny.bot else: tiny.top fi\\ y_=y$; % we assume that |y$=y$$|
259 (from_x,y_)=whatever[z.from,z$]; (to_x,y_)=whatever[z$$,z.to];
260 if x$$>x$: x_=x$+sharpness_in*length(z$-(from_x,y_));
261 xx_=x$$-sharpness_out*length(z$$-(to_x,y_));
262 if xx_<x_: xx_:=x_:=.5[xx_,x_]; fi
263 else: x_=x$-sharpness_in*length(z$-(from_x,y_));
264 xx_=x$$+sharpness_out*length(z$$-(to_x,y_));
265 if xx_>x_: xx_:=x_:=.5[xx_,x_]; fi fi
266 sharpness_in[z$,(from_x,y_)]{z$-z.from}
267 ...{z$$-z$}(x_,y$)..(xx_,y$){z$$-z$}
268 ...{z.to-z$$}sharpness_out[z$$,(to_x,y_)] enddef;
269 %%% at from to %%%% restore normal formatting
270
271 vardef special_diag_end(suffix $$,$,@,@@) = % for top middle of w's
272 if x@r<=x$r: diag_end($$r,$r,1,1,@l,@@l)
273 else: z0=whatever[z$$l,z$l]=whatever[z@l,z@@l];
274 diag_end($$r,$r,1,1,$l,0)--z0 fi enddef;
275
276 def prime_points_inside(suffix $,$$) =
277 theta_:=angle(z$r-z$l);
278 penpos$'(whatever,theta_);
279 if y$$>y$: z$'=(0,pen_top) rotated theta_ + whatever[z$l,z$r];
280 theta_:=angle(z$$-z$)-90;
281 else: z$'=(0,pen_bot) rotated theta_ + whatever[z$l,z$r];
282 theta_:=angle(z$$-z$)+90; fi
283 z$'l+(pen_lft,0) rotated theta_=z$l+whatever*(z$-z$$);
284 z$'r+(pen_rt,0) rotated theta_=z$r+whatever*(z$-z$$);
285 enddef;
286
287 def ellipse_set(suffix $,@,@@,$$) = % given |z$,x@,z$$|, find |y@| and |z@@|
288 % such that the path |z${x@-x$,0}..z@{0,y@-y$}..{z$$-z@@}z@@|
289 % is consistent with an ellipse
290 % and such that the line |z@@--z$$| has a given |slope|
291 alpha_:=slope*(x@-x$); beta_:=y$$-y$-slope*(x$$-x$);
292 gamma_:=alpha_/beta_;
293 y@-y$=.5(beta_-alpha_*gamma_);
294 x@@-x$=-2gamma_*(x@-x$)/(1+gamma_*gamma_);
295 y@@-y$$=slope*(x@@-x$$) enddef;
296
297 vardef diag_ratio(expr a,b,y,c) = % assuming that $a>\vert b/y\vert$,
298 % compute the value $\alpha=(x\6{++}y)/y$ such that $ax+b\alpha=c$
299 numeric a_,b_; b_=b/y; a_=a*a-b_*b_;
300 (a*(c++y*sqrt a_)-b_*c)/a_/y enddef;
301
302 def f_stroke(suffix $,$$,@,left_serif,right_serif)(expr left_jut,right_jut)=
303 pickup tiny.nib; bot y$=0;
304 penpos@0(x$r-x$l,0); x@0l=x$l; top y@0=x_height;
305 filldraw stroke z$e--z@0e; % stem
306 pickup fine.nib; pos@0'(x$r-x$l-(hround stem_corr)+tiny,180);
307 y@0'=y@0; lft x@0'r=tiny.lft x$l;
308 penpos@1(x@0'l-x@0'r,180); x@1=x@0'; y@1+.5vair=.5[x_height,h];
309 pos@2(vair,90); top y@2r=h+oo;
310 if serifs: x@2=.6[x@1,x$$r]; (x@,y@2r)=whatever[z@2l,z@1l];
311 x@2r:=min(x@,.5[x@2,x$$r]); pos@3(hair,0); bulb(@2,@3,$$); % bulb
312 filldraw stroke z@0'e--z@1e & super_arc.e(@1,@2); % arc
313 dish_serif($,@0,left_serif,1/3,left_jut,right_serif,1/3,right_jut); % serif
314 else: x@2=.6[x@1,x$$]; y@1l:=1/3[y@1l,y@2l];
315 filldraw stroke z@0'e--z@1e & super_arc.e(@1,@2)
316 & term.e(@2,$$,right,.9,4); fi % arc and terminal
317 penlabels(@0,@1,@2); enddef;
318
319 def h_stroke(suffix $,@,@@,$$) =
320 penpos$$(x@@r-x@@l,0); x$$=x@@; bot y$$=0;
321 y@@=1/3[bar_height,x_height];
322 penpos$''(x$r-x$l,0); x$''=x$; y$''=1/8[bar_height,x_height];
323 filldraw stroke z$''e--z$e; % thicken the lower left stem
324 penpos@0(min(rt x$r-lft x$l,thin_join)-fine,180); pickup fine.nib;
325 rt x@0l=tiny.rt x$r; y@0=y$'';
326 pos@1(vair,90); pos@@'(x@@r-x@@l+tiny,0); z@@'=z@@;
327 x@1=.5[rt x@0l,rt x@@'r]; top y@1r=x_height+oo;
328 (x@,y@1l)=whatever[z@1r,z@0l]; x@1l:=x@;
329 filldraw stroke z@0e{up}...{right}z@1e
330 &{{interim superness:=hein_super; super_arc.e(@1,@@')}}; % arch
331 pickup tiny.nib; filldraw stroke z@@e--z$$e; % right stem
332 labels(@0); penlabels(@1); enddef;
333
334 def hook_out(suffix $,$$,$$$)suffix modifier= % |x$| and |x$$$| (only) are known
335 pos$(stem,0); pos$$(vair,90);
336 x$$$:=hround(x$$$+.5hair-eps)-.5hair; pos$$$(hair,180);
337 y$=1/4x_height; bot y$$l=-oo; y$$$=1/3x_height;
338 if skewed.modifier: x$$=x$+1.25u;
339 filldraw stroke z$e{-u,-x_height}...z$$e{right}...{up}z$$$e; % hook
340 else: x$$=x$+1.5u;
341 filldraw stroke z$e{down}...z$$e{right}
342 ...{x$$$-(x$+2.5u),x_height}z$$$e; fi enddef; % hook
343
344 def empty_hook_out(suffix $,$$,$$$)suffix modifier= % |x$| and |x$$$| (only) are known
345 pos$(stem,0); pos$$(vair,90);
346 x$$$:=hround(x$$$+.5hair-eps)-.5hair; pos$$$(hair,180);
347 y$=1/4x_height; bot y$$l=-oo; y$$$=1/3x_height;
348 if skewed.modifier: x$$=x$+1.25u;
349 % filldraw stroke z$e{-u,-x_height}...z$$e{right}...{up}z$$$e; % hook
350 else: x$$=x$+1.5u;
351 % filldraw stroke z$e{down}...z$$e{right}
352 % ...{x$$$-(x$+2.5u),x_height}z$$$e;
353 fi enddef; % empty_hook_out
354
355 def hook_in(suffix $,$$,$$$)suffix modifier= % |x$| and |x$$$| (only) are known
356 x$:=hround(x$-.5hair)+.5hair; pos$(hair,180);
357 pos$$(vair,90); pos$$$(stem,0);
358 y$=2/3x_height; top y$$r=x_height+oo; y$$$=3/4x_height;
359 if skewed.modifier: x$$=x$$$-1.25u;
360 filldraw stroke z$e{up}...z$$e{right}...{-u,-x_height}z$$$e; % hook
361 else: x$$=x$$$-1.5u;
362 filldraw stroke z$e{x$$$-2.5u-x$,x_height}
363 ...z$$e{right}...{down}z$$$e; fi enddef; % hook
364
365 def ital_arch(suffix $,$$,$$$) = % |z$| and |z$$$| (only) are known
366 pos$'(hair,180); z$'=z$;
367 pos$$(vair,90); pos$$$(stem,0);
368 {{interim superness := more_super; x$$=.6[x$,x$$$];
369 top y$$r=x_height+oo; y$$$=.65x_height;
370 filldraw stroke z$'e{up}...super_arc.e($$,$$$);}} enddef; % stroke
371
372 def compute_spread(expr normal_spread,big_spread)=
373 spread#:=math_spread[normal_spread,big_spread];
374 spread:=ceiling(spread#*hppp)+eps; enddef;
375
376 def v_center(expr h_sharp) =
377 .5h_sharp+math_axis#, .5h_sharp-math_axis# enddef;
378
379 def circle_points =
380 x4=x8=.5[x2,x6]; x1=x3=superness[x4,x2]; x5=x7=superness[x4,x6];
381 y2=y6=.5[y4,y8]; y1=y7=superness[y2,y8]; y3=y5=superness[y2,y4];
382 enddef;
383 def draw_circle =
384 draw z8{right}...z1{z2-z8}...z2{down}...z3{z4-z2}...z4{left}
385 ...z5{z6-z4}...z6{up}...z7{z8-z6}...cycle enddef;
386
387 def left_paren(expr min_breadth, max_breadth) =
388 pickup fine.nib; pos1(hround min_breadth,0);
389 pos2(hround max_breadth,0); pos3(hround min_breadth,0);
390 rt x1r=rt x3r=hround(w-1.25u+.5min_breadth); lft x2l=hround 1.25u;
391 top y1=h; y2=.5[y1,y3]; bot y3=1-d;
392 filldraw stroke z1e{3(x2e-x1e),y2-y1}...z2e
393 ...{3(x3e-x2e),y3-y2}z3e; % arc
394 penlabels(1,2,3); enddef;
395
396 def right_paren(expr min_breadth, max_breadth) =
397 pickup fine.nib; pos1(hround min_breadth,0);
398 pos2(hround max_breadth,0); pos3(hround min_breadth,0);
399 lft x1l=lft x3l=hround(1.25u-.5min_breadth); rt x2r=hround(w-1.25u);
400 top y1=h; y2=.5[y1,y3]; bot y3=1-d;
401 filldraw stroke z1e{3(x2e-x1e),y2-y1}...z2e
402 ...{3(x3e-x2e),y3-y2}z3e; % arc
403 penlabels(1,2,3); enddef;
404
405 def left_bracket(expr breadth,do_top,do_bot) =
406 pickup crisp.nib;
407 numeric thickness; thickness=hround breadth;
408 pos1(thickness,0); pos2(thickness,0);
409 top y1=h; bot y2=1-d; lft x1l=lft x2l=hround(2.5u-.5thickness);
410 filldraw stroke z1e--z2e; % stem
411 pos3(thickness,90); pos4(thickness,90);
412 pos5(thickness,90); pos6(thickness,90);
413 x3=x5=x1l; rt x4=rt x6=hround(w-.75u+.5thickness);
414 y3r=y4r=y1; y5l=y6l=y2;
415 if do_top: filldraw stroke z3e--z4e; fi % upper bar
416 if do_bot: filldraw stroke z5e--z6e; fi % lower bar
417 penlabels(1,2,3,4,5,6); enddef;
418
419 def right_bracket(expr breadth,do_top,do_bot) =
420 pickup crisp.nib;
421 numeric thickness; thickness=hround breadth;
422 pos1(thickness,0); pos2(thickness,0);
423 top y1=h; bot y2=1-d; rt x1r=rt x2r=hround(w-2.5u+.5thickness);
424 filldraw stroke z1e--z2e; % stem
425 pos3(thickness,90); pos4(thickness,90);
426 pos5(thickness,90); pos6(thickness,90);
427 x3=x5=x1r; lft x4=lft x6=hround(.75u-.5thickness);
428 y3r=y4r=y1; y5l=y6l=y2;
429 if do_top: filldraw stroke z3e--z4e; fi % upper bar
430 if do_bot: filldraw stroke z5e--z6e; fi % lower bar
431 penlabels(1,2,3,4,5,6); enddef;
432
433 def left_curly(expr min_breadth, max_breadth) =
434 pickup fine.nib;
435 forsuffixes $=1,1',4,4',7,7': pos$(hround min_breadth,0); endfor
436 forsuffixes $=2,3,5,6: pos$(hround max_breadth,0); endfor
437 x2=x3=x5=x6; x1=x1'=x7=x7'=w-x4=w-x4';
438 lft x4l=hround(1.5u-.5min_breadth); lft x2l=hround(.5w-.5max_breadth);
439 top y1=h; bot y7=1-d; .5[y4,y4']=.5[y1,y7]=.5[y2,y6]=.5[y3,y5];
440 y1-y2=y3-y4=(y1-y4)/4;
441 y1-y1'=y4-y4'=y7'-y7=vround(min_breadth-fine);
442 filldraw z1l{3(x2l-x1l),y2-y1}...z2l---z3l...{3(x4l-x3l),y4-y3}z4l
443 --z4'l{3(x5l-x4l),y5-y4'}...z5l---z6l...{3(x7l-x6l),y7-y6}z7l
444 --z7r--z7'r{3(x6r-x7r),y6-y7'}...z6r---z5r
445 ...{3(x4r-x5r),.5[y4,y4']-y5}.5[z4r,z4'r]{3(x3r-x4r),y3-.5[y4,y4']}
446 ...z3r---z2r...{3(x1r-x2r),y1'-y2}z1'r--z1r--cycle; % stroke
447 penlabels(1,2,3,4,5,6,7); enddef;
448
449 def right_curly(expr min_breadth, max_breadth) =
450 pickup fine.nib;
451 forsuffixes $=1,1',4,4',7,7': pos$(hround min_breadth,0); endfor
452 forsuffixes $=2,3,5,6: pos$(hround max_breadth,0); endfor
453 x2=x3=x5=x6; x1=x1'=x7=x7'=w-x4=w-x4';
454 lft x1l=hround(1.5u-.5min_breadth); lft x2l=hround(.5w-.5max_breadth);
455 top y1=h; bot y7=1-d; .5[y4,y4']=.5[y1,y7]=.5[y2,y6]=.5[y3,y5];
456 y1-y2=y3-y4=(y1-y4)/4;
457 y1-y1'=y4-y4'=y7'-y7=vround(min_breadth-fine);
458 filldraw z1r{3(x2r-x1r),y2-y1}...z2r---z3r...{3(x4r-x3r),y4-y3}z4r
459 --z4'r{3(x5r-x4r),y5-y4'}...z5r---z6r...{3(x7r-x6r),y7-y6}z7r
460 --z7l--z7'l{3(x6l-x7l),y6-y7'}...z6l---z5l
461 ...{3(x4l-x5l),.5[y4,y4']-y5}.5[z4l,z4'l]{3(x3l-x4l),y3-.5[y4,y4']}
462 ...z3l---z2l...{3(x1l-x2l),y1'-y2}z1'l--z1l--cycle; % stroke
463 penlabels(1,2,3,4,5,6,7); enddef;
464
465 def left_angle(expr breadth) =
466 pickup pencircle scaled breadth;
467 x1=x3=good.x(w-u)+eps; lft x2=hround u-eps;
468 top y1=h+eps; .5[y1,y3]=y2=good.y .5[-d+eps,h];
469 draw z1--z2--z3; % diagonals
470 labels(1,2,3); enddef;
471
472 def right_angle(expr breadth) =
473 pickup pencircle scaled breadth;
474 x1=x3=good.x u-eps; rt x2=hround(w-u)+eps;
475 top y1=h+eps; .5[y1,y3]=y2=good.y .5[-d+eps,h];
476 draw z1--z2--z3; % diagonals
477 labels(1,2,3); enddef;
478
479 % (CMBR)
480 def beginarithchar(expr c) = % ensure consistent dimensions for $+$, $-$, etc.
481 if monospace: beginchar(c,14u#,27/7u#+math_axis#,27/7u#-math_axis#);
482 % else: beginchar(c,14sym_u#,6sym_u#+math_axis#,6sym_u#-math_axis#); fi
483 else: beginchar(c,11u#,4.5u#+math_axis#,4.5u#-math_axis#); fi% (CMBR)
484 italcorr math_axis#*slant-.5u#;
485 adjust_fit(0,0); enddef;
486
487 def center_on(expr x) = if not monospace: % change width for symmetric fit
488 r:=r+2x-w; w:=2x; fi enddef;
489
490 def super_crescent(suffix i,j,k) =
491 draw z.i{x.j-x.i,0}
492 ... (.8[x.i,x.j],.8[y.j,y.i]){z.j-z.i}
493 ... z.j{0,y.k-y.i}
494 ... (.8[x.k,x.j],.8[y.j,y.k]){z.k-z.j}
495 ... z.k{x.k-x.j,0} enddef;
496
497 newinternal l,r,shrink_fit; % adjustments to spacing
498
499 def do_expansion(expr expansion_factor) =
500 forsuffixes $=u,jut,cap_jut,beak_jut,apex_corr:
501 $:=$.#*expansion_factor*hppp; endfor
502 enddef;
503
504 def normal_adjust_fit(expr left_adjustment,right_adjustment) =
505 numeric charwd_in; charwd_in=charwd;
506 l:=-hround(left_adjustment*hppp)-letter_fit;
507 interim xoffset:=-l;
508 charwd:=charwd+2letter_fit#+left_adjustment+right_adjustment;
509 r:=l+hround(charwd*hppp)-shrink_fit;
510 w:=r-hround(right_adjustment*hppp)-letter_fit;
511 do_expansion(w/(charwd_in*hppp));
512 enddef;
513
514 def mono_adjust_fit(expr left_adjustment,right_adjustment) =
515 numeric charwd_in; charwd_in=charwd;
516 numeric expansion_factor;
517 mono_charwd#=2letter_fit#
518 +expansion_factor*(charwd+left_adjustment+right_adjustment);
519 l:=-hround(left_adjustment*expansion_factor*hppp)-letter_fit;
520 interim xoffset:=-l;
521 r:=l+mono_charwd-shrink_fit;
522 w:=r-hround(right_adjustment*expansion_factor*hppp)-letter_fit;
523 charwd:=mono_charwd#; charic:=mono_charic#;
524 do_expansion(w/(charwd_in*hppp));
525 enddef;
526
527 extra_endchar:=extra_endchar&"r:=r+shrink_fit;w:=r-l;";
528
529 def ignore_math_fit(expr left_adjustment,right_adjustment) = enddef;
530 def do_math_fit(expr left_adjustment,right_adjustment) =
531 l:=l-hround(left_adjustment*hppp); interim xoffset:=-l;
532 charwd:=charwd+left_adjustment+right_adjustment;
533 r:=l+hround(charwd*hppp)-shrink_fit;
534 charic:=charic-right_adjustment;
535 if charic<0: charic:=0; fi enddef;
536 def zero_width = charwd:=0; r:=l-shrink_fit enddef;
537 def change_width = if not monospace: % change width by $\pm1$
538 if r+shrink_fit-l=floor(charwd*hppp): w:=w+1; r:=r+1;
539 else: w:=w-1; r:=r-1; fi fi enddef;
540 def padded expr del_sharp =
541 charht:=charht+del_sharp; chardp:=chardp+del_sharp enddef;
542
543 def font_setup =
544 if monospace: let adjust_fit=mono_adjust_fit;
545 if true_mono: let normal_adjust_fit=mono_adjust_fit; fi
546 def mfudged=fudged enddef;
547 mono_charic#:=body_height#*slant;
548 if mono_charic#<0: mono_charic#:=0; fi
549 mono_charwd#:=9u#; define_whole_pixels(mono_charwd);
550 else: let adjust_fit=normal_adjust_fit;
551 def mfudged= enddef; fi
552 if math_fitting: let math_fit=do_math_fit
553 else: let math_fit=ignore_math_fit fi;
554 define_pixels(u,width_adj,serif_fit,cap_serif_fit,jut,cap_jut,beak,
555 bar_height,dish,bracket,beak_jut,stem_corr,vair_corr,apex_corr,sym_u);%(CMBR)
556 define_blacker_pixels(notch_cut,cap_notch_cut);
557 forsuffixes $=notch_cut,cap_notch_cut: if $<3: $:=3; fi endfor
558 define_whole_pixels(letter_fit,fine,crisp,tiny);
559 define_whole_vertical_pixels(body_height,asc_height,
560 cap_height,acc_height,fig_height,x_height,comma_depth,desc_depth,serif_drop,
561 sym_height);% (CMBR)
562 define_whole_blacker_pixels(thin_join,hair,stem,curve,flare,
563 dot_size,cap_hair,cap_stem,cap_curve);
564 define_whole_vertical_blacker_pixels(vair,bar,slab,cap_bar,cap_band);
565 define_corrected_pixels(o,apex_o);
566 forsuffixes $=hair,stem,cap_stem:
567 fudged$.#:=fudge*$.#; fudged$:=hround(fudged$.#*hppp+blacker);
568 forever: exitif fudged$>.9fudge*$; fudged$:=fudged$+1; endfor endfor
569 rule_thickness:=ceiling(rule_thickness#*hppp);
570 heavy_rule_thickness:=ceiling(3rule_thickness#*hppp);
571 oo:=vround(.5o#*hppp*o_correction)+eps;
572 apex_oo:=vround(.5apex_o#*hppp*o_correction)+eps;
573 lowres_fix(stem,curve,flare) 1.3;
574 lowres_fix(stem,curve) 1.2;
575 lowres_fix(cap_stem,cap_curve) 1.2;
576 lowres_fix(hair,cap_hair) 1.2;
577 lowres_fix(cap_band,cap_bar,bar,slab) 1.2;
578 stem':=hround(stem-stem_corr); cap_stem':=hround(cap_stem-stem_corr);
579 vair':=vround(vair+vair_corr);
580 vstem:=vround .8[vair,stem]; cap_vstem:=vround .8[vair,cap_stem];
581 ess:=(ess#/stem#)*stem; cap_ess:=(cap_ess#/cap_stem#)*cap_stem;
582 dw:=(curve#-stem#)*hppp; bold:=curve#*hppp+blacker;
583 dh#:=.6designsize;
584 stem_shift#:=if serifs: 2stem_corr# else: 0 fi;
585 more_super:=max(superness,sqrt .77superness);
586 hein_super:=max(superness,sqrt .81225258superness); % that's $2^{-.3}$
587 clear_pen_memory;
588 if fine=0: fine:=1; fi
589 forsuffixes $=fine,crisp,tiny:
590 %%% fine $ %%%% temporary formatting convention for MFT
591 if $>fudged.hair: $:=fudged.hair; fi
592 $.breadth:=$;
593 pickup if $=0: nullpen else: pencircle scaled $; $:=$-eps fi;
594 $.nib:=savepen; breadth_[$.nib]:=$;
595 forsuffixes $$=lft,rt,top,bot: shiftdef($.$$,$$ 0); endfor endfor
596 %%% @ $ %%%% restore ordinary formatting for $
597 min_Vround:=max(fine.breadth,crisp.breadth,tiny.breadth);
598 if min_Vround<vround min_Vround: min_Vround:=vround min_Vround; fi
599 if flare<vround flare: flare:=vround flare; fi
600 forsuffixes $=vair,bar,slab,cap_bar,cap_band,vair',vstem,cap_vstem,bold:
601 if $<min_Vround: $:=min_Vround; fi endfor
602 pickup pencircle scaled min(hair,vair); extra_rule.nib :=savepen;
603 pickup pencircle scaled rule_thickness; rule.nib:=savepen;
604 math_axis:=good.y(math_axis#*hppp);
605 pickup pencircle scaled if hefty:(.6[vair,fudged.hair]) else:fudged.hair fi;
606 light_rule.nib:=savepen;
607 currenttransform:=identity slanted slant
608 yscaled aspect_ratio scaled granularity;
609 if currenttransform=identity: let t_=relax
610 else: def t_ = transformed currenttransform enddef fi;
611 numeric paren_depth#; .5[body_height#,-paren_depth#]=math_axis#;
612 numeric asc_depth#; .5[asc_height#,-asc_depth#]=math_axis#;
613 body_depth:=desc_depth+body_height-asc_height;
614 shrink_fit:=1+hround(2letter_fit#*hppp)-2letter_fit;
615 if not string mode: if mode<=smoke: shrink_fit:=0; fi fi
616 enddef;
617
618 def shiftdef(suffix $)(expr delta) =
619 vardef $ primary x = x+delta enddef enddef;
620
621 def makebox(text rule) =
622 for y=0,(cap_height+acc_height),
623 asc_height,body_height,x_height,bar_height,-desc_depth,-body_depth:
624 rule((l,y)t_,(r,y)t_); endfor % horizontals
625
626 for y=-3.5pt,8.5pt,(x_height+acc_height):
627 rule((l-4pt,y)t_,(l-2pt,y)t_); endfor
628 for x=l,r: rule((x,-body_depth)t_,(x,body_height)t_); endfor % verticals
629 for x=u*(1+floor(l/u)) step u until r-1:
630 rule((x,-body_depth)t_,(x,body_height)t_); endfor % more verticals
631
632 for x=0.5w:
633 rule((x,-body_depth-1pt)t_,(x,-body_depth-1.5pt)t_);
634 rule((x,cap_height+acc_height+1pt)t_,(x,cap_height+acc_height+1.5pt)t_);
635 endfor
636 if charic<>0:
637 rule((r+charic*pt,h.o_),(r+charic*pt,.5h.o_)); fi % italic correction
638 enddef;
639 def maketicks(text rule) =
640 for y=0,h.o_,-d.o_:
641 rule((l,y),(l+10,y)); rule((r-10,y),(r,y)); endfor % horizontals
642 for x=l,r:
643 rule((x,10-d.o_),(x,-d.o_)); rule((x,h.o_-10),(x,h.o_)); endfor % verticals
644 if charic<>0:
645 rule((r+charic*pt,h.o_-10),(r+charic*pt,h.o_)); fi % italic correction
646 enddef;
647 rulepen:=pensquare;
648
649 vardef stroke text t =
650 forsuffixes e = l,r: path_.e:=t; endfor
651 if cycle path_.l:
652 errmessage "Beware: `stroke' isn't intended for cycles"; fi
653 path_.l -- reverse path_.r -- cycle enddef;
654
655 vardef circ_stroke text t =
656 forsuffixes e = l,r: path_.e:=t; endfor
657 if cycle path_.l:
658 errmessage "Beware: `stroke' isn't intended for cycles"; fi
659 path_.l -- reverse path_.r .. cycle enddef;
660
661 vardef super_arc.r(suffix $,$$) = % outside of super-ellipse
662 pair center,corner;
663 if y$=y$r: center=(x$$r,y$r); corner=(x$r,y$$r);
664 else: center=(x$r,y$$r); corner=(x$$r,y$r); fi
665 z$.r{corner-z$.r}...superness[center,corner]{z$$.r-z$.r}
666 ...{z$$.r-corner}z$$.r enddef;
667
668 vardef super_arc.l(suffix $,$$) = % inside of super-ellipse
669 pair center,corner;
670 if y$=y$r: center=(x$$l,y$l); corner=(x$l,y$$l);
671 else: center=(x$l,y$$l); corner=(x$$l,y$l); fi
672 z$l{corner-z$l}...superness[center,corner]{z$$l-z$l}
673 ...{z$$l-corner}z$$l enddef;
674
675 vardef pulled_super_arc.r(suffix $,$$)(expr superpull) =
676 pair center,corner;
677 if y$=y$r: center=(x$$r,y$r); corner=(x$r,y$$r);
678 else: center=(x$r,y$$r); corner=(x$$r,y$r); fi
679 z$r{corner-z$r}...superness[center,corner]{z$$r-z$r}
680 ...{z$$r-corner}z$$r enddef;
681
682 vardef pulled_super_arc.l(suffix $,$$)(expr superpull) =
683 pair center,corner,outer_point;
684 if y$=y$r: center=(x$$l,y$l); corner=(x$l,y$$l);
685 outer_point=superness[(x$$r,y$r),(x$r,y$$r)];
686 else: center=(x$l,y$$l); corner=(x$$l,y$l);
687 outer_point=superness[(x$r,y$$r),(x$$r,y$r)]; fi
688 z$l{corner-z$l}
689 ...superpull[superness[center,corner],outer_point]{z$$l-z$l}
690 ...{z$$l-corner}z$$l enddef;
691
692 vardef pulled_arc@#(suffix $,$$) =
693 pulled_super_arc@#($,$$)(superpull) enddef;
694
695 vardef serif_arc(suffix $,$$) =
696 z${x$$-x$,0}...(.75[x$,x$$],.25[y$,y$$]){z$$-z$}...{0,y$$-y$}z$$ enddef;
697
698 vardef penpos@#(expr b,d) =
699 if known b: if b<=0:
700 errmessage "bad penpos (width is negative)"; fi fi
701 (x@#r-x@#l,y@#r-y@#l)=(b,0) rotated d;
702 x@#=.5(x@#l+x@#r); y@#=.5(y@#l+y@#r) enddef;
703
704 newinternal currentbreadth;
705 vardef pos@#(expr b,d) =
706 if known b: if b<=currentbreadth:
707 errmessage "bad pos (breadth of current pen wider than pos width)"; fi fi
708 (x@#r-x@#l,y@#r-y@#l)=(b-currentbreadth,0) rotated d;
709 x@#=.5(x@#l+x@#r); y@#=.5(y@#l+y@#r) enddef;
710 def numeric_pickup_ primary q =
711 currentpen:=pen_[q];
712 pen_lft:=pen_lft_[q]; pen_rt:=pen_rt_[q];
713 pen_top:=pen_top_[q]; pen_bot:=pen_bot_[q];
714 currentpen_path:=pen_path_[q];
715 if known breadth_[q]: currentbreadth:=breadth_[q]; fi enddef;
716
717 vardef ic# = charic enddef;
718 vardef h# = charht enddef;
719 vardef w# = charwd enddef;
720 vardef d# = chardp enddef;
721
722 let {{=begingroup; let }}=endgroup;
723 def .... = .. tension atleast .9 .. enddef;
724 def less_tense = save ...; let ...=.... enddef;
725 def ?? = hide(showvariable x,y) enddef;
726
727 let semi_ =;; let colon_ = :; let endchar_ = endchar;
728 def iff expr b = if b:let next_=use_it else:let next_=lose_it fi; next_ enddef;
729 def use_it = let : = restore_colon; enddef;
730 def restore_colon = let : = colon_; enddef;
731 def lose_it = let endchar=fi; inner ecchar; let ;=fix_ semi_ if false enddef;
732 def fix_=let ;=semi_; let endchar=endchar_; outer ecchar; enddef;
733 def always_iff = let : = endgroup; killboolean enddef;
734 def killboolean text t = use_it enddef;
735 outer ecchar;
736
737 %%% fine hi higher
738 % |higher| is a counterpart to |lower| (see the file excsc.mf),
739 % |hi| facilitates using higher values (which are reference points in
740 % the floating world of CM fonts)
741 def hi = if is_small_cap: higher fi\\ enddef;
742
743 %
744 % special routines for accenting
745 %
746 vardef uppercase_hat
747 (expr x_center,y_move,hat_zero,hat_one,hat_two,hat_three,hat_four) =
748 if serifs:
749 pickup crisp.nib;
750 pos[hat_two](.5[vair,curve],90);
751 top y[hat_two]r=cap_accent_height+oo;
752 x[hat_two]=good.x x_center; % optically centered
753 x[hat_one]=good.x x[hat_two]-2.25u if monospace: /expansion_factor fi ;
754 x[hat_three]=2x[hat_two]-x[hat_one];
755 % |accent_gap| is defined by the acute accent, it is known when needed
756 y[hat_one]=y[hat_three] = accent_gap + cap_height;
757 pos[hat_one](hair,angle(z[hat_two]-z[hat_one])+90);
758 pos[hat_three](hair,angle(z[hat_three]-z[hat_two])+90);
759 filldraw stroke z[hat_one]e--z[hat_two]e--z[hat_three]e; % diagonals
760 else:
761 pickup fine.nib;
762 pos[hat_one](vair,0);
763 pos[hat_three](vair,0);
764 pos[hat_two](stem,0);
765 top y[hat_two]=cap_accent_height+oo;
766 x[hat_two]=good.x x_center; % optically centered
767 x[hat_one]=good.x x[hat_two]-2.25u if monospace: /expansion_factor fi ;
768 x[hat_three]=2x[hat_two]-x[hat_one];
769 % |accent_gap| is defined by the acute accent, it is known when needed
770 bot y[hat_one]=bot y[hat_three]=.5accent_gap + cap_height;
771 z[hat_zero]=whatever[z[hat_one]r,z[hat_two]r]=
772 whatever[z[hat_two]l,z[hat_three]l];
773 y[hat_four]l=y[hat_four]r=y[hat_two];
774 x[hat_four]l=good.x .2[x[hat_two]l,x[hat_two]];
775 x[hat_four]r=w-x[hat_four]l;
776 filldraw z[hat_four]l--z[hat_one]l--z[hat_one]r--
777 z[hat_zero]--z[hat_three]l--
778 z[hat_three]r--z[hat_four]r--cycle; fi % diagonals
779 enddef;
780 %
781 vardef lowercase_hat
782 (expr x_center,y_move,hat_zero,hat_one,hat_two,hat_three,hat_four) =
783 if serifs:
784 pickup crisp.nib;
785 pos[hat_two](.5[vair,curve],90);
786 top y[hat_two]r=h+y_move;
787 x[hat_two]=good.x x_center; % optically centered
788 x[hat_one]=good.x x[hat_two]-2.25u if monospace: /expansion_factor fi ;
789 x[hat_three]=2x[hat_two]-x[hat_one];
790 y[hat_one]=y[hat_three] =
791 max(y[hat_two]-0.5(min(asc_height,2x_height)-x_height),
792 1/6[x_height,h]);
793 pos[hat_one](hair,angle(z[hat_two]-z[hat_one])+90);
794 pos[hat_three](hair,angle(z[hat_three]-z[hat_two])+90);
795 filldraw stroke z[hat_one]e--z[hat_two]e--z[hat_three]e; % diagonals
796 else:
797 pickup fine.nib;
798 pos[hat_one](vair,0);
799 pos[hat_three](vair,0);
800 pos[hat_two](stem,0);
801 top y[hat_two]=h+y_move;
802 x[hat_two]=good.x x_center; % optically centered
803 x[hat_one]=good.x x[hat_two]-2.25u if monospace: /expansion_factor fi ;
804 x[hat_three]=2x[hat_two]-x[hat_one];
805 bot y[hat_one]=bot y[hat_three]=vround (2/3[h,x_height]-eps);
806 % same slope as in the acute accent
807 z[hat_zero]=whatever[z[hat_one]r,z[hat_two]r]=
808 whatever[z[hat_two]l,z[hat_three]l];
809 y[hat_four]l=y[hat_four]r=y[hat_two];
810 x[hat_four]l=good.x .2[x[hat_two]l,x[hat_two]];
811 x[hat_four]r=w-x[hat_four]l;
812 filldraw z[hat_four]l--z[hat_one]l--z[hat_one]r--
813 z[hat_zero]--z[hat_three]l--
814 z[hat_three]r--z[hat_four]r--cycle; fi % diagonals
815 enddef;
816 %
817 %
818 vardef lowercase_tilde(expr x_move,y_move,tilde_one,tilde_two,tilde_three,
819 tilde_four,tilde_five)=
820 h':=min(asc_height,10/7x_height+.5dot_size);
821 if serifs: numeric theta;
822 theta=angle(1/6(
823 6u if monospace: /expansion_factor fi-vair),
824 1/4(h'-x_height));
825 pickup crisp.nib;
826 numeric mid_width; mid_width=.4[vair,stem];
827 pos[tilde_one](vair,theta+90);
828 pos[tilde_two](vair,theta+90);
829 pos[tilde_three](vair,theta+90);
830 pos[tilde_four](vair,theta+90);
831 z[tilde_two]-z[tilde_one]=
832 z[tilde_four]-z[tilde_three]=(mid_width-crisp)*dir theta;
833 lft x[tilde_one]r=hround(x_move+0.5w-3u if monospace: /expansion_factor fi);
834 rt x[tilde_four]l=hround(x_move+0.5w+3u if monospace: /expansion_factor fi);
835 top y[tilde_four]r=h';
836 pair delta;
837 ypart delta=3(y[tilde_three]l-y[tilde_one]l);
838 delta=whatever*dir theta;
839 bot y[tilde_one]l=vround(bot y[tilde_one]l+
840 min(2/3[x_height,h'],y[tilde_three]l-.25vair)-top y[tilde_one]r);
841 filldraw z[tilde_one]l..
842 controls(z[tilde_one]l+
843 delta)and(z[tilde_three]l-delta)..z[tilde_three]l..z[tilde_four]l
844 --z[tilde_four]r..
845 controls(z[tilde_four]r-delta)and(z[tilde_two]r+delta)..
846 z[tilde_two]r..z[tilde_one]r--cycle; % stroke
847 else:
848 pickup fine.nib;
849 pos[tilde_one](vair,180);
850 pos[tilde_two](vair,90);
851 pos[tilde_three](.5[vair,slab],90);
852 pos[tilde_four](vair,90);
853 pos[tilde_five](vair,180);
854 lft x[tilde_one]r=hround (x_move + 0.5w-3u);
855 rt x[tilde_five]l=hround (x_move + 0.5w+3u);
856 x[tilde_two]-x[tilde_one]=
857 x[tilde_three]-x[tilde_two]=
858 x[tilde_four]-x[tilde_three]=x[tilde_five]-x[tilde_four];
859 bot y[tilde_one]=bot y[tilde_four]l=y_move+vround(.75[x_height,h]-vair);
860 top y[tilde_two]r=top y[tilde_five]=h+y_move;
861 y[tilde_three]=.5[y[tilde_two],y[tilde_four]];
862 filldraw stroke
863 z[tilde_one]e{up}...
864 z[tilde_two]e{right}..
865 z[tilde_three]e..
866 {right}z[tilde_four]e...{up}z[tilde_five]e; fi % stroke
867 enddef;
868
869 %
870 vardef uppercase_tilde(expr x_move,y_move,tilde_one,tilde_two,tilde_three,
871 tilde_four,tilde_five)=
872 if serifs: numeric theta;
873 theta=angle(1/8(7u if monospace: /expansion_factor fi-vair),1/4acc_height);
874 pickup crisp.nib;
875 numeric mid_width; mid_width=.4[vair,stem];
876 pos[tilde_one](vair,theta+90);
877 pos[tilde_two](vair,theta+90);
878 pos[tilde_three](vair,theta+90);
879 pos[tilde_four](vair,theta+90);
880 z[tilde_two]-z[tilde_one]=
881 z[tilde_four]-z[tilde_three]=(mid_width-crisp)*dir theta;
882 lft x[tilde_one]r=hround(x_move+0.5w-3.5u if monospace: /expansion_factor fi);
883 rt x[tilde_four]l=hround(x_move+0.5w+3.5u if monospace: /expansion_factor fi);
884 top y[tilde_four]r=h;
885 % |accent_gap| is defined by the acute accent, it is known when needed
886 % bot y[tilde_one]l=accent_gap+cap_height;
887 bot y[tilde_one]l=vround(bot y[tilde_one]l
888 +min(2/3[cap_height,cap_accent_height],y[tilde_three]l-.25vair)
889 -top y[tilde_one]r);
890 pair delta;
891 ypart delta=3(y[tilde_three]l-y[tilde_one]l);
892 delta=whatever*dir theta;
893 filldraw z[tilde_one]l..
894 controls(z[tilde_one]l+
895 delta)and(z[tilde_three]l-delta)..z[tilde_three]l..z[tilde_four]l
896 --z[tilde_four]r..
897 controls(z[tilde_four]r-delta)and(z[tilde_two]r+delta)..
898 z[tilde_two]r..z[tilde_one]r--cycle; % stroke
899 else:
900 pickup fine.nib;
901 pos[tilde_one](vair,180);
902 pos[tilde_two](vair,90);
903 pos[tilde_three](.5[vair,slab],90);
904 pos[tilde_four](vair,90);
905 pos[tilde_five](vair,180);
906 lft x[tilde_one]r=w-rt x[tilde_five]l=hround 1.5u+0.5(w-9u);
907 x[tilde_two]-x[tilde_one]=
908 x[tilde_three]-x[tilde_two]=
909 x[tilde_four]-x[tilde_three]=x[tilde_five]-x[tilde_four];
910 % |accent_gap| is defined by the acute accent, it is known when needed
911 bot y[tilde_one]=bot y[tilde_four]l=cap_height+.5accent_gap;
912 top y[tilde_two]r=top y[tilde_five]=h;
913 y[tilde_three]=.5[y[tilde_two],y[tilde_four]];
914 filldraw stroke
915 z[tilde_one]e{up}...
916 z[tilde_two]e{right}..
917 z[tilde_three]e..
918 {right}z[tilde_four]e...{up}z[tilde_five]e; fi % stroke
919 enddef;
920 %
921 %
922 %
923 vardef lowercase_umlaut(expr x_move,y_move,umlaut_one,umlaut_two,
924 umlaut_three,umlaut_four) =
925 % do not accumulate rounding errors and use always the same value:
926 numeric dot_dist; dot_dist:=round(3.5u); % (CMBR)
927 pickup tiny.nib;
928 pos[umlaut_one](udot_diam,0);
929 pos[umlaut_two](udot_diam,90);
930 x[umlaut_one]=x[umlaut_two]=x_move+.5w-0.5dot_dist %(CMBR)
931 if monospace:/expansion_factor fi ;
932 top y[umlaut_two]r=lc_trema_height;
933 y[umlaut_one]=y_move+.5[y[umlaut_two]l,y[umlaut_two]r];
934 dot([umlaut_one],[umlaut_two]); % left dot
935 pos[umlaut_three](udot_diam,0);
936 penpos[umlaut_four](y[umlaut_two]r-y[umlaut_two]l,90);
937 y[umlaut_three]=y[umlaut_four]=y[umlaut_one];
938 x[umlaut_three]=x[umlaut_four]=x[umlaut_one]
939 % +3.5u if monospace: /expansion_factor fi ;
940 +dot_dist if monospace: /expansion_factor fi ; % (CMBR)
941 dot([umlaut_three],[umlaut_four]); % right dot
942 enddef;
943 %
944 vardef uppercase_umlaut(expr x_move,y_move,umlaut_one,umlaut_two,
945 umlaut_three,umlaut_four) =
946 numeric dot_dist; dot_dist:=round(3.5u); %(CMBR)
947 pickup tiny.nib;
948 pos[umlaut_one](udot_diam,0);
949 pos[umlaut_two](udot_diam,90);
950 x[umlaut_one]=x[umlaut_two]=x_move+.5w-0.5dot_dist %(CMBR)
951 if monospace:/expansion_factor fi ;
952 top y[umlaut_two]r=vround(cap_height+dot_height#*hppp);
953 y[umlaut_one]=y_move+.5[y[umlaut_two]l,y[umlaut_two]r];
954 dot([umlaut_one],[umlaut_two]); % left dot
955 pos[umlaut_three](udot_diam,0);
956 penpos[umlaut_four](y[umlaut_two]r-y[umlaut_two]l,90);
957 y[umlaut_three]=y[umlaut_four]=y[umlaut_one];
958 x[umlaut_three]=x[umlaut_four]=x[umlaut_one]
959 % +3.5u if monospace: /expansion_factor fi ;
960 +dot_dist if monospace: /expansion_factor fi ; % (CMBR)
961 dot([umlaut_three],[umlaut_four]); % right dot
962 enddef;
963 %
964 %
965 vardef lowercase_circle(expr
966 x_center,y_bottom,circ_one,circ_two,circ_three,circ_four)=
967 numeric circ_hair,circ_vair;
968 circ_hair=hround min(hair,u if monospace: /expansion_factor fi +.5);
969 circ_vair=vround min(vair,(h-x_height)/6+.5);
970 penpos[circ_one](circ_vair,90); penpos[circ_three](circ_vair,-90);
971 penpos[circ_two](circ_hair,180); penpos[circ_four](circ_hair,0);
972 x[circ_one]=x[circ_three]=x_center; %
973 x[circ_two]r=hround(x[circ_one]-1.5u-.5circ_hair);
974 x[circ_four]r=hround(x[circ_one]+1.5u+.5circ_hair);
975 y[circ_one]r=h+apex_o;
976 y[circ_two]=y[circ_four]=.5[y[circ_one],y[circ_three]];
977 y[circ_three]l=vround y_bottom; % (1/3[x_height,h]+apex_o);
978 penstroke pulled_arc.e([circ_one],[circ_two])
979 & pulled_arc.e([circ_two],[circ_three])
980 & pulled_arc.e([circ_three],[circ_four])
981 & pulled_arc.e([circ_four],[circ_one]) & cycle; % bowl
982 enddef;
983 %
984 vardef uppercase_circle(expr
985 x_center,y_bottom,circ_one,circ_two,circ_three,circ_four)=
986 numeric circ_hair,circ_vair;
987 circ_hair=hround min(hair,u if monospace: /expansion_factor fi +.5);
988 circ_vair=vround vair; % min(vair,(h-x_height)/6+.5);
989 penpos[circ_one](circ_vair,90); penpos[circ_three](circ_vair,-90);
990 penpos[circ_two](circ_hair,180); penpos[circ_four](circ_hair,0);
991 x[circ_one]=x[circ_three]=x_center; % .5w;
992 x[circ_two]r
993 = hround(x[circ_one]-1.5u if monospace: /expansion_factor fi -.5circ_hair);
994 x[circ_four]r
995 = hround(x[circ_one]+1.5u if monospace: /expansion_factor fi +.5circ_hair);
996 y[circ_one]r=cap_height + acc_height+apex_o;
997 y[circ_two]=y[circ_four]=.5[y[circ_one],y[circ_three]];
998 y[circ_three]l=vround y_bottom; % (1/3[x_height,h]+apex_o);
999 penstroke pulled_arc.e([circ_one],[circ_two])
1000 & pulled_arc.e([circ_two],[circ_three])
1001 & pulled_arc.e([circ_three],[circ_four])
1002 & pulled_arc.e([circ_four],[circ_one]) & cycle; % bowl
1003 enddef;
1004 %
1005 %
1006 vardef lowercase_cedilla (expr x_center,y_move,
1007 cedi_one,cedi_two,cedi_three,cedi_four,cedi_five) =
1008 x[cedi_one]=x_center; % .5w+.5u;
1009 if serifs:
1010 pickup crisp.nib;
1011 pos[cedi_one](stem,0);
1012 pos[cedi_two](stem,0);
1013 pos[cedi_three](vair,90);
1014 pos[cedi_four](stem,0);
1015 pos[cedi_five](vair,-90);
1016 x[cedi_one]=x[cedi_two];
1017 z[cedi_three]l=z[cedi_two]l;
1018 x[cedi_four]=x[cedi_two]+1.5u;
1019 x[cedi_five]=x[cedi_three]-1.5u;
1020 bot y[cedi_one]=0;
1021 bot y[cedi_two]=-vround 2/7d-o;
1022 y[cedi_four]=.5[y[cedi_three],y[cedi_five]];
1023 bot y[cedi_five]=-d-o;
1024 filldraw stroke z[cedi_one]e--z[cedi_two]e; % stem
1025 filldraw stroke z[cedi_three]e{right}...
1026 z[cedi_four]e{down}...{left}z[cedi_five]e; % hook
1027 else: pickup fine.nib; pos[cedi_one](vair,0); top y[cedi_one]=-o-2;
1028 pos[cedi_two](.5[vair,stem],0);
1029 bot y[cedi_two]=-d-o; x[cedi_two]=x[cedi_one]-1.25u;
1030 filldraw stroke z[cedi_one]e--z[cedi_two]e; fi % diagonal
1031 enddef;
1032 %
1033 vardef uppercase_cedilla(expr x_center,y_move,
1034 cedi_one,cedi_two,cedi_three,cedi_four,cedi_five) =
1035 x[cedi_one]=x_center;;
1036 if serifs:
1037 pickup crisp.nib;
1038 pos[cedi_one](stem,0);
1039 pos[cedi_two](stem,0);
1040 pos[cedi_three](vair,90);
1041 pos[cedi_four](stem,0);
1042 pos[cedi_five](vair,-90);
1043 x[cedi_one]=x[cedi_two];
1044 z[cedi_three]l=z[cedi_two]l;
1045 x[cedi_four]=x[cedi_two]+1.5u if monospace: /expansion_factor fi;
1046 x[cedi_five]=x[cedi_three]-1.5u if monospace: /expansion_factor fi;
1047 top y[cedi_one]=y_move;
1048 bot y[cedi_two]=-vround 2/7d-o;
1049 y[cedi_four]=.5[y[cedi_three],y[cedi_five]];
1050 bot y[cedi_five]=-d-o;
1051 filldraw stroke z[cedi_one]e--z[cedi_two]e; % stem
1052 filldraw stroke z[cedi_three]e{right}...
1053 z[cedi_four]e{down}...{left}z[cedi_five]e; % hook
1054 else: pickup fine.nib; pos[cedi_one](vair,0);
1055 top y[cedi_one]=-o-2;
1056 pos[cedi_two](.5[vair,stem],0);
1057 bot y[cedi_two]=-d-o; x[cedi_two] =
1058 x[cedi_one]-1.25u if monospace: /expansion_factor fi;
1059 filldraw stroke z[cedi_one]e--z[cedi_two]e; fi % diagonal
1060 enddef;
1061 %
1062 %
1063 vardef lowercase_breve(expr x_center,y_move,breve_one,breve_two,breve_three)=
1064 pickup crisp.nib; pos[breve_one](vair,-180);
1065 pos[breve_three](vair,0);
1066 top y[breve_one]=top y[breve_three]=h;
1067 x[breve_two]=x_center;
1068 lft x[breve_one]r=hround(x[breve_two]-2.5u
1069 if monospace: /expansion_factor fi -0.5vair);
1070 rt x[breve_three]r=hround(x[breve_two]+2.5u
1071 if monospace: /expansion_factor fi +0.5vair);
1072 numeric mid_thickness; mid_thickness=vround 1/3[vair,stem];
1073 pos[breve_two](mid_thickness,-90);
1074 bot y[breve_two]r=
1075 vround max(x_height+o+tiny,1/3[x_height,h]+o-.5mid_thickness);
1076 filldraw stroke z[breve_one]e{down}...
1077 z[breve_two]e{right}...{up}z[breve_three]e; % stroke
1078 enddef;
1079 %
1080 vardef uppercase_breve (expr x_center,y_move,breve_one,
1081 breve_two,breve_three)=
1082 pickup crisp.nib; pos[breve_one](vair,-180);
1083 pos[breve_three](vair,0);
1084 top y[breve_one]=top y[breve_three]=cap_height + acc_height;
1085 x[breve_two]=hround x_center;
1086 x[breve_two]-rt x[breve_one]l
1087 =(lft x[breve_three]l)-x[breve_two]
1088 =hround (2.5u if monospace: /expansion_factor fi -.5vair);
1089 numeric mid_thickness;
1090 mid_thickness=vround min(1/3[vair,stem],.5acc_height);
1091 pos[breve_two](mid_thickness,-90);
1092 % |accent_gap| is defined by the acute accent, it is known when needed
1093 bot y[breve_two]r=cap_height + if hefty: .5 fi accent_gap;
1094 filldraw stroke z[breve_one]e{down}...z[breve_two]e{right}...
1095 {up}z[breve_three]e; % stroke
1096 enddef;
1097
1098 %
1099 vardef lowercase_ogonek(expr x_move,y_move,ogon_one,ogon_two,ogon_three) =
1100 x[ogon_one]r=x_move;
1101 pickup crisp.nib;
1102 pos[ogon_one](
1103 if currentbreadth<0.9vair: 0.9vair else: currentbreadth+eps fi,-60);
1104 pos[ogon_two](stem,0);
1105 pos[ogon_three](vair,145);
1106 x[ogon_two]=x[ogon_one]-2.5u if monospace: / expansion_factor fi ;
1107 x[ogon_three]=x[ogon_one]+0.5u if monospace: / expansion_factor fi ;
1108 bot y[ogon_one]r = y_move;
1109 bot y[ogon_three]=0.5(-d-o)+y_move; %0.4
1110 bot y[ogon_two]=0.5(-d-o)+y_move;
1111 filldraw stroke z[ogon_one]e{dir 225}...
1112 z[ogon_two]e{dir -110}...{dir 60}z[ogon_three]e; % hook
1113 enddef;
1114
1115 % ---------------------------------------------------------------------------
1116 % MACROS FOR PROCESSING CHARS TWICE:
1117 % PASS 1: COLLECTING TFM (SHARP) INFORMATION
1118 % PASS 2: CREATING THE GLYPH
1119 % ---------------------------------------------------------------------------
1120 %%% define_pixels prepare_pen
1121 %%% beginchar beginchar_twice
1122 %%% endfor repeat_once
1123
1124 % A special provision is necessary if one uses |modes.mf|:
1125 % This file assumes, that one never wants to use more than one mode
1126 % in the same font, but we will do so.
1127 %
1128 % Make sure, that you never input |modes.mf| after this file, otherwise
1129 % unpleasant surprises wait for you.
1130
1131 def clear_mode_guards =
1132 forsuffixes $=proofing,fontmaking,tracingtitles,pixels_per_inch,
1133 blacker,fillin,o_correction,blacker_min,aspect_ratio:
1134 numeric mode_guard_$;
1135 endfor
1136 enddef;
1137
1138 let ori_draw:=draw;
1139 let ori_fill:=fill;
1140 let ori_filldraw:=filldraw;
1141 let ori_erase:=erase;
1142 let ori_penstroke:=penstroke;
1143 let ori_special:=special;
1144 let ori_numspecial:=numspecial;
1145
1146 mode_def canonical_sharp_mode = % nearly |proof| mode
1147 proofing:=0; % no, we aren't making full proofs
1148 fontmaking:=0; % yes, we are making a font
1149 tracingtitles:=0; % don't show titles online
1150 pixels_per_inch:=2601.72; % that's 36 pixels per pt
1151 blacker:=0; % no additional blackness
1152 blacker_min:=0; % no write_white provision
1153 fillin:=0; % no compensation for fillin
1154 o_correction:=1; % no reduction in overshoot
1155 enddef;
1156
1157 def beginchar_twice(expr c,w_sharp,h_sharp,d_sharp) =
1158 begingroup
1159 if string mode: string prev_mode; prev_mode:=mode;
1160 else: numeric prev_mode; prev_mode:=mode;
1161 fi
1162 for sharp_calc_:=1,whatever:
1163 % |sharp_calc| is checked in |corrital|, |mark_height|, and |put_accent|
1164 sharp_calc:=sharp_calc_;
1165 if known sharp_calc: % carry out ``sharp'' calculations
1166 begingroup save mode,mag; mode:=canonical_sharp_mode;
1167 clear_mode_guards; mode_setup; font_setup; pseudo_setup;
1168 if is_small_cap: % excerpt from |font_setup|
1169 define_pixels(higher.u,higher.bar_height);
1170 define_corrected_pixels(higher.o);
1171 define_whole_pixels(higher.letter_fit);
1172 define_whole_vertical_pixels(higher.x_height,higher.body_height);
1173 define_whole_blacker_pixels(higher.stem);
1174 fi
1175 endgroup;
1176 def draw expr e=enddef;
1177 let fill:=draw;
1178 let filldraw:=draw;
1179 let erase:=killtext; % |killtext| was absent from earlier versions of plain
1180 let penstroke:=killtext;
1181 def special primary t = enddef;
1182 def numspecial primary t = enddef;
1183 charwd:=w_sharp; charht:=h_sharp; chardp:=d_sharp; charic:=0;
1184 else: % carry out ``discrete'' calculations
1185 mode:=prev_mode;
1186 clear_mode_guards; mode_setup; font_setup; pseudo_setup;
1187 if is_small_cap: % excerpt from |font_setup|
1188 define_pixels(higher.u,higher.bar_height);
1189 define_corrected_pixels(higher.o);
1190 define_whole_pixels(higher.letter_fit);
1191 define_whole_vertical_pixels(higher.x_height,higher.body_height);
1192 define_whole_blacker_pixels(higher.stem);
1193 fi
1194 let draw:=ori_draw;
1195 let fill:=ori_fill;
1196 let filldraw:=ori_filldraw;
1197 let erase:=ori_erase;
1198 let penstroke:=ori_penstroke;
1199 let special:=ori_special;
1200 let numspecial:=ori_numspecial;
1201 charwd:=w_sharp;
1202 fi
1203 charcode:=if known c: byte c else: 0 fi;
1204 w:=hround(w_sharp*hppp); h:=vround(h_sharp*hppp); d:=vround(d_sharp*hppp);
1205 clearxy; clearit; clearpen; scantokens extra_beginchar;
1206 enddef;
1207
1208 let repeat_once = endfor;
1209
1210 % ---------------------------------------------------------------------------
1211 %
1212 %
1213 %
1214 % some extra font parameters
1215 %
1216 def font_cap_height expr x = fontdimen 8: x enddef;
1217 def font_asc_height expr x = fontdimen 9: x enddef;
1218 def font_acc_cap_height expr x = fontdimen 10: x enddef;
1219 def font_desc_depth expr x = fontdimen 11: x enddef;
1220 def font_max_height expr x = fontdimen 12: x enddef;
1221 def font_max_depth expr x = fontdimen 13: x enddef;
1222 def font_digit_width expr x = fontdimen 14: x enddef;
1223 def font_cap_stem expr x = fontdimen 15: x enddef;
1224 def font_baselineskip expr x = fontdimen 16: x enddef;
1225
1226
1227
1228 %
1229 % XXXXXXX The following routines generate the parameter
1230 % X X sets by extrapolation
1231 % X X
1232 % X X
1233 % X X
1234 % XXXX XXXX
1235 % X X
1236 % X X
1237 % X X
1238 % X X
1239 % X X
1240 % X
1241 %
1242 %
1243 % needed variables
1244 %
1245
1246 vardef simple_gendef@#(text aa)(text t)=
1247 string s[];
1248 s1:="";
1249 s2:=str @#;
1250 index:=1;
1251 forsuffixes $=t: ydata[index]:=$ if s1<>s2: *@# fi;
1252 index:=index+1;
1253 endfor;
1254 if numpoints>(index-1): errmessage "Missing parameter"; message str aa; fi;
1255 if numpoints<(index-1): errmessage "Too many parameters"; message str aa; fi;
1256 aa:=ydata[merke];
1257 if gencheck: message str aa fi;
1258 enddef;
1259
1260 vardef extended_gendef@#(text aa)(text t)=
1261 string s[];
1262 s1:="";
1263 s2:=str @#;
1264 index:=1;
1265 forsuffixes $=t: ydata[index]:=$ if s1<>s2: *@# fi;
1266 index:=index+1;
1267 endfor;
1268 if numpoints>(index-1): errmessage "Missing parameter"; message str aa; fi;
1269 if numpoints<(index-1): errmessage "Too many parameters"; message str aa; fi;
1270 if gensize>basedata[numpoints]:
1271 numeric hilf [];
1272 hilf[1]:=(ydata[numpoints]-ydata[numpoints-1])/(basedata[numpoints]-basedata[numpoints-1]);
1273 hilf[2]:=(ydata[numpoints]-ydata[numpoints-2])/(basedata[numpoints]-basedata[numpoints-2]);
1274 hilf[3]:=ydata[numpoints]-hilf1*basedata[numpoints];
1275 hilf[4]:=ydata[numpoints]-hilf2*basedata[numpoints];
1276 spy:=(hilf[1]*gensize+hilf[3])/2+(hilf[2]*gensize+hilf[4])/2;
1277 aa:=spy;
1278 else:
1279 for index = 1 upto numpoints-1:
1280 interval[index]:=basedata[index+1]-basedata[index];
1281 endfor;
1282 for index=1 upto numpoints:
1283 spline[1][index]:=ydata[index];
1284 endfor;
1285 for index=2 upto numpoints-1:
1286 alpha[index]:=3*((spline[1][index+1]*interval[index-1])%
1287 -(spline[1][index]*(basedata[index+1]-basedata[index-1]))%
1288 +(spline[1][index-1]*interval[index]))%
1289 /(interval[index-1]*interval[index]);
1290 endfor;
1291 spl[1]:=0;
1292 spmu[1]:=0;
1293 spz[1]:=0;
1294 for index=2 upto numpoints-1:
1295 spl[index]:=2*(basedata[index+1]-basedata[index-1])%
1296 -interval[index-1]*spmu[index-1];
1297 spmu[index]:=interval[index]/spl[index];
1298 spz[index]:=(alpha[index]-interval[index-1]*spz[index-1])/spl[index];
1299 endfor;
1300 spline[3][numpoints]:=0;
1301 for index=numpoints-1 downto 1:
1302 spline[3][index]:=spz[index]-spmu[index]*spline[3][index+1];
1303 endfor;
1304 for index=numpoints -1 downto 1:
1305 spline[2][index]:=(spline[1][index+1]-spline[1][index])/interval[index]%
1306 -interval[index]*(spline[3][index+1]*spline[3][index])/3;
1307 spline[4][index]:=(spline[3][index+1]-spline[3][index])/(3*interval[index]);
1308 endfor;
1309 location:=1;
1310 for term=1 upto numpoints-1:
1311 if gensize > basedata[term]: location:=term; fi
1312 endfor;
1313 spx:=gensize-basedata[location];
1314 spy:=((spline[4][location]*spx+spline[3][location])*spx+spline[2][location])*spx+spline[1][location];
1315 aa:=spy; fi;
1316 if gencheck: message str aa fi;
1317 enddef;
1318
1319 vardef basedef(text t)=
1320 boolean basevalue; boolean gencheck;
1321 numeric index; numeric ergbnis; numeric location; numeric term;
1322 numeric numpoints; numeric spx; numeric spy;
1323 numeric basedata[]; numeric interval[]; numeric alpha[];
1324 numeric spl[]; numeric spmu[]; numeric spz[];
1325 numeric ydata[]; numeric spline[][];
1326 basevalue:=false; gencheck:=false;
1327 index:=1;
1328 forsuffixes $=t: basedata[index]:=$;
1329 if $=gensize: basevalue:=true; merke:=index; fi;
1330 index:=index+1;
1331 endfor;
1332 numpoints:=index-1;
1333 if numpoints<3: errmessage "Not enough reference points"; fi
1334 if basevalue: def gendef=simple_gendef enddef; else:
1335 def gendef=extended_gendef enddef; fi
1336 enddef;
1337
1338 def clear_extra_memory= % Release ressources hold by the extrapolation routine
1339 numeric index; numeric ergbnis; numeric location; numeric term;
1340 numeric numpoints; numeric spx; numeric spy;
1341 numeric basedata[]; numeric interval[]; numeric alpha[];
1342 numeric spl[]; numeric spmu[]; numeric spz[];
1343 numeric ydata[]; numeric spline[][];
1344 numeric hilf []; string s[];
1345 enddef;
1346
1347 endinput;