summaryrefslogtreecommitdiff
path: root/fonts/mathabx/source/mathcdrv.mf
blob: 3780a3914da79af1076e32dd76659c81995f4933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
% mathematical symbols by Anthony Phan.
% file: mathadrv.mf (driver file for matha serie,
% U stands for Unsupported)
% last modification: May 16, 2005.

mode_setup;
math_setup;
%
% This file calls calu.mf and then extends
% the superb work of N. N. Billawala into
% a whole OT1 font.
%

%
% First thing to do is to copy Computer Modern's
% control sequences and setup.
%
%slant := 0;
newinternal l, r, shrink_fit; % adjustments to spacing
boolean math_fitting;

flare := dtsz;
flare# := dtsz#;

def cal_setup = 
  let adjust_fit = normal_adjust_fit;
  pickup pencircle xscaled cap_curve yscaled cap_hair rotated 30;
  cal.nib := savepen;
  pair cal.extension; cal.extension := (.75cap_curve, 0) rotated 30;
  pickup pencircle xscaled cap_curve yscaled cap_hair rotated 70;
  tilted.nib := savepen;
  pickup pencircle xscaled curve yscaled cap_hair rotated 70;
  med_tilted.nib := savepen;
  pickup pencircle xscaled cap_stem yscaled cap_hair rotated 30;
  med_cal.nib := savepen;
  pickup pencircle xscaled stem yscaled cap_hair rotated 30;
  light_cal.nib := savepen;
  % 
  % lowercase and punctuation
  %
  pickup pencircle xscaled curve yscaled hair rotated 30;
  lower_cal.nib := savepen;
  lower_cal_width# := curve#*cosd 30+hair#*sind 30;
  pickup pencircle xscaled 0.5[hair, curve] yscaled hair rotated 30;
  fine_cal.nib := savepen;
  %
  pickup pencircle xscaled(cap_curve+dw) yscaled cap_hair rotated 30;
  heavy_cal.nib := savepen;
  bot_flourish_line := -0.5u-o;
  pair bend; bend = (.5u, 0);
  pair flourish_change; flourish_change = (4u, .2asc_height);
  join_radius := u;
  shrink_fit := 1+hround(2letter_fit#*hppp)-2letter_fit;
enddef;

let cmchar = \;
def .... = .. tension atleast .9 .. enddef;
vardef w# = charwd enddef;
vardef d# = chardp enddef;
vardef h# = charht enddef;
vardef ic# = charic enddef;

def do_expansion(expr expansion_factor) = 
  forsuffixes $ = u, jut, cap_jut, beak_jut, apex_corr:
    $ := $.#*expansion_factor*hppp; endfor
enddef;

def normal_adjust_fit(expr left_adjustment, right_adjustment) = 
  numeric charwd_in; charwd_in = charwd;
  l := -hround(left_adjustment*hppp)-letter_fit;
  interim xoffset := -l;
  charwd := charwd+2letter_fit#+left_adjustment+right_adjustment;
  r := l+hround(charwd*hppp)-shrink_fit;
  w := r-hround(right_adjustment*hppp)-letter_fit;
  do_expansion(w/(charwd_in*hppp));
enddef;

def mono_adjust_fit(expr left_adjustment, right_adjustment) = 
  numeric charwd_in; charwd_in = charwd;
  numeric expansion_factor;
  mono_charwd# = 2letter_fit#
  +expansion_factor*(charwd+left_adjustment+right_adjustment);
  l := -hround(left_adjustment*expansion_factor*hppp)-letter_fit;
  interim xoffset := -l;
  r := l+mono_charwd-shrink_fit;
  w := r-hround(right_adjustment*expansion_factor*hppp)-letter_fit;
  charwd := mono_charwd#; charic := mono_charic#;
  do_expansion(w/(charwd_in*hppp));
enddef;

extra_endchar := extra_endchar&"r := r+shrink_fit; w := r-l;";

def ignore_math_fit(expr left_adjustment, right_adjustment) = enddef;

def do_math_fit(expr left_adjustment, right_adjustment) = 
  l := l-hround(left_adjustment*hppp); interim xoffset := -l;
  charwd := charwd+left_adjustment+right_adjustment;
  r := l+hround(charwd*hppp)-shrink_fit;
  charic := charic-right_adjustment;
  if charic<0: charic := 0; fi
enddef;

currenttransform := identity slanted slant
yscaled aspect_ratio scaled granularity;
def t_ = transformed currenttransform enddef;

cal_setup;
autorounding := hair;

%
% UPPERCASE
%

let math_fit = do_math_fit;
math_fitting := true;
input calu.mf;

%
% OTHER CASES
%

let math_fit = ignore_math_fit;
math_fitting := false;

vardef hook_in(suffix $, $$, $$$) = 
  x$ := good.x x$;
  x$$ = max(x$$$-1.25u, 0.5[x$, x$$$]);
  top y$$ = x_height+oo; y$ = good.y 7/8[0, y$$];
  y$$$ = 3/4x_height;
  z$...z$$ right_to_down z$$$
enddef;

vardef hook_out(suffix $, $$, $$$) = 
  x$$$ := good.x x$$$;
  x$$ = min(x$+1.25u, 0.5[x$, x$$$]);
  bot y$$ = -oo; y$ = 1/4x_height; y$$$ = good.y 7/8[x_height, y$$];
  z$ down_to_right z$$...z$$$ % super_arc
enddef;

vardef ital_arch(suffix $, $$, $$$) = 
  x$$ = 0.6[x$, x$$$];
  top y$$ = x_height+oo; y$$$ = 0.65x_height;
  z${up}...z$$ right_to_down z$$$ % super_arc
enddef;

vardef desc_curve(suffix $, $$, $$$) = 
  x$$$ := good.x x$$$; x$$ = 0.6[x$, x$$$];
  y$ = 0; bot y$$ = -d-oo; y$$$ = good.y 1/3[y$$, y$];
  z${down}...z$$ left_to_up z$$$...z$$$+round(1.1u*dir 60)
enddef;

vardef cal_dot@#(expr $, $$, dotsize) = 
  rt x@#a-lft x@#c = top y@#b-bot y@#d = dotsize+2eps;
  rt x@#a = hround($+0.5dotsize)+eps;
  top y@#b = vround($$+0.5dotsize)+eps;
  y@#a = y@#c = 0.5[y@#b, y@#d];
  x@#b = x@#d = 0.5[x@#c, x@#a];
  filldraw superellipse(z@#a, z@#b, z@#c, z@#d, superness);
  labels(@#a, @#b, @#c, @#d);
enddef;

comma_depth# := 0.75desc_depth#;
comma_depth := vround 0.75desc_depth;

vardef cal_comma@#(expr $, $$, deviation, prof) = 
  pickup fine_cal.nib;
  cal_dot@#($, $$, dtsz);
  if $$>prof: bot else: top fi y@#f = prof;
  y@#e = 0.25[$$, y@#f];
  if deviation>0:
    x@#f = x@#c; rt x@#e = hround($+dtsz)+eps;
    draw if $$>prof: z@#b else: z@#d fi right_to_down z@#e
    ...{x@#f-x@#e, (1-superness)*(y@#f-y@#e)}z@#f;
  else:
    x@#f = x@#a; lft x@#e = hround($-dtsz)-eps;
    draw if $$<prof: z@#d else: z@#b fi right_to_up z@#e
    ...{x@#f-x@#e, (1-superness)*(y@#f-y@#e)}z@#f;
  fi
  labels(@#e, @#f);
enddef;

%
% LOWERCASE, DIGITS, PUNCTUATION
%

input mathcall;

%
% GREEK
%

input mathcallgreek;

currenttransform := identity
yscaled aspect_ratio scaled granularity;
autorounding := 0;
extra_endchar := "";
standard_proofing;

extra_endchar := extra_endchar & "; charcode := charcode+code_offset;";
dagesh := false; code_offset := 128;

%
% HEBREW
%

input mathhbrw;

dagesh := true; code_offset := 160;

%
% HEBREAW WITH DAGESH
%

input mathhbrw;

code_offset := 0;

% parameters for TFM files.

font_slant = 0;
font_x_height = x_height#;
font_normal_stretch = 3u#;
font_normal_shrink = 2u#;
font_quad = 18u#+4letter_fit#;
font_extra_space = 2u#;
font_normal_space = 6u#+2letter_fit#;

end.