%
% lgrusl.mf
%
%% Cyrillic font container with T2 encoding beta-support
%
% This file is future part of lxfonts package
% Version 3.2 // Patchlevel=0
% (c) O.Lapko
%
% This package belongs to the public domain under conditions similar to
% those of D. E. Knuth specified for the Computer Modern family of fonts.
% In particular, only the author is entitled to modify this file
% and to save it under the same name.
%
% Content:
%
% Lowercase Russian letters from a to ya and yo
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% (there are some letters with common witdh
% they have comments as: v_width (the witdh of russian letter v)
% and n_width (russian letter n) at the end of `cyrchar...' line)
%

LHver_check(3,2);

if kapitel:   input lgcrusl; fi

iff not kapitel:%
lhchar "Lowercase Russian letter a";
cyrchar(a,9u#,x_height#,0);
bh#:=min(bar_height#,1.14x_height#-bar_height#); define_pixels(bh);
italcorr 1/3[bh#,x_height#]*slant+.5stem#-serif_fit#-2u#;
adjust_fit(0,serif_fit# if serifs: if hair#+.5stem#>1.5u#:-.25u# fi\\fi);
% lower_a;
pickup fine.nib; top y3r=h+vround 1.5oo;
if serifs:
 pos1(flare,180); pos2(hair,180); pos3(vair,90);
 lft x1r=hround max(u,2.1u-.5flare); x3=.5w-.5u;
 y1=min(bh+.5flare+2vair+2,.9[bh,h]-.5flare);
 bulb(3,2,1);  % bulb
else:
 pos1(5/7[vair,flare],95); x1l=good.x 1.5u; x1r:=good.x x1r;
 pos3(1/8[vair,thin_join],90); x3=.5w-.2u;
 top y1r=vround .82[bh,top y3r];
 filldraw stroke term.e(3,1,left,.9,4); fi  % terminal
pos4(stem,0); rt x4r=hround(w-2.5u+.5stem); y4=1/3[bh,h];
pos5(stem,0); x5=x4; y5=max(.55bh,2vair);
filldraw stroke super_arc.e(3,4)&z4e..z5e;  % arc and stem
pos6(.3[thin_join,vair],90); x6=x4; bot y6=bh;
pos7(hround(curve-2stem_corr),180);
lft x7r=hround max(.5u,1.5u-.5curve); y7=1/3[top y8l,top y6r];
pos8(vair,270); x8l=.5w-.75u; bot y8r=-oo;
pos9(thin_join,360); z9l=z5l; (x,y8r)=whatever[z8l,z9l]; x8r:=max(x,x8-u);
{{interim superness:=more_super;
 filldraw stroke z9e{down}...z8e{left}...{up}z7e&super_arc.e(7,6)}}; % bowl
if serifs:
 numeric shaved_stem; shaved_stem=hround(stem-3stem_corr);
 if hair#+.5stem#>1.5u#:
  pickup tiny.nib;
  pos5'(shaved_stem,0); rt x5'r=fine.rt x5r; y5'=y5;
  pos10(shaved_stem,0); x10=x5'; y10=.2[.5tiny,bh];
  pos11(shaved_stem,0); rt x11r=hround(w-.25u); bot y11=0;
  pos12(shaved_stem,0); x11=x12; top y12=slab+eps;
  filldraw z5'l---z10l...z11l{right}--z11r
   --z12r{left}...z10r+.75(z12-z11)---z5'r--cycle;  % foot
 else:
  pickup crisp.nib; pos5'(shaved_stem,0); rt x5'r=fine.rt x5r; y5'=y5;
  pos10(shaved_stem,0); x10=x5'; y10=1/3bh;
  pos11(.2[vair,stem],90); x11r=.5[x10r,x12r]; bot y11l=-vround .5oo;
  pos12(hair,180); rt x12l=hround(w-.1u); y12=max(y10,y11+vair);
  pos13(hair,180); x13=x12; top y13=max(vround .6bh,top y12);
  (x',y11l)=whatever[z11r,z12r]; x11l:=max(x',x10);
  filldraw stroke z5'e---z10e...z11e{right}...z12e---z13e; fi  % hook
else:
 numeric shaved_stem; shaved_stem=hround(stem-stem_corr);
 pickup tiny.nib; pos5'(shaved_stem,0); rt x5'r=fine.rt x5r; y5'=y5;
 pos10(shaved_stem,0); x10=x5'; bot y10=0;
 filldraw stroke z5'e--z10e; fi  % base of stem
%%%%%
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13); endchar;

iff not kapitel:%
lhchar "Lowercase Russian letter b";
cyrchar(b,9u#,asc_height#,0); % v_witdh
italcorr asc_height#*slant-serif_fit#+.5stem#-2u#; %d
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi);
numeric stem[]; stem1=.5[vair,curve];
stem2= max(fine.breadth,if serifs: hair else: vair fi);
penpos1(vair,90); penpos3(vair',-90); penpos2(curve,180); penpos4(curve,0);
x1=x3=.5w; y1r=x_height+vround 1.5oo; y3r=-oo;
x2r=hround max(.5u,1.25u-.5curve); x4r=w-x2r;
y2=y4=.5x_height-vair_corr; y2l:=y4l:=.52x_height;
if serifs:
 penstroke pulled_arc.e(1,2) & pulled_arc.e(2,3)
  & pulled_arc.e(3,4) & pulled_arc.e(4,1) & cycle; % o bowl
else:
 penpos2''(.7[fudged.hair,vair]-3stem_corr,180); z2''l=z2l;
 penstroke pulled_arc.e(2,3) & pulled_arc.e(3,4)
  & pulled_arc.e(4,1) & pulled_arc.e(1,2'')..cycle; fi % o bowl
pickup fine.nib;
pos7(stem2,180); rt x7l=min(w-u,rt 4r-.1u); top y7=h;
pos2'(stem2,180); lft x2'r=x2r; y2'=y2;
if hefty:
 pos5(stem1,90); pos6(stem1,90);
 x5=max(x1l,lft x1); x6=x4+if monospace:-.5 else:+.5 fi fine;
 x6'=x6-.5stem1;
 top y6r=h; y5=y6-1/15(h-x_height-.5tiny); y6'=y6l;
 filldraw z6r---z6...z6'---z5l....{down}z2'l--z2'r{up}....z5r---cycle; % upper tail
else:
 pos5(max(stem2,.7[fudged.hair,fudged.stem]),135);
 pos6(max(stem2,.9[fudged.hair,fudged.stem]),120);
 x5=max(.55[x2r,x1],x2l+.1u);
 forsuffixes $=l,r:
  z5'$=((x5,0)..(x5,h)) intersectionpoint (z2${up}...{right}z1$); endfor
 y5=max(y5'r+.7(y5'r-y5'l),h-.45(asc_height-x_height));
 z6r=whatever[z5r,z7r];  x6=x7-1.2max(u,stem2);
 filldraw stroke z7e..z6e{z5-z6}..z5e....{down}z2'e; fi
penlabels(1,2,2',3,4,5,6,7); endchar;

lhchar "Lowercase Russian letter v (looks like B)";
cyrchar(v,9u#,x_height#,0); % v_witdh
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
adjust_fit(serif_fit#,if monospace:.5u# else:0 fi);
numeric right_curve; pickup tiny.nib;
pos1(fudged.stem,0); pos2(fudged.stem,0);
lft x1l=lft x2l=hround (2.5u-.5stem'); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
penpos3(Vround(vair-vair_corr),90); penpos4(Vround(vair-vair_corr),90);
penpos5(right_curve-stem_corr,0); penpos10(right_curve,0);
penpos11(vair,-90); penpos12(vair,-90);
z3r=top z1; y4=y3; y5=.5[y4,y6]+eps;
set_bar_axis; y6l=y7l=y8r=y9r=y2.bh; y6r=y7r=y8l=y9l=y1.bh; y6=y7=y8=y9=y0.bh;
z12r=bot z2; y11=y12; y10=.5[y11,y9];
x6l=x6r=x4-if not serifs:2 fi u;
x9l=x9r=x11-if serifs:.5 fi u=x4 if not serifs:-u fi;
x7l=x7r=x8l=x8r=x1; x9l:=x4 if serifs:+.25u else:-.25u fi;
x10r=hround(w-.6u); x5r=min(x10r-1-eps,hround(w-u));
if serifs:
 right_curve=curve-stem_corr; x4=.5[x1,w-1.5u];
else:
 right_curve=curve-3stem_corr; x4=.5[x1,w-1u];
 x4l:=x4l-.5u; x9l:=x9l-.5u; fi
x6l:=x6l+.5u; x11l:=x11l-.5u; x9r:=max(x6r,x9r-u);
fill stroke
 {{if not serifs:interim superness:=hein_super; fi z3e..super_arc.e(4,5)}}
 & super_arc.e(5,6)..z7e;  % upper lobe
fill stroke z8e..super_arc.e(9,10) &
 {{if not serifs:interim superness:=hein_super; fi super_arc.e(10,11)..z12e}};  % lower lobe
if serifs:
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,jut,b,1/3,.5jut);	% upper serif
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,jut,d,1/3,.5jut); fi	% lower serif
penlabels(1,2,3,4,5,6,7,8,9,10,11,12); endchar;

lhchar "Lowercase Russian letter g (looks like Gamma)";
cyrchar(g,8u#-.5width_adj#,x_height#,0);
italcorr x_height#*slant-beak_jut#+.25u#; %Gamma->x_height+.5u#
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ 0);
% lower_g;
pickup tiny.nib; pos1(stem,0); pos2(stem,0);
lft x1l=lft x2l=hround (2.5u-.5stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pickup crisp.nib; pos3(Vround(vair-vair_corr),90); pos4(hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-.45u); y4=good.y(y3l-beak/1.4)-eps;
arm(3,4,e,beak_darkness,.4beak_jut);  % upper arm and beak
if serifs:
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,jut,b,1/3,.5jut);	% upper serif
 slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,1.25jut); fi	% lower serif
%%%%%
penlabels(1,2,3,4); endchar;

iff not concrete:%
lhchar "Lowercase Russian letter d";
cyrchar(d,10u# %if not serifs:+.5width_adj# fi % dl_width;n_width
 ,x_height#,sbeak#);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit#
 if not serifs:+\\.5(stem#-u#),.5(stem#-u#)+ else:,fi\\ serif_fit#); %dl_adj
% lower_d;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
rt x1r=rt x2r=w-hround (2.5u-.5fudged.stem-eps); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; %stem
numeric light_hair,light_stem,outer_jut;
light_hair=if hefty:.5[vair,fudged.hair] else: fudged.hair fi;
light_stem=max(tiny.breadth+eps,min(fudged.stem,fudged.hair if hefty:-4stem_corr fi));
outer_jut=
   if serifs: max(limit_dist,1.1jut) else: hround (r-rt x2r-.5u) fi;
penpos3(light_hair,0); penpos0(light_hair,0); x0=x3-eps; y0=0; y3=h;
x3=1/3[w-rt x1r-1/8(outer_jut if not serifs:-.5(stem-u) fi),rt x1r]
    if not serifs: -.5(stem-u) fi +eps;
x4l=w-rt x1r-1/3outer_jut-eps; y4l=vair;
x2'=x2; y2'=if serifs: 1/2 else: 2/3 fi h;
penpos4(light_hair,angle((y2',-x2')-(y4l,-x4l))); if y4r<0: y4r:=0; fi
fill z4l{z2'-z4}...{up}diag_end(0l,3l,1,1,3r,0){down}
 ...{z4-z2'}z4r--cycle; %left stem
numeric inner_jut;
save slab; % lower.slab
if serifs:
 inner_jut=.5(x1l-lft x3r)+.5crisp+eps; prime_points_inside(3,0);
 slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(3',0,a,1/3,jut,b,1/3,inner_jut);  % upper left serif
 nodish_serif(1,2,c,1/3,inner_jut,d,1/3,jut);  % upper right serif
else:
 pos3'(vair,90); pos1'(vair,90);
 lft x3'=x3l; top y3'r=top y1'r=h; rt x1'=x1;
 filldraw stroke z3'e--z1'e; fi % upper bar
% lower descenders
slab:=vair; % lower.slab
inner_jut:=.5(x2l+x2r-w)+eps;
r_serif(2,1,e,1/3,inner_jut,f,1/3,beak_darkness,outer_jut,.6beak_jut); % right descender
% lower de_serif
y5=y.f1; y0'=y.f4; x5=good.x(w-x.f1);
bot y6=bot y7=vround (-d+eps);
x6=good.x(w-x.f2); x7=good.x(w-x.f3);
pair beak_corner; ypart beak_corner=y0'; beak_corner=z7+whatever*(z5-z6);
x8=w-x1+.5(fudged.stem-3stem_corr-tiny); x0'=w-x1+inner_jut; y8=y0';
filldraw z5--z6--z7{z5-z6}
    ...beak_darkness[beak_corner,.5[z7,z8]]
    ...{right}z8---z0'--(x0',y5)--cycle; % de_serif
if serifs:
   numeric bracket_height;
   bracket_height=min(y2+bracket,y1);
   if bracket_height>y4l:
      path p.r,p.l; y5:=top y5;
      p.r=(z4r{z2'-z4}...{up}z3r); p.l=(z4l{z2'-z4}...{up}z3l);
      forsuffixes e=l,r:
          z9e=((0,bracket_height)--(w,bracket_height)) intersectionpoint p.e;
      endfor
      vardef t (suffix @) =
          angle direction directiontime z9@ of p.@ of p.@ enddef;
      fill z9l{dir (t(l)+180)}...1/3[(x4l,y5),.5[z9l,z5]]{z5-z9l}
          ...{left}z5--(x5,y0')--z0'--(x0',y5)
          --(x9r+(light_stem/bracket_height)*(x4r-x4l),y5){left}
          ...{dir t(r)}z9r--cycle; % top part of de_serif
   fi
fi
%%%%%
penlabels(0',1',1,2,3,4,5,6,7,8,9); endchar;

iff not kapitel:%
lhchar "Lowercase Russian letter e";
cyrchar(e,7.25u#+max(.75u#,.5curve#),x_height#,0);
italcorr .5[bar_height#,x_height#]*slant+.5min(curve#-1.5u#,0);
adjust_fit(if monospace: .25u#,.5u# else: 0,0 fi);
% lower_e;
numeric left_curve,right_curve;
left_curve=right_curve+6stem_corr=curve if not serifs: -3stem_corr fi;
if right_curve<tiny.breadth: right_curve:=tiny.breadth; fi
if left_curve<tiny.breadth: left_curve:=tiny.breadth; fi
pickup tiny.nib; pos1(right_curve,0);
pos2(vair,90); pos3(left_curve,180);
y1=good.y bar_height; top y2r=h+vround 1.5oo; y0l=bot y1;
rt x1r=hround min(w-.5u,w-u+.5right_curve);
lft x3r=hround max(.5u,1.25u-.5left_curve); x2=.5w+.25u;
{{interim superness:=more_super;
 filldraw stroke super_arc.e(1,2)}};  % right bowl
y3=.5[y2,y4]; bot y4r=-oo; x4=x2+.25u;
if serifs:
 pos4(vair',270); pos5(hair,360);
 y5=max(good.y(.5bar_height-.9),y4l+vair); x5r=x1r;
 (x,y4l)=whatever[z4r,z5]; x4l:=min(x,x4l+.5u);
 filldraw stroke pulled_arc.e(2,3) & pulled_arc.e(3,4)
  ...{x5-x4,5(y5-y4)}z5e; % left bowl, arc, and terminal
else:
 pos4(vair,270);
 filldraw stroke super_arc.e(2,3) & super_arc.e(3,4);  % left bowl and arc
 pickup fine.nib; pos4'(vair,270); z4=z4';
 pos5(.5[vair,flare],275); rt x5r=hround(w-.6u);
 y5r=good.y(y5r+1/3bar_height-y5); y5l:=good.y y5l; x5l:=good.x x5l;
 filldraw stroke term.e(4',5,right,1,4); fi  % terminal
path testpath; testpath=super_arc.r(2,3) & super_arc.r(3,4);
y1'r=y0r=y0l+.6[thin_join,vair]; y1'l=y0l; x1'l=x1'r=x1;
forsuffixes $=l,r:
 x0$=xpart(((0,y0$)--(x1,y0$)) intersectionpoint testpath); endfor
fill stroke z0e--z1'e;  % crossbar
%%%%%
penlabels(0,1,2,3,4,5); endchar;

iff not concrete:%
iff not specific:%
lhchar "Lowercase Russian letter zh (`roman')";
cyrchar(zh,if serifs: 10u# else: 9.5u# fi % zhk_width: n_width;keng_width
 ,x_height#,0);
italcorr x_height#*slant-.2u#;
adjust_fit(w#-5u#+ %zhr_adj
 if monospace: 0,0 else: serif_fit#,serif_fit# fi); %wlett_adj
% lowerr_zh;
pickup tiny.nib; numeric stem[];
stem0=max(tiny.breadth,hround(fudged.stem-stem_corr));
if odd((r-l)-stem0): change_width; fi % symmetric & all three equal
pos1(stem0,0); pos2(stem0,0);
lft x1l=lft x2l=hround (.5[l,r]-.5fudged.stem)-eps; % middle stem point
top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
save slab; % lower.slab
if serifs:
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,jut);	% upper stem serif
 slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,jut); fi% lower stem serif
% k_rbowl;zh%monospace:+.25u
numeric right_jut,stem[],alpha[]; pickup tiny.nib;
right_jut=if serifs:.6jut else:.4tiny fi;
stem1=max(tiny.breadth,hround(fudged.hair if hefty:-\\4stem_corr fi));
stem2=max(tiny.breadth,fudged.stem-3stem_corr);
rt x3r=hround(r-letter_fit-.7u-right_jut if monospace:+.25u fi)+eps; %!!!
rt x6r=hround(r-letter_fit-.3u-right_jut if monospace:+.25u fi)+eps; %!!!
y4=.7bar_height; top y3=h; bot y6=0; x4=x1;
penpos3(alpha1*(stem1-tiny),0); penpos4(whatever,-90);
alpha1=diag_ratio(1,.5(stem1-tiny),y3-y4,x3r-x4);
penpos6(alpha2*(stem2-tiny),0);
alpha2=diag_ratio(1,.5(stem2-tiny),y1-y6,x6r-x1);
forsuffixes $=l,r: y3'$=h; y6'$=0; z4.$=z3'$+whatever*(z3-z4);
 z5.$=z6'$+whatever*(z1-z6)=whatever[z3,z4]; endfor
z5=.5[z5l,z5r];
z3'r=z3r+penoffset z3-z4 of currentpen+whatever*(z3-z4);
% we have also |z3'l=z3l+penoffset z4-z3 of currentpen+whatever*(z3-z4)|;\]
z6'r=z6r+penoffset z1-z6 of currentpen+whatever*(z1-z6);
z6'l=z6l+penoffset z6-z1 of currentpen+whatever*(z1-z6);
fill z4r--diag_end(4r,3'r,1,.5,3'l,4l)--z4l--cycle;  % upper diagonal
fill z5l--diag_end(5l,6'l,.5,1,6'r,5r)--z5r--cycle;  % lower diagonal
%%
if serifs:
 numeric inner_jut,up_inner_jut;
 if rt x2r+jut+.5u+1<=lft x6l-jut: inner_jut=jut;
  else: rt x2r+jut+.5u+1=lft x6l-inner_jut; fi
 if rt x1r+jut+.5u+1<=lft x3l-1.2jut: up_inner_jut=1.2jut;
  else: rt x1r+jut+.5u+1=lft x3l-up_inner_jut; fi
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(3,4,e,2/3,up_inner_jut,f,1/2,right_jut)(dark); % upper diagonal serif
 slab:=vair; % lower.slab
 dish_serif(6,5,g,1/2,inner_jut,h,1/3,right_jut)(dark); fi % lower diagonal serif
%%%
% mirror
forsuffixes $ = 3'r,3,3'l,4r,4,4l,5l,5,5r,6'l,6,6'r:
 x.m$=l+(r-x$); y.m$=y$; endfor;
fill z.m4r--diag_end(.m4r,.m3'r,1,.5,.m3'l,.m4l)--z.m4l--cycle;  % upper diagonal
fill z.m5l--diag_end(.m5l,.m6'l,.5,1,.m6'r,.m5r)--z.m5r--cycle;  % lower diagonal
%%
if serifs:
 penpos7(alpha1*(stem1-tiny),0); penpos8(whatever,-90);
 penpos10(alpha2*(stem2-tiny),0);
 z7=z.m3; z8=z.m4; z9l=z.m5r; z9=z.m5; z9r=z.m5l; z10=z.m6;
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(7,8,i,1/2,right_jut,j,2/3,up_inner_jut)(dark); % upper diagonal serif
 slab:=vair; % lower.slab
 dish_serif(10,9,k,1/3,right_jut,l,1/2,inner_jut)(dark); fi % lower diagonal serif
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Lowercase Russian letter z";
cyrchar(z,8u#,x_height#,0);
italcorr .5x_height#*slant+min(.5curve#-.65u#,+.1u#); %p+.2u#
adjust_fit(if monospace:.5u#,.5u# else: 0,0 fi);
% lower_z;
set_bar_axis; y4l=y5r=y6r=y2.bh; y6l=y5l=y4r=y1.bh; y6=y0.bh;
pickup fine.nib; numeric right_curve;
if serifs: right_curve=curve-stem_corr; else: right_curve=curve-3stem_corr; fi
penpos2(vair,90); penpos3(max(vair+stem_corr,right_curve-stem_corr),0);
penpos7(max(vair'+stem_corr,right_curve),0); penpos8(vair',-90);
y2r=vround(h+1.5oo); x2=x6l=x6r=x8=.5(w-u); x7r=hround(w-.6u);
x3r=min(rt x7r-1,hround(w-.8u)); y3=.5[y4l,y2l]+eps; y8r=-oo;
y7=.5[y6l,y8l]; x4l=x4r=1/3[x5l,x3l];
if serifs:
 pos1(hair,180); pos9(hair,-180);
 lft x1r=lft x9r+.1u=hround.5u;
 y1=min(y2.bh+flare-.25vair+eps,.9[bar_height,h]-.75flare);
 y9=max(good.y(.5bar_height-.9),y8l+vair');
else:
 pos1(4/7[vair,flare],115); pos9(.6[vair',flare],-115);
 lft x1r=good.x .6u; lft x9r=good.x .5u;
 top y1r=vround .82[bar_height,y2r];
 y9r=good.y(y9r+1/3bar_height-y9); y9l:=good.y y9l; x9l:=good.x x9l;
fi
lft x5l=lft x5r=hround (2.5u-.5)-eps;
x4r:=max(x5r,x4r-u); x6r:=max(x5r,x6r-u);
fill stroke
     {{interim superness:=if serifs: more_super else: hein_super fi;
       super_arc.e(2,3)}} & super_arc.e(3,4)..(x5e,y4e); % upper bowl
{{interim superness:=more_super;
  fill stroke z5e..super_arc.e(6,7) & super_arc.e(7,8)}}; % lower bowl
fill
 z5r{left}
 if bot y5r>top y5l:..(lft x5r,bot y5r)---(lft x5l,top y5l)..
    else: ... fi
 {right}z5l--cycle; % bar point
pos2'(vair,90); z2'=z2; pos8'(vair',-90); z8'=z8;
if serifs:
   filldraw stroke z1e{x2-x1,7(y2-y1)}....{right}z2'e; % upper arc
   {{interim superness:=more_super;
     filldraw stroke super_arc.e(8',9)}}; % lower arc
else:
   filldraw stroke term.e(2',1,left,.8,4); % upper terminal
   forsuffixes e=l,r: path p.e; p.e=z8'e{left}..tension .9 and 1..z9e;
      if angle direction 1 of p.e<105:
         p.e:=z8'e{left}..tension atleast.9 and 1..{dir 105}z9e; fi endfor
   filldraw stroke p.e; % lower arc
fi
if serifs:
 path upper_arc; upper_arc=z1{x2-x1,7(y2-y1)}....{right}z2;
 pos10(.3[fine.breadth,hair],0); x10l=x1r; top y10=vround(h+1.5oo);
 x1'-x1l=1.5curve; y1'=y1;
 numeric t; t=xpart(upper_arc intersectiontimes (z10r--z1'));
 filldraw z1r--z10l--z10r--subpath(t,0) of upper_arc--cycle; fi % upper serif
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Lowercase Russian letter i (looks like backwards N)";
cyrchar(i,10u# if not serifs:+.5width_adj# fi,x_height#,0); % n_width
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit#,serif_fit#);
% lower_i;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
pos3(fudged.stem,0); pos4(fudged.stem,0);
lft x1l=lft x2l=hround(2.5u-.5fudged.stem-eps); 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:
 stem1=fudged.hair-2stem_corr;
 penpos5(stem1,0); penpos6(stem1,0);
 if monospace:
  y5l=vround(vair'+eps); y6r=vround(h-vair-eps);
 else: y5l=0; y6r=h; fi
 x5=x1r; x6=x3l;
 numeric upper_notch,lower_notch;
 upper_notch=y6-notch_cut+eps; lower_notch=y5+notch_cut-eps;
 x2'=rt x1r; z2'=whatever[z5l,z6l]; x3'=lft x4l; z3'=whatever[z5r,z6r];
 fill z5l..
  if y2'>lower_notch: {right}(x2'+1,lower_notch){up}... fi
  {z6-z5}diag_in(5l,6l,1,6r)--z6r..
  if y3'<upper_notch: {left}(x3'-1,upper_notch){down}... fi
  {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonal
else:
 x5=hround (rt x1r-.5)-eps; x6=hround (lft x3l+.5)+eps;
 y5l=vround(y2+bracket+eps); y6r=vround(y3-bracket-eps);
 stem1=max(tiny.breadth,fudged.hair-2stem_corr);
 alpha1=diag_ratio(1,stem1,x6-x5,top y6r-bot y5l);
 penpos5(alpha1*stem1,90); penpos6(alpha1*stem1,90);
 fill stroke z5e--z6e; fi % diagonal
if serifs:
 numeric inner_jut;
 if rt x1r+jut+.5u+1<=lft x3l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);	% upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);	% upper right serif
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut);	% lower left serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut); fi	% lower right serif
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Lowercase Russian letter i_shrt - short i";
cyrchar(i_shrt,10u# if not serifs:+.5width_adj# fi, % n_width
  x_height#+acc_height#,0);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit#,serif_fit#); full_h:=h; h:=x_height;
% lower_i;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
pos3(fudged.stem,0); pos4(fudged.stem,0);
lft x1l=lft x2l=hround(2.5u-.5fudged.stem-eps); 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:
 stem1=fudged.hair-2stem_corr;
 penpos5(stem1,0); penpos6(stem1,0);
 if monospace:
  y5l=vround(vair'+eps); y6r=vround(h-vair-eps);
 else: y5l=0; y6r=h; fi
 x5=x1r; x6=x3l;
 numeric upper_notch,lower_notch;
 upper_notch=y6-notch_cut+eps; lower_notch=y5+notch_cut-eps;
 x2'=rt x1r; z2'=whatever[z5l,z6l]; x3'=lft x4l; z3'=whatever[z5r,z6r];
 fill z5l..
  if y2'>lower_notch: {right}(x2'+1,lower_notch){up}... fi
  {z6-z5}diag_in(5l,6l,1,6r)--z6r..
  if y3'<upper_notch: {left}(x3'-1,upper_notch){down}... fi
  {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonal
else:
 x5=hround (rt x1r-.5)-eps; x6=hround (lft x3l+.5)+eps;
 y5l=vround(y2+bracket+eps); y6r=vround(y3-bracket-eps);
 stem1=max(tiny.breadth,fudged.hair-2stem_corr);
 alpha1=diag_ratio(1,stem1,x6-x5,top y6r-bot y5l);
 penpos5(alpha1*stem1,90); penpos6(alpha1*stem1,90);
 fill stroke z5e--z6e; fi % diagonal
if serifs:
 numeric inner_jut;
 if rt x1r+jut+.5u+1<=lft x3l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);	% upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);	% upper right serif
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut);	% lower left serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut); fi	% lower right serif
%%%%%
% the accent
h:=full_h; cbreve(.5w,0, 7,8,9,10,11,12,13);
penlabels(1,2,3,4,5,6, 7,8,9,10,11,12,13); endchar;

iff not concrete:%
iff not specific:%
lhchar "Lowercase Russian letter k (`roman')";
cyrchar(k,if serifs: 10u# else: 9.5u# fi % zhk_width: n_width;keng_width
 ,x_height#,0);
italcorr x_height#*slant-.2u#;
adjust_fit(serif_fit#,serif_fit#);
% lowerr_k;
pickup tiny.nib; numeric stem[];
stem0=max(tiny.breadth,hround(fudged.stem-stem_corr));
pos1(stem0,0); pos2(stem0,0);
lft x1l=lft x2l=hround (2.5u-.5fudged.stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
save slab; % lower.slab
if serifs:
 slab:=Vround(vair-vair_corr);%lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,jut);	% upper stem serif
 slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,jut); fi% lower stem serif
% k_rbowl;
numeric right_jut,stem[],alpha[]; pickup tiny.nib;
right_jut=if serifs:.6jut else:.4tiny fi;
stem1=max(tiny.breadth,hround(fudged.hair if hefty:-\\4stem_corr fi));
stem2=max(tiny.breadth,fudged.stem-3stem_corr);
rt x3r=hround(r-letter_fit-.7u-right_jut)+eps;
rt x6r=hround(r-letter_fit-.3u-right_jut)+eps;
y4=.7bar_height; top y3=h; bot y6=0; x4=x1;
penpos3(alpha1*(stem1-tiny),0); penpos4(whatever,-90);
alpha1=diag_ratio(1,.5(stem1-tiny),y3-y4,x3r-x4);
penpos6(alpha2*(stem2-tiny),0);
alpha2=diag_ratio(1,.5(stem2-tiny),y1-y6,x6r-x1);
forsuffixes $=l,r: y3'$=h; y6'$=0; z4.$=z3'$+whatever*(z3-z4);
 z5.$=z6'$+whatever*(z1-z6)=whatever[z3,z4]; endfor
z5=.5[z5l,z5r];
z3'r=z3r+penoffset z3-z4 of currentpen+whatever*(z3-z4);
% we have also |z3'l=z3l+penoffset z4-z3 of currentpen+whatever*(z3-z4)|;\]
z6'r=z6r+penoffset z1-z6 of currentpen+whatever*(z1-z6);
z6'l=z6l+penoffset z6-z1 of currentpen+whatever*(z1-z6);
fill z4r--diag_end(4r,3'r,1,.5,3'l,4l)--z4l--cycle;  % upper diagonal
fill z5l--diag_end(5l,6'l,.5,1,6'r,5r)--z5r--cycle;  % lower diagonal
%%
if serifs:
 numeric inner_jut,up_inner_jut;
 if rt x2r+jut+.5u+1<=lft x6l-jut: inner_jut=jut;
  else: rt x2r+jut+.5u+1=lft x6l-inner_jut; fi
 if rt x1r+jut+.5u+1<=lft x3l-1.2jut: up_inner_jut=1.2jut;
  else: rt x1r+jut+.5u+1=lft x3l-up_inner_jut; fi
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(3,4,e,2/3,up_inner_jut,f,1/2,right_jut)(dark); % upper diagonal serif
 slab:=vair; % lower.slab
 dish_serif(6,5,g,1/2,inner_jut,h,1/3,right_jut)(dark); fi % lower diagonal serif
%%%
%%%%%
penlabels(1,2,3,4,5,6); endchar;

iff not concrete:%
lhchar "Lowercase Russian letter l";
cyrchar(l,10u# % if not serifs:+.5width_adj# fi % dl_width;n_width
 ,x_height#,0);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit# if not serifs:+.5(stem#-u#) fi, %dl_adj
 serif_fit#); %
% lower_l;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
rt x1r=rt x2r=w-hround (2.5u-.5fudged.stem-eps); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; %stem
numeric light_hair,bot_vair,bulb_diam,left_jut;
light_hair=if hefty:.5[vair,fudged.hair] else: fudged.hair fi;
bot_vair=Vround(.5[vair,light_hair]);
bulb_diam=hround 7/8[hair,flare];
left_jut=
   if serifs: max(limit_dist,1.1jut) else: hround (w+serif_fit-rt x2r-.5u) fi;
x3=1/3[w-rt x1r-(1/8left_jut),rt x1r] if not serifs: -.5(stem-u) fi +eps;
if serifs:
 pos3(light_hair,0); pos4(light_hair,-90);
 pos6(bulb_diam,-180); pos5(hair,-180);
 top y3=h; y6-.5bulb_diam=.12desc_depth-eps; z6r=z5r;
 lft x6r=l+letter_fit+hround(.35u-.5);
 x4=max(lft x5r+.5bulb_diam,.4[lft x5r,rt x3r]);
 bot y4r=-1.5oo-eps; {{less_tense; bulb(4,5,6)}}; %bulb
 filldraw stroke z4e{right}
  ..controls (min(15/16[x4,x3],max(x4,lft x6r+1.75bulb_diam))+(x3e-x3),y4e)
  and (x3e,max(y4l,min(y6-.5,1/3h+eps))+1/3(y4e-y4))..{up}z3e; % left tail
else:
 pos3'(vair,90); pos1'(vair,90);
 lft x3'=x3-.5light_hair; rt x1'=x1r; top y3'r=top y1'r=h;
 filldraw stroke z3'e--z1'e; % upper bar
 pickup fine.nib; pos3(light_hair,0); pos4(bot_vair,-90); pos5(bot_vair,-90);
 bot y5r=0; x4=.67[x3l,x5];
 lft x5=l+letter_fit+hround(.35u-.5); bot y4r=bot y5r; y3=y3';
 filldraw stroke z3e{down}..controls (x3e,y5e+.35h)
  and (min(7/8[x4e,x3e],x4e+2light_hair+eps),y4e-eps)..{left}z4e--z5e; fi % left stem
%%%
if serifs:
 x0=x3; y0=0;
 numeric inner_jut; inner_jut=.5(x1l-x3r)+.5crisp+eps;
 save slab; slab:=vair; % lower.slab
 dish_serif(2,1,a,1/3,jut,b,1/3,jut);		% lower right serif
 slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,c,1/3,inner_jut,d,1/3,jut);	% upper right serif
 nodish_serif(3,0,e,1/3,1.05jut,f,1/3,inner_jut); fi% upper left serif
%%%%%
penlabels(0,1,1',2,3,3',4,5,6);endchar;

lhchar "Lowercase Russian letter m";
cyrchar(m,12u# if not serifs:+width_adj# fi,x_height#,0);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(if monospace: 0,0 else: serif_fit#,serif_fit# fi); %wlett_adj
% lower_m;
numeric stem[]; % thicknesses of the four strokes
stem1=hround(fudged.hair+stem_corr);
stem2=hround(fudged.stem-3stem_corr);
stem3=min(stem2,hround (fudged.hair-2stem_corr));
stem4=max(stem1,hround(fudged.stem-3stem_corr));
pickup tiny.nib; pos1(stem1,0); pos2(stem1,0);
pos3(stem4,0); pos4(stem4,0);
x1=x2; x3=x4; x1l=w-x3r; rt x3r=hround (w-2.5u+.5stem4);
top y1=top y3=h; bot y2=bot y4=0;
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
penpos5(stem2,0); penpos6(stem2,0); penpos7(stem3,0); penpos8(stem3,0);
x5l=x1; x6l=x7l; x8=lft x3l; x6-x5=x8-x7; y5=y8=h; y6=y7;
if hefty:
 y6=if monospace: vround 1/3h else: oo fi;
 numeric upper_notch,lower_notch;
 upper_notch=h-notch_cut+eps; lower_notch=y5+notch_cut-eps;
 x1'=rt x1r; z1'=whatever[z5l,z6l]; x3'=lft x3l; z3'=whatever[z7r,z8r];
 z0=whatever[z5r,z6r]=whatever[z7l,z8l];
 fill z5l..
  if y1'<upper_notch: {right}(x1'+1,upper_notch){down}... fi
  {z6-z5}diag_in(5l,6l,1,6r)..diag_out(7l,1,7r,8r){z8-z7}
  if y3'<upper_notch: ...{up}(x3'-1,upper_notch){right} fi
  ..z8r--diag_out(8r,1,8l,7l){z7-z8}
  if y0<=lower_notch: ..{z7-z8}z0{z5-z6}..
  else: ...{down}(x0+.5+eps,lower_notch)--(x0-.5-eps,lower_notch){up}... fi
  {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonals
else:
 y6=0; z0=whatever[z5r,z6r]=whatever[z7l,z8l];
 fill z5l..{z6-z5}diag_in(5l,6l,1,6r)..diag_out(7l,1,7r,8r){z8-z7}
  ..z8r--diag_out(8r,1,8l,7l){z7-z8}..{z7-z8}z0{z5-z6}
  ..{z5-z6}diag_in(6r,5r,1,5l)--cycle; fi  % diagonals
%%%
if serifs:
 numeric inner_jut;
 if rt x2r+jut+.5u+1+eps+.5stem3<=lft x4l-.5stem3-jut: inner_jut=jut;
  else: rt x2r+inner_jut+.5u+1+eps+.5stem3=lft x4l-.5stem3-inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 serif(1,2,a,1/3,-jut);	% upper left serif
 serif(3,4,d,1/3,jut);	% upper right serif
 slab:=vair; % lower.slab
 dish_serif(2,1,b,1/2,jut,c,1/2,jut)(dark); % lower left serif
 dish_serif(4,3,e,1/3,jut,f,1/3,jut); fi    % lower right serif
%%%%%
penlabels(0,1,1',2,3,3',4,5,6,7,8); endchar;

lhchar "Lowercase Russian letter n (looks like H)";
cyrchar(n,10u#, % if not serifs:+.5width_adj# fi, % n_width
 x_height#,0);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit#,serif_fit#);
% lower_n;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
pos3(fudged.stem,0); pos4(fudged.stem,0);
lft x1l=lft x2l=hround(2.5u-.5fudged.stem-eps); 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
bar_stroke(x1,x3); % bar
%%%
if serifs:
 numeric inner_jut;
 if rt x1r+jut+.5u+1<=lft x3l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);	% upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);	% upper right serif
 slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut);	% lower left serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut); fi	% lower right serif
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Lowercase Russian letter o";
cyrchar(o,9u#,x_height#,0);
italcorr .7x_height#*slant;
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi); %o
% lower_o;
penpos1(vair,90); penpos3(vair',-90); penpos2(curve,180); penpos4(curve,0);
x2r=hround max(.5u,1.25u-.5curve);
x4r=w-x2r; x1=x3=.5w; y1r=h+vround 1.5oo; y3r=-oo;
y2=y4=.5h-vair_corr; y2l:=y4l:=.52h;
penstroke pulled_arc.e(1,2) & pulled_arc.e(2,3)
 & pulled_arc.e(3,4) & pulled_arc.e(4,1) & cycle;  % bowl
%%%%%
penlabels(1,2,3,4); endchar;

lhchar "Lowercase Russian letter p (looks like PI)";
cyrchar(p,10u#, % if not serifs:+.5width_adj# fi, % n_width
 x_height#,0);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit#,serif_fit#);
% lower_p;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
pos3(fudged.stem,0); pos4(fudged.stem,0);
lft x1l=lft x2l=hround (2.5u-.5fudged.stem-eps); 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
%%%
if serifs:
 numeric inner_jut;
 if rt x1r+jut+.5u+1<=lft x3l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 save slab; slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut);	% lower left serif
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut);	% lower right serif
 inner_jut:=.5(x3l-x1r)+.5crisp+eps;
 slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);	% upper left serif
 nodish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);	% upper right serif
else:
 lft x1'= lft x1l; top y1'r=h; pos1'(vair,90);
 rt x3'=rt x3r; y3'=y1'; pos3'(vair,90);
 filldraw stroke z1'e--z3'e; fi % upper bar
%%%%%
penlabels(1,2,3,4); endchar;

iff not kapitel:%
lhchar "Lowercase Russian letter r (looks like p)";
cyrchar(r,10u#+serif_fit#,x_height#,desc_depth#);
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
adjust_fit(serif_fit#,0);
% lower_r;
pickup tiny.nib; pos1(stem',0); pos2(stem,0);
pos0'(stem',0); pos0(stem,0); z0l=z0'l; x0'=x1; x0=x2;
lft x1l=hround(2.5u-.5stem'); top y1=h if serifs: +min(oo,serif_drop) fi;
numeric edge; edge=rt x2r;
pickup fine.nib; pos3(if hefty: thin_join else: hair fi,180);
pos4(vair',90); pos5(curve,0); pos6(vair,-90); penpos7(x3l-x3r,-180);
rt x3l=max(rt x3l-(lft x3r-tiny.lft x2l), 1/3[rt x2,edge]);
y3=1/8[bar_height,x_height];
x4l=w-.5(w-serif_fit)+.5u; top y4r=x_height+oo;
rt x5r=hround min(w-1.35u+.5curve,w-.6u); y5=.5x_height;
x6l=x4l-.2u; bot y6r=-oo;
x7=x3; y7=min(y3,y6+y4-y3+.6vair);
(x,y4r)=whatever[z3l,z4l]; x4r:=min(x,.5[x5r,x4]);
(x',y6r)=whatever[z7l,z6l]; x6r:=min(x',.5[x5r,x6]);
filldraw stroke z3e{up}...{right}z4e&super_arc.e(4,5)
 &super_arc.e(5,6)&z6e{left}...{up}z7e;  % bowl
y0=ypart(((edge,h)--(edge,0))intersectionpoint(z3l{up}...{right}z4l));
pickup tiny.nib; bot y2=-d;
filldraw stroke z1e--z0'e--z0e--z2e;  % stem
pickup crisp.nib; pos8(hair,0); pos7'(stem,0);
z7'=z2; x8l=x7'l; bot y8=0;
filldraw stroke z7'e--z8e;  % point
if serifs:
 sloped_serif.l(1,0',a,1/3,jut,serif_drop);  % upper serif
 dish_serif(2,0,b,1/3,jut,c,1/3,jut); fi  % lower serif
%%%%%
penlabels(0,1,2,3,4,5,6,7,8); endchar;

lhchar "Lowercase Russian letter s (looks like c)";
cyrchar(s,8u#,x_height#,0);
italcorr x_height#*slant-.2u#;
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi);
% lower_s;
pickup fine.nib; pos2(vair',90); pos4(vair',270);
x2=x4=.5(w+u); top y2r=vround(h+1.5oo); bot y4r=-oo;
pos3(curve,180); lft x3r=hround max(.6u,1.35u-.5curve); y3=.5h; % eng
if serifs:
 pos1(hair,0); pos0(flare,0);
 y1=min(bar_height+.5flare+2vair'+2,.9[bar_height,h]-.5flare);
 rt x1r=hround(w-.7u); bulb(2,1,0); % bulb
 pos5(hair,0); rt x5r=hround(w-.5u);
 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:
 pos1(4/7[vair',flare],80);
 rt x1r=hround(w-.6u); top y1r=vround .82[bar_height,top y2r];
 filldraw stroke term.e(2,1,right,.8,4); % upper terminal
 pos5(.6[vair',flare],275); rt x5r=hround(w-.5u);
 y5r=good.y(y5r+1/3bar_height-y5); y5l:=good.y y5l; x5l:=good.x x5l;
 forsuffixes e=l,r: path p.e; p.e=z4e{right}..tension .9 and 1..z5e;
  if angle direction 1 of p.e>75:
   p.e:=z4e{right}..tension atleast.9 and 1..{dir 75}z5e; fi endfor
 filldraw stroke pulled_super_arc.e(2,3)(.7superpull)
  & pulled_super_arc.e(3,4)(.5superpull) & p.e; fi  % arc and lower terminal
%%%%%
penlabels(0,1,2,3,4,5); endchar;

lhchar "Lowercase Russian letter t";
cyrchar(t,9u#-width_adj#,x_height#,0);
italcorr x_height#*slant-beak_jut#+.35u#; %Gamma->x_height+.65u#
adjust_fit(0,0); if odd(stem-w): change_width; fi % symmetric & all three equal
% lower_t;
pickup tiny.nib; pos1(stem,0); pos2(stem,0);
lft x1l=lft x2l=hround(.5w-.5stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pickup crisp.nib; pos3(vair,90); pos4(hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-.45u); y4=good.y(y3l-beak/1.4)-eps;
arm(3,4,e,beak_darkness,.4beak_jut);  % right arm and beak
pos5(hair,180); x5=w-x4; y5=y4;
arm(3,5,f,beak_darkness,-.4beak_jut);  % left arm and beak
%%%
if serifs:
 save slab; slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,1.414jut,d,1/3,1.414jut);	% lower serif
 slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,.5jut,b,1/3,.5jut); fi	% upper bracketing
%%%%%
penlabels(1,2,3,4,5); endchar;

iff not kapitel:%
lhchar "Lowercase Russian letter u (looks like y)";
cyrchar(u,if serifs: 9.5u# else: 9u# fi,x_height#,desc_depth#); % eng
italcorr x_height#*slant+.25u#;
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ serif_fit#);
% lower_u;
numeric left_stem,right_stem,bot_stem,bot_vair,outer_jut;
left_stem=fudged.stem-stem_corr; right_stem=fudged.hair if hefty:-2stem_corr fi;
bot_stem=fudged.hair if hefty:-8stem_corr fi;
bot_vair=Vround(if serifs: vair else:.5[vair,bot_stem] fi); outer_jut=.75jut;
x1l=w-x4r=l+letter_fit+outer_jut+.25u; y1=y4r=h; y2=y3=0; x2l=x3l;
numeric alpha,alpha[]; x9=3u; y9=bot_vair-d-oo;
alpha1=diag_ratio(2,bot_stem,y1-y3,x4r-x1l-apex_corr);
alpha2=diag_ratio(1,bot_stem,y1-y9,x4r-x9);
if alpha1<alpha2:
 x2l-x1l=x4r-x3r+apex_corr; alpha=alpha1;
else:
 alpha=alpha2; z3l=whatever[z9,z4r-(alpha*bot_stem,0)]; fi
penpos3(alpha*bot_stem,0); penpos4(alpha*right_stem,0);
alpha3=(y1++(x2l-x1l))/y1;
penpos1(alpha3*left_stem,0); penpos2(alpha3*left_stem,0);
z0=whatever[z1r,z2r]=z4l+whatever*(z3r-z4r);
if y0>notch_cut:
 y0:=notch_cut;
 fill z0+.5right{up}...{z4r-z3r}diag_end(0,4l,1,1,4r,3r)
  --z3r--z2l--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{down}z0+.5left--cycle; % left and right diagonals
else:
 fill z0--diag_end(0,4l,1,1,4r,3r)--z3r--z2l
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
penpos5(alpha*bot_stem,0); z5r=whatever[z3r,z4r]; y5-.5vair=-.5d;
if serifs:
 numeric light_bulb; light_bulb=hround 7/8[hair,flare]; clearpen;
 penpos6(vair,-90); penpos7(hair,-180); penpos8(light_bulb,-180);
 x6=2u; y6r=-d-oo; y8-.5light_bulb=-.85d; x8r=hround .35u;
 fill stroke z3e---z5e...{left}z6e; bulb(6,7,8);  % arc and bulb
 numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(4,3);
 if rt x1'r+jut+.5u+1<=lft x4'l-jut: inner_jut=jut;
  else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut);	% left serif
 dish_serif(4',3,c,.6,inner_jut,d,1/2,outer_jut)(dark);	% right serif
else:
 penpos6(bot_vair,-90); x6=2.5u; y6r=-d-oo;
 fill stroke z3e---z5e...{left}z6e;  % arc
 pickup fine.nib; pos6'(bot_vair,-90); z6'=z6;
 pos7(2/3[bot_vair,flare],-85);
 lft x7l=hround u; bot y7r=vround-.96d-oo; y7l:=good.y y7l;
 filldraw stroke term.e(6',7,left,1,4); fi % arc and terminal
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9); endchar;

iff not kapitel:%
lhchar "Lowercase Russian letter f (looks like phi)";
cyrchar(f,if serifs: 9.5u# else: 9.75u# fi+serif_fit#,
  asc_height#,desc_depth#);
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#);
adjust_fit(w#-5u# if monospace:-\\.5u#,-.5u#+ else:,fi\\ 0);
if odd((r-l)-stem'): change_width; fi % symmetric & all three equal
pickup tiny.nib; pos1(stem',0); pos2(stem',0);
lft x1l=lft x2l=hround(.5[l,r]-.5stem')-eps; top y1=h; bot y2=-d; % middle stem point
numeric edge; edge=rt x2r;
% f_bowl
 pickup fine.nib;
 pos3(if hefty: thin_join else:hair fi,180);
 pos4(vair',90); pos5(curve,0); pos6(vair,-90);
 rt x3l=(max(rt x3l-(lft x3r-tiny.lft x2l),1/3[rt x2,edge]));
 penpos7(x3l-x3r,-180);
 y3=1/8[bar_height,x_height];
 x4l=(w-.5(w-serif_fit)if not serifs:+.3u fi);
 rt x5r=(hround min(w-1.35u+.5curve,w-.6u)+eps);
 top y4r=x_height+oo; y5=.5x_height;
 x6l=x4l; bot y6r=-oo; x7=x3; y7=min(y3,y6+y4-y3+.6vair);
 (x,y4r)=whatever[z3l,z4l];
 x4r:=min(x,.5[x5r,x4]); (x',y6r)=whatever[z7l,z6l];
 x6r:=min(x',.5[x5r,x6]);
 filldraw stroke z3e{up}...{right}z4e & super_arc.e(4,5)
  & super_arc.e(5,6) & z6e{left}...{up}z7e;  % bowl
% mirror
forsuffixes $ = 3l,3r,4l,4,4r,5l,5,5r,6l,6,6r,7l,7r:
  x.m$=l+(r-x$); y.m$=y$; endfor;
 filldraw stroke z.m3e{up}...{left}z.m4e & super_arc.e(.m4,.m5)
  & super_arc.e(.m5,.m6) & z.m6e{right}...{up}z.m7e;  % bowl
% stem
pickup tiny.nib; filldraw stroke z1e--z2e; % stem
if serifs:
 numeric outer_jut; outer_jut=if monospace: 1.414 fi jut;
 sloped_serif.l(1,2,a,1/3,outer_jut,serif_drop);    % upper serif
 dish_serif(2,1,b,1/3,outer_jut,c,1/3,outer_jut); fi % lower serif
penlabels(0,0',1,2,3,4,5,6,7,7',8); endchar;

lhchar "Lowercase Russian letter h - kha (looks like X)";
cyrchar(h,if serifs: 9.5u# else: 9u# fi,x_height#,0);
italcorr x_height#*slant-.05u#;
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ serif_fit#);
% lower_h;
numeric stem[],outer_jut,xjut,alpha[];
stem1=fudged.stem-4stem_corr; stem2=min(fudged.hair,stem1);
outer_jut=.75jut; xjut= if serifs: (stem1-stem2)/4 else: 0 fi;
x1l=l+letter_fit+.1u+outer_jut; x2r=r-letter_fit-.3u-outer_jut-xjut;
x3l=l+letter_fit+outer_jut+xjut; x4r=r-letter_fit-outer_jut; y1=y2=h; y3=y4=0;
alpha1=diag_ratio(1,stem1,h,x4r-x1l); alpha2=diag_ratio(1,stem2,h,x2r-x3l);
penpos1(alpha1*stem1,0); penpos2(alpha2*stem2,0);
penpos3(alpha2*stem2,0); penpos4(alpha1*stem1,0);
if hefty:
 z0=whatever[z1,z4]=whatever[z2,z3];
 x12=x34=x0; y13=y24=y0;
 z12=whatever[z2l,z3l]; z13=whatever[z2l,z3l];
 z24=whatever[z2r,z3r]; z34=whatever[z2r,z3r];
 forsuffixes $=13,24,34: z$'=.2[z$,z0]; endfor
 fill diag_end(12,1r,.5,1,1l,13')--z13'--diag_end(13',3l,1,.5,3r,34')--z34'
  --diag_end(34',4l,.5,1,4r,24')--z24'
  --diag_end(24',2r,1,.5,2l,12)--z12--cycle; % diagonals
else:
 fill diag_end(4r,1r,.5,1,1l,4l)
  --diag_end(1l,4l,.5,1,4r,1r)--cycle; % left diagonal
 fill diag_end(2l,3l,.5,1,3r,2r)
  --diag_end(3r,2r,.5,1,2l,3l)--cycle; fi  % right diagonal
%%%
if serifs:
 numeric inner_jut[]; pickup tiny.nib;
 prime_points_inside(1,4); prime_points_inside(2,3);
 prime_points_inside(3,2); prime_points_inside(4,1);
 if rt x1'r+jut+.5u+1<=lft x2'l-jut-xjut: inner_jut1=jut;
  else: rt x1'r+inner_jut1+.5u+1=lft x2'l-inner_jut1-xjut; fi
 if rt x3'r+jut+.5u+1<=lft x4'l-jut-xjut: inner_jut2=jut;
  else: rt x3'r+inner_jut2+.5u+1=lft x4'l-inner_jut2-xjut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1',4,a,1/3,outer_jut,b,2/3,inner_jut1); % upper left serif
 dish_serif(2',3,e,2/3,inner_jut1+xjut,f,1/2,outer_jut+xjut)(dark); % upper right serif
 slab:=vair; % lower.slab
 dish_serif(4',1,c,2/3,inner_jut2,d,1/3,outer_jut); % lower right serif
 dish_serif(3',2,g,1/2,outer_jut+xjut,h,2/3,inner_jut2+xjut)(dark); fi % lower left serif
%%%%%
penlabels(0,1,2,3,4,12,13,24,34); endchar;

lhchar "Lowercase Russian letter c - tse";
cyrchar(c,10u# if not serifs:+.5width_adj# fi, % n_width
 x_height#,sbeak#);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit#,
 serif_fit# if not serifs:+.5(stem#-u#) fi); %dl_adj
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
pos3(fudged.stem,0); pos4(fudged.stem,0);
lft x1l=lft x2l=hround (2.5u-.5fudged.stem-eps); 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 inner_jut,right_jut;
save slab; % lower.slab
if serifs:
 if rt x1r+jut+.5u+1<=lft x3l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);	% upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);	% upper right serif
 inner_jut:=.5(x3l-x1r)+.5crisp+eps;
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,jut,d,1/3,inner_jut);	% lower left serif
else:
 lft x2'= lft x2l; bot y2'l=0; pos2'(vair,90);
 rt x4'= rt x4r; y4'=y2'; pos4'(vair,90);
 filldraw stroke z2'e--z4'e; fi
% lowercase descender
slab:=vair; % lower.slab
inner_jut:=.5(x3l-x1r)+.5crisp+eps;
right_jut=if serifs: max(limit_dist,1.1jut) else: hround (r-rt x4r-.5u) fi;
r_serif(4,3,g,1/3,inner_jut,h,1/3,beak_darkness,right_jut,.6beak_jut); % lower rt descender
penlabels(1,2,3,4); endchar;

lhchar "Lowercase Russian letter ch";
cyrchar(ch,10u# if not serifs:+.5width_adj# fi,x_height#,0); % n_width
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit#,serif_fit#);
% lower_ch;
pickup tiny.nib;
numeric middle_weight; middle_weight=.6[thin_join,vair];
pos1(fudged.stem,0); pos2(fudged.stem,0);
pos3(fudged.stem,0); pos4(fudged.stem,0);
penpos2'(fudged.stem,0); z2'=z2;
penpos5(middle_weight,90); penpos6(middle_weight,90);
penpos6'(middle_weight,90);
lft x1l=lft x2l=hround(2.5u-.5fudged.stem-eps); x3=x4=w-x1;
top y1=top y3=h; bot y2=.3[y6,h]; bot y4=0; x5l=1/3[x1,x3];
y6l=vround(.48h-.5middle_weight if serifs:-.15(.5[hair,.7stem]) fi);
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
y5l=y6l; x6=x6'=x3;
if serifs: y6'l=min(3/5h,y6l-hair+1.05stem); fi
if serifs:
 if ((y6'l-y6l)>=middle_weight+1+eps):
  fill stroke z2'e{down}..z5e{right}...{.75(z5-z6)+z6'}z6'e;  % arc
 else:
  fill stroke pulled_arc.e(2',5) & z5e--z6e; fi % arc
 numeric inner_jut; pickup tiny.nib;
 if rt x1r+jut+.5u+1<=lft x3l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
%%%
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);  % upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);  % upper right serif
 slab:=vair; % lower.slab
 dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut);  % lower right serif
else:
 fill stroke pulled_arc.e(2',5) & z5e{right}...{right}z6e; fi % arc
%%%%%
penlabels(1,2,3,4,5,6); endchar;

lhchar "Lowercase Russian letter sh";
cyrchar(sh,14.5u# if serifs:+.5width_adj# fi,x_height#,0);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(if monospace: 0,0 else: serif_fit#,serif_fit# fi); %wlett_adj
% lower_sh;
if odd(fudged.stem-w): change_width; fi % symmetric & all three equal
pickup tiny.nib;
pos1(fudged.stem,0); pos2(fudged.stem,0); pos3(fudged.stem,0);
pos4(fudged.stem,0); pos5(fudged.stem,0); pos6(fudged.stem,0);
lft x1l=lft x2l=hround(2.5u-.5fudged.stem-eps); x3=x4=w-x1;
top y1=top y3=top y5=h; bot y2=bot y4=bot y6=0;
lft x5l=lft x6l=hround (.5[x1,x3]-.5fudged.stem); % middle stem point
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
filldraw stroke z5e--z6e; % center stem
if serifs:
 numeric inner_jut;
 if rt x1r+jut+.5u+1<=lft x5l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x5l-inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);	% upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);	% upper right serif
 dish_serif(5,6,i,1/3,inner_jut,j,1/3,inner_jut); % upper center serif
 inner_jut:=.5(x3l-x5r)+.5crisp+eps;
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,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,jut);	% lower right serif
else:
 lft x2'= lft x2l; bot y2'l=0; pos2'(vair,90);
 rt x4'=rt x4r; y4'=y2'; pos4'(vair,90);
 filldraw stroke z2'e--z4'e; fi
penlabels(1,2,3,4,5,6); endchar;

lhchar "Lowercase Russian letter shch";
cyrchar(shch,14.5u# if serifs:+.5width_adj# fi,x_height#,sbeak#);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(if monospace: 0 else: serif_fit# fi, %wlett_adj
 if monospace: 0 else: serif_fit# if not serifs:+.5(stem#-u#) fi fi) %dl_adj&wlett_adj
% lower_sh;
if odd(fudged.stem-w): change_width; fi % symmetric & all three equal
pickup tiny.nib;
pos1(fudged.stem,0); pos2(fudged.stem,0); pos3(fudged.stem,0);
pos4(fudged.stem,0); pos5(fudged.stem,0); pos6(fudged.stem,0);
lft x1l=lft x2l=hround(2.5u-.5fudged.stem-eps); x3=x4=w-x1;
top y1=top y3=top y5=h; bot y2=bot y4=bot y6=0;
lft x5l=lft x6l=hround (.5[x1,x3]-.5fudged.stem); % middle stem point
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
filldraw stroke z5e--z6e; % center stem
save slab; % lower.slab
if serifs:
 numeric inner_jut;
 if rt x1r+jut+.5u+1<=lft x5l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x5l-inner_jut; fi
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);	% upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);	% upper right serif
 dish_serif(5,6,i,1/3,inner_jut,j,1/3,inner_jut); % upper center serif
 inner_jut:=.5(x3l-x5r)+.5crisp+eps;
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,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,jut);	% lower right serif
else:
 lft x2'= lft x2l; bot y2'l=0; pos2'(vair,90);
 rt x4'=rt x4r; y4'=y2'; pos4'(vair,90);
 filldraw stroke z2'e--z4'e; fi
% lowercase descender
slab:=vair; % lower.slab
inner_jut:=.5(x3l-x5r)+.5crisp+eps;
numeric right_jut;
right_jut:=if serifs: max(limit_dist,1.1jut) else: hround (r-rt x4r-.5u) fi;
r_serif(4,3,o,1/3,inner_jut,p,1/3,beak_darkness,right_jut,.6beak_jut); % lower rt descender
penlabels(1,2,3,4,5,6); endchar;

lhchar "Lowercase Russian letter hrdsn - hard sign";
cyrchar(hrdsn,9u#,x_height#,0); % v_witdh
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
adjust_fit(2u#-.5width_adj#,if monospace:.5u# else:0 fi);
% lower_hrdsn;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
lft x1l=lft x2l=hround (2.5u-.5fudged.stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
% lower left beak
pickup crisp.nib; top y3r=h; x3=x1; pos3(vair,90);
pos4(hair,180); lft x4r=l+letter_fit+hround.45u; y4=good.y(y3l-beak/1.4)-eps;
arm(3,4,q,beak_darkness,-.4beak_jut);
if serifs:
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,.5jut,b,1/3,.5jut);	% upper serif
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,jut,d,1/3,.5jut); fi	% lower serif
% lsftsn_bowl(2);
_zero:=2;
_one:=5; _two:=6; _three:=7; _four:=8; _five:=9;
%
set_bar_axis;
penpos[_three](curve if hefty:-3stem_corr fi,0);
penpos[_four](vair',-90); penpos[_five](vair',-90);
z[_five]r=bot z[_zero]; y[_four]=y[_five];
y[_three]=.5[y[_two]l,y[_four]l];
y[_one]l=y[_two]l=y1.bh; y[_one]r=y[_two]r=y2.bh;
x[_two]l=x[_two]r=x[_four]=w-3.75u; %.5v_width+.75u;
x[_one]l=x[_one]r=x[_zero]; x[_three]r=hround(w-.6u);
x[_two]l:=x[_four]l:=x[_two]r-.25curve;
fill stroke
 {{if not serifs: interim superness:=more_super; fi
  z[_five]e..super_arc.e([_four],[_three])}} &
 super_arc.e([_three],[_two])..z[_one]e;  % lobe
%%%
%%%%%
penlabels(1,2,3,4,5,6,7,8,9); endchar;

lhchar "Lowercase Russian letter ery";
cyrchar(ery,9u#,x_height#,0); % v_witdh
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(if monospace: 0,0 else: serif_fit#,serif_fit# fi %wlett_adj
 +4u#);
% lower_ery;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
lft x1l=lft x2l=hround (2.5u-.5fudged.stem-eps); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs:
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,jut);		% upper serif
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,jut,d,1/3,.5jut); fi	% lower serif
% lsftsn_bowl(2);
_zero:=2;
_one:=3; _two:=4; _three:=5; _four:=6; _five:=7;
%
set_bar_axis;
penpos[_three](curve if hefty:-3stem_corr fi,0);
penpos[_four](vair',-90); penpos[_five](vair',-90);
z[_five]r=bot z[_zero]; y[_four]=y[_five];
y[_three]=.5[y[_two]l,y[_four]l];
y[_one]l=y[_two]l=y1.bh; y[_one]r=y[_two]r=y2.bh;
x[_two]l=x[_two]r=x[_four]=w-3.75u; %.5v_width+.75u;
x[_one]l=x[_one]r=x[_zero]; x[_three]r=hround(w-.6u);
x[_two]l:=x[_four]l:=x[_two]r-.25curve;
fill stroke
 {{if not serifs: interim superness:=more_super; fi
  z[_five]e..super_arc.e([_four],[_three])}} &
 super_arc.e([_three],[_two])..z[_one]e;  % lobe
%%%
% I
w:=w+4u;
rt x8r=rt x9r=w-lft x1l; top y8=h; bot y9=0;
pos8(fudged.stem,0); pos9(fudged.stem,0);
filldraw stroke z8e--z9e; % stem
if serifs:
 slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(8,9,e,1/3,jut,f,1/3,jut);	% upper serif
 slab:=vair; % lower.slab
 dish_serif(9,8,g,1/3,jut,h,1/3,jut); fi% lower serif
%%%%%
penlabels(1,2,3,4,5,6,7,8,9); endchar;

lhchar "Lowercase Russian letter sftsn - soft sign";
cyrchar(sftsn,9u#,x_height#,0);
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+else:,fi\\0);
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
lft x1l=lft x2l=hround (2.5u-.5fudged.stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs:
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,jut);		% upper serif
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,jut,d,1/3,.5jut); fi	% lower serif
% lsftsn_bowl(2);
_zero:=2;
_one:=3; _two:=4; _three:=5; _four:=6; _five:=7;
%
set_bar_axis;
penpos[_three](curve if hefty:-3stem_corr fi,0);
penpos[_four](vair',-90); penpos[_five](vair',-90);
z[_five]r=bot z[_zero]; y[_four]=y[_five];
y[_three]=.5[y[_two]l,y[_four]l];
y[_one]l=y[_two]l=y1.bh; y[_one]r=y[_two]r=y2.bh;
x[_two]l=x[_two]r=x[_four]=w-3.75u; %.5v_width+.75u;
x[_one]l=x[_one]r=x[_zero]; x[_three]r=hround(w-.6u);
x[_two]l:=x[_four]l:=x[_two]r-.25curve;
fill stroke
 {{if not serifs: interim superness:=more_super; fi
  z[_five]e..super_arc.e([_four],[_three])}} &
 super_arc.e([_three],[_two])..z[_one]e;  % lobe
%%%
%%%%%
penlabels(1,2,3,4,5,6,7); endchar;

lhchar "Lowercase Russian letter erev - reverse e";
cyrchar(erev,8u#,x_height#,0);
italcorr .7x_height#*slant-.1u#; %o
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi);
% lower_erev;
set_bar_axis;
pickup fine.nib; pos2(vair',90); pos3(curve,0); pos4(vair',-90);
x2=x4=w-.5(w+u); top y2r=vround(h+1.5oo); bot y4r=-oo;
rt x3r=w-hround max(.6u,1.35u-.5curve); y3=.5h; % eng
if serifs:
 pos1(hair,180); pos5(hair,-180);
 y1=min(y2.bh+flare-.25vair+eps,.9[bar_height,h]-.75flare);
 lft x1r=lft x5r=hround.5u;
 y5=max(good.y(.5bar_height-.9),y4l+vair');
 (x,y4l)=whatever[z4r,z5l]; x4l:=max(x,x4l-.5u);
 filldraw stroke z1e{x2-x1,5(y2-y1)}...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
 pos6(.3[fine.breadth,hair],180); x6r=x1r; top y6=h+oo;
 x1'-x1r=1.5curve; y1'=y1;
 path upper_arc; upper_arc=z1{x2-x1,5(y2-y1)}..z2{right};
 numeric t; t=xpart(upper_arc intersectiontimes (z6l--z1'));
 filldraw z1r--z6r--z6l--subpath(t,0) of upper_arc--cycle; % barb
else:
 pos1(4/7[vair',flare],100); pos5(.6[vair',flare],-95);
 lft x1r=good.x .6u; top y1r=vround .82[bar_height,top y2r];
 filldraw stroke term.e(2,1,left,.8,4);  % upper terminal
 lft x5r=good.x .5u;
 y5r=good.y(y5r+1/3bar_height-y5); y5l:=good.y y5l; x5l:=good.x x5l;
 forsuffixes e=l,r: path p.e; p.e=z4e{left}..tension .9 and 1..z5e;
  if angle direction 1 of p.e<105:
   p.e:=z4e{left}..tension atleast.9 and 1..{dir 105}z5e; fi
 endfor
 filldraw stroke pulled_super_arc.e(2,3)(.7superpull)
  & pulled_super_arc.e(3,4)(.5superpull) & p.e; fi  % arc and lower terminal
%%%
% lerev_bar;
if (serifs=true) and (bar#<=.5curve#):
   x7r=max(rt x1l+.5hair,0.85[x3l,x1l]); x8r=x3l;
   y7l=y8l=y1.bh; y7r=y8r=y2.bh; x7l=x7r; x8l=x8r;
   numeric bar[];
   bar2=7/8[bar,fudged.stem-2stem_corr];
   penpos9(bar2,45); z9=.475[z7l,z8l];
   fill circ_stroke z7e{2,1}..{2,-1}z9e..{2,1}z8e; % curve /\/
else:
   bar_stroke(max(rt x1l+.5hair,0.85[x3l,x1l]),x3l); % bar --
fi
%%%%%
penlabels(1,1',2,3,4,5,6,7,8,9); endchar;

lhchar "Lowercase Russian letter yu (looks like IO)";
cyrchar(yu,9u#,x_height#,0);
italcorr .7x_height#*slant; %o
adjust_fit(if monospace: 4u# else: 4.5u# fi +serif_fit#, %li_part_adj
 if monospace: -.45u# else: 0 fi);
% lower_yu;
penpos1(vair,90); penpos3(vair',-90); penpos2(curve,180); penpos4(curve,0);
x2r=hround max(.5u,1.25u-.5curve);
x4r=w-x2r; x1=x3=.5w; y1r=h+vround 1.5oo; y3r=-oo;
y2=y4=.5h-vair_corr; y2l:=y4l:=.52h;
penstroke pulled_arc.e(1,2) & pulled_arc.e(2,3)
 & pulled_arc.e(3,4) & pulled_arc.e(4,1) & cycle;  % bowl
save slab; % lower.slab
% barh_i_part(2);
_zero:=2;
_one:=5; _two:=6;
%
pickup tiny.nib;
pos[_one](stem,0); pos[_two](stem,0);
lft x[_one]l=lft x[_two]l=
    l+letter_fit+if not monospace: serif_fit+ fi hround (2.5u-.5stem-eps);
top y[_one]=h; bot y[_two]=0;
filldraw stroke z[_one]e--z[_two]e; % stem
bar_stroke(x[_one],x[_zero]); % bar
if serifs:
   slab:=Vround(vair-vair_corr); % lower.slab
   dish_serif([_one],[_two],s,1/3,jut,t,1/3,jut); % upper serif
   slab:=vair; % lower.slab
   dish_serif([_two],[_one],u,1/3,jut,v,1/3,jut); % lower serif
fi
%%%%%
penlabels(1,2,3,4,5,6,7,8); endchar;

iff not concrete:%
iff not specific:%
lhchar "Lowercase Russian letter ya (looks like backward R) (`roman')";
cyrchar(ya,if serifs: 9.75u# else: 10u#-.5width_adj# fi,x_height#,0); % n_width if serifs:-.25u
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(if serifs:serif_fit# else:0 fi,serif_fit#);
% lowerr_ya;
pickup tiny.nib; pos1(stem',0); pos2(stem',0);
rt x1r=rt x2r=hround(w-2.5u+.5stem'); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
penpos3(vair,90); penpos4(vair,90); penpos5(curve if hefty:-3stem_corr fi,180);
y6r=y7r=hround (if serifs:.52h else:.5h fi-.6[thin_join,vair]/2);
y6l=y7l=y6r+.6[thin_join,vair]; y6=y7=.5[y6l,y6r];%
z3r=top z1; y4=y3; y5=.52[y4r,y6r]+eps;
x7l=x7r=x2; x4+.25u=x6l=x6r; x4=.5w if serifs:+.25u else:-.25u fi;
x5r=hround min(1.25u,2u-.5curve);
x4l:=x4+.125curve; x6l:=x6l+.125curve;
{{interim superness:=2/3[superness,max(superness,sqrt.77superness)];%|2/3[super,more_super]|
   fill stroke z7e..pulled_arc.e(6,5) & pulled_arc.e(5,4)..z3e}};  % lobe
numeric stem[],alpha,right_jut;
right_jut=if serifs:.6jut else:.4tiny fi;
stem1=max(tiny.breadth,hround(fudged.stem-3stem_corr));
lft x9l=hround(l+letter_fit+.3u+right_jut)-eps; bot y9=0;
alpha=diag_ratio(1,.5(stem1-tiny),y1-y9,x9l-x1);
penpos9(alpha*(stem1-tiny),0);
x8=x6l-if serifs:.75u else:.25u fi; y8=y6;
forsuffixes $=l,r: y9'$=0; endfor
z9'r=z9r+penoffset z1-z9 of currentpen+whatever*(z1-z9);
z9'l=z9l+penoffset z9-z1 of currentpen+whatever*(z1-z9);
z8=z9'+whatever*(z1-z9);
penpos8(if serifs: x9'r-x9'l else: stem fi-2stem_corr,0);
fill z8l--diag_end(8l,9'l,1,.5,9'r,8r)--z8r--cycle;  % diagonal
if serifs:
 numeric inner_jut;
 if lft x2l-jut-.5u+1>=rt x9r+jut: inner_jut=jut;
  else: lft x2l-jut-.5u+1=rt x9r+inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,.5jut,b,1/3,jut); % upper serif
 slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,jut); % lower serif
 dish_serif(9,8,g,1/2,right_jut,h,1/3,inner_jut)(dark); fi % lower diagonal serif
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9); endchar;

iff not kapitel:%
lhchar "Lowercase Russian letter yo (looks like e umlaut)";
cyrchar(yo,7.25u#+max(.75u#,.5curve#),lc_trema_height#,0);
italcorr .5[bar_height#,x_height#]*slant+.5min(curve#-1.5u#,0);
adjust_fit(if monospace:.25u#,.5u# else:0,0 fi); full_h:=h; h:=x_height;
% lower_e;
numeric left_curve,right_curve;
left_curve=right_curve+6stem_corr=curve if not serifs: -3stem_corr fi;
if right_curve<tiny.breadth: right_curve:=tiny.breadth; fi
if left_curve<tiny.breadth: left_curve:=tiny.breadth; fi
pickup tiny.nib; pos1(right_curve,0);
pos2(vair,90); pos3(left_curve,180);
y1=good.y bar_height; top y2r=h+vround 1.5oo; y0l=bot y1;
rt x1r=hround min(w-.5u,w-u+.5right_curve);
lft x3r=hround max(.5u,1.25u-.5left_curve); x2=.5w+.25u;
{{interim superness:=more_super;
 filldraw stroke super_arc.e(1,2)}};  % right bowl
y3=.5[y2,y4]; bot y4r=-oo; x4=x2+.25u;
if serifs:
 pos4(vair',270); pos5(hair,360);
 y5=max(good.y(.5bar_height-.9),y4l+vair); x5r=x1r;
 (x,y4l)=whatever[z4r,z5]; x4l:=min(x,x4l+.5u);
 filldraw stroke pulled_arc.e(2,3) & pulled_arc.e(3,4)
  ...{x5-x4,5(y5-y4)}z5e; % left bowl, arc, and terminal
else:
 pos4(vair,270);
 filldraw stroke super_arc.e(2,3) & super_arc.e(3,4);  % left bowl and arc
 pickup fine.nib; pos4'(vair,270); z4=z4';
 pos5(.5[vair,flare],275); rt x5r=hround(w-.6u);
 y5r=good.y(y5r+1/3bar_height-y5); y5l:=good.y y5l; x5l:=good.x x5l;
 filldraw stroke term.e(4',5,right,1,4); fi  % terminal
path testpath; testpath=super_arc.r(2,3) & super_arc.r(3,4);
y1'r=y0r=y0l+.6[thin_join,vair]; y1'l=y0l; x1'l=x1'r=x1;
forsuffixes $=l,r:
 x0$=xpart(((0,y0$)--(x1,y0$)) intersectionpoint testpath); endfor
fill stroke z0e--z1'e;  % crossbar
%%%%%
% the accent
h:=full_h; lowercase_umlaut(0,0, 6,7,8,9);
penlabels(0,1,2,3,4,5, 6,7,8,9); endchar;

endinput;
% end of file
