1%% filename: cyrilu.mf
2%% version: 2.2
3%% date: 1995/01/04
4%%
5%% American Mathematical Society
6%% Technical Support
7%% Publications Technical Group
8%% 201 Charles Street
9%% Providence, RI 02904
10%% USA
11%% tel: (401) 455-4080
12%%      (800) 321-4267 (USA and Canada only)
13%% fax: (401) 331-3842
14%% email: tech-support@ams.org
15%%
16%% Copyright 1995 Humanities and Arts Computing Center, University of
17%% Washington.
18%%
19%% Unlimited copying and redistribution of this file are permitted as
20%% long as this file is not modified.  Modifications, and distribution
21%% of modified versions, are permitted, but only if the resulting file
22%% is renamed.
23%%
24%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25%  This file contains definitions of letters that have the same shapes in
26%  both upper and lower case.
27
28cmchar "The Russian letter TSE";
29beginchar("C",13u#+width_adj#,cap_height#,0);
30italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
31adjust_fit(cap_serif_fit#,cap_serif_fit#);
32pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
33pos3(cap_stem,0); pos4(cap_stem,0);
34lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
35top y1=top y3=h; bot y2=bot y4=0;
36filldraw stroke z1e--z2e; % left stem
37filldraw stroke z3e--z4e; % right stem
38if serifs: numeric inner_jut;
39  if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
40  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
41  dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
42  dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper left serif
43  inner_jut:=.5(x3l-x1r);
44  nodish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
45  r_cyr_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);   % lower left serif
46else:
47  lcyrsanserif(4); lft x2'= lft x2l; bot y2'l=0; pos2'(slab,90);
48  rt x4'=rt x4r; y4'=y2'; pos4'(slab,90); filldraw stroke z2'e--z4'e;
49fi
50math_fit(0,.5ic#); penlabels(1,2,3,4,5,6); endchar;
51
52cmchar "The Russian letter DE";
53beginchar("D",13u#,cap_height#,0);
54adjust_fit(.25u#,.75u#);
55pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
56lft x1l=lft x2l=hround(w-3u); top y1=h; bot y2=0;
57x3=u+.75cap_jut; bot y3l=0; pos3(cap_hair,90); lft x3'l=x3l; bot y3'=0;
58if serifs: pos3'(1.5cap_hair,0); else: pos3'(cap_hair,0); fi
59x5=.42[x3,x1]; top y5=h;
60if serifs: pos5(1.5cap_hair,0); else: pos5(cap_hair,0);  fi
61filldraw stroke z1e--z2e;
62filldraw stroke z3'e{z1-z3}...{up}z5e;
63bot y4l=0; x4=x2r; pos4(cap_hair,90);
64%filldraw stroke z3e--z4e;
65pickup crisp.nib;
66top y6=h;  x6-.75cap_jut=rt x1r; pos6(slab,90);
67x9=x5; y9r=0; pos9(cap_hair,90);
68if serifs:
69  numeric inner_jut;
70  inner_jut=.5(x1-x5);
71  nodish_serif(5,9,aa,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
72  nodish_serif(1,2,ae,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
73  inner_jut:=.5(x2-x3);
74  l_cyr_serif(3',1,ac,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
75  r_cyr_serif(2,1,ag,1/3,inner_jut,h,1/3,cap_jut);   % lower right serif
76else:
77  cyrsanserif(3'); lcyrsanserif(2);
78  x5'=lft x5l; top y5'=h; pos5'(slab,90);
79  filldraw stroke z3e--z4e; filldraw stroke z5'e--z6e;
80fi
81endchar;
82
83cmchar "The Russian letter GHE (looks like Gamma)";
84beginchar("G",11.5u#-width_adj#,cap_height#,0);
85italcorr cap_height#*slant-beak_jut#-.25u#;
86adjust_fit(cap_serif_fit#,0);
87h:=vround(h-stem_corr);
88pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
89lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); top y1=h; bot y2=0;
90filldraw stroke z1e--z2e; % stem
91pickup crisp.nib; pos3(slab,90); pos4(hair,0);
92top y3r=h; x3=x1; rt x4r=hround(w-.75u); y4=good.y(y3l-beak)-eps;
93arm(3,4,e,beak_darkness,beak_jut);  % upper arm and beak
94pos5(cap_bar,-90); pos6(hair,0);
95top y5l=vround(.5[y2,y1]+.5cap_bar); x5=x1;
96pos0(cap_bar,90); pos7(hair,0);
97z0=z5; x6=x7; y6-y5l=y0l-y7;
98if serifs: rt x6r=hround(w-4u+.5hair); y6=good.y(y5l+.6beak)+eps;
99  rt x9r=hround(w-.5u);
100else: rt x6r=hround(w-1.5u); y6=y5l+eps; rt x9r=hround(w-.75u);
101fi
102%arm(5,6,f,beak_darkness,0); arm(0,7,g,beak_darkness,0);  % middle arm and serif
103if serifs: nodish_serif(1,2,a,1/3,cap_jut,b,1/3,.5cap_jut);  % upper serif
104  dish_serif(2,1,c,1/3,cap_jut,d,1/3,1.25cap_jut);  % lower serif
105fi
106math_fit(0,ic#-2.5u#); penlabels(0,1,2,3,4,5,6,7,8,9); endchar;
107
108cmchar "The Russian letter KHA (looks like X)";
109beginchar("H",13u#,cap_height#,0);
110italcorr cap_height#*slant-.25u#;
111adjust_fit(cap_serif_fit#,cap_serif_fit#);
112numeric stem[],outer_jut,xjut,alpha[];
113stem1=cap_stem-2stem_corr; stem2=min(cap_hair,stem1);
114outer_jut=.75cap_jut; xjut= if serifs: (stem1-stem2)/4 else: 0 fi;
115x1l=l+letter_fit+.5u+outer_jut; x2r=r-letter_fit-u-outer_jut-xjut;
116x3l=l+letter_fit+.25u+outer_jut+xjut; x4r=r-letter_fit-.25u-outer_jut;
117y1=y2=h; y3=y4=0;
118alpha1=diag_ratio(1,stem1,h,x4r-x1l);
119alpha2=diag_ratio(1,stem2,h,x2r-x3l);
120penpos1(alpha1*stem1,0); penpos2(alpha2*stem2,0);
121penpos3(alpha2*stem2,0); penpos4(alpha1*stem1,0);
122if hefty: z0=whatever[z1,z4]=whatever[z2,z3];
123  x12=x34=x0; y13=y24=y0;
124  z12=whatever[z2l,z3l]; z13=whatever[z2l,z3l];
125  z24=whatever[z2r,z3r]; z34=whatever[z2r,z3r];
126  forsuffixes $=13,24,34: z$'=.1[z$,z0]; endfor
127  fill diag_end(12,1r,.5,1,1l,13')--z13'--diag_end(13',3l,1,.5,3r,34')--z34'
128   --diag_end(34',4l,.5,1,4r,24')--z24'
129   --diag_end(24',2r,1,.5,2l,12)--z12--cycle; % diagonals
130else: fill diag_end(4r,1r,.5,1,1l,4l)
131   --diag_end(1l,4l,.5,1,4r,1r)--cycle; % left diagonal
132  fill diag_end(2l,3l,.5,1,3r,2r)
133   --diag_end(3r,2r,.5,1,2l,3l)--cycle;  % right diagonal
134fi
135if serifs: numeric inner_jut[]; pickup tiny.nib;
136  prime_points_inside(1,4); prime_points_inside(2,3);
137  prime_points_inside(3,2); prime_points_inside(4,1);
138  if rt x1'r+cap_jut+.5u+1<=lft x2'l-cap_jut-xjut: inner_jut1=cap_jut;
139  else: rt x1'r+inner_jut1+.5u+1=lft x2'l-inner_jut1-xjut; fi
140  if rt x3'r+cap_jut+.5u+1<=lft x4'l-cap_jut-xjut: inner_jut2=cap_jut;
141  else: rt x3'r+inner_jut2+.5u+1=lft x4'l-inner_jut2-xjut; fi
142  dish_serif(1',4,a,1/3,outer_jut,b,2/3,inner_jut1);  % upper left serif
143  dish_serif(4',1,c,2/3,inner_jut2,d,1/3,outer_jut);  % lower right serif
144  dish_serif(2',3,e,2/3,inner_jut1+xjut,
145   f,1/2,outer_jut+xjut)(dark);  % upper right serif
146  dish_serif(3',2,g,1/2,outer_jut+xjut,
147   h,2/3,inner_jut2+xjut)(dark);  % lower left serif
148fi
149math_fit(0,.5ic#); penlabels(0,1,2,3,4,12,13,24,34); endchar;
150
151cmchar "The Russian letter I (looks like backwards N)";
152beginchar("I",14u#+width_adj#,cap_height#,0);
153italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
154adjust_fit(cap_serif_fit#,cap_serif_fit#);
155pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
156pos3(cap_stem,0); pos4(cap_stem,0);
157lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
158top y1=top y3=h; bot y2=bot y4=0;
159filldraw stroke z1e--z2e; % left stem
160filldraw stroke z3e--z4e; % right stem
161if serifs: penpos5(.85cap_stem,90); penpos6(.85cap_stem,90);
162else: penpos5(cap_stem,90); penpos6(cap_stem,90);
163fi
164x5=x1r; x6=x3l; if serifs: y5=.1h; y6=.9h; else: bot y5l=0; top y6r=h; fi
165fill stroke z5e--z6e;  % bar
166if serifs: numeric inner_jut;
167  if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
168  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
169  dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
170  dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
171  dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper left serif
172  dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);  % lower left serif
173fi
174math_fit(0,.5ic#); penlabels(1,2,3,4,5,6); endchar;
175
176%  The letter "K" is the last character defined in this file.
177%  See below for comments.
178
179cmchar "The Russian letter EL";
180beginchar("L",13u#,cap_height#,0);
181adjust_fit(0,1.5u#);
182numeric ldot_size; ldot_size=1.15flare;
183pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
184lft x1l=lft x2l=hround(w-3u); top y1=h; bot y2=0;
185filldraw stroke z1e--z2e;
186if serifs:
187  numeric inner_jut; inner_jut=.5(x1-x5);
188  x4=u+.5ldot_size; x3=x4+.5ldot_size; bot y3r=0; pos3(1.5cap_hair,-90);
189  x5=.42[x4,x1]; top y5=h; pos5(1.5cap_hair,0); pos4(ldot_size,-180);
190  pos10(hair,-180);
191  filldraw stroke z3e{right}...{up}z5e;
192  y4=ldot_size; bulb(3,10,4);
193  dish_serif(2,1,a,1/3,cap_jut,b,1/3,cap_jut);
194  nodish_serif(1,2,c,1/3,inner_jut,d,1/3,cap_jut);
195  top y6=h;  x6-.75cap_jut=rt x1r; pos6(slab,90);
196  x5'+.5cap_jut=lft x5l; top y5'=h; pos5'(slab,90);
197  x9=x5; y9=0; pos9(cap_hair,0);
198  nodish_serif(5,9,aa,1/3,cap_jut,ab,1/3,inner_jut);  % upper left serif
199else:
200  x5r=hround u; bot y5r=vround(.06h-o); bot y4r=-o; x4r=.35[x5,x3r];
201  x3=x5+3flare; top y3=h; lft x3'=lft x3l; top y3'r=h; rt x1'r=rt x1r;
202  top y1'r=h; pos3'(slab,90); pos1'(slab,90); pos5(flare,-120); pos4(vair,-90);
203  pos3(hair,0);
204  filldraw stroke z5e...{right}z4e...{up}z3e;
205  filldraw stroke z3'e--z1'e;
206fi
207endchar;
208
209cmchar "The Russian letter EM";
210beginchar("M",16u#+width_adj#,cap_height#,0);
211italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
212adjust_fit(cap_serif_fit#,cap_serif_fit#);
213numeric stem[]; % thicknesses of the four strokes
214stem1=hround(fudged.hair+stem_corr);
215stem2=hround(fudged.cap_stem-4stem_corr);
216stem3=hround(fudged.hair-stem_corr);
217stem4=hround(fudged.cap_stem-3stem_corr);
218if stem4<stem1: stem4:=stem1; fi
219pickup tiny.nib; pos1(stem1,0); pos2(stem1,0);
220pos3(stem4,0); pos4(stem4,0);
221x1=x2; x3=x4; x1l=w-x3r; rt x3r=hround min(w-2u,w-3u+.5stem4);
222top y1=top y3=h; bot y2=bot y4=0;
223filldraw stroke z1e--z2e; % left stem
224filldraw stroke z3e--z4e; % right stem
225penpos5(stem2,0); penpos6(stem2,0); penpos7(stem3,0); penpos8(stem3,0);
226x5l=x1; x6l=x7l; x8=lft x3l; x6-x5=x8-x7; y5=y8=h; y6=y7;
227if hefty: y6=if monospace: vround 1/3h else: o fi;
228 numeric upper_notch,lower_notch;
229 upper_notch=h-cap_notch_cut; lower_notch=y6+cap_notch_cut;
230 x1'=rt x1r; z1'=whatever[z5l,z6l]; x3'=lft x3l; z3'=whatever[z7r,z8r];
231 z0=whatever[z5r,z6r]=whatever[z7l,z8l];
232 fill z5l..
233  if y1'<upper_notch: {right}(x1'+1,upper_notch){down}... fi
234  {z6-z5}diag_in(5l,6l,1,6r)..diag_out(7l,1,7r,8r){z8-z7}
235  if y3'<upper_notch: ...{up}(x3'-1,upper_notch){right} fi
236  ..z8r--diag_out(8r,1,8l,7l){z7-z8}
237  if y0<=lower_notch: ..{z7-z8}z0{z5-z6}..
238  else: ...{down}(x0+.5,lower_notch)--(x0-.5,lower_notch){up}... fi
239  {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonals
240else: y6=0; z0=whatever[z5r,z6r]=whatever[z7l,z8l];
241 fill z5l..{z6-z5}diag_in(5l,6l,1,6r)..diag_out(7l,1,7r,8r){z8-z7}
242  ..z8r--diag_out(8r,1,8l,7l){z7-z8}..{z7-z8}z0{z5-z6}
243  ..{z5-z6}diag_in(6r,5r,1,5l)--cycle; fi  % diagonals
244if serifs: serif(1,2,a,1/3,-cap_jut);  % upper left serif
245 dish_serif(2,1,b,1/2,cap_jut,c,1/2,cap_jut)(dark); % lower left serif
246 serif(3,4,d,1/3,cap_jut); %  upper right serif
247 dish_serif(4,3,e,1/3,cap_jut,f,1/3,cap_jut); fi  % lower right serif
248math_fit(0,max(.5ic#-.5u#,0));
249penlabels(0,1,1',2,3,3',4,5,6,7,8); endchar;
250
251cmchar "The Russian letter EN (looks like H)";
252beginchar("N",13u#+width_adj#,cap_height#,0);
253italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
254adjust_fit(cap_serif_fit#,cap_serif_fit#);
255pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
256pos3(cap_stem,0); pos4(cap_stem,0);
257lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
258top y1=top y3=h; bot y2=bot y4=0;
259filldraw stroke z1e--z2e; % left stem
260filldraw stroke z3e--z4e; % right stem
261penpos5(cap_bar,90); penpos6(cap_bar,90);
262x5=x1; x6=x3; y5=y6=.52h;
263fill stroke z5e--z6e;  % bar
264if serifs: numeric inner_jut;
265 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
266 else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
267 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
268 dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
269 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper left serif
270 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut); fi  % lower left serif
271math_fit(0,.5ic#); penlabels(1,2,3,4,5,6); endchar;
272
273cmchar "The Russian letter PE (looks like PI)";
274beginchar("P",13u#+width_adj#,cap_height#,0);
275italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
276adjust_fit(cap_serif_fit#,cap_serif_fit#);
277pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
278pos3(cap_stem,0); pos4(cap_stem,0);
279lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
280top y1=top y3=h; bot y2=bot y4=0;
281filldraw stroke z1e--z2e; % left stem
282filldraw stroke z3e--z4e; % right stem
283if serifs: numeric inner_jut;
284 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
285 else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
286 dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
287 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);   % lower left serif
288 inner_jut:=.5(x3l-x1r);
289 nodish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
290 nodish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper left serif
291else:
292 lft x1'= lft x1l; top y1'r=h; pos1'(slab,90);
293 rt x3'=rt x3r; y3'=y1'; pos3'(slab,90); filldraw stroke z1'e--z3'e;
294fi
295math_fit(0,.5ic#); penlabels(1,2,3,4,5,6); endchar;
296
297cmchar "The Russian letter CHE";
298beginchar("Q",14u#+width_adj#,cap_height#,0);
299italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
300adjust_fit(cap_serif_fit#,cap_serif_fit#);
301pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
302pos3(cap_stem,0); pos4(cap_stem,0);
303lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
304top y1=top y3=h; %bot y2=x_height;
305bot y4=0;
306x22=x3; y22=.65h; %x_height-.25bar_height;
307pos22(cap_bar,90); y2=y22;
308filldraw stroke z1e--z2e{down}...{1,2}z22e; % left stem and bowl
309filldraw stroke z3e--z4e; % right stem
310if serifs: numeric inner_jut;
311 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
312 else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
313 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
314% dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
315 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper left serif
316 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut); fi  % lower left serif
317math_fit(0,.5ic#); penlabels(1,2,3,4,5,6); endchar;
318
319cmchar "The Russian letter TE";
320beginchar("T",13u#-width_adj#,cap_height#,0);
321italcorr cap_height#*slant-beak_jut#-.25u#;
322adjust_fit(0,0);
323h:=vround(h-2stem_corr);
324pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
325lft x1l=lft x2l=hround(.5w-.5cap_stem); top y1=h; bot y2=0;
326filldraw stroke z1e--z2e; % stem
327pickup crisp.nib; pos3(slab,90); pos4(hair,0);
328top y3r=h; x3=x1; rt x4r=hround(w-.65u); y4=good.y(y3l-beak)-eps;
329arm(3,4,e,beak_darkness,.7beak_jut);  % right arm and beak
330pos5(hair,180); x5=w-x4; y5=y4;
331arm(3,5,f,beak_darkness,-.7beak_jut);  % left arm and beak
332if serifs: dish_serif(2,1,c,1/3,1.414cap_jut,d,1/3,1.414cap_jut);  % lower serif
333 nodish_serif(1,2,a,1/3,.5cap_jut,b,1/3,.5cap_jut); fi  % upper bracketing
334math_fit(-.75cap_height#*slant,ic#-2.5u#); penlabels(1,2,3,4,5,6); endchar;
335
336cmchar "The Russian letter VE (looks like B)";
337beginchar("V",12.5u#,cap_height#,0);
338italcorr .75cap_height#*slant-.5u#;
339adjust_fit(cap_serif_fit#,0);
340numeric left_stem,right_curve,middle_weight;
341left_stem=cap_stem-hround 2stem_corr; middle_weight=.6vair+.5;
342pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
343lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
344filldraw stroke z1e--z2e; % stem
345penpos3(cap_band,90); penpos4(cap_band,90);
346penpos6(middle_weight,-90); penpos7(middle_weight,-90);
347penpos8(middle_weight,90); penpos9(middle_weight,90);
348penpos5(right_curve-stem_corr,0); penpos10(right_curve,0);
349penpos11(cap_band,-90); penpos12(cap_band,-90);
350z3r=top z1; y4=y3; y5=.5[y4,y6]; y6=y7; y7l-y8l=vair;
351z12r=bot z2; y11=y12; y10=.5[y11,y9]; y8=y9; .5[y7l,y8l]=.52h;
352x4=x6; x9=x11=x4+.5u; x7=x8=x1; x9l:=x4+.25u;
353x5r=hround(w-1.5u); x10r=hround(w-u);
354if serifs: right_curve=cap_curve-stem_corr; x4=.5[x1,w-1.5u];
355else: right_curve=cap_curve-3stem_corr; x4=.5[x1,w-2.5u];
356 x4l:=x4l-.5u; x9l:=x9l-.5u; fi
357x6l:=x6l-.5u; x11l:=x11l-.5u;
358fill stroke z3e..super_arc.e(4,5) & super_arc.e(5,6)..z7e;  % upper lobe
359fill stroke z8e..super_arc.e(9,10) & super_arc.e(10,11)..z12e;  % lower lobe
360if serifs: nodish_serif(1,2,a,1/3,cap_jut,b,1/3,.5cap_jut);  % upper serif
361 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
362math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,8,9,10,11,12); endchar;
363
364cmchar "The Russian letter SHCHA";
365beginchar("W",19u#+width_adj#,cap_height#,0);
366italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
367adjust_fit(cap_serif_fit#,cap_serif_fit#);
368pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
369pos3(cap_stem,0); pos4(cap_stem,0); pos5(cap_stem,0); pos6(cap_stem,0);
370lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
371top y1=top y3=h; bot y2=bot y4=0;
372z5=.5[z1,z3]; z6=.5[z2,z4];
373filldraw stroke z1e--z2e; % left stem
374filldraw stroke z3e--z4e; % right stem
375filldraw stroke z5e--z6e; % center stem
376if serifs: numeric inner_jut;
377 if rt x1r+cap_jut+.5u+1<=lft x5l-cap_jut: inner_jut=cap_jut;
378 else: rt x1r+inner_jut+.5u+1=lft x5l-inner_jut; fi
379 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
380 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
381 dish_serif(5,6,i,1/3,inner_jut,j,1/3,inner_jut); % upper center serif
382 inner_jut:=.5(x3l-x5r);
383 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
384 nodish_serif(6,5,k,1/3,inner_jut,m,1/3,inner_jut); % lower center serif
385 r_cyr_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);   % lower right serif
386else:
387 lcyrsanserif(4); lft x2'= lft x2l; bot y2'l=0; pos2'(slab,90);
388 rt x4'=rt x4r; y4'=y2'; pos4'(slab,90); filldraw stroke z2'e--z4'e;
389fi
390math_fit(0,.5ic#); penlabels(1,2,3,4,5,6); endchar;
391
392cmchar "The Russian letter SHA";
393beginchar("X",19u#+width_adj#,cap_height#,0);
394italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
395adjust_fit(cap_serif_fit#,cap_serif_fit#);
396pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
397pos3(cap_stem,0); pos4(cap_stem,0); pos5(cap_stem,0); pos6(cap_stem,0);
398lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
399top y1=top y3=h; bot y2=bot y4=0;
400z5=.5[z1,z3]; z6=.5[z2,z4];
401filldraw stroke z1e--z2e; % left stem
402filldraw stroke z3e--z4e; % right stem
403filldraw stroke z5e--z6e; % center stem
404if serifs: numeric inner_jut;
405 if rt x1r+cap_jut+.5u+1<=lft x5l-cap_jut: inner_jut=cap_jut;
406 else: rt x1r+inner_jut+.5u+1=lft x5l-inner_jut; fi
407 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
408 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
409 dish_serif(5,6,i,1/3,inner_jut,j,1/3,inner_jut); % upper center serif
410 inner_jut:=.5(x3l-x5r);
411 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
412 nodish_serif(6,5,k,1/3,inner_jut,m,1/3,inner_jut); % lower center serif
413 nodish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);   % lower right serif
414else:
415 lft x2'= lft x2l; bot y2'l=0; pos2'(slab,90);
416 rt x4'=rt x4r; y4'=y2'; pos4'(slab,90); filldraw stroke z2'e--z4'e;
417fi
418math_fit(0,.5ic#); penlabels(1,2,3,4,5,6); endchar;
419
420cmchar "The Russian letter ERY";
421beginchar("Y",12.5u#,cap_height#,0);
422italcorr .75cap_height#*slant-.5u#;
423adjust_fit(cap_serif_fit#,if serifs: 5u# else: 4.25u# fi);
424numeric left_stem,right_curve,middle_weight;
425left_stem=cap_stem-hround 2stem_corr; middle_weight=.6vair+.5;
426pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
427lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
428filldraw stroke z1e--z2e; % stem
429penpos3(cap_band,90); penpos4(cap_band,90);
430penpos6(middle_weight,-90); penpos7(middle_weight,-90);
431penpos8(middle_weight,90); penpos9(middle_weight,90);
432penpos5(right_curve-stem_corr,0); penpos10(right_curve,0);
433penpos11(cap_band,-90); penpos12(cap_band,-90);
434z3r=top z1; y4=y3; y5=.5[y4,y6]; y6=y7; y7l-y8l=vair;
435z12r=bot z2; y11=y12; y10=.5[y11,y9]; y8=y9; .5[y7l,y8l]=.52h;
436x4=x6; x9=x11=x4+.5u; x7=x8=x1; x9l:=x4+.25u;
437x5r=hround(w-1.5u); x10r=hround(w-u);
438if serifs: right_curve=cap_curve-stem_corr; x4=.5[x1,w-1.5u];
439else: right_curve=cap_curve-3stem_corr; x4=.5[x1,w-2.5u];
440 x4l:=x4l-.5u; x9l:=x9l-.5u; fi
441x6l:=x6l-.5u; x11l:=x11l-.5u;
442fill stroke z8e..super_arc.e(9,10) & super_arc.e(10,11)..z12e;  % lower lobe
443if serifs: dish_serif(1,2,a,1/3,cap_jut,b,1/3,cap_jut);  % upper serif
444 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
445pickup tiny.nib;
446x80=x81=w if serifs: +2u else: +1.25u fi; top y80=h; bot y81=0; pos80(cap_stem,0); pos81(cap_stem,0);
447filldraw stroke z80e--z81e;
448if serifs:
449  dish_serif(80,81,e,1/3,cap_jut,f,1/3,cap_jut);
450  dish_serif(81,80,g,1/3,cap_jut,h,1/3,cap_jut);
451fi
452math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,8,9,10,11,12); endchar;
453
454cmchar "The Russian letter ZE (looks like numeral 3)";
455beginchar("Z",11u#,cap_height#,0);
456italcorr cap_height#*slant-.5u#;
457adjust_fit(0,0);
458numeric top_thickness,mid_thickness,bot_thickness;
459top_thickness=max(fine.breadth,vround(slab-2vair_corr));
460mid_thickness=max(fine.breadth,vround 2/3vair);
461bot_thickness=max(fine.breadth,vround(slab-vair_corr));
462pickup fine.nib; pos2(top_thickness,90); top y2r=h+o;
463pos3(max(fine.breadth,.6[curve,cap_curve]-stem_corr),0);
464rt x3r=hround(w-1.25u);
465pos4(vair,-90); pos5(vair,-90);
466pos6(mid_thickness,90); x2=x6=x8=.5[1.5u,x7];
467pos7(cap_curve,0); rt x7r=hround(w-.75u); lft x5=min(hround 3u,lft x6)-eps;
468pos8(bot_thickness,-90); bot y8r=-o;
469y3=.6[top y4l,bot y2l]; y7=.5[bot y6l,top y8l];
470top y5l=vround(.54h+.5vair); y5r=y6l;
471x4=1/3[x5,x3l]; z4=z5+whatever*(150u,h);
472lft x1r=hround 1.25u; y1=.8h;
473if serifs: pos1(cap_hair,180); pos9(cap_hair,-180); else: pos1(1.5cap_hair,135); pos9(1.5cap_hair,-135); fi
474 lft x9r=hround .75u; y9=.2h;
475filldraw stroke z1e{x2-x1,10(y2-y1)}...{right}z2e & pulled_super_arc.e(2,3)(.5superpull)
476 & z3e{down}...z4e---z5e;  % upper bowl
477filldraw z5r--z6l--z6r--z5l---cycle;  % middle tip
478filldraw stroke pulled_super_arc.e(6,7)(.5superpull)
479 & pulled_super_arc.e(7,8)(.5superpull)
480 & z8e{left}....{up}z9e;  % lower bowl %this line added for changing bulb to barb
481if serifs: numeric bulb_diam[];
482 %bulb_diam1=flare+.5(cap_stem-stem); bulb_diam2=flare+cap_stem-stem;
483 %pos0(bulb_diam1,180); pos1(hair,180);
484 %lft x0r=hround 1.25u; y0=min(.9h-.5bulb_diam1,.75h+.5bulb_diam1);
485 % bulb(2,1,0);  % upper bulb
486 %pos10(bulb_diam2,-180);
487 % bulb(8,9,10);  % lower bulb
488% barbs on end of strokes
489 path upper_arc; upper_arc=z1{x2-x1,10(y2-y1)}..{right}z2;
490 path lower_arc; lower_arc=z8{left}....{up}z9;
491 pos20(hair,0); x20r=x1l; top y20=top y2r; x1'-x1l=1.6cap_curve; y1'=y1;
492 numeric t; t=xpart(upper_arc intersectiontimes (z20r--z1'));
493 filldraw z1r--z20l--z20r--subpath(t,0) of upper_arc--cycle;
494 pos30(hair,0); x30r=x9l; bot y30=bot y8r; x9'-x9l=1.6cap_curve; y9'=y9;
495 t:=xpart(lower_arc intersectiontimes (z30r--z9'));
496 filldraw z9r--z30l--z30r--subpath(t,1) of lower_arc--cycle;
497%else: %pos1(.5[vair,flare],angle(-8u,h));
498 %lft x1r=hround u; bot y1l=vround .75h+o;
499 %y1r:=good.y y1r+eps; x1l:=good.x x1l;
500 %pos9(bot_thickness,angle(-2u,-h));
501 %lft x9r=hround .75u; top y9l=vround .25h-o;
502 %y9r:=good.y y9r-eps; x9l:=good.x x9l;
503% filldraw stroke term.e(2,1,left,1,4);  % upper terminal
504% filldraw stroke term.e(8,9,left,1,4);
505fi  % lower terminal
506penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;
507
508cmchar "The Russian letter Soft Sign";
509beginchar(oct"136",12.5u#,cap_height#,0);
510italcorr .75cap_height#*slant-.5u#;
511adjust_fit(cap_serif_fit#,0);
512numeric left_stem,right_curve,middle_weight;
513left_stem=cap_stem-hround 2stem_corr; middle_weight=.6vair+.5;
514pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
515lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
516filldraw stroke z1e--z2e; % stem
517penpos3(cap_band,90); penpos4(cap_band,90);
518penpos6(middle_weight,-90); penpos7(middle_weight,-90);
519penpos8(middle_weight,90); penpos9(middle_weight,90);
520penpos5(right_curve-stem_corr,0); penpos10(right_curve,0);
521penpos11(cap_band,-90); penpos12(cap_band,-90);
522z3r=top z1; y4=y3; y5=.5[y4,y6]; y6=y7; y7l-y8l=vair;
523z12r=bot z2; y11=y12; y10=.5[y11,y9]; y8=y9; .5[y7l,y8l]=.52h;
524x4=x6; x9=x11=x4+.5u; x7=x8=x1; x9l:=x4+.25u;
525x5r=hround(w-1.5u); x10r=hround(w-u);
526if serifs: right_curve=cap_curve-stem_corr; x4=.5[x1,w-1.5u];
527else: right_curve=cap_curve-3stem_corr; x4=.5[x1,w-2.5u];
528 x4l:=x4l-.5u; x9l:=x9l-.5u; fi
529x6l:=x6l-.5u; x11l:=x11l-.5u;
530fill stroke z8e..super_arc.e(9,10) & super_arc.e(10,11)..z12e;  % lower lobe
531if serifs: dish_serif(1,2,a,1/3,cap_jut,b,1/3,cap_jut);  % upper serif
532 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
533math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,8,9,10,11,12); endchar;
534
535cmchar "The Russian letter Hard Sign";
536beginchar(oct"137",12.5u#,cap_height#,0);
537italcorr .75cap_height#*slant-.5u#;
538adjust_fit(if serifs: 4 else: 2 fi u#+cap_serif_fit#,0);
539numeric left_stem,right_curve,middle_weight;
540left_stem=cap_stem-hround 2stem_corr; middle_weight=.6vair+.5;
541pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
542lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
543filldraw stroke z1e--z2e; % stem
544penpos3(cap_band,90); penpos4(cap_band,90);
545penpos6(middle_weight,-90); penpos7(middle_weight,-90);
546penpos8(middle_weight,90); penpos9(middle_weight,90);
547penpos5(right_curve-stem_corr,0); penpos10(right_curve,0);
548penpos11(cap_band,-90); penpos12(cap_band,-90);
549z3r=top z1; y4=y3; y5=.5[y4,y6]; y6=y7; y7l-y8l=vair;
550z12r=bot z2; y11=y12; y10=.5[y11,y9]; y8=y9; .5[y7l,y8l]=.52h;
551x4=x6; x9=x11=x4+.5u; x7=x8=x1; x9l:=x4+.25u;
552x5r=hround(w-1.5u); x10r=hround(w-u);
553if serifs: right_curve=cap_curve-stem_corr; x4=.5[x1,w-1.5u];
554else: right_curve=cap_curve-3stem_corr; x4=.5[x1,w-2.5u];
555 x4l:=x4l-.5u; x9l:=x9l-.5u; fi
556x6l:=x6l-.5u; x11l:=x11l-.5u;
557%fill stroke z3e..super_arc.e(4,5) & super_arc.e(5,6)..z7e;  % upper lobe
558fill stroke z8e..super_arc.e(9,10) & super_arc.e(10,11)..z12e;  % lower lobe
559if serifs: nodish_serif(1,2,a,1/3,.5cap_jut,b,1/3,.5cap_jut);  % upper serif
560 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,.5cap_jut); fi  % lower serif
561pickup crisp.nib;
562top y55r=h; x55=x1; pos55(slab,90); pos56(hair,180); x56=x1-if serifs: 6 else: 3 fi u;
563y56=good.y(y55l-beak)-eps;
564arm(55,56,q,beak_darkness**.8,-.4beak_jut);
565math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,8,9,10,11,12); endchar;
566
567%  The shape "K" is saved as a picture, to be used by the next file input.
568%  It is defined here to minimize storage time.
569cmchar "The Russian letter KA";
570beginchar("K",12u#,cap_height#,0);
571italcorr cap_height#*slant-.5u#;
572adjust_fit(0,.25u#);
573pickup tiny.nib; pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
574lft x1l=lft x2l=hround max(2u,3u-.5fudged.cap_stem); top y1=h; bot y2=0;
575filldraw stroke z1e--z2e; % stem
576if serifs:  dish_serif(1,2,a,1/3,cap_jut,b,1/3,cap_jut); % upper stem serif
577 dish_serif(2,1,c,1/3,cap_jut,d,1/3,cap_jut);  % lower stem serif
578% pickup fine.nib; pos3(vair,90); x3=x1; y3=.55h; x3'=x3; y3'=y3+1; pos3'(slab,90);
579 pickup fine.nib; pos3(vair,90); x3=x1; y3=.55h; z3'=z3; pos3'(varwid,90);
580% pos4(vair,90); x4=w-2u; top y4r=h+oo;
581 pos4(varwid,90); x4=w-.75flare-.125u; top y4r=h+oo; %original x4=w-2u
582% filldraw stroke z3'e{right}..{right}z4e;  % upper diagonal
583 x41=x4; y41=y3'; x42=x4-2u; y42=y4;
584 filldraw stroke z3'e..controls z41 and z42..z4e;  % upper diagonal
585 pos5(hair,0); pos6(flare,0);
586 rt x5r=hround(w-.125u); y5+.5flare=vround(top y4r-hair)+1; %original bot y4l-.03h
587 top y4'r=top y4r; x4'=x4; pos4'(hair,90);
588 bulb(4',5,6); % bulb
589% pos7(stem,0); pos8(vair,90); pos9(hair,180);
590 pos7(stem,0); pos8(varwid,90); pos9(hair,180);
591 x9+.5hair=hround(w+.5hair-eps); y9=1/3x_height;
592 lft x7l=hround(w-2.75u-.5stem); y7=1/2y3; x8=w-1.2u; bot y8l=-oo;
593 filldraw stroke z3e{right}...z7e{down}
594 ...z8e{right}...{up}z9e;  % lower diagonal
595else:
596 numeric right_jut,stem[],alpha[];
597 right_jut=.4tiny;
598 pickup tiny.nib;
599 stem2=max(tiny.breadth,fudged.cap_stem-3stem_corr);
600 stem1=max(tiny.breadth,fudged.hair if hefty:-3stem_corr fi);
601 top y3=h; rt x3r=hround(r-letter_fit-u-right_jut);
602 bot y6=0; rt x6r=hround(r-letter_fit-.75u-right_jut);
603 x4=x1; y4=1/3h;
604 alpha1=diag_ratio(1,.5(stem1-tiny),y3-y4,x3r-x4);
605 penpos3(alpha1*(stem1-tiny),0); penpos4(whatever,-90);
606 alpha2=diag_ratio(1,.5(stem2-tiny),y1-y6,x6r-x1);
607 penpos6(alpha2*(stem2-tiny),0);
608 forsuffixes $=l,r: y3'$=h; y6'$=0; z4$=z3'$+whatever*(z3-z4);
609  z5$=z6'$+whatever*(z1-z6)=whatever[z3,z4]; endfor
610%forsuffixes $=l,r: x5$:=x5$+.5u; y5$:=y5$-.5u; endfor
611 z5=.5[z5l,z5r];
612 z3'r=z3r+penoffset z3-z4 of currentpen+whatever*(z3-z4);
613 % we have also |z3'l=z3l+penoffset z4-z3 of currentpen+whatever*(z3-z4)|;\]
614 z6'r=z6r+penoffset z1-z6 of currentpen+whatever*(z1-z6);
615 z6'l=z6l+penoffset z6-z1 of currentpen+whatever*(z1-z6);
616% fill z4r{right}..diag_end(4r,3'r,1,.5,3'l,4l)..{left}z4l--cycle;  % upper diagonal
617 fill z4r--diag_end(4r,3'r,1,.5,3'l,4l)--z4l--cycle;  % upper diagonal
618 fill z5l--diag_end(5l,6'l,.5,1,6'r,5r)--z5r--cycle;  % lower diagonal
619fi
620picture K_pic; K_pic=currentpicture;
621math_fit(0,.5ic#); penlabels(1,2,3,4,5,6); endchar;
622