%
% lgt2slvu.mf
%
%% Cyrillic font container with T2 encoding beta-support
%
% This file is future part of lxfonts package
% Version 3.5 // Patchlevel=1
% (c) O.Lapko
%
% This package is freeware product under conditions similar to
% those of D. E. Knuth specified for the Computer Modern family of fonts.
% In particular, only the authors are entitled to modify this file
% (and all this package as well) and to save it under the same name.
%
% Content:
%
% Uppercase Old Slav letters
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% List of letternames
%
% AZ
% I_AZ      i-alpha
% L_YUS
% IL_YUS
% GERV
% NASH
% ZEMLA
% VIZHE
% IZHE     used LAT_I
% IZH      in lgcomu
% OMGA
% OMGA_rnd
% OT
% OMGA_tlo
% VZELO    used LAT_S
% FITA     in lgcomu
% KOPPA
% UK
% YAT      in lgcomu
% CHERV
% PSI
% SHTA
% B_YUS    in lgcomu
% IB_YUS
% KSI
% EST      used UKR_E (lgcomu)
% I_EST
% NARROW_E used EPS
%

LHver_check(3,5); % like |version_check| in ec

lhchar "Uppercase Cyrillic letter ligature AZ - OLD A";
cyrchar(AZ,12u#,cap_height#,0);
if is_small_cap: getcharcode(az); fi
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#);
adjust_fit(0,cap_serif_fit#);
pickup fine.nib;
forsuffixes $=hair,stem: shaved$:=mfudged$; save $; $=shaved$; endfor
pickup tiny.nib; numeric light_stem; light_stem=fudged.cap_stem;
% a_part of lowercase ae
pos1(light_stem,0); pos2(light_stem,0);
penpos6(vair-fine,-225); penpos4(cap_curve-fine,-180);
rt x1r=rt x2r=hround(w-max(2u,3u-.5light_stem));
if serifs: top y1=h+min(o,serif_drop); else: top y1=h; fi
bot y2=0; y3=.52h; x6=x1; y6+bar+eps=min(8h,h-max(bracket,.5slab));
penpos5(vair'-fine,-90); penpos3(thin_join-fine,0);
pickup fine.nib; lft x3l=tiny.lft x1l;
lft x4r=hround(1.5u-.5cap_curve); x5=.5[x4,x3];
y4=.3[y5,y1]; bot y5r=-o;
filldraw stroke z6e{3(x4-x1),y4-y1}...pulled_arc.e(4,5)
 & pulled_arc.e(5,3);  %  bowl of a
pickup tiny.nib;
filldraw stroke z1e--z2e;  % stem
if serifs: sloped_serif.l(1,2,a,1/3,cap_jut,serif_drop);  % upper serif
 serif(2,1,d,1/3,cap_jut); fi % lower serif
%%%%%
penlabels(0,1,2,3,4,5,6, 7,8,9,10); endchar;

lhchar "Uppercase Cyrillic letter ligature I_AZ - IOT AZ";
cyrchar(I_AZ,12u#,cap_height#,0);
if is_small_cap: getcharcode(i_az); fi
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#);
adjust_fit(if monospace: 6.5u# else:
        max(5u#+.5cap_stem#,6u#)+cap_serif_fit# fi, %Ipart_adj
 cap_serif_fit#); pickup fine.nib;
forsuffixes $=hair,stem: shaved$:=mfudged$; save $; $=shaved$; endfor
pickup tiny.nib; numeric light_stem; light_stem=fudged.cap_stem;
% a_part of lowercase ae
pos1(light_stem,0); pos2(light_stem,0);
penpos6(vair-fine,-225); penpos4(cap_curve-fine,-180);
rt x1r=rt x2r=hround(w-max(2u,3u-.5light_stem));
if serifs: top y1=h+min(o,serif_drop); else: top y1=h; fi
bot y2=0; y3=.52h; x6=x1; y6+bar+eps=min(8h,h-max(bracket,.5slab));
penpos5(vair'-fine,-90); penpos3(thin_join-fine,0);
pickup fine.nib; lft x3l=tiny.lft x1l;
lft x4r=hround(1.5u-.5cap_curve); x5=.5[x4,x3];
y4=.3[y5,y1]; bot y5r=-o;
filldraw stroke z6e{3(x4-x1),y4-y1}...pulled_arc.e(4,5)
 & pulled_arc.e(5,3);  %  bowl of a
pickup tiny.nib;
filldraw stroke z1e--z2e;  % stem
if serifs: sloped_serif.l(1,2,a,1/3,cap_jut,serif_drop);  % upper serif
 serif(2,1,d,1/3,cap_jut); fi % lower serif
%I_part(6);
_zero:=6;
_one:=7; _two:=8; _three:=9; _four:=10;
%
pickup tiny.nib; pos[_one](cap_stem,0); pos[_two](cap_stem,0);%pos
lft x[_one]l=lft x[_two]l=
	l+letter_fit+if monospace:-.35u else: cap_serif_fit fi
	+hround max(2u,3u-.5cap_stem);
top y[_one]=h; bot y[_two]=0;
filldraw stroke z[_one]e--z[_two]e; % stem
x[_three]=x[_one]; y[_three]=y[_zero];
x[_four]=x[_zero]; y[_four]=y[_three];
pos[_three](cap_bar,90); pos[_four](cap_bar,90);
filldraw stroke z[_three]e--z[_four]e; % bar
if serifs: dish_serif([_one],[_two],s,1/3,cap_jut,t,1/3,cap_jut);
 dish_serif([_two],[_one],u,1/3,cap_jut,v,1/3,cap_jut); fi
%%%%%
penlabels(0,1,2,3,4,5,6, 7,8,9,10); endchar;

lhchar "Uppercase Cyrillic letter L_YUS - LITTLE YUS";
cyrchar(L_YUS,13u#+2cap_stem#,cap_height#,0);
if is_small_cap: getcharcode(l_yus); fi
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_amod;
numeric left_stem,right_stem,outer_jut,alpha; outer_jut=.8cap_jut;
x1l=w-x4r=l+letter_fit+outer_jut+.5u;
%
right_stem=cap_stem-stem_corr;
left_stem=min(cap_hair if hefty: -3stem_corr fi,right_stem); pickup tiny.nib;
y1=y4=0; x2-x1=x4-x3; x3r=x2r+apex_corr; y2=y3=h+apex_o+apex_oo;
alpha=diag_ratio(2,left_stem,y2-y1,x4r-x1l-apex_corr);
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*right_stem,0);
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
if y0<h-cap_notch_cut: y0:=h-cap_notch_cut;
 fill z0+.5right{down}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)
  --diag_end(4r,3r,1,1,2l,1l)--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{up}z0+.5left--cycle; % left and right diagonals
else: fill z0--diag_end(0,4l,1,1,4r,3r)--diag_end(4r,3r,1,1,2l,1l)
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
penpos5(whatever,angle(z2-z1)); z5=whatever[z1r,z2r];
penpos6(whatever,angle(z3-z4)); z6=whatever[z3l,z4l]; y6=y5;
if hefty: y5r else: y5 fi =.5y0; y5r-y5l=y6r-y6l=cap_band; 
forsuffixes $=l,r: if x5$>x6$: x5$:=x6$-eps; fi endfor;	
penstroke z5e--z6e; % bar line
pickup tiny.nib;
x7=.5[x5,x6]; top y7=y5; x8=x7; bot y8=0;
pos7(max(currentbreadth+eps,.5[cap_band,cap_stem]),0);
pos8(max(currentbreadth+eps,.5[cap_band,cap_stem]),0);
filldraw stroke z8e--z7e;
if serifs: pickup tiny.nib; numeric inner_jut;
 prime_points_inside(1,2); prime_points_inside(4,3);
 if rt x1'r+.7cap_jut+.5u+1<=lft x8l-.7cap_jut: inner_jut=.7cap_jut;
 else: rt x1'r+inner_jut+.5u+1=lft x8l-inner_jut; fi
 dish_serif(1',2,a,1/2,outer_jut,b,.6,inner_jut)(dark);  % left serif
 dish_serif(4',3,c,1/2,inner_jut,d,1/3,outer_jut);  % right serif
 dish_serif(8,7,e,1/3,inner_jut,f,1/3,inner_jut); fi % middle serif
%%%%%
penlabels(1,1',2,3,4,4',5,6,7,8); endchar;

lhchar "Uppercase Cyrillic letter IL_YUS - IOT LITTLE YUS";
cyrchar(IL_YUS,13u#+2cap_stem#,cap_height#,0);
if is_small_cap: getcharcode(il_yus); fi
adjust_fit(if monospace: 6.5u# else:
        max(5u#+.5cap_stem#,6u#)+cap_serif_fit# fi, %Ipart_adj
 cap_serif_fit#);
% upper_amod;iot
numeric left_stem,right_stem,outer_jut,alpha; outer_jut=.8cap_jut;
x1l=w-x4r=outer_jut+.5u; %!!!
%
right_stem=cap_stem-stem_corr;
left_stem=min(cap_hair if hefty: -3stem_corr fi,right_stem); pickup tiny.nib;
y1=y4=0; x2-x1=x4-x3; x3r=x2r+apex_corr; y2=y3=h+apex_o+apex_oo;
alpha=diag_ratio(2,left_stem,y2-y1,x4r-x1l-apex_corr);
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*right_stem,0);
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
if y0<h-cap_notch_cut: y0:=h-cap_notch_cut;
 fill z0+.5right{down}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)
  --diag_end(4r,3r,1,1,2l,1l)--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{up}z0+.5left--cycle; % left and right diagonals
else: fill z0--diag_end(0,4l,1,1,4r,3r)--diag_end(4r,3r,1,1,2l,1l)
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
penpos5(whatever,angle(z2-z1)); z5=whatever[z1r,z2r]-(eps,0);
penpos6(whatever,angle(z3-z4)); z6=whatever[z3l,z4l]+(eps,0); y6=y5;
if hefty: y5r else: y5 fi =.5y0; y5r-y5l=y6r-y6l=cap_band; 
forsuffixes $=l,r: if x5$>x6$: x5$:=x6$-eps; fi endfor;	
penstroke z5e--z6e; % bar line
pickup tiny.nib;
x7=.5[x5,x6]; top y7=y5; x8=x7; bot y8=0;
pos7(max(currentbreadth+eps,.5[cap_band,cap_stem]),0);
pos8(max(currentbreadth+eps,.5[cap_band,cap_stem]),0);
filldraw stroke z8e--z7e;
if serifs: pickup tiny.nib; numeric inner_jut;
 prime_points_inside(1,2); prime_points_inside(4,3);
 if rt x1'r+.7cap_jut+.5u+1<=lft x8l-.7cap_jut: inner_jut=.7cap_jut;
 else: rt x1'r+inner_jut+.5u+1=lft x8l-inner_jut; fi
 dish_serif(1',2,a,1/2,outer_jut,b,.6,inner_jut)(dark);  % left serif
 dish_serif(4',3,c,1/2,inner_jut,d,1/3,outer_jut);  % right serif
 dish_serif(8,7,e,1/3,inner_jut,f,1/3,inner_jut); fi % middle serif
%%%%%
%I_part(3);
_zero:=6;
_one:=9; _two:=10; _three:=11; _four:=12;
%
pickup tiny.nib; pos[_one](cap_stem,0); pos[_two](cap_stem,0);%pos
lft x[_one]l=lft x[_two]l=
	l+letter_fit+if monospace:-.35u else: cap_serif_fit fi
	+hround max(2u,3u-.5cap_stem);
top y[_one]=h; bot y[_two]=0;
filldraw stroke z[_one]e--z[_two]e; % stem
x[_three]=x[_one]; y[_three]=y[_zero];
x[_four]=x[_zero]; y[_four]=y[_three];
pos[_three](cap_bar,90); pos[_four](cap_bar,90);
filldraw stroke z[_three]e--z[_four]e; % bar
if serifs: dish_serif([_one],[_two],s,1/3,cap_jut,t,1/3,cap_jut);
 dish_serif([_two],[_one],u,1/3,cap_jut,v,1/3,cap_jut); fi
%%%%%
penlabels(0,1,2,3,4,5,6,7,8, 9,10,11,12); endchar;

lhchar "Uppercase Cyrillic (Glagolic) letter GERV";
cyrchar(GERV,12.5u#,cap_height#,0); %CH width
if is_small_cap: getcharcode(gerv); fi
italcorr cap_height#*slant-.25u#;
adjust_fit(cap_serif_fit#,cap_serif_fit#);
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
penpos3(cap_bar,90); penpos5'(cap_stem,0);
pos5(cap_stem,0); pos6(cap_stem,0);
x5=x6=w-x1; y6=y2; x3=x1r; y5=1/8[bar_height,x_height]; z5'=z5;
if (serifs=false) or (cap_bar#>.5cap_curve#) or (cap_bar<3):
 penpos4(cap_bar,90);
 top y3r=top y4r=x_height+oo; x4=.5[x1,w-rt x3r if not serifs:-u fi];
else:
 penpos4(1/18[cap_bar,cap_curve],90);
 y3r+.35cap_bar=y4r=x_height+oo;
 x4=.5[x1,w-1.5u]-.5u;
fi
fill stroke z3e..pulled_arc.e(4,5'); % arc
filldraw stroke z5e--z6e; % stem
if serifs:
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,cap_jut);  % upper right serif
 numeric inner_jut; pickup tiny.nib;
 if rt x2r+.5jut+.5u+1<=lft x6l-.5cap_jut: inner_jut=.5cap_jut;
  else: rt x2r+jut+.5u+1=lft x6l-inner_jut; fi
 dish_serif(2,1,c,1/3,.5cap_jut,d,1/3,inner_jut); % lower right serif
 dish_serif(6,5,e,1/3,inner_jut,f,1/3,.5cap_jut); fi % lower left serif
% hcross
pickup crisp.nib; pos8(bar,90); pos9(bar,90);
lft x8=w-x9-4u; %hround 1/3u if serifs:-serif_fit fi;
x9=hround(w-2.65u); %x4; %1r+2.5u;
top y8r=top y9r=vround .85h;%vround x_height+eps;
filldraw stroke z8e--z9e; % cross bar
%%%%%
penlabels(1,2,3,4); endchar;

lhchar "Uppercase Cyrillic letter NASH -- OLD N (like Latin N)";
cyrchar(NASH,13.5u#,cap_height#,0); % N_width
if is_small_cap: getcharcode(nash); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,cap_serif_fit#);
pickup tiny.nib; pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
pos3(fudged.cap_stem,0); pos4(fudged.cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=0;
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
numeric stem[],alpha[];
if hefty: numeric upper_notch,lower_notch;
 stem1=fudged.hair-stem_corr;
 upper_notch=y5-cap_notch_cut-eps; lower_notch=y6+cap_notch_cut+eps;
 x5r =rt x1r; x6l =lft x3l; y6=bar_height;
 if monospace: y5=vround(h-1.2slab-eps); else: y5=h; fi
  alpha1=diag_ratio(1,stem1,y5-y6,x5r-x6l);
  penpos5(min(2fudged.cap_stem,alpha1*stem1),0);
  penpos6(min(2fudged.cap_stem,alpha1*stem1),0);
  x5'=x1l; z5'=whatever[z5l,z6l]; x6'=x4r; z6'=whatever[z5r,z6r];
  x5l:=x5'; x6r:=x6'; y5l:=y5'; y6r:=y6'; x5:=max(x1l,x5);
  x2'=rt x1r; z2'=whatever[z5l,z6l]; x3'=lft x4l; z3'=whatever[z5r,z6r];
 fill z5--z5l..
  if y2'<upper_notch: {right}(x2'+1,upper_notch){down}... fi
  {z6-z5} diag_in(5l,6l,1,6)--z6--z6r ..
  if y3'>lower_notch: {left}(x3'-1,lower_notch){up}... fi
  {z5-z6}diag_in(6r,5r,1,5) --cycle;  % diagonal
else: y5r=vround(y3-1.2bracket-(slab-vair)-eps); y6l=bar_height;
 x5=hround (rt x1r-.5)-eps; x6=hround (lft x3l+.5)+eps;
 stem1=max(tiny.breadth,fudged.hair);
 alpha1=diag_ratio(1,stem1,x6-x5,top y6l-bot y5r);
 penpos5(alpha1*stem1,90); penpos6(alpha1*stem1,90);
 fill stroke z5e--z6e; fi % diagonal
if serifs:
 numeric inner_jut;
 if rt x1r+cap_jut+.5u+1<=lft x3l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut);  % lower left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut); fi % lower right serif
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Cyrillic letter ZEMLA";
cyrchar(ZEMLA,11u#,cap_height#,cap_sbeak#);
if is_small_cap: getcharcode(zemla); fi
italcorr cap_height#*slant-.5u#;
adjust_fit(0,0);
numeric arm_thickness[],z_stem;
if hefty: arm_thickness1=Vround(slab-vair_corr); arm_thickness2=slab;
 z_stem=.8[vair,cap_stem];
else: arm_thickness1=slab; arm_thickness2=vround(slab+vair_corr);
 z_stem=.9[vair,cap_stem]; fi
pickup tiny.nib; x3l=x4l=w-x1r=w-x2r; lft x3l=hround u;
top y1=h; y2=min(y1,h-2/3arm_thickness1);
bot y4=0; y3=max(y4,2/3arm_thickness2);
numeric alpha; alpha=diag_ratio(1,z_stem-tiny,y2-y3,x2r-x3l);
penpos1(alpha*(z_stem-tiny),0); penpos2(alpha*(z_stem-tiny),0);
penpos3(alpha*(z_stem-tiny),0); penpos4(alpha*(z_stem-tiny),0);
pair delta; delta=penoffset z3-z2 of currentpen;
fill top lft z1l--z2l+delta---z3l+delta..lft z3l---lft z4l..bot z4l
 ---bot rt z4r--z3r-delta---z2r-delta..rt z2r---rt z1r..top z1r
 ---cycle;  % diagonal
pickup crisp.nib; pos5(arm_thickness1,90); pos6(hair,180);
top y5r=h; x5=x1; lft x6r=hround 1.25u; y6=good.y(y5l-beak)-eps;
arm(5,6,a,beak_darkness**.8,-.4beak_jut);  % upper arm and beak
% the beak is turning down
pos7(arm_thickness2,90); pos8(hair,0);%!!!
bot y7l=0; x7=x4; rt x8r=hround(w-.9u);%!!!
y8=good.y(y7l-1.2beak)-eps;%!!!
arm(7,8,b,beak_darkness**.9,.6beak_jut);  % lower arm and beak
math_fit(0,.5ic#); penlabels(1,2,3,4,5,6,7,8); endchar;

% like CYR_.Z or numeral 3
lhchar "Uppercase Cyrillic letter KSI";
cyrchar(KSI,10u#,cap_height#+1.75dot_size#,desc_depth#);
if is_small_cap: getcharcode(ksi); fi
italcorr .75cap_height#*slant-.5u#; %B
adjust_fit(0,.5serif_fit#); h:=cap_height;
pickup fine.nib; numeric right_curve,middle_weight,low_curve;
middle_weight=max(fine.breadth,.6vair+.5);
if serifs: right_curve=cap_curve-stem_corr;
 else: right_curve=cap_curve-3stem_corr; fi
pos2(cap_band,90); pos3(.6[hair,cap_curve],0);
pos4(middle_weight,-90); pos5(middle_weight,-90);
pos5'(middle_weight,90); pos6(middle_weight,90);
top y2r=h+o; x2=x6=x8=.5[1.5u,w-.75u-.5stem]; lft x1r=hround 1.1u;
rt x3r=hround(w-1.25u); rt x7r=hround(w-.75u);
lft x5=lft x5'=min(hround 3.5u,lft x2)+eps;
y3=.5[y4l,y2l]; x4=1/3[x5,x3l]; y4=y5; y5'=y6;
top y5l-bot y5'l=vair; .5[y5l,y5'l]=.52h;
{{interim superness:=if serifs:more_super else:hein_super fi;
 filldraw stroke super_arc.e(2,3)}};
filldraw stroke  super_arc.e(3,4)..z5e; % upper bowl
numeric theta; theta=-90+angle(22u,x_height); slope:=x_height/22u;
pos9(max(currentbreadth+eps,cap_curve-5stem_corr),theta);
x7r-x7l=hround.5[vair,cap_stem]-fine;
x9=x10=2u; x11=.5w-.5u; y9=-.3d; bot y10l=-d-oo;
ellipse_set(6l,7l,8l,9l); ellipse_set(6r,7r,8r,9r);
if serifs: pos0(flare+(cap_stem-stem),180); pos1(cap_hair,180);
 y1=.4[y5l,y2l]+.5flare; bulb(2,1,0); % bulb
 pos10(vair,90);
%"hachek"
 penpos14(vair',90); pos15(whatever,0); x14=x6; y14=h+o-eps;
 x6-x15=x16-x6=good.x 2.25u; top y15=top y16=h+.65acc_height+o;
 pos16(.25[vair,curve],angle(z16-z14)+90);
 z15l=z14l+whatever*(z14-z15); z15r=z14r+whatever*(z14-z15);
 filldraw stroke z15e--z14e{z16r-z14}..{.5right}z16e;  % hachek
else: y1=.8h; pos1(max(currentbreadth+eps,min(cap_hair,1.2flare)-.2tiny),170);
 filldraw stroke z1e{x2-x1,10(y2-y1)}...{right}z2e; % upper bowl
 pos10(middle_weight,45);
 filldraw stroke z10e{left}...z9e{z8e-z9e}; % tail
%"hachek"
 pickup pencircle scaled min(.5fine,.15vair);
 pos14(vair,0); pos16(vair,0); pos15(stem,0);
 x8-x14=x16-x8; bot y15=h; x15=x8;
 top y14=top y16=h+.65acc_height+o; lft x14l=hround(rt x15r-3.25u-.5vair);
 z0=whatever[z14r,z15r]=whatever[z15l,z16l];
 filldraw z15l--z14l--z14r--z0--z16l--z16r--z15r--cycle; fi  % hachek
pickup fine.nib;
{{less_tense;
 filldraw stroke z10e{left}...z9e---z8e
 ...{up}z7e...{left}z6e...{left}z5'e}};  % main stroke
penlabels(1,2,3,4,5,6,7,8,9,9',10,11,12,13,14,15,16); endchar;

lhchar "Uppercase Cyrillic letter VIZHE - Variant IZHE";
cyrchar(VIZHE,max(6u#,4u#+cap_stem#),cap_height#,0);
if is_small_cap: getcharcode(vizhe); fi
italcorr cap_height#*slant-.25u#;
adjust_fit(cap_serif_fit#,cap_serif_fit#); h:=cap_height;
% upper_ukri; - borrowed from ec
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround(.5w-.5cap_stem); top y1=cap_height; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs or monospace:
 dish_serif(1,2,a,1/3,1.05cap_jut,b,1/3,1.05cap_jut);  % upper serif
 dish_serif(2,1,c,1/3,1.05cap_jut,d,1/3,1.05cap_jut);  fi % lower serif
if slitex:
 pickup crisp.nib;           % arms based on proportions of uppercase E
 pos3(slab,90); pos4(slab if not serifs:+2stem_corr fi,-90);
 x3=x4=x1; top y3r=h; bot y4r=0;
 pos5(hair,0); pos6(hair,0); % top and bottom right arms
 rt x5r=rt x6r=hround(w-u);
 pos7(hair,180); pos8(hair,180); % top and bottom left arms
 lft x7r=lft x8r=hround(u);
 y5=y7=good.y(y3l-beak)-eps; % beak in case we ever want a beaked serif!
 y6=y8=good.y(y4l+beak)+eps; % watch that this doesn't get too heavy
 arm(3,5,a,darkness,jut); arm(3,7,b,darkness,jut); % top left and right arms
 arm(4,6,c,darkness,jut); arm(4,8,d,darkness,jut); % bottom left and right
fi
%%%%%
% the dot
numeric stem[]; stem1=if serifs: stem+2cap_jut else: w-2(u-oo) fi;
pos9(stem1,0); pos10(stem1,90); x9=x1; y9=.5h; z10=z9;
{{square_dots:=false; dot(9,10)}}; % dot
penlabels(1,2,3,4,5,6,7,8, 9,10); endchar;

lhchar "Uppercase Cyrillic letter IZHE - like Latin I (as latin I)";
cyrchar(IZHE,max(6u#,4u#+cap_stem#),cap_height#,0);
if is_small_cap: getcharcode(izhe); fi
italcorr cap_height#*slant-.25u#;
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_ukri; - borrowed from ec
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround(.5w-.5cap_stem); top y1=cap_height; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs or monospace:
 dish_serif(1,2,a,1/3,1.05cap_jut,b,1/3,1.05cap_jut);  % upper serif
 dish_serif(2,1,c,1/3,1.05cap_jut,d,1/3,1.05cap_jut);  fi % lower serif
if slitex:
 pickup crisp.nib;           % arms based on proportions of uppercase E
 pos3(slab,90); pos4(slab if not serifs:+2stem_corr fi,-90);
 x3=x4=x1; top y3r=h; bot y4r=0;
 pos5(hair,0); pos6(hair,0); % top and bottom right arms
 rt x5r=rt x6r=hround(w-u);
 pos7(hair,180); pos8(hair,180); % top and bottom left arms
 lft x7r=lft x8r=hround(u);
 y5=y7=good.y(y3l-beak)-eps; % beak in case we ever want a beaked serif!
 y6=y8=good.y(y4l+beak)+eps; % watch that this doesn't get too heavy
 arm(3,5,a,darkness,jut); arm(3,7,b,darkness,jut); % top left and right arms
 arm(4,6,c,darkness,jut); arm(4,8,d,darkness,jut); % bottom left and right
fi
%%%%%
penlabels(1,2,3,4,5,6,7,8); endchar;

lhchar "Uppercase Cyrillic letter OMGA - OMEGA";
cyrchar(OMGA,if serifs: 18u#+width_adj#
	else: 16.5u# fi,cap_height#,0);%CYR_.SH width
if is_small_cap: getcharcode(omga); fi
italcorr .7cap_height#*slant-.5u#; %O
adjust_fit(0,0);
% upper_omega;
numeric shaved_stem; shaved_stem=cap_stem-hround 2stem_corr;
if odd(shaved_stem-w): change_width; fi % symmetric & all three equal
if not serifs: interim superness:=more_super; fi
if serifs: pickup tiny.nib; else: pickup fine.nib; fi
pos6(shaved_stem,0); top y6=.52h;
lft x6l=hround (.5w-.5shaved_stem); % middle stem point
% Omega_bowl
pos2(vair',90); pos3(cap_curve,180); pos4(vround(vair+1.5vair_corr),270);
if serifs:
 pos1(cap_hair,0); pos0(flare,0); pos5(fudged.hair,0);
 top y2r=h+o; bot y4r=-o; lft x3r=hround u; y3=.5[y2,y4];
 y1=h-vround max(.1fig_height+.5flare,.15fig_height-.5flare)+o;
 x5=(.5w+eps);
 rt x1r=hround min(.5w-max(
	if monospace:.67u,.55stem else:u,.7stem fi),lft x5l-1)+eps;
 x2=x4+if monospace:-fi.25u=hround min(.67[lft x3r,rt x1r],rt x1r-.5)-eps;
 {{less_tense; bulb(2,1,0)}};  % bulb
 y5=max(good.y(.5bar_height-.9),y4l+vair');
 (x,y4l)=whatever[z4r,z5l]; x4l:=min(x,x4l+.5u);
 filldraw stroke pulled_super_arc.e(2,3)(.7superpull)
  & pulled_super_arc.e(3,4)(.5superpull)
  ..tension .9 and 1..{x5-x4,5(y5-y4)}z5e;  % arc and lower terminal
else:
 pos5(flare,275);
 x2=x4=(.25w+1.25u); lft x3r=hround max(u,2u-.5cap_curve);
 x5r=(.5w+eps); top y2r=h+o; y3=.5h;
 bot y4r=-o; bot y5r=vround .08h-o; y5l:=good.y y5l; x5l:=good.x x5l;
 filldraw stroke super_arc.e(2,3) & super_arc.e(3,4) &
  term.e(4,5,right,.8,4); % arc and terminals
fi
%%%
% mirror + middle stem
forsuffixes $ = if serifs: 1l,1r,0l, fi 2l,2,2r,3l,3,3r,4l,4,4r,5l,5,5r:
 x.m$-x6r=x6l-x$; y.m$=y$; endfor;
if serifs:
 {{less_tense; bulb(m2,m1,m0)}};  % bulb
 filldraw stroke pulled_super_arc.e(.m2,.m3)(.7superpull)
  & pulled_super_arc.e(.m3,.m4)(.5superpull)
  ..tension .9 and 1..{x.m5-x.m4,5(y.m5-y4)}z.m5e;  % arc and lower terminal
else:
 filldraw stroke super_arc.e(.m2,.m3) & super_arc.e(.m3,.m4) &
  term.e(.m4,.m5,left,.8,4); % arc and terminals
fi
if serifs:
 path p.l,p.r; numeric t;
 p.l=z4r{right}..tension .9 and 1..{x5-x4,5(y5-y4)}z5r;
 p.r=z.m4r{left}..tension .9 and 1..{x.m5-x.m4,5(y.m5-y.m4)}z.m5r;
 t=ypart(((x6l,0)--(x6l,h)) intersectiontimes p.l); if t<0: t:=1; fi
 filldraw reverse subpath(t,1) of p.r---z6r--z6l---subpath(t,1) of p.l..cycle; %middle stem
 z5'l=(x6l,y5); z5'r=(x6r,y5); z5'=.5[z5'l,z5'r]; z6=.5[z6l,z6r];
 dish_serif(6,5',a,1/3,.5cap_jut,b,1/3,.5cap_jut);
else:
 path p.l,p.r; numeric t; p.l=term.r(4,5,right,.8,4);
 p.r=term.r(.m4,.m5,left,.8,4);
 t=ypart(((x6l,0)--(x6l,h)) intersectiontimes p.l);
 filldraw reverse subpath(t,1) of p.r---z6r--z6l---subpath(t,1) of p.l..cycle; %middle stem
fi
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Uppercase Cyrillic letter OMGA_rnd - OMEGA round";
cyrchar(OMGA_rnd,17u#,cap_height#,0); %F width+u
if is_small_cap: getcharcode(omga_rnd); fi
italcorr .7cap_height#*slant-.5u#;
adjust_fit(0,0);
penpos1(vair',90); penpos3(vround(vair+1.5vair_corr),-90);
penpos2(cap_curve,180); penpos4(cap_curve,0);
if monospace: x2r=hround 1.5u;
 interim superness:=sqrt superness;  % make |"O"|, not |"0"|
else: if serifs: interim superness:=1.05 superness;
 else: interim superness:=1.075 superness; fi x2r=hround u; fi
x4r=w-x2r; x1=x3=.5w; y1r=h+o; y3r=-o;
y2=y4=.5h-vair_corr; y2l:=y4l:=.52h;
penstroke pulled_super_arc.e(1,2)(.5superpull)
 & pulled_super_arc.e(2,3)(.5superpull)
 & pulled_super_arc.e(3,4)(.5superpull)
 & pulled_super_arc.e(4,1)(.5superpull) & cycle;  % bowl
% dots
if serifs: pickup crisp.nib; else: pickup fine.nib; fi
numeric bulb_diam; bulb_diam=flare+(cap_stem-stem);%1.1flare;
z5=z1r; z6=z3r; pos5(bulb_diam,0); pos6(bulb_diam,0);
x5'=x6'=x1; y5'=max(.5h+1,bot y1l-.7bulb_diam);
y6'=min(.5h-1,top y3l+.7bulb_diam);
pos6'(min(bulb_diam,cap_vstem),0);
pos5'(min(bulb_diam,cap_vstem),0);
filldraw circ_stroke z5e--z5'e; filldraw circ_stroke z6e--z6'e; %dots
penlabels(1,2,3,4,5,6,7,8); endchar;

lhchar "Uppercase Cyrillic letter OT - OMEGA with te accent";
cyrchar(OT,if serifs: 18u#+width_adj#
	else: 16.5u# fi,cap_height#+acc_height#,0);%CYR_.SH width
if is_small_cap: getcharcode(ot); fi
italcorr .7cap_height#*slant-.5u#; %O
adjust_fit(0,0);
full_h:=h; h:=cap_height;
% upper_omega;
numeric shaved_stem; shaved_stem=cap_stem-hround 2stem_corr;
if odd(shaved_stem-w): change_width; fi % symmetric & all three equal
if not serifs: interim superness:=more_super; fi
if serifs: pickup tiny.nib; else: pickup fine.nib; fi
pos6(shaved_stem,0); top y6=.52h;
lft x6l=hround (.5w-.5shaved_stem); % middle stem point
% Omega_bowl
pos2(vair',90); pos3(cap_curve,180); pos4(vround(vair+1.5vair_corr),270);
if serifs:
 pos1(cap_hair,0); pos0(flare,0); pos5(fudged.hair,0);
 top y2r=h+o; bot y4r=-o; lft x3r=hround u; y3=.5[y2,y4];
 y1=h-vround max(.1fig_height+.5flare,.15fig_height-.5flare)+o;
 x5=(.5w+eps);
 rt x1r=hround min(.5w-max(
	if monospace:.67u,.55stem else:u,.7stem fi),lft x5l-1)+eps;
 x2=x4+if monospace:-fi.25u=hround min(.67[lft x3r,rt x1r],rt x1r-.5)-eps;
 {{less_tense; bulb(2,1,0)}};  % bulb
 y5=max(good.y(.5bar_height-.9),y4l+vair');
 (x,y4l)=whatever[z4r,z5l]; x4l:=min(x,x4l+.5u);
 filldraw stroke pulled_super_arc.e(2,3)(.7superpull)
  & pulled_super_arc.e(3,4)(.5superpull)
  ..tension .9 and 1..{x5-x4,5(y5-y4)}z5e;  % arc and lower terminal
else:
 pos5(flare,275);
 x2=x4=(.25w+1.25u); lft x3r=hround max(u,2u-.5cap_curve);
 x5r=(.5w+eps); top y2r=h+o; y3=.5h;
 bot y4r=-o; bot y5r=vround .08h-o; y5l:=good.y y5l; x5l:=good.x x5l;
 filldraw stroke super_arc.e(2,3) & super_arc.e(3,4) &
  term.e(4,5,right,.8,4); % arc and terminals
fi
%%%
% mirror + middle stem
forsuffixes $ = if serifs: 1l,1r,0l, fi 2l,2,2r,3l,3,3r,4l,4,4r,5l,5,5r:
 x.m$-x6r=x6l-x$; y.m$=y$; endfor;
if serifs:
 {{less_tense; bulb(m2,m1,m0)}};  % bulb
 filldraw stroke pulled_super_arc.e(.m2,.m3)(.7superpull)
  & pulled_super_arc.e(.m3,.m4)(.5superpull)
  ..tension .9 and 1..{x.m5-x.m4,5(y.m5-y4)}z.m5e;  % arc and lower terminal
else:
 filldraw stroke super_arc.e(.m2,.m3) & super_arc.e(.m3,.m4) &
  term.e(.m4,.m5,left,.8,4); % arc and terminals
fi
if serifs:
 path p.l,p.r; numeric t;
 p.l=z4r{right}..tension .9 and 1..{x5-x4,5(y5-y4)}z5r;
 p.r=z.m4r{left}..tension .9 and 1..{x.m5-x.m4,5(y.m5-y.m4)}z.m5r;
 t=ypart(((x6l,0)--(x6l,h)) intersectiontimes p.l); if t<0: t:=1; fi
 filldraw reverse subpath(t,1) of p.r---z6r--z6l---subpath(t,1) of p.l..cycle; %middle stem
 z5'l=(x6l,y5); z5'r=(x6r,y5); z5'=.5[z5'l,z5'r]; z6=.5[z6l,z6r];
 dish_serif(6,5',a,1/3,.5cap_jut,b,1/3,.5cap_jut);
else:
 path p.l,p.r; numeric t; p.l=term.r(4,5,right,.8,4);
 p.r=term.r(.m4,.m5,left,.8,4);
 t=ypart(((x6l,0)--(x6l,h)) intersectiontimes p.l);
 filldraw reverse subpath(t,1) of p.r---z6r--z6l---subpath(t,1) of p.l..cycle; %middle stem
fi
%%%%%
% the accent
% up_te(7);
_zero:=7; x7=.5[x6l,x6r];
_one:=8; _two:=9; _three:=10; _four:=11; _five:=12;
%
if serifs: pickup crisp.nib;
 else: pickup pencircle scaled min(.5fine,.15vair); fi
numeric stem[]; stem1=max(currentbreadth+eps,if hefty: fudged.hair-2stem_corr else: .7[vair,stem] fi);
stem2=if serifs: vair else: max(currentbreadth+eps,.6[thin_join,vair]) fi;
stem3=if serifs: hair else: max(currentbreadth+eps,.6[thin_join,vair]) fi;
pos[_one](stem1,0); pos[_two](stem1,0);
lft x[_one]l=lft x[_two]l=hround(x[_zero]-.5stem1);
numeric mid_thickness;
mid_thickness=vround if serifs:1/4 else: 1/3 fi[vair,stem];
bot y[_two]=bot y[_four]=bot y[_five]=
  vround max(h+o+max(tiny,.5mid_thickness),1/3[h,h+acc_height]+o-.5mid_thickness);
top y[_one]=top y[_three]r=max(h+acc_height,bot y[_two]+1.5vair);
filldraw stroke z[_one]e--z[_two]e; % stem
pos[_three](stem2,90); pos[_four](stem3,0); pos[_five](stem3,180);
x[_three]=x[_one];
rt x[_four]r=hround(x[_zero]+2.5u if monospace:/expansion_factor fi+.5vair);
x[_four]-x[_three]=x[_three]-x[_five];
z[_four]'=beak_darkness[(x[_four]l,y[_three]l),
 .5[(x[_one]r,y[_three]l),z[_four]l] ];
z[_five]'=beak_darkness[(x[_five]l,y[_three]l),
 .5[(x[_one]l,y[_three]l),z[_five]l] ];
filldraw z[_four]r--z[_four]l{up}...z[_four]'
 ...{left}(x[_one]r,y[_three]l)--(x[_one]r,y[_three]l){left}...z[_five]'
 ...{down}z[_five]l--z[_five]r---
 (x[_five]r,y[_three]r)---(x[_four]r,y[_three]r)---cycle;
%%%
penlabels(1,2,3,4,5,6, 7,8,9,10,11,12); endchar;

lhchar "Uppercase Cyrillic letter OMGA_tlo - OMEGA titlo";
cyrchar(OMGA_tlo,if serifs: 18u#+width_adj#
	else: 16.5u# fi,cap_height#+acc_height#,0);%CYR_.SH width
if is_small_cap: getcharcode(omga_tlo); fi
italcorr .7cap_height#*slant-.5u#; %O
adjust_fit(0,0);
full_h:=h; h:=cap_height;
% upper_omega;
numeric shaved_stem; shaved_stem=cap_stem-hround 2stem_corr;
if odd(shaved_stem-w): change_width; fi % symmetric & all three equal
if not serifs: interim superness:=more_super; fi
if serifs: pickup tiny.nib; else: pickup fine.nib; fi
pos6(shaved_stem,0); top y6=.52h;
lft x6l=hround (.5w-.5shaved_stem); % middle stem point
% Omega_bowl
pos2(vair',90); pos3(cap_curve,180); pos4(vround(vair+1.5vair_corr),270);
if serifs:
 pos1(cap_hair,0); pos0(flare,0); pos5(fudged.hair,0);
 top y2r=h+o; bot y4r=-o; lft x3r=hround u; y3=.5[y2,y4];
 y1=h-vround max(.1fig_height+.5flare,.15fig_height-.5flare)+o; x5=(.5w+eps);
 rt x1r=hround min(.5w-max(
	if monospace:.67u,.55stem else:u,.7stem fi),lft x5l-1)+eps;
 x2=x4+if monospace:-fi.25u=hround min(.67[lft x3r,rt x1r],rt x1r-.5)-eps;
 {{less_tense; bulb(2,1,0)}};  % bulb
 y5=max(good.y(.5bar_height-.9),y4l+vair');
 (x,y4l)=whatever[z4r,z5l]; x4l:=min(x,x4l+.5u);
 filldraw stroke pulled_super_arc.e(2,3)(.7superpull)
  & pulled_super_arc.e(3,4)(.5superpull)
  ..tension .9 and 1..{x5-x4,5(y5-y4)}z5e;  % arc and lower terminal
else: pos5(flare,275);
 x2=x4=(.25w+1.25u); lft x3r=hround max(u,2u-.5cap_curve);
 x5r=(.5w+eps); top y2r=h+o; y3=.5h;
 bot y4r=-o; bot y5r=vround .08h-o; y5l:=good.y y5l; x5l:=good.x x5l;
 filldraw stroke super_arc.e(2,3) & super_arc.e(3,4) &
  term.e(4,5,right,.8,4); % arc and terminals
fi
%%%
% mirror + middle stem
forsuffixes $ = if serifs: 1l,1r,0l, fi 2l,2,2r,3l,3,3r,4l,4,4r,5l,5,5r:
 x.m$-x6r=x6l-x$; y.m$=y$; endfor;
if serifs: {{less_tense; bulb(m2,m1,m0)}};  % bulb
 filldraw stroke pulled_super_arc.e(.m2,.m3)(.7superpull)
  & pulled_super_arc.e(.m3,.m4)(.5superpull)
  ..tension .9 and 1..{x.m5-x.m4,5(y.m5-y4)}z.m5e;  % arc and lower terminal
else:
 filldraw stroke super_arc.e(.m2,.m3) & super_arc.e(.m3,.m4) &
  term.e(.m4,.m5,left,.8,4); % arc and terminals
fi
if serifs:
 path p.l,p.r; numeric t;
 p.l=z4r{right}..tension .9 and 1..{x5-x4,5(y5-y4)}z5r;
 p.r=z.m4r{left}..tension .9 and 1..{x.m5-x.m4,5(y.m5-y.m4)}z.m5r;
 t=ypart(((x6l,0)--(x6l,h)) intersectiontimes p.l); if t<0: t:=1; fi
 filldraw reverse subpath(t,1) of p.r---z6r--z6l---subpath(t,1) of p.l..cycle; %middle stem
 z5'l=(x6l,y5); z5'r=(x6r,y5); z5'=.5[z5'l,z5'r]; z6=.5[z6l,z6r];
 dish_serif(6,5',a,1/3,.5cap_jut,b,1/3,.5cap_jut);
else: path p.l,p.r; numeric t; p.l=term.r(4,5,right,.8,4);
 p.r=term.r(.m4,.m5,left,.8,4);
 t=ypart(((x6l,0)--(x6l,h)) intersectiontimes p.l);
 filldraw reverse subpath(t,1) of p.r---z6r--z6l---subpath(t,1) of p.l..cycle; %middle stem
fi
%%%%%
% the accents
h:=full_h;
% up_palatal(expr .5w+u,0,-o);
x_center:=.5w-.25u; x_move:=0; y_move:=-o;
_one:=8; _two:=9; _three:=10; _four:=11;
%
pickup fine.nib; numeric stem[];
stem1=if serifs: vair else: max(currentbreadth+eps,1/3[thin_join,vair]) fi;
stem2=if serifs: .8[hair,stem] else: 1/3[vair,hair] fi;
pos[_one](stem2,180); pos[_three](1/5[stem2,stem1],0);
pos[_two](stem1,90); pos[_four](stem1,90);
top y[_two]r=h+o; x[_two]=x_center;
x:=if serifs: 4u else: 3.5u fi;
rt x[_one]l =hround(x[_two]-x if monospace: /expansion_factor fi +.5stem2);
lft x[_three]l=hround(x[_two]+x if monospace: /expansion_factor fi -.5stem2);
bot y[_one]=bot y[_three]=
   if serifs: max(2/3[cap_height+acc_height,cap_height],x_height+o+hair)-.5crisp
      else:   vround 2/3[cap_height+acc_height,cap_height] fi;
bot y[_four]l=max(cap_height+o,.5[cap_height,y[_one]]);
x[_four]=x_center+if serifs: 5.75u else: 5.25u fi+eps;
forsuffixes e=l,r:
  path p; p=z[_two]e{right}...{(x[_three]-x[_one]),-7acc_height}z[_three]e;
  z[_three]'e=point .8 of p; endfor
filldraw stroke z[_one]e{(x[_three]-x[_one]),7acc_height}...z[_two]e{right}...
         {direction .8 of p}z[_three]'e...{right}z[_four]e; % stroke
%%%
% cap_zvat!!!moved down;
x_center:=.5w-.25u; y_move:=-max(1/3acc_height,.5[vair,curve])-oo-eps;
_one:=12; _two:=13; _three:=14;
%
numeric stem[];
stem1=if serifs: vair else: max(currentbreadth+eps,1/3[thin_join,vair]) fi;
stem2=if serifs:vround  (1/3[vair,stem]) else: vair fi;
theta:=45; y:=min(asc_height,2x_height)+cap_height-x_height;
z[_one]=(x_center-u,.55[y[_three],y]+y_move);%!!!
z[_two]=(x_center+u,4/5[y[_three],y]+y_move);%!!!
bot z[_three]r=(x_center+.5u,
   if serifs: max(2/3[cap_height+acc_height,cap_height],x_height+o+hair)%!!!
                  -.5 if serifs: crisp else: fine fi
      else:   vround 2/3[cap_height+acc_height,cap_height] fi+y_move);%!!!
pos[_one](stem1,theta+90); pos[_two](stem2,theta);
pos[_three](stem1,theta-90);
filldraw stroke z[_one]e{dir(theta+45)}
         ..{dir(theta-90)}z[_two]e..{dir(theta+180)}z[_three]e;  % stroke
%
penlabels(1,2,3,4,5,6, 7,8,9,10,11, 12,13,14); endchar;

lhchar "Uppercase Cyrillic letter KOPPA (C with tail)";
cyrchar(KOPPA,if serifs:13u# else:11.5u# fi,cap_height#,desc_depth#);
if is_small_cap: getcharcode(koppa); fi
italcorr cap_height#*slant-.5u#;
adjust_fit(0,0);
pickup fine.nib;
if serifs: pos1(cap_hair,0); pos2(cap_band,90);
 x2=.55[u+.5curve,x1]; top y2r=h+o;
 rt x1r=hround(w-u); bot y1=min(vround max(.6h,x_height-.5vair),bot y2l-eps);
 filldraw stroke z1e{x2-x1,10(y2-y1)}...{left}z2e;
 pos6'(.3[fine.breadth,cap_hair],0); x6'r=x1r; top y6'=h+o;
 x1r-x1'=2cap_curve-fine; y1'=y1; lft x3r=hround u;
 path upper_arc; upper_arc=z1{x2-x1,10(y2-y1)}..z2{left};
 numeric t; t=xpart(upper_arc intersectiontimes (z6'l--z1'));
 filldraw z1r--z6'r--z6'l--subpath(t,0) of upper_arc--cycle; % barb
else: pos1(1.2flare,80); pos2(slab,90);
 rt x1r=hround(w-1.1u); x2=x4=.5w+1.25u;
 top y1r=vround.95h+o; top y2r=h+o; lft x3r=hround max(u,2u-.5cap_curve);
 filldraw stroke rterm.e(2,1,right,.9,4); fi
numeric theta; theta=-90-angle(40u,x_height); slope:=x_height/-40u;
pos5(max(fine.breadth,fudged.cap_stem-3stem_corr),theta);
pos6(max(fine.breadth,.6[thin_join,vair]),150);
x3l-x3r=hround.8[vair,fudged.cap_stem]-fine;
x5=w-4u; x6l=x1r; y5=-.1d; bot y6l=-d-o;
ellipse_set(2l,3l,4l,5l); ellipse_set(2r,3r,4r,5r);
{{less_tense;
 filldraw stroke z6e {dir (theta+135)} ...
  z5e---z4e...{up}z3e...{right}z2e}}; % main stroke
penlabels(1,1',2,3,4,5,6); endchar;

% Y-o combination
lhchar "Uppercase Cyrillic letter UK";
cyrchar(UK,13u#,cap_height#,0);
if is_small_cap: getcharcode(uk); fi
italcorr cap_height#*slant+.45u#;
adjust_fit(cap_serif_fit#,cap_serif_fit#);
% upper_uk;
numeric left_stem,right_stem,outer_jut,dy,alpha;
left_stem=cap_stem-stem_corr;
right_stem=min(cap_hair if hefty:-2stem_corr fi,left_stem);
outer_jut=.75cap_jut; x1l=w-x4r=l+letter_fit+outer_jut+.05u;
x2l=x5l=hround(.5w-.5left_stem); x3r=x5r; y1=y4=h; y2=y3=y5=.5h; %.4h;
dy=y1-y2; alpha=((x2l-x1l)++dy)/dy;
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*right_stem,0);
penpos5(left_stem,0); penpos6(left_stem,0); x5=x6; y6=.45y5;
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
if y0>y2+cap_notch_cut: y0:=y2+cap_notch_cut;
  fill z0+.5right{up}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)--z5r
    --diag_end(5r,6r,1,1,6l,5l)--z5l--diag_end(2l,1l,1,1,1r,2r){z2-z1}
    ...{down}z0+.5left--cycle; % diagonals and stem
else: fill z0--diag_end(0,4l,1,1,4r,3r)--z5r
    --diag_end(5r,6r,1,1,6l,5l)--z5l
    --diag_end(2l,1l,1,1,1r,0)--cycle; fi  % diagonals and stem
if serifs: numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(4,3); prime_points_inside(6,5);
 if rt x1'r+cap_jut+.5u+1<=lft x4'l-cap_jut: inner_jut=cap_jut;
 else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut);  % upper left serif
 dish_serif(4',3,c,.6,inner_jut,d,1/2,outer_jut)(dark);  % upper right serif
 serif(6',5,e,1/3,if serifs:-jut else:.5stem fi); fi % lower serif
% o
penpos7(vair,90); penpos9(vair',-90);
penpos8(curve,180); penpos10(curve,0);
x8r=hround(l+.5u);
x10r=w-x8r; x7=x9=.5w; y7r=y5 if not hefty:-vair fi; y9r=-o;
y8=y10=.5y7-vair_corr; y8l:=y10l:=.52y7;
penstroke pulled_super_arc.e(7,8)(.5superpull)
 & pulled_super_arc.e(8,9)(.5superpull)
 & pulled_super_arc.e(9,10)(.5superpull)
 & pulled_super_arc.e(10,7)(.5superpull) & cycle;  % bowl
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Uppercase Cyrillic letter CHERV - Old CHE";
cyrchar(CHERV,13.5u#,cap_height#,0); % N_width
if is_small_cap: getcharcode(cherv); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,cap_serif_fit#);
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
pos3(cap_stem,0); pos4(cap_stem,0);
numeric middle_weight; middle_weight=.5[vair,cap_band];
pos5(middle_weight,90); pos6(middle_weight,-90);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=.3[y6,h]; x5l=x6=x7=.5[x1,x3]; z5=z6;
y6=good.y (h-.52h if serifs: -.35(.5[cap_hair,.7cap_stem]) fi);
filldraw stroke z1e--z2e & pulled_arc.e(2,5);
filldraw stroke pulled_arc.e(6,4) & z4e--z3e; % U
pos6'(cap_stem,0); pos7(cap_stem,0); top z6'=z6; bot y7=0;
filldraw stroke z6'e--z7e; % stem
if serifs: pickup tiny.nib; numeric inner_jut,fit; fit=.5u+1;
 if rt x1r+cap_jut+fit<=lft x3r-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+fit=lft x3r-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper left serif
 dish_serif(7,6,g,1/3,inner_jut,h,1/3,cap_jut); fi % lower left serif
penlabels(1,2,3,4,5,6,7); endchar;

lhchar "Uppercase Cyrillic letter PSI";
cyrchar(PSI,14u#,cap_height#,0);
if is_small_cap: getcharcode(psi); fi
italcorr .8cap_height#*slant-.5u#;
adjust_fit(0,0);
numeric shaved_stem; shaved_stem=cap_stem-hround 2stem_corr;
pickup tiny.nib; pos1(shaved_stem,0); pos2(shaved_stem,0);
lft x1l=lft x2l=hround(.5w-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pos3(shaved_stem,-180); pos4(shaved_stem,-180);
pos5(vair,-90); x5=x1; bot y5r=vround(.15h if serifs:+slab fi);
pos6(shaved_stem,0); pos7(shaved_stem,0);
lft x3r=hround u; x7=w-x3; lft x4r=hround(3u-.5shaved_stem); x6=w-x4;
pos3'(vair,90); pos7'(vair,90); z3'r=z3r; z7'r=z7r;
y3=y7; y4=y6=.6h; y3=good.y(y3+.84h if serifs:-slab fi-y3');
interim superness:=more_super;
filldraw z3'l{right}...z4r{down} & super_arc.r(4,5)
 & super_arc.r(5,6) & z6r{up}...z7'l{right}
 --z7r---z7l...z6l{down} & super_arc.l(6,5)
 & super_arc.l(5,4) & z4l{up}...z3l---z3r--cycle;  % stroke
if serifs: dish_serif(1,2,a,1/3,1.25cap_jut,b,1/3,1.25cap_jut);  % upper serif
 dish_serif(2,1,c,1/3,1.25cap_jut,d,1/3,1.25cap_jut); fi  % lower serif
penlabels(1,2,3,4,5,6,7); endchar;

lhchar "Uppercase Cyrillic letter SHTA - Old SH";
cyrchar(SHTA,19.7u#+width_adj#,cap_height#,cap_sbeak#);
if is_small_cap: getcharcode(shta); fi
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,if serifs: cap_serif_fit# else: -.3u#+.1tiny# fi);
if odd(fudged.cap_stem-w): change_width; fi % symmetric & all three equal
% upper_sh;
pickup tiny.nib;
pos1(fudged.cap_stem,0); pos2(fudged.cap_stem,0);
pos3(fudged.cap_stem,0); pos4(fudged.cap_stem,0);
pos5(fudged.cap_stem,0); pos6(fudged.cap_stem,0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=0; z5=.5[z1,z3]; z6=.5[z2,z4];
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
filldraw stroke z5e--z6e; % center stem
numeric inner_jut,arm_thickness;
arm_thickness=vround(slab+vair_corr);
if serifs: numeric inner_jut;
 if rt x1r+cap_jut+.5u+1<=lft x5l-cap_jut: inner_jut=cap_jut;
  else: rt x1r+inner_jut+.5u+1=lft x5l-inner_jut; fi
 dish_serif(1,2,a,1/3,cap_jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,cap_jut);  % upper right serif
 dish_serif(5,6,i,1/3,inner_jut,j,1/3,inner_jut); % upper center serif
 inner_jut:=min(.5(lft x3l-rt x1r)-eps,.5cap_jut);
 save slab; slab:=arm_thickness; % bottom.bar.slab
 nodish_serif(2,1,c,1/3,cap_jut,d,1/3,inner_jut); % lower left serif
 nodish_serif(6,5,k,1/3,inner_jut,m,1/3,inner_jut); % lower center serif
 nodish_serif(4,3,g,1/3,inner_jut,h,1/3,cap_jut);   % lower right serif
 filldraw z.d0--z.d1--z.g1--z.g0--cycle; % lower inter_serif bar
else:
 save slab; slab:=arm_thickness; % bottom.bar.slab
 lft x2'= lft x2l; bot y2'l=0; pos2'(slab,90);
 rt x4'=rt x4r; y4'=y2'; pos4'(slab,90); filldraw stroke z2'e--z4'e; fi
% middle serif
pickup tiny.nib; x7=x6; bot y7=-d;
if serifs: numeric light_hair;
 light_hair=min(fudged.stem,fudged.hair if hefty:-4stem_corr fi);
 pos7(light_hair,0);
 filldraw stroke z6e....{down}z7e;
else: pos7(fudged.cap_stem,0);
 filldraw stroke z6e--z7e; fi % middle serif
penlabels(1,2,3,4,5,6); endchar;

iff not specific:%
lhchar "Uppercase Cyrillic letter IB_YUS - IOT BIG YUS (`roman')";
cyrchar(IB_YUS,18u#,cap_height#,0);
if is_small_cap: getcharcode(ib_yus); fi
adjust_fit(if monospace: 6.5u# else:
        max(5u#+.5cap_stem#,6u#)+cap_serif_fit# fi, %Ipart_adj
 cap_serif_fit#);
if odd(fudged.cap_stem-w): change_width; fi % symmetric & all three equal
% upperr_yus;
% top_Yus;
numeric stem[];
stem1=fudged.cap_stem if hefty:-3stem_corr fi;
stem2=min(stem1,cap_hair if hefty:-2stem_corr fi);
penpos1(stem1,0); penpos2(stem2,0); penpos3(stem1,0); penpos4(stem2,0);
x1l=w-x2r=.2w; y1=h; y2=y1; y3=y4=.52h;
x3l=hround(.5w-.5stem1); x3r=x4r;
z0'=whatever[z4l,z2l]=whatever[z1r,z3r];
if hefty:
 numeric lower_notch; lower_notch=y3+cap_notch_cut;
 fill z3l--diag_end(3l,1l,1,1,1r,3r){z3r-z1r}
 if y0'<=lower_notch: ..{z3r-z1r}z0'{z2l-z4l}..
  else: ...{down}(x0'+.5,lower_notch)--(x0'-.5,lower_notch){up}... fi
 {z2l-z4l}diag_end(4l,2l,1,1,2r,4r)--z4r--cycle; %v
else:
 fill z3l--diag_end(3l,1l,1,1,1r,3r)--z0'--
  diag_end(4l,2l,1,1,2r,4r)--z4r--cycle; fi %v
penpos5(stem1,0); x5=x3; y5=0;
fill z3l--diag_end(3l,5l,1,1,5r,3r)--z3r--cycle; %middle stem
z6=whatever[z4,z2]; z7=whatever[z1,z3]; y6=y7=good.y(y1-slab)-eps;
fill z1--z7--z6--z2--cycle; % upper bar
% Yus_rbowl;
pickup tiny.nib; numeric stem[],alpha[],right_jut,middle_weight;
right_jut=.6cap_jut; middle_weight=cap_bar;
penpos10(middle_weight,90);
y10r=y3+.5min(cap_bar,cap_notch_cut); x10=x3; y9=y12=.8y10;
rt x8r=w-lft x11l=hround(r-letter_fit-.3u-right_jut); bot y8=bot y11=y5;
stem2=max(tiny.breadth,fudged.cap_stem-3stem_corr);
alpha2=diag_ratio(1,.5(stem2-tiny),h-y8,x8r-x3);
penpos8(alpha2*(stem2-tiny),0); penpos11(alpha2*(stem2-tiny),0);
forsuffixes $=l,r: y8'$=0; y11'$=0; endfor
z8'r=z8r+penoffset (x3,h)-z8 of currentpen+whatever*((x3,h)-z8);
z8'l=z8l+penoffset z8-(x3,h) of currentpen+whatever*((x3,h)-z8);
z11'r=z11r+penoffset (x3,h)-z11 of currentpen+whatever*((x3,h)-z11);
z11'l=z11l+penoffset z11-(x3,h) of currentpen+whatever*((x3,h)-z11);
z8'=.5[z8'l,z8'r]; z11'=.5[z11'l,z11'r];
z9=z8'+whatever*((x3,h)-z8);  z12=z11'+whatever*((x3,h)-z11);
penpos9(cap_stem-2stem_corr,0); penpos12(cap_stem-2stem_corr,0);
fill z10l{right}...{z8'l-z9l}z9l--diag_end(9l,8'l,.5,1,8'r,9r)
 --z9r{z9r-z8'r}...{left}z10r--cycle; % right diagonal
 fill z10r{left}...{z11'l-z12l}z12l--diag_end(12l,11'l,1,.5,11'r,12r)
  --z12r{z12r-z11'r}...{right}z10l--cycle; % left diagonal
if serifs: numeric inner_jut; prime_points_inside(5,3);
 if rt x5r+cap_jut+.5u+1<=lft x8l-cap_jut: inner_jut=cap_jut;
  else: rt x5r+cap_jut+.5u+1=lft x8l-inner_jut; fi
 dish_serif(11,12,a,1/3,right_jut,b,1/2,inner_jut)(dark); % lower diagonal serif
 dish_serif(8,9,e,1/2,inner_jut,f,1/3,right_jut)(dark); % lower diagonal serif
 dish_serif(5',3,c,1/3,.75jut,d,1/3,.75jut); fi % middle serif
%%%%%
%I_part(13);
_zero:=10;
_one:=13; _two:=14; _three:=15; _four:=16;
%
pickup tiny.nib; pos[_one](cap_stem,0); pos[_two](cap_stem,0);%pos
lft x[_one]l=lft x[_two]l=
	l+letter_fit+if monospace:-.35u else: cap_serif_fit fi
	+hround max(2u,3u-.5cap_stem);
top y[_one]=h; bot y[_two]=0;
filldraw stroke z[_one]e--z[_two]e; % stem
x[_three]=x[_one]; y[_three]=y[_zero];
x[_four]=x[_zero]; y[_four]=y[_three];
pos[_three](cap_bar,90); pos[_four](cap_bar,90);
filldraw stroke z[_three]e--z[_four]e; % bar
if serifs: dish_serif([_one],[_two],s,1/3,cap_jut,t,1/3,cap_jut);
 dish_serif([_two],[_one],u,1/3,cap_jut,v,1/3,cap_jut); fi
%%%%%
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 16,17,18,19); endchar;

iff serifs:%
lhchar "Uppercase Cyrillic letter I_EST - IOT EST (IC with mid-line)";
cyrchar(I_EST,13u#,cap_height#,0);
if is_small_cap: getcharcode(i_est); fi
italcorr cap_height#*slant-.5u#;
adjust_fit(if monospace: 6.5u# else:
        max(5u#+.5cap_stem#,6u#)+cap_serif_fit# fi, %Ipart_adj
 0);
% upper_ukre;
pickup fine.nib; pos1(cap_hair,0); pos2(cap_band,90);
pos3(cap_curve,180); pos4(cap_band,270); pos5(hair,360);
rt x1r=rt x5r=hround(w-u); lft x3r=(hround u); x2=x4=.55[x3,x1];
top y2r=h+o; bot y4r=-o; y3=.5h-vair_corr; y3l:=.52h;
bot y1=min(vround .675h,bot y2l-eps); y5=max(good.y .95(h-y1),y4l+eps);
(x2l',y2l)=whatever[z2r,z1l]; x2l:=min(x2l',x2l+.5u);
(x4l',y4l)=whatever[z4r,z5l]; x4l:=min(x4l',x4l+.5u);
filldraw stroke z1e{x2-x1,10(y2-y1)}...pulled_super_arc.e(2,3)(.5superpull)
 & pulled_super_arc.e(3,4)(.5superpull)...{up}z5e; % arc
pos6(.3[fine.breadth,cap_hair],0); x6r=x1r; top y6=h+o;
x1r-x1'=2cap_curve-fine; y1'=y1;
path upper_arc; upper_arc=z1{x2-x1,10(y2-y1)}..z2{left};
numeric t; t=xpart(upper_arc intersectiontimes (z6l--z1'));
filldraw z1r--z6r--z6l--subpath(t,0) of upper_arc--cycle; % barb
% upukre_bar;
numeric bar[]; y7=y8=y3;
x7=x3l; x8=(min(lft x1l-.5hair,0.85[x3l,x1l]));
if (serifs=true) and (bar#<=.5curve#):
 penpos7(cap_bar,90); penpos8(cap_bar,90);
 bar2=7/8[cap_bar,fudged.cap_stem-3stem_corr]; penpos9(bar2,45); z9=.575[z7l,z8l];
 fill circ_stroke z8e{-2,-1}..{-2,1}z9e..{-2,-1}z7e; % curve /\/
else: pickup fine.nib; pos7(cap_bar,90); pos8(cap_bar,90);
 filldraw stroke z7e--z8e; fi % bar --
%%%%%
%I_part(3);
_zero:=3;
_one:=10; _two:=11; _three:=12; _four:=13;
%
pickup tiny.nib; pos[_one](cap_stem,0); pos[_two](cap_stem,0);%pos
lft x[_one]l=lft x[_two]l=
	l+letter_fit+if monospace:-.35u else: cap_serif_fit fi
	+hround max(2u,3u-.5cap_stem);
top y[_one]=h; bot y[_two]=0;
filldraw stroke z[_one]e--z[_two]e; % stem
x[_three]=x[_one]; y[_three]=y[_zero];
x[_four]=x[_zero]; y[_four]=y[_three];
pos[_three](cap_bar,90); pos[_four](cap_bar,90);
filldraw stroke z[_three]e--z[_four]e; % bar
if serifs: dish_serif([_one],[_two],s,1/3,cap_jut,t,1/3,cap_jut);
 dish_serif([_two],[_one],u,1/3,cap_jut,v,1/3,cap_jut); fi
%%%%%
penlabels(1,1',2,3,4,5,6,7,8,9, 10,11,12,13); endchar;

iff not serifs:%
lhchar "Uppercase Cyrillic letter I_EST - IOT EST (HC with mid-line)";
cyrchar(I_EST,11.5u#,cap_height#,0);
if is_small_cap: getcharcode(i_est); fi
italcorr cap_height#*slant-.5u#;
adjust_fit(if monospace: 6.5u# else:
        max(5u#+.5cap_stem#,6u#)+cap_serif_fit# fi, %Ipart_adj
 0);
% uppers_ukre;
pickup fine.nib; pos1(1.2flare,80); pos2(slab,90);
pos3(cap_curve,180); pos4(slab,270); pos5(flare,275);
rt x1r=hround(w-1.1u); x2=x4=.5w+1.25u;
lft x3r=hround max(u,2u-.5cap_curve); rt x5r=hround(w-.9u);
top y1r=vround.95h+o; top y2r=h+o; y3=.5h;
bot y4r=-o; bot y5r=vround .08h-o; y5l:=good.y y5l; x5l:=good.x x5l;
filldraw stroke rterm.e(2,1,right,.9,4) & super_arc.e(2,3)
 & super_arc.e(3,4) & term.e(4,5,right,.8,4);
% uukres_bar;
numeric bar[]; y6=y7=y3; x6=x3l; x7=(min(lft x1l-.5hair,0.85[x3l,x1l]));
pickup fine.nib;
bar1=if is_small_cap:max(fine.breadth+eps,.6[thin_join,vair]) else:cap_bar fi;
pos6(bar1,90); pos7(bar1,90);
filldraw stroke z6e--z7e; % bar --
%%%%%
%I_part(3);
_zero:=3;
_one:=9; _two:=10; _three:=11; _four:=12;
%
pickup tiny.nib; pos[_one](cap_stem,0); pos[_two](cap_stem,0);%pos
lft x[_one]l=lft x[_two]l=
	l+letter_fit+if monospace:-.35u else: cap_serif_fit fi
	+hround max(2u,3u-.5cap_stem);
top y[_one]=h; bot y[_two]=0;
filldraw stroke z[_one]e--z[_two]e; % stem
x[_three]=x[_one]; y[_three]=y[_zero];
x[_four]=x[_zero]; y[_four]=y[_three];
pos[_three](cap_bar,90); pos[_four](cap_bar,90);
filldraw stroke z[_three]e--z[_four]e; % bar
if serifs: dish_serif([_one],[_two],s,1/3,cap_jut,t,1/3,cap_jut);
 dish_serif([_two],[_one],u,1/3,cap_jut,v,1/3,cap_jut); fi
%%%%%
penlabels(1,1',2,3,4,5,6,7,8, 9,10,11,12); endchar;

endinput;
%end of file
