| 1 |
% The base file for sans CM-style (a supplement to {\tt plain.mf}) |
| 2 |
% edited because the CM-style defaults do not give quite ideal |
| 3 |
% results when we make sans serif math fonts |
| 4 |
% and some bits of cmbase.mf are not ideal |
| 5 |
% |
| 6 |
% By Ariel Barton, March 2013 |
| 7 |
|
| 8 |
|
| 9 |
sansfontbase:=1; % when |sansfontbase| is known, this file has been input |
| 10 |
|
| 11 |
let cmchar=\; % `|cmchar|' should precede each character |
| 12 |
let generate=input; % `|generate|' should follow the parameters |
| 13 |
|
| 14 |
autorounding:=0; smoothing:=0; % we do our own rounding |
| 15 |
def autorounded = interim autorounding:=2 enddef; |
| 16 |
|
| 17 |
newinternal slant,fudge,math_spread,superness,superpull,beak_darkness,ligs; |
| 18 |
boolean square_dots,hefty,serifs, |
| 19 |
monospace,variant_g,low_asterisk,math_fitting; |
| 20 |
|
| 21 |
boolean dark,dark.dark,skewed,skewed.skewed; % for fast option testing |
| 22 |
dark=skewed=false; dark.dark=skewed.skewed=true; |
| 23 |
|
| 24 |
vardef Vround primary y = y_:=vround y; |
| 25 |
if y_<min_Vround: min_Vround else: y_ fi enddef; |
| 26 |
newinternal y_,min_Vround; |
| 27 |
|
| 28 |
vardef serif(suffix $,$$,@) % serif at |z$| for stroke from |z$$| |
| 29 |
(expr darkness,jut) suffix modifier = |
| 30 |
pickup crisp.nib; numeric bracket_height; pair downward; |
| 31 |
bracket_height=if dark.modifier: 1.5 fi\\ bracket; |
| 32 |
if y$<y$$: y@2=min(y$+bracket_height,y$$); |
| 33 |
top y@1-slab=bot y@0+eps=tiny.bot y$; downward=z$-z$$; |
| 34 |
if y@1>y@2: y@2:=y@1; fi |
| 35 |
else: y@2=max(y$-bracket_height,y$$); |
| 36 |
bot y@1+slab=top y@0-eps=tiny.top y$; downward=z$$-z$; |
| 37 |
if y@1<y@2: y@2:=y@1; fi fi |
| 38 |
y@3=y@2; z@3=whatever[z$,z$$]; |
| 39 |
if jut<0: z@2+penoffset downward of currentpen = |
| 40 |
z$l+penoffset downward of pen_[tiny.nib]+whatever*downward; |
| 41 |
lft x@0=lft x@1=tiny.lft x$l+jut; |
| 42 |
if x@3<x@2+eps: x@3:=x@2+eps; fi |
| 43 |
else: z@2-penoffset downward of currentpen = |
| 44 |
z$r-penoffset downward of pen_[tiny.nib]+whatever*downward; |
| 45 |
rt x@0=rt x@1=tiny.rt x$r+jut; |
| 46 |
if x@3>x@2-eps: x@3:=x@2-eps; fi fi |
| 47 |
pair corner; ypart corner=y@1; corner=z@2+whatever*downward; |
| 48 |
filldraw z@2{z$-z$$} |
| 49 |
...darkness[corner,.5[z@1,z@2] ]{z@1-z@2} |
| 50 |
...{jut,0}z@1--z@0--(x$,y@0)--z@3--cycle; % the serif |
| 51 |
labels (@1,@2); enddef; |
| 52 |
|
| 53 |
def dish_serif(suffix $,$$,@)(expr left_darkness,left_jut) |
| 54 |
(suffix @@)(expr right_darkness,right_jut) suffix modifier = |
| 55 |
serif($,$$,@,left_darkness,-left_jut) modifier; |
| 56 |
serif($,$$,@@,right_darkness,right_jut) modifier; |
| 57 |
if dish>0: pickup tiny.nib; numeric dish_out,dish_in; |
| 58 |
if y$<y$$: dish_out=bot y$; dish_in=dish_out+dish; let rev_=reverse; |
| 59 |
else: dish_out=top y$; dish_in=dish_out-dish; let rev_=relax; fi |
| 60 |
erase fill rev_ |
| 61 |
((x@1,dish_out)..(x$,dish_in){right}..(x@@1,dish_out)--cycle); |
| 62 |
fi enddef; |
| 63 |
|
| 64 |
def nodish_serif(suffix $,$$,@)(expr left_darkness,left_jut) |
| 65 |
(suffix @@)(expr right_darkness,right_jut) suffix modifier = |
| 66 |
serif($,$$,@,left_darkness,-left_jut) modifier; |
| 67 |
serif($,$$,@@,right_darkness,right_jut) modifier; enddef; |
| 68 |
|
| 69 |
vardef sloped_serif.l(suffix $,$$,@)(expr darkness,jut,drop) = |
| 70 |
pickup crisp.nib; pos@2(slab,90); |
| 71 |
lft x@0=tiny.lft x$l; rt x@1=tiny.rt x$r; top y@1=tiny.top y$r; |
| 72 |
lft x@2=lft x@0-jut; y@2r=y@1-drop; |
| 73 |
y@0=y@2l-bracket-eps; |
| 74 |
if drop>0: erase fill z@1--top z@1 |
| 75 |
--(x@2r,top y@1)--z@2r--cycle; fi % erase excess at top |
| 76 |
filldraw z@1--z@2r--z@2l{right} |
| 77 |
...darkness[(x@0,y@2l),.5[z@2l,z@0] ]{z@0-z@2l} |
| 78 |
...{down}z@0--(x@1,y@0)--cycle; % sloped serif |
| 79 |
labels(@0,@1,@2); enddef; |
| 80 |
|
| 81 |
vardef sloped_serif.r(suffix $,$$,@)(expr darkness,jut,drop) = |
| 82 |
pickup crisp.nib; pos@2(slab,-90); |
| 83 |
rt x@0=tiny.rt x$r; lft x@1=tiny.lft x$l; bot y@1=tiny.bot y$l; |
| 84 |
rt x@2=rt x@0+jut; y@2r=y@1+drop; |
| 85 |
y@0=y@2l+bracket+eps; |
| 86 |
if drop>0: erase fill z@1--bot z@1 |
| 87 |
--(x@2r,bot y@1)--z@2r--cycle; fi % erase excess at bottom |
| 88 |
filldraw z@1--z@2r--z@2l{left} |
| 89 |
...darkness[(x@0,y@2l),.5[z@2l,z@0] ]{z@0-z@2l} |
| 90 |
...{up}z@0--(x@1,y@0)--cycle; % sloped serif |
| 91 |
labels(@0,@1,@2); enddef; |
| 92 |
|
| 93 |
vardef term.l(suffix $,$$)(expr d,t,s)= % ``robust'' sans-serif terminal |
| 94 |
path p_; p_=z$l{d}..tension t..z$$l; |
| 95 |
pair d_; d_=(x$$l-x$l,s*(y$$l-y$l)); |
| 96 |
if (abs angle direction 1 of p_ < abs angle d_)<>(x$l<x$$l): |
| 97 |
p_:=z$l{d}..tension atleast t..{d_}z$$l; fi |
| 98 |
p_ enddef; |
| 99 |
vardef term.r(suffix $,$$)(expr d,t,s)= |
| 100 |
path p_; p_=z$r{d}..tension t..z$$r; |
| 101 |
pair d_; d_=(x$$r-x$r,s*(y$$r-y$r)); |
| 102 |
if (abs angle direction 1 of p_ < abs angle d_)<>(x$r<x$$r): |
| 103 |
p_:=z$r{d}..tension atleast t..{d_}z$$r; fi |
| 104 |
p_ enddef; |
| 105 |
def rterm=reverse term enddef; |
| 106 |
|
| 107 |
vardef arm(suffix $,$$,@)(expr darkness,jut) = % arm from |z$| to |z$$| |
| 108 |
x@0=good.x(x$$r-jut); y@0=y$r; |
| 109 |
if serifs: y@1=y$l; z@1=z$$l+whatever*(z$$r-z@0); |
| 110 |
z@2=.5[z$l,z@1]; |
| 111 |
path p_; p_= z$$l{z@1-z$$l}...darkness[z@1,.5[z@2,z$$l] ]...z@2 |
| 112 |
---z$l--z$r--z@0--z$$r--cycle; |
| 113 |
if (y$$>y$) <> (ypart precontrol 1 of p_ > ypart postcontrol 1 of p_): |
| 114 |
p_:=z$$l{z@1-z$$l}...darkness[z@1,.5[z@2,z$$l] ] |
| 115 |
---z$l--z$r--z@0--z$$r--cycle; fi |
| 116 |
filldraw p_; % arm and beak |
| 117 |
else: filldraw z$l--z$r--z@0--z$$r--cycle; fi % sans-serif arm |
| 118 |
penlabels(@0,@1,@2); enddef; |
| 119 |
|
| 120 |
def pi_stroke = pickup fine.nib; |
| 121 |
if serifs: |
| 122 |
pos1(hair,0); pos2(vstem,-90); pos3(vstem,-90); |
| 123 |
x1-.5hair=hround -.5hair; x2=2u; x3=w-1.5u; |
| 124 |
y1=x_height-x_height/3.141592653589793; y2=y3; top y3l=x_height; |
| 125 |
filldraw circ_stroke z3e---z2e...{x1-x2,3.14159(y1-y2)}z1e; |
| 126 |
else: |
| 127 |
pos1(hair,-20); pos2(vstem,-90); pos3(vstem,-90); |
| 128 |
x1l=hround -.5hair; x2=2u; x3=w-1.2u; |
| 129 |
y1=x_height-x_height/3.141592653589793; y2=y3; top y3l=x_height; |
| 130 |
filldraw stroke z3e---z2e...{x1-x2,3.14159(y1-y2)}z1e; |
| 131 |
fi enddef; |
| 132 |
|
| 133 |
def bulb(suffix $,$$,$$$) = |
| 134 |
z$$$r=z$$r; |
| 135 |
path_.l:=z$l{x$$r-x$r,0}...{0,y$$r-y$r}z$$l; |
| 136 |
filldraw path_.l--z$$r{0,y$r-y$$r}...{x$r-x$$r,0}z$r--cycle; % link |
| 137 |
path_.r:=z$$$l{0,y$r-y$$r}..z$$$r{0,y$$r-y$r}; % near-circle |
| 138 |
%% New |
| 139 |
if serifs: filldraw subpath(0,xpart(path_.r intersectiontimes path_.l)) of path_.r |
| 140 |
--z$$r{0,y$$r-y$r}..cycle; fi % bulb |
| 141 |
enddef; |
| 142 |
|
| 143 |
def v_bulb(suffix $,$$)= % |pos$| is known |
| 144 |
if serifs: |
| 145 |
y$$+.5curve=x_height+oo; x$$+.5curve=w-u; |
| 146 |
numeric theta; theta=angle(4(x$-x$$),y$-y$$); pos$$(curve,theta+90); |
| 147 |
filldraw z$$l{dir theta}..tension atleast 1 and 1..{down}z$l |
| 148 |
--z$r{up}...{-dir theta}z$$r..cycle; % bulb |
| 149 |
else: |
| 150 |
y$$r=x_height; x$$+.5curve=w-u; |
| 151 |
pos$$(curve,15); filldraw stroke z$e{up}..z$$e; |
| 152 |
fi |
| 153 |
enddef; |
| 154 |
|
| 155 |
def sansbulb(suffix $,$$,$$$) = |
| 156 |
if serifs: bulb($,$$,$$$); |
| 157 |
else: |
| 158 |
x$$r=x$$$r; y$$=y$$$+(x$$r-x$$); |
| 159 |
filldraw circ_stroke z$$e{0,y$r-y$$r}..z$e{x$r-x$$r,0}; |
| 160 |
fi |
| 161 |
enddef; |
| 162 |
|
| 163 |
def dot(suffix $,$$) = |
| 164 |
filldraw if square_dots: (x$l,y$$l)--(x$r,y$$l) |
| 165 |
--(x$r,y$$r)--(x$l,y$$r)--cycle % squarish dot |
| 166 |
else: z$l...z$$l...z$r...z$$r...cycle fi % roundish dot |
| 167 |
enddef; |
| 168 |
|
| 169 |
def comma(suffix $,@)(expr dot_size,jut,depth) = |
| 170 |
pickup fine.nib; pos$(dot_size,90); |
| 171 |
if square_dots: pos$'(dot_size,0); z$'=z$; dot($',$); % squarish dot |
| 172 |
comma_join_:=max(fine.breadth,floor .7dot_size); |
| 173 |
comma_bot_:=max(fine.breadth,floor .5dot_size); |
| 174 |
pos@0(comma_join_,0); pos@1(comma_join_,0); |
| 175 |
pos@2(comma_bot_,0); y@0=y$; y@1=y$l; y@2=y@1-depth; |
| 176 |
x@0r=x@1r=x$'r; rt x@2r=good.x(x$-eps); |
| 177 |
filldraw stroke z@[email protected]@2e; % tail |
| 178 |
else: pos@1(vair,90); pos@2(vair,0); pos@3(vair,-45); |
| 179 |
z@1r=z$r; rt x@2r=hround(x$+.5dot_size+jut)+2eps; x@3=x$-.5u; |
| 180 |
y@2=1/3[y@1,y@3]; bot y@3r=vround(y$-.5dot_size-depth); |
| 181 |
y_:=ypart((z@1{right}...z@2{down}...z@3) |
| 182 |
intersectiontimes (z$l{right}..{left}z$r)); if y_<0: y_:=1; fi |
| 183 |
filldraw z$r{left}..subpath (0,y_) of (z$l{right}..{left}z$r)--cycle; % dot |
| 184 |
filldraw stroke z@1e{right}...z@2e{down}...z@3e; fi % tail |
| 185 |
penlabels(@1,@2,@3); enddef; |
| 186 |
|
| 187 |
def ammoc(suffix $,@)(expr dot_size,jut,depth) = % reversed comma |
| 188 |
pickup fine.nib; pos$(dot_size,90); |
| 189 |
if square_dots: pos$'(dot_size,0); z$'=z$; dot($',$); % squarish dot |
| 190 |
comma_join_:=max(fine.breadth,floor .7dot_size); |
| 191 |
comma_top_:=max(fine.breadth,floor .5dot_size); |
| 192 |
pos@0(comma_join_,0); pos@1(comma_join_,0); |
| 193 |
pos@2(comma_top_,0); y@0=y$; y@1=y$r; y@2=y@1+depth; |
| 194 |
x@0l=x@1l=x$'l; lft x@2l=good.x(x$+eps); |
| 195 |
filldraw stroke z@[email protected]@2e; % tail |
| 196 |
else: pos@1(vair,90); pos@2(vair,0); pos@3(vair,-45); |
| 197 |
z@1l=z$l; lft x@2l=hround(x$-.5dot_size-jut)-2eps; x@3=x$+.5u; |
| 198 |
y@2=1/3[y@1,y@3]; top y@3l=vround(y$+.5dot_size+depth); |
| 199 |
y_:=ypart((z@1{left}...z@2{up}...z@3) |
| 200 |
intersectiontimes (z$r{left}..{right}z$l)); if y_<0: y_:=1; fi |
| 201 |
filldraw z$l{right}..subpath (0,y_) of (z$r{left}..{right}z$l)--cycle; % dot |
| 202 |
filldraw stroke z@1e{left}...z@2e{up}...z@3e; fi % tail |
| 203 |
penlabels(@1,@2,@3); enddef; |
| 204 |
|
| 205 |
%%% @ from to %%%% temporary formatting change |
| 206 |
vardef diag_in(suffix from,$)(expr sharpness)(suffix $$) = |
| 207 |
pickup tiny.nib; save from_x,y_; |
| 208 |
if y.from>y$: bot else: top fi\\ y_=y$; |
| 209 |
(from_x,y_)=whatever[z.from,z$]; |
| 210 |
sharpness[z$,(from_x,y_)]{z$-z.from} |
| 211 |
...{z$$-z$}z$+sharpness*length(z$-(from_x,y_))*unitvector(z$$-z$) enddef; |
| 212 |
|
| 213 |
vardef diag_out(suffix $)(expr sharpness)(suffix $$,to) = |
| 214 |
pickup tiny.nib; save to_x,y_; |
| 215 |
if y.to>y$: bot else: top fi\\ y_=y$; |
| 216 |
(to_x,y_)=whatever[z$$,z.to]; |
| 217 |
z$$-sharpness*length(z$$-(to_x,y_))*unitvector(z$$-z$){z$$-z$} |
| 218 |
...{z.to-z$$}sharpness[z$$,(to_x,y_)] enddef; |
| 219 |
|
| 220 |
vardef diag_end(suffix from,$)(expr sharpness_in,sharpness_out)(suffix $$,to)= |
| 221 |
save from_x,to_x,y_,x_,xx_; |
| 222 |
if y.from>y$: tiny.bot else: tiny.top fi\\ y_=y$; % we assume that |y$=y$$| |
| 223 |
(from_x,y_)=whatever[z.from,z$]; (to_x,y_)=whatever[z$$,z.to]; |
| 224 |
if x$$>x$: x_=x$+sharpness_in*length(z$-(from_x,y_)); |
| 225 |
xx_=x$$-sharpness_out*length(z$$-(to_x,y_)); |
| 226 |
if xx_<x_: xx_:=x_:=.5[xx_,x_]; fi |
| 227 |
else: x_=x$-sharpness_in*length(z$-(from_x,y_)); |
| 228 |
xx_=x$$+sharpness_out*length(z$$-(to_x,y_)); |
| 229 |
if xx_>x_: xx_:=x_:=.5[xx_,x_]; fi fi |
| 230 |
sharpness_in[z$,(from_x,y_)]{z$-z.from} |
| 231 |
...{z$$-z$}(x_,y$)..(xx_,y$){z$$-z$} |
| 232 |
...{z.to-z$$}sharpness_out[z$$,(to_x,y_)] enddef; |
| 233 |
%%% at from to %%%% restore normal formatting |
| 234 |
|
| 235 |
vardef special_diag_end(suffix $$,$,@,@@) = % for top middle of w's |
| 236 |
if x@r<=x$r: diag_end($$r,$r,1,1,@l,@@l) |
| 237 |
else: z0=whatever[z$$l,z$l]=whatever[z@l,z@@l]; |
| 238 |
diag_end($$r,$r,1,1,$l,0)--z0 fi enddef; |
| 239 |
|
| 240 |
def prime_points_inside(suffix $,$$) = |
| 241 |
theta_:=angle(z$r-z$l); |
| 242 |
penpos$'(whatever,theta_); |
| 243 |
if y$$>y$: z$'=(0,pen_top) rotated theta_ + whatever[z$l,z$r]; |
| 244 |
theta_:=angle(z$$-z$)-90; |
| 245 |
else: z$'=(0,pen_bot) rotated theta_ + whatever[z$l,z$r]; |
| 246 |
theta_:=angle(z$$-z$)+90; fi |
| 247 |
z$'l+(pen_lft,0) rotated theta_=z$l+whatever*(z$-z$$); |
| 248 |
z$'r+(pen_rt,0) rotated theta_=z$r+whatever*(z$-z$$); |
| 249 |
enddef; |
| 250 |
|
| 251 |
def ellipse_set(suffix $,@,@@,$$) = % given |z$,x@,z$$|, find |y@| and |z@@| |
| 252 |
% such that the path |z${x@-x$,0}..z@{0,y@-y$}..{z$$-z@@}z@@| |
| 253 |
% is consistent with an ellipse |
| 254 |
% and such that the line |z@@--z$$| has a given |slope| |
| 255 |
alpha_:=slope*(x@-x$); beta_:=y$$-y$-slope*(x$$-x$); |
| 256 |
gamma_:=alpha_/beta_; |
| 257 |
y@-y$=.5(beta_-alpha_*gamma_); |
| 258 |
x@@-x$=-2gamma_*(x@-x$)/(1+gamma_*gamma_); |
| 259 |
y@@-y$$=slope*(x@@-x$$) enddef; |
| 260 |
|
| 261 |
vardef diag_ratio(expr a,b,y,c) = % assuming that $a>\vert b/y\vert$, |
| 262 |
% compute the value $\alpha=(x\6{++}y)/y$ such that $ax+b\alpha=c$ |
| 263 |
numeric aa_,bb_,cc_; bb_=b/y; cc_=c/y; aa_=a*a-bb_*bb_; |
| 264 |
(a*(cc_++sqrt aa_)-bb_*cc_)/aa_ enddef; |
| 265 |
|
| 266 |
def f_stroke(suffix $,$$,@,left_serif,right_serif)(expr left_jut,right_jut)= |
| 267 |
pickup tiny.nib; bot y$=0; |
| 268 |
penpos@0(x$r-x$l,0); x@0l=x$l; top y@0=x_height; |
| 269 |
filldraw stroke z$e--z@0e; % stem |
| 270 |
pickup fine.nib; pos@0'(x$r-x$l-(hround stem_corr)+tiny,180); |
| 271 |
y@0'=y@0; lft x@0'r=tiny.lft x$l; |
| 272 |
penpos@1(x@0'l-x@0'r,180); x@1=x@0'; y@1+.5vair=.5[x_height,h]; |
| 273 |
pos@2(vair,90); top y@2r=h+oo; |
| 274 |
if serifs: x@2=.6[x@1,x$$r]; (x@,y@2r)=whatever[z@2l,z@1l]; |
| 275 |
x@2r:=min(x@,.5[x@2,x$$r]); pos@3(hair,0); bulb(@2,@3,$$); % bulb |
| 276 |
filldraw stroke z@0'e--z@1e & super_arc.e(@1,@2); % arc |
| 277 |
dish_serif($,@0,left_serif,1/3,left_jut,right_serif,1/3,right_jut); % serif |
| 278 |
else: x@2=.6[x@1,x$$]; y@1l:=1/3[y@1l,y@2l]; |
| 279 |
filldraw stroke z@0'e--z@1e & super_arc.e(@1,@2) |
| 280 |
& term.e(@2,$$,right,.9,4); fi % arc and terminal |
| 281 |
penlabels(@0,@1,@2); enddef; |
| 282 |
|
| 283 |
def h_stroke(suffix $,@,@@,$$) = |
| 284 |
penpos$$(x@@r-x@@l,0); x$$=x@@; bot y$$=0; |
| 285 |
y@@=1/3[bar_height,x_height]; |
| 286 |
penpos$''(x$r-x$l,0); x$''=x$; y$''=1/8[bar_height,x_height]; |
| 287 |
filldraw stroke z$''e--z$e; % thicken the lower left stem |
| 288 |
penpos@0(min(rt x$r-lft x$l,thin_join)-fine,180); pickup fine.nib; |
| 289 |
rt x@0l=tiny.rt x$r; y@0=y$''; |
| 290 |
pos@1(vair,90); pos@@'(x@@r-x@@l+tiny,0); z@@'=z@@; |
| 291 |
x@1=.5[rt x@0l,rt x@@'r]; top y@1r=x_height+oo; |
| 292 |
(x@,y@1l)=whatever[z@1r,z@0l]; x@1l:=x@; |
| 293 |
filldraw stroke z@0e{up}...{right}z@1e |
| 294 |
&{{interim superness:=hein_super; super_arc.e(@1,@@')}}; % arch |
| 295 |
pickup tiny.nib; filldraw stroke z@@e--z$$e; % right stem |
| 296 |
labels(@0); penlabels(@1); enddef; |
| 297 |
|
| 298 |
def hook_out(suffix $,$$,$$$)suffix modifier= % |x$| and |x$$$| (only) are known |
| 299 |
x$$$:=hround(x$$$+.5hair-eps)-.5hair; |
| 300 |
% New; better hooks for sans serif |
| 301 |
if serifs: |
| 302 |
pos$(stem,0); pos$$(vair,90); |
| 303 |
pos$$$(hair,180); |
| 304 |
y$=1/4x_height; bot y$$l=-oo; y$$$=1/3x_height; |
| 305 |
else: |
| 306 |
pos$(stem,0); pos$$(vair,90); |
| 307 |
pos$$$(vair,170); |
| 308 |
y$=1/4x_height; bot y$$l=-oo; y$$$=1/3x_height; |
| 309 |
fi |
| 310 |
if skewed.modifier: x$$=x$+1.25u; |
| 311 |
filldraw stroke z$e{-u,-x_height}...z$$e{right}...{up}z$$$e; % hook |
| 312 |
else: x$$=x$+1.5u; |
| 313 |
filldraw stroke z$e{down}...z$$e{right} |
| 314 |
...{x$$$-(x$+2.5u),x_height}z$$$e; fi enddef; % hook |
| 315 |
|
| 316 |
def hook_in(suffix $,$$,$$$)suffix modifier= % |x$| and |x$$$| (only) are known |
| 317 |
x$:=hround(x$-.5hair)+.5hair; |
| 318 |
% New; better hooks for sans serif |
| 319 |
if serifs: |
| 320 |
pos$(hair,180); |
| 321 |
pos$$(vair,90); pos$$$(if hefty: vair else: stem fi,0); |
| 322 |
y$=2/3x_height; top y$$r=x_height+oo; y$$$=3/4x_height; |
| 323 |
else: |
| 324 |
pos$(vair,170); |
| 325 |
pos$$(vair,90); pos$$$(if hefty: vair else: stem fi,0); |
| 326 |
y$=3/4x_height; top y$$r=x_height+oo; y$$$=3/4x_height; |
| 327 |
fi |
| 328 |
if skewed.modifier: x$$=x$$$-1.25u; |
| 329 |
filldraw stroke z$e{up}...z$$e{right}...{-u,-x_height}z$$$e; % hook |
| 330 |
else: x$$=x$$$-1.5u; |
| 331 |
filldraw stroke z$e{x$$$-2.5u-x$,x_height} |
| 332 |
...z$$e{right}...{down}z$$$e; fi enddef; % hook |
| 333 |
|
| 334 |
def ital_arch(suffix $,$$,$$$) = % |z$| and |z$$$| (only) are known |
| 335 |
pos$'(hair,180); z$'=z$; |
| 336 |
pos$$(vair,90); pos$$$(stem,0); |
| 337 |
{{interim superness := more_super; x$$=.6[x$,x$$$]; |
| 338 |
top y$$r=x_height+oo; y$$$=.65x_height; |
| 339 |
filldraw stroke z$'e{up}...super_arc.e($$,$$$);}} enddef; % stroke |
| 340 |
|
| 341 |
def compute_spread(expr normal_spread,big_spread)= |
| 342 |
spread#:=math_spread[normal_spread,big_spread]; |
| 343 |
spread:=2ceiling(spread#*hppp/2)+eps; enddef; |
| 344 |
|
| 345 |
def v_center(expr h_sharp) = |
| 346 |
.5h_sharp+math_axis#, .5h_sharp-math_axis# enddef; |
| 347 |
|
| 348 |
def circle_points = |
| 349 |
x4=x8=.5[x2,x6]; x1=x3=superness[x4,x2]; x5=x7=superness[x4,x6]; |
| 350 |
y2=y6=.5[y4,y8]; y1=y7=superness[y2,y8]; y3=y5=superness[y2,y4]; |
| 351 |
enddef; |
| 352 |
def draw_circle = |
| 353 |
draw z8{right}...z1{z2-z8}...z2{down}...z3{z4-z2}...z4{left} |
| 354 |
...z5{z6-z4}...z6{up}...z7{z8-z6}...cycle enddef; |
| 355 |
|
| 356 |
def left_paren(expr min_breadth, max_breadth) = |
| 357 |
pickup fine.nib; pos1(hround min_breadth,0); |
| 358 |
pos2(hround max_breadth,0); pos3(hround min_breadth,0); |
| 359 |
rt x1r=rt x3r=hround(w-1.25u+.5min_breadth); lft x2l=hround 1.25u; |
| 360 |
top y1=h; y2=.5[y1,y3]; bot y3=1-d; |
| 361 |
filldraw stroke z1e{3(x2e-x1e),y2-y1}...z2e |
| 362 |
...{3(x3e-x2e),y3-y2}z3e; % arc |
| 363 |
penlabels(1,2,3); enddef; |
| 364 |
|
| 365 |
def right_paren(expr min_breadth, max_breadth) = |
| 366 |
pickup fine.nib; pos1(hround min_breadth,0); |
| 367 |
pos2(hround max_breadth,0); pos3(hround min_breadth,0); |
| 368 |
lft x1l=lft x3l=hround(1.25u-.5min_breadth); rt x2r=hround(w-1.25u); |
| 369 |
top y1=h; y2=.5[y1,y3]; bot y3=1-d; |
| 370 |
filldraw stroke z1e{3(x2e-x1e),y2-y1}...z2e |
| 371 |
...{3(x3e-x2e),y3-y2}z3e; % arc |
| 372 |
penlabels(1,2,3); enddef; |
| 373 |
|
| 374 |
def left_bracket(expr breadth,do_top,do_bot) = |
| 375 |
pickup crisp.nib; |
| 376 |
numeric thickness; thickness=hround breadth; |
| 377 |
pos1(thickness,0); pos2(thickness,0); |
| 378 |
top y1=h; bot y2=1-d; lft x1l=lft x2l=hround(2.5u-.5thickness); |
| 379 |
filldraw stroke z1e--z2e; % stem |
| 380 |
pos3(thickness,90); pos4(thickness,90); |
| 381 |
pos5(thickness,90); pos6(thickness,90); |
| 382 |
x3=x5=x1l; rt x4=rt x6=hround(w-.75u+.5thickness); |
| 383 |
y3r=y4r=y1; y5l=y6l=y2; |
| 384 |
if do_top: filldraw stroke z3e--z4e; fi % upper bar |
| 385 |
if do_bot: filldraw stroke z5e--z6e; fi % lower bar |
| 386 |
penlabels(1,2,3,4,5,6); enddef; |
| 387 |
|
| 388 |
def right_bracket(expr breadth,do_top,do_bot) = |
| 389 |
pickup crisp.nib; |
| 390 |
numeric thickness; thickness=hround breadth; |
| 391 |
pos1(thickness,0); pos2(thickness,0); |
| 392 |
top y1=h; bot y2=1-d; rt x1r=rt x2r=hround(w-2.5u+.5thickness); |
| 393 |
filldraw stroke z1e--z2e; % stem |
| 394 |
pos3(thickness,90); pos4(thickness,90); |
| 395 |
pos5(thickness,90); pos6(thickness,90); |
| 396 |
x3=x5=x1r; lft x4=lft x6=hround(.75u-.5thickness); |
| 397 |
y3r=y4r=y1; y5l=y6l=y2; |
| 398 |
if do_top: filldraw stroke z3e--z4e; fi % upper bar |
| 399 |
if do_bot: filldraw stroke z5e--z6e; fi % lower bar |
| 400 |
penlabels(1,2,3,4,5,6); enddef; |
| 401 |
|
| 402 |
def left_curly(expr min_breadth, max_breadth) = |
| 403 |
pickup fine.nib; |
| 404 |
forsuffixes $=1,1',4,4',7,7': pos$(hround min_breadth,0); endfor |
| 405 |
forsuffixes $=2,3,5,6: pos$(hround max_breadth,0); endfor |
| 406 |
x2=x3=x5=x6; x1=x1'=x7=x7'=w-x4=w-x4'; |
| 407 |
lft x4l=hround(1.5u-.5min_breadth); lft x2l=hround(.5w-.5max_breadth); |
| 408 |
top y1=h; bot y7=1-d; .5[y4,y4']=.5[y1,y7]=.5[y2,y6]=.5[y3,y5]; |
| 409 |
y1-y2=y3-y4=(y1-y4)/4; |
| 410 |
y1-y1'=y4-y4'=y7'-y7=vround(min_breadth-fine); |
| 411 |
filldraw z1l{3(x2l-x1l),y2-y1}...z2l---z3l...{3(x4l-x3l),y4-y3}z4l |
| 412 |
--z4'l{3(x5l-x4l),y5-y4'}...z5l---z6l...{3(x7l-x6l),y7-y6}z7l |
| 413 |
--z7r--z7'r{3(x6r-x7r),y6-y7'}...z6r---z5r |
| 414 |
...{3(x4r-x5r),.5[y4,y4']-y5}.5[z4r,z4'r]{3(x3r-x4r),y3-.5[y4,y4']} |
| 415 |
...z3r---z2r...{3(x1r-x2r),y1'-y2}z1'r--z1r--cycle; % stroke |
| 416 |
penlabels(1,2,3,4,5,6,7); enddef; |
| 417 |
|
| 418 |
def right_curly(expr min_breadth, max_breadth) = |
| 419 |
pickup fine.nib; |
| 420 |
forsuffixes $=1,1',4,4',7,7': pos$(hround min_breadth,0); endfor |
| 421 |
forsuffixes $=2,3,5,6: pos$(hround max_breadth,0); endfor |
| 422 |
x2=x3=x5=x6; x1=x1'=x7=x7'=w-x4=w-x4'; |
| 423 |
lft x1l=hround(1.5u-.5min_breadth); lft x2l=hround(.5w-.5max_breadth); |
| 424 |
top y1=h; bot y7=1-d; .5[y4,y4']=.5[y1,y7]=.5[y2,y6]=.5[y3,y5]; |
| 425 |
y1-y2=y3-y4=(y1-y4)/4; |
| 426 |
y1-y1'=y4-y4'=y7'-y7=vround(min_breadth-fine); |
| 427 |
filldraw z1r{3(x2r-x1r),y2-y1}...z2r---z3r...{3(x4r-x3r),y4-y3}z4r |
| 428 |
--z4'r{3(x5r-x4r),y5-y4'}...z5r---z6r...{3(x7r-x6r),y7-y6}z7r |
| 429 |
--z7l--z7'l{3(x6l-x7l),y6-y7'}...z6l---z5l |
| 430 |
...{3(x4l-x5l),.5[y4,y4']-y5}.5[z4l,z4'l]{3(x3l-x4l),y3-.5[y4,y4']} |
| 431 |
...z3l---z2l...{3(x1l-x2l),y1'-y2}z1'l--z1l--cycle; % stroke |
| 432 |
penlabels(1,2,3,4,5,6,7); enddef; |
| 433 |
|
| 434 |
def left_angle(expr breadth) = |
| 435 |
pickup pencircle scaled breadth; |
| 436 |
x1=x3=good.x(w-u)+eps; lft x2=hround u-eps; |
| 437 |
top y1=h+eps; .5[y1,y3]=y2=good.y .5[-d+eps,h]; |
| 438 |
draw z1--z2--z3; % diagonals |
| 439 |
labels(1,2,3); enddef; |
| 440 |
|
| 441 |
def right_angle(expr breadth) = |
| 442 |
pickup pencircle scaled breadth; |
| 443 |
x1=x3=good.x u-eps; rt x2=hround(w-u)+eps; |
| 444 |
top y1=h+eps; .5[y1,y3]=y2=good.y .5[-d+eps,h]; |
| 445 |
draw z1--z2--z3; % diagonals |
| 446 |
labels(1,2,3); enddef; |
| 447 |
|
| 448 |
def big_slash(expr breadth) = |
| 449 |
adjust_fit(-letter_fit#,-letter_fit#); pickup pencircle scaled breadth; |
| 450 |
rt x1=hround(w-u); lft x2=hround u; top y1=h+eps; bot y2=1-d-eps; |
| 451 |
draw z1--z2; % diagonal |
| 452 |
labels(1,2); enddef; |
| 453 |
|
| 454 |
def big_blash(expr breadth) = |
| 455 |
adjust_fit(-letter_fit#,-letter_fit#); pickup pencircle scaled breadth; |
| 456 |
lft x1=hround u; rt x2=hround(w-u); top y1=h+eps; bot y2=1-d-eps; |
| 457 |
draw z1--z2; % diagonal |
| 458 |
labels(1,2); enddef; |
| 459 |
|
| 460 |
def big_sqrt = |
| 461 |
adjust_fit(0,-letter_fit#); pickup rule.nib; |
| 462 |
x1=good.x 4/9w; x2=good.x(w+.5); bot y1=-d; bot y2=0; |
| 463 |
draw z1--z2; % diagonal |
| 464 |
pickup crisp.nib; pos3(max(curve,rule_thickness),0); |
| 465 |
x3l=1.5[x2,x1]; y3=.5[y1,y2]; |
| 466 |
pos4(rule_thickness,0); x4=x1; bot y4=-d; |
| 467 |
pos5(min(vair,rule_thickness),-45); |
| 468 |
x5l=good.x(x3l-u); z5l=whatever[z3r,z2]; |
| 469 |
z6=z5r+whatever*(z2-z3r)=whatever[z3l,z4l]; |
| 470 |
z7=whatever[z1,z2]=z3r+whatever*(z4l-z3l); |
| 471 |
filldraw z5r--z6--z4l--z4--z7--z3r--z5l--cycle; % left diagonal and serif |
| 472 |
penlabels(1,2,3,4,5,6,7); enddef; |
| 473 |
|
| 474 |
def big_hat = |
| 475 |
adjust_fit(0,0); |
| 476 |
pickup crisp.nib; pos2(.6[vair,curve],90); top y2r=h+o; x2=.5w; |
| 477 |
x1=w-x3=good.x -eps; y1=y3=.5[x_height,y2]; |
| 478 |
pos1(min(hair,rule_thickness),angle(z2-z1)+90); |
| 479 |
pos3(min(hair,rule_thickness),angle(z3-z2)+90); |
| 480 |
filldraw stroke z1e--z2e--z3e; % diagonals |
| 481 |
penlabels(1,2,3); enddef; |
| 482 |
|
| 483 |
def big_tilde = |
| 484 |
adjust_fit(0,0); pickup crisp.nib; |
| 485 |
numeric theta; theta=angle(1/6(w-vair),1/4(h-x_height)); |
| 486 |
numeric mid_width; mid_width=.4[vair,stem]; |
| 487 |
pos1(min(vair,rule_thickness),theta+90); pos2(min(vair,rule_thickness),theta+90); |
| 488 |
pos3(min(vair,rule_thickness),theta+90); pos4(min(vair,rule_thickness),theta+90); |
| 489 |
z2-z1=z4-z3=(mid_width-crisp)*dir theta; |
| 490 |
lft x1r=w-rt x4l=0; top y4r=h; |
| 491 |
bot y1l=vround(bot y1l+min(2/3[x_height,h],y3l-.25vair)-top y1r); |
| 492 |
pair delta; ypart delta=3(y3l-y1l); delta=whatever*dir theta; |
| 493 |
filldraw z1l..controls(z1l+delta)and(z3l-delta)..z3l..z4l |
| 494 |
--z4r..controls(z4r-delta)and(z2r+delta)..z2r..z1r--cycle; % stroke |
| 495 |
penlabels(1,2,3,4); enddef; |
| 496 |
|
| 497 |
def beginarithchar(expr c) = % ensure consistent dimensions for $+$, $-$, etc. |
| 498 |
if monospace: beginchar(c,14u#,27/7u#+math_axis#,27/7u#-math_axis#); |
| 499 |
else: beginchar(c,14u#,6u#+math_axis#,6u#-math_axis#); fi |
| 500 |
italcorr math_axis#*slant-.5u#; |
| 501 |
adjust_fit(0,0); enddef; |
| 502 |
|
| 503 |
newinternal l,r,shrink_fit; % adjustments to spacing |
| 504 |
|
| 505 |
def do_expansion(expr expansion_factor) = |
| 506 |
forsuffixes $=u,jut,cap_jut,beak_jut,apex_corr: |
| 507 |
$:=$.#*expansion_factor*hppp; endfor |
| 508 |
enddef; |
| 509 |
|
| 510 |
def normal_adjust_fit(expr left_adjustment,right_adjustment) = |
| 511 |
numeric charwd_in; charwd_in=charwd; |
| 512 |
l:=-hround(left_adjustment*hppp)-letter_fit; |
| 513 |
interim xoffset:=-l; |
| 514 |
charwd:=charwd+2letter_fit#+left_adjustment+right_adjustment; |
| 515 |
r:=l+hround(charwd*hppp)-shrink_fit; |
| 516 |
w:=r-hround(right_adjustment*hppp)-letter_fit; |
| 517 |
do_expansion(w/(charwd_in*hppp)); |
| 518 |
enddef; |
| 519 |
|
| 520 |
def mono_adjust_fit(expr left_adjustment,right_adjustment) = |
| 521 |
numeric charwd_in; charwd_in=charwd; |
| 522 |
numeric expansion_factor; |
| 523 |
mono_charwd#=2letter_fit# |
| 524 |
+expansion_factor*(charwd+left_adjustment+right_adjustment); |
| 525 |
l:=-hround(left_adjustment*expansion_factor*hppp)-letter_fit; |
| 526 |
interim xoffset:=-l; |
| 527 |
r:=l+mono_charwd-shrink_fit; |
| 528 |
w:=r-hround(right_adjustment*expansion_factor*hppp)-letter_fit; |
| 529 |
charwd:=mono_charwd#; charic:=mono_charic#; |
| 530 |
do_expansion(w/(charwd_in*hppp)); |
| 531 |
enddef; |
| 532 |
|
| 533 |
extra_endchar:=extra_endchar&"r:=r+shrink_fit;w:=r-l;"; |
| 534 |
|
| 535 |
def ignore_math_fit(expr left_adjustment,right_adjustment) = enddef; |
| 536 |
def do_math_fit(expr left_adjustment,right_adjustment) = |
| 537 |
l:=l-hround(left_adjustment*hppp); interim xoffset:=-l; |
| 538 |
charwd:=charwd+left_adjustment+right_adjustment; |
| 539 |
r:=l+hround(charwd*hppp)-shrink_fit; |
| 540 |
charic:=charic-right_adjustment; |
| 541 |
if charic<0: charic:=0; fi enddef; |
| 542 |
def zero_width = charwd:=0; r:=l-shrink_fit enddef; |
| 543 |
def change_width = if not monospace: % change width by $\pm1$ |
| 544 |
if r+shrink_fit-l=floor(charwd*hppp): w:=w+1; r:=r+1; |
| 545 |
else: w:=w-1; r:=r-1; fi fi enddef; |
| 546 |
def center_on(expr x) = if not monospace: % change width for symmetric fit |
| 547 |
r:=r+2x-w; w:=2x; fi enddef; |
| 548 |
def padded expr del_sharp = |
| 549 |
charht:=charht+del_sharp; chardp:=chardp+del_sharp enddef; |
| 550 |
|
| 551 |
def font_setup = |
| 552 |
%% New: don't display while running metafont |
| 553 |
displaying := 0; |
| 554 |
% New parameters |
| 555 |
if known bigdw#: else: bigdw# = dw#; fi |
| 556 |
if known I_cap_jut#: else: I_cap_jut# = cap_jut#; fi |
| 557 |
if known I_beak#: else: I_beak# = beak#; fi |
| 558 |
if known cal_cap_hair#: else: cal_cap_hair# = cap_hair#; fi |
| 559 |
if known cal_cap_curve#: else: cal_cap_curve# = cap_curve#; fi |
| 560 |
if known cal_cap_stem#: else: cal_cap_stem# = cap_stem#; fi |
| 561 |
if known cal_curve#: else: cal_curve# = curve#; fi |
| 562 |
if known cal_stem#: else: cal_stem# = stem#; fi |
| 563 |
if monospace: let adjust_fit=mono_adjust_fit; |
| 564 |
def mfudged=fudged enddef; |
| 565 |
mono_charic#:=body_height#*slant; |
| 566 |
if mono_charic#<0: mono_charic#:=0; fi |
| 567 |
mono_charwd#:=9u#; define_whole_pixels(mono_charwd); |
| 568 |
else: let adjust_fit=normal_adjust_fit; |
| 569 |
def mfudged= enddef; fi |
| 570 |
if math_fitting: let math_fit=do_math_fit |
| 571 |
else: let math_fit=ignore_math_fit fi; |
| 572 |
define_pixels(u,width_adj,serif_fit,cap_serif_fit,jut,cap_jut,beak, |
| 573 |
bar_height,dish,bracket,beak_jut,stem_corr,vair_corr,apex_corr); |
| 574 |
define_pixels(I_cap_jut, I_beak, bigdw); %% New (special I serif parameters, big dw) |
| 575 |
define_blacker_pixels(notch_cut,cap_notch_cut); |
| 576 |
forsuffixes $=notch_cut,cap_notch_cut: if $<3: $:=3; fi endfor |
| 577 |
define_whole_pixels(letter_fit,fine,crisp,tiny); |
| 578 |
define_whole_vertical_pixels(body_height,asc_height, |
| 579 |
cap_height,fig_height,x_height,comma_depth,desc_depth,serif_drop); |
| 580 |
define_whole_blacker_pixels(thin_join,hair,stem,cal_stem,curve, cal_curve,flare, |
| 581 |
dot_size,cap_hair,cal_cap_hair,cap_stem,cal_cap_stem, cap_curve,cal_cap_curve); |
| 582 |
define_whole_vertical_blacker_pixels(vair,bar,slab,cap_bar,cap_band); |
| 583 |
define_corrected_pixels(o,apex_o); |
| 584 |
forsuffixes $=hair,stem,cap_stem: |
| 585 |
fudged$.#:=fudge*$.#; fudged$:=hround(fudged$.#*hppp+blacker); |
| 586 |
forever: exitif fudged$>.9fudge*$; fudged$:=fudged$+1; endfor endfor |
| 587 |
rule_thickness:=ceiling(rule_thickness#*hppp); |
| 588 |
heavy_rule_thickness:=ceiling(3rule_thickness#*hppp); |
| 589 |
oo:=vround(.5o#*hppp*o_correction)+eps; |
| 590 |
apex_oo:=vround(.5apex_o#*hppp*o_correction)+eps; |
| 591 |
lowres_fix(stem,cal_stem,curve,cal_curve,flare) 1.3; |
| 592 |
lowres_fix(stem,cal_stem,curve,cal_curve) 1.2; |
| 593 |
lowres_fix(cap_stem,cal_cap_stem,cap_curve,cal_cap_curve) 1.2; |
| 594 |
lowres_fix(hair,cap_hair,cal_cap_hair) 1.2; |
| 595 |
lowres_fix(cap_band,cap_bar,bar,slab) 1.2; |
| 596 |
stem':=hround(stem-stem_corr); cap_stem':=hround(cap_stem-stem_corr); |
| 597 |
vair':=vround(vair+vair_corr); |
| 598 |
vstem:=vround .8[vair,stem]; cap_vstem:=vround .8[vair,cap_stem]; |
| 599 |
ess:=(ess#/stem#)*stem; cap_ess:=(cap_ess#/cap_stem#)*cap_stem; |
| 600 |
dw:=(curve#-stem#)*hppp; bold:=curve#*hppp+blacker; |
| 601 |
dh#:=.6designsize; |
| 602 |
stem_shift#:=if serifs: 2stem_corr# else: 0 fi; |
| 603 |
more_super:=max(superness,sqrt .77superness); |
| 604 |
hein_super:=max(superness,sqrt .81225258superness); % that's $2^{-.3}$ |
| 605 |
clear_pen_memory; |
| 606 |
if fine=0: fine:=1; fi |
| 607 |
forsuffixes $=fine,crisp,tiny: |
| 608 |
%%% fine $ %%%% temporary formatting convention for MFT |
| 609 |
if $>fudged.hair: $:=fudged.hair; fi |
| 610 |
$.breadth:=$; |
| 611 |
pickup if $=0: nullpen else: pencircle scaled $; $:=$-eps fi; |
| 612 |
$.nib:=savepen; breadth_[$.nib]:=$; |
| 613 |
forsuffixes $$=lft,rt,top,bot: shiftdef($.$$,$$ 0); endfor endfor |
| 614 |
%%% @ $ %%%% restore ordinary formatting for $ |
| 615 |
min_Vround:=max(fine.breadth,crisp.breadth,tiny.breadth); |
| 616 |
if min_Vround<vround min_Vround: min_Vround:=vround min_Vround; fi |
| 617 |
if flare<vround flare: flare:=vround flare; fi |
| 618 |
forsuffixes $=vair,bar,slab,cap_bar,cap_band,vair',vstem,cap_vstem,bold: |
| 619 |
if $<min_Vround: $:=min_Vround; fi endfor |
| 620 |
pickup pencircle scaled rule_thickness; rule.nib:=savepen; |
| 621 |
math_axis:=good.y(math_axis#*hppp); |
| 622 |
% Edited: make sure the light rule is no heavier than the regular rule |
| 623 |
pickup pencircle scaled if hefty:(min(rule_thickness,.6[vair,fudged.hair])) else:fudged.hair fi; |
| 624 |
light_rule.nib:=savepen; |
| 625 |
% Edited: use cal_cap_curve and cal_cap_hair for calligraphy |
| 626 |
% (cal.nib, tilted.nib and cal.extension are used only in calu.mf) |
| 627 |
pickup pencircle xscaled cal_cap_curve yscaled cal_cap_hair rotated 30; |
| 628 |
cal.nib:=savepen; |
| 629 |
pair cal.extension; cal.extension:=(.75cal_cap_curve,0) rotated 30; |
| 630 |
pickup pencircle xscaled cal_cap_curve yscaled cal_cap_hair rotated 70; |
| 631 |
tilted.nib:=savepen; |
| 632 |
pickup pencircle xscaled cal_curve yscaled cal_cap_hair rotated 70; |
| 633 |
med_tilted.nib:=savepen; |
| 634 |
pickup pencircle xscaled cal_cap_stem yscaled cal_cap_hair rotated 30; |
| 635 |
med_cal.nib:=savepen; |
| 636 |
pickup pencircle xscaled cal_stem yscaled cal_cap_hair rotated 30; |
| 637 |
light_cal.nib:=savepen; |
| 638 |
pickup pencircle xscaled(cal_cap_curve+dw) yscaled cal_cap_hair rotated 30; |
| 639 |
heavy_cal.nib:=savepen; |
| 640 |
bot_flourish_line:=-.5u-o; |
| 641 |
pair bend; bend=(.5u,0); |
| 642 |
pair flourish_change; flourish_change=(4u,.2asc_height); |
| 643 |
join_radius:=u; |
| 644 |
currenttransform:=identity slanted slant |
| 645 |
yscaled aspect_ratio scaled granularity; |
| 646 |
if currenttransform=identity: let t_=relax |
| 647 |
else: def t_ = transformed currenttransform enddef fi; |
| 648 |
numeric paren_depth#; .5[body_height#,-paren_depth#]=math_axis#; |
| 649 |
numeric asc_depth#; .5[asc_height#,-asc_depth#]=math_axis#; |
| 650 |
body_depth:=desc_depth+body_height-asc_height; |
| 651 |
shrink_fit:=1+hround(2letter_fit#*hppp)-2letter_fit; |
| 652 |
if not string mode: if mode<=smoke: shrink_fit:=0; fi fi |
| 653 |
enddef; |
| 654 |
|
| 655 |
def shiftdef(suffix $)(expr delta) = |
| 656 |
vardef $ primary x = x+delta enddef enddef; |
| 657 |
|
| 658 |
def makebox(text rule) = |
| 659 |
for y=0,asc_height,body_height,x_height,bar_height,-desc_depth,-body_depth: |
| 660 |
rule((l,y)t_,(r,y)t_); endfor % horizontals |
| 661 |
for x=l,r: rule((x,-body_depth)t_,(x,body_height)t_); endfor % verticals |
| 662 |
for x=u*(1+floor(l/u)) step u until r-1: |
| 663 |
rule((x,-body_depth)t_,(x,body_height)t_); endfor % more verticals |
| 664 |
if charic<>0: |
| 665 |
rule((r+charic*pt,h.o_),(r+charic*pt,.5h.o_)); fi % italic correction |
| 666 |
enddef; |
| 667 |
def maketicks(text rule) = |
| 668 |
for y=0,h.o_,-d.o_: |
| 669 |
rule((l,y),(l+10,y)); rule((r-10,y),(r,y)); endfor % horizontals |
| 670 |
for x=l,r: |
| 671 |
rule((x,10-d.o_),(x,-d.o_)); rule((x,h.o_-10),(x,h.o_)); endfor % verticals |
| 672 |
if charic<>0: |
| 673 |
rule((r+charic*pt,h.o_-10),(r+charic*pt,h.o_)); fi % italic correction |
| 674 |
enddef; |
| 675 |
rulepen:=pensquare; |
| 676 |
|
| 677 |
vardef stroke text t = |
| 678 |
forsuffixes e = l,r: path_.e:=t; endfor |
| 679 |
if cycle path_.l: |
| 680 |
errmessage "Beware: `stroke' isn't intended for cycles"; fi |
| 681 |
path_.l -- reverse path_.r -- cycle enddef; |
| 682 |
|
| 683 |
vardef circ_stroke text t = |
| 684 |
forsuffixes e = l,r: path_.e:=t; endfor |
| 685 |
if cycle path_.l: |
| 686 |
errmessage "Beware: `stroke' isn't intended for cycles"; fi |
| 687 |
path_.l -- reverse path_.r .. cycle enddef; |
| 688 |
|
| 689 |
vardef sans_circ_stroke text t = |
| 690 |
forsuffixes e = l,r: path_.e:=t; endfor |
| 691 |
if cycle path_.l: |
| 692 |
errmessage "Beware: `stroke' isn't intended for cycles"; fi |
| 693 |
path_.l -- reverse path_.r if serifs: .. else: -- fi cycle enddef; |
| 694 |
|
| 695 |
|
| 696 |
vardef super_arc.r(suffix $,$$) = % outside of super-ellipse |
| 697 |
pair center,corner; |
| 698 |
if y$=y$r: center=(x$$r,y$r); corner=(x$r,y$$r); |
| 699 |
else: center=(x$r,y$$r); corner=(x$$r,y$r); fi |
| 700 |
z$.r{corner-z$.r}...superness[center,corner]{z$$.r-z$.r} |
| 701 |
...{z$$.r-corner}z$$.r enddef; |
| 702 |
|
| 703 |
vardef super_arc.l(suffix $,$$) = % inside of super-ellipse |
| 704 |
pair center,corner; |
| 705 |
if y$=y$r: center=(x$$l,y$l); corner=(x$l,y$$l); |
| 706 |
else: center=(x$l,y$$l); corner=(x$$l,y$l); fi |
| 707 |
z$l{corner-z$l}...superness[center,corner]{z$$l-z$l} |
| 708 |
...{z$$l-corner}z$$l enddef; |
| 709 |
|
| 710 |
vardef pulled_super_arc.r(suffix $,$$)(expr superpull) = |
| 711 |
pair center,corner; |
| 712 |
if y$=y$r: center=(x$$r,y$r); corner=(x$r,y$$r); |
| 713 |
else: center=(x$r,y$$r); corner=(x$$r,y$r); fi |
| 714 |
z$r{corner-z$r}...superness[center,corner]{z$$r-z$r} |
| 715 |
...{z$$r-corner}z$$r enddef; |
| 716 |
|
| 717 |
vardef pulled_super_arc.l(suffix $,$$)(expr superpull) = |
| 718 |
pair center,corner,outer_point; |
| 719 |
if y$=y$r: center=(x$$l,y$l); corner=(x$l,y$$l); |
| 720 |
outer_point=superness[(x$$r,y$r),(x$r,y$$r)]; |
| 721 |
else: center=(x$l,y$$l); corner=(x$$l,y$l); |
| 722 |
outer_point=superness[(x$r,y$$r),(x$$r,y$r)]; fi |
| 723 |
z$l{corner-z$l} |
| 724 |
...superpull[superness[center,corner],outer_point]{z$$l-z$l} |
| 725 |
...{z$$l-corner}z$$l enddef; |
| 726 |
|
| 727 |
vardef pulled_arc@#(suffix $,$$) = |
| 728 |
pulled_super_arc@#($,$$)(superpull) enddef; |
| 729 |
|
| 730 |
vardef serif_arc(suffix $,$$) = |
| 731 |
z${x$$-x$,0}...(.75[x$,x$$],.25[y$,y$$]){z$$-z$}...{0,y$$-y$}z$$ enddef; |
| 732 |
|
| 733 |
vardef penpos@#(expr b,d) = |
| 734 |
if known b: if b<=0: errmessage "bad penpos"; fi fi |
| 735 |
(x@#r-x@#l,y@#r-y@#l)=(b,0) rotated d; |
| 736 |
x@#=.5(x@#l+x@#r); y@#=.5(y@#l+y@#r) enddef; |
| 737 |
|
| 738 |
newinternal currentbreadth; |
| 739 |
vardef pos@#(expr b,d) = |
| 740 |
if known b: if b<=currentbreadth: errmessage "bad pos"; fi fi |
| 741 |
(x@#r-x@#l,y@#r-y@#l)=(b-currentbreadth,0) rotated d; |
| 742 |
x@#=.5(x@#l+x@#r); y@#=.5(y@#l+y@#r) enddef; |
| 743 |
def numeric_pickup_ primary q = |
| 744 |
currentpen:=pen_[q]; |
| 745 |
pen_lft:=pen_lft_[q]; pen_rt:=pen_rt_[q]; |
| 746 |
pen_top:=pen_top_[q]; pen_bot:=pen_bot_[q]; |
| 747 |
currentpen_path:=pen_path_[q]; |
| 748 |
if known breadth_[q]: currentbreadth:=breadth_[q]; fi enddef; |
| 749 |
|
| 750 |
vardef ic# = charic enddef; |
| 751 |
vardef h# = charht enddef; |
| 752 |
vardef w# = charwd enddef; |
| 753 |
vardef d# = chardp enddef; |
| 754 |
|
| 755 |
let {{=begingroup; let }}=endgroup; |
| 756 |
def .... = .. tension atleast .9 .. enddef; |
| 757 |
def less_tense = save ...; let ...=.... enddef; |
| 758 |
def ?? = hide(showvariable x,y) enddef; |
| 759 |
|
| 760 |
let semi_ =;; let colon_ = :; let endchar_ = endchar; |
| 761 |
def iff expr b = if b:let next_=use_it else:let next_=lose_it fi; next_ enddef; |
| 762 |
def use_it = let : = restore_colon; enddef; |
| 763 |
def restore_colon = let : = colon_; enddef; |
| 764 |
def lose_it = let endchar=fi; inner cmchar; let ;=fix_ semi_ if false enddef; |
| 765 |
def fix_=let ;=semi_; let endchar=endchar_; outer cmchar; enddef; |
| 766 |
def always_iff = let : = endgroup; killboolean enddef; |
| 767 |
def killboolean text t = use_it enddef; |
| 768 |
outer cmchar; |