%
% lgt2lol.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:
%
% Lowercase Cyrillic letters 0--127 for T2 encoding
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% List of letternames and their codes in T2
%
%                X2      T2A  T2B  T2C
%
% ae            "61  a   "ac   -    -    Ligature AE
% abh_ch        "64  d    -    -   "b1   Abkhasian che (same as lower e with hook)
% abh_ch_dsc    "65  e    -    -   "b2   Abkhasian che descender
% k_vcrs        "66  f   "ab   -    -    Ka vertically crossed
% k_hcrs        "67  g    -    -   "ab   Ka horisontally crossed
% l_dsc         "68  h    -   "aa  "aa   El with descender
% m_dsc         "6c  l    -    -   "a8   Em with descender
% abh_ha        "6e  n    -    -   "b7   Abkhasian kha
% p_tl          "6f  o    -    -   "a0   Pe with tail
%
% r_dsc         "70  p    -    -   "a5   Er with descender
% lat_q         "71  q    -    -    -    Latin letter Q
% t_dsc         "72  r    -    -   "a2   Te with descender
% tetse         "74  t    -    -   "a1   Ligature Te-Tse
% ch_vcrs       "76  v   "b7   -    -    Che vertically crossed
% lat_w         "77  w    -    -    -    Latin letter W
%
% n_ltl         "1d       -    -   "b9   En with left tail
% delta         "1f       -   "a6   -    Delta
% m_tl           -        -    -   "ae   Em with tail
% r_gcrs         -        -    -   "a6   Er grave crossed
% s_acrs         -        -    -   "b1   Es acute crossed
% g_crsdsc       -        -   "a0   -    Ghe crossed with descender
% h_hcrs         -        -   "b4   -    Kha horisontally crossed
%
% semisn          -        -    -   "b3   Semi Soft Sign
% i_shdsc        -        -    -   "b4   I Short with descender
% r_tl           -        -    -   "bb   Er with tail
%

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

lhchar "Lowercase Cyrillic letter ae - ligature ae";
cyrchar(ae,13u#,x_height#,0);
italcorr .5[bar_height#,x_height#]*slant+.5min(curve#-1.5u#,0);
adjust_fit(0,0); numeric left_curve,right_curve;
if monospace: right_curve=left_curve=fudged.stem;
else: left_curve=max(tiny.breadth,hround(curve-2stem_corr));
right_curve=
   max(tiny.breadth,hround(curve-if serifs: 6 else: 8 fi\\stem_corr));fi
pickup tiny.nib; pos11(right_curve,0);
pos12(vair,90); pos13(mfudged.stem,180);
y11=good.y bar_height; top y12r=h+vround 1.5oo; y10l=bot y11;
rt x11r=hround min(w-.5u,w-u+.5right_curve);
lft x13r=hround (.5w-.5mfudged.stem); x12=.55[x13,x11];
{{interim superness:=more_super;
 filldraw stroke super_arc.e(11,12)}};  % right bowl of e
y13=.5[y12,y14]; bot y14r=-oo; x14=x12+.25u;
if serifs:
 pos14(vair',270); pos15(mfudged.hair,360);
 y15=max(good.y(.5bar_height-.9),y14l+vair); x15r=x11r;
 (x,y14l)=whatever[z14r,z15]; x14l:=min(x,x14l+.5u);
 filldraw stroke pulled_arc.e(12,13)
  & pulled_super_arc.e(13,14)(.8superpull)
  ...{x15-x14,5(y15-y14)}z15e; % left bowl, arc, and terminal of e
else:
 pos14(vair,270);
 filldraw stroke super_arc.e(12,13)
  & super_arc.e(13,14);  % left bowl and arc of e
 pickup fine.nib; pos14'(vair,270); z14=z14';
 pos15(.5[vair,flare],275); rt x15r=hround(w-.6u);
 y15r=good.y(y15r+1/3bar_height-y15); y15l:=good.y
 y15l; x15l:=good.x x15l;
 filldraw stroke term.e(14',15,right,1,4); fi  % right terminal
y11'r=y10r=y10l+.6[thin_join,vair]; y11'l=y10l;
x11'l=x11'r=x11; x10l=x10r=x13;
fill stroke z10e--z11'e;  % crossbar
pickup fine.nib; top y3r=h+vround 1.5oo;
if serifs:
 pos1(flare,180); pos2(mfudged.hair,180);
 pos3(vair,90);  lft x1r=hround max(u,2.1u-.5flare); x3=4u;
 y1=min(bar_height+.5flare+2vair+2,.9[bar_height,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=4.3u; top y1r=vround .82[bar_height,top y3r];
 filldraw stroke term.e(3,1,left,.9,4); fi  % left terminal
pos4(mfudged.stem,0); x4=x13; y4=1/3[bar_height,h];
pos5(mfudged.stem,0); x5=x4; y5=min(y4,y13);
filldraw stroke super_arc.e(3,4)&z4e--z5e;  % arc and stem
pos6(.6[thin_join,vair],90); x6=x4; bot y6=y10l;
pos7(left_curve,180); lft x7r=hround max(.5u,1.5u-.5left_curve);
y7=1/3[top y8l,top y6r];
pos8(vair,270); x8l=3.75u; bot y8r=-oo;
pos9(.5[vair,fudged.stem],360); x9=x5; y9=.55bar_height;
(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 y9<y5:
 filldraw stroke z5e{down}..{down}z9e; fi  % link (usually hidden)
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
endchar;

lhchar "Lowercase Cyrillic letter abh_ch - lower e hook";
cyrchar(abh_ch,7.25u#+max(.75u#,.5curve#),x_height#,0);
italcorr .5[bar_height#,x_height#]*slant+.5min(curve#-1.5u#,0);
adjust_fit(1.25dot_size# if monospace:+\\.25u#,.5u#+ else:,fi\\ 0);
% 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
%%%%%
% bulb
if serifs: pickup crisp.nib; fi
pos6(max(currentbreadth+eps,.6[thin_join,vair]),-90);
x6=x3; bot y6r=y0l;
lft x7r=min(l+letter_fit+hround(.5u-.5),lft x0l-flare-1); y7=.5[y1,y2];
if serifs:
 pos7(hair,-180); pos8(hround 7/8[hair,flare],-180); z8r=z7r;
 {{less_tense; cyrbulb(6,7,8)}};
else:
 pos7(vair,-150);
 filldraw stroke z6e{left}...{dir60}z7e; fi
%%%
penlabels(0,1,2,3,4,5,6,7); endchar;

lhchar "Lowercase Cyrillic letter abh_ch_dsc - lower e hook ogonek";
cyrchar(abh_ch_dsc,7.25u#+max(.75u#,.5curve#),x_height#,desc_depth#);
italcorr .5[bar_height#,x_height#]*slant+.5min(curve#-1.5u#,0);
adjust_fit(1.25dot_size# if monospace:+\\.25u#,.5u#+ else:,fi\\ 0);
% 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
%%%
% bulb
if serifs: pickup crisp.nib; fi
pos6(max(currentbreadth+eps,.6[thin_join,vair]),-90);
x6=x3; bot y6r=y0l;
lft x7r=min(l+letter_fit+hround(.5u-.5),lft x0l-flare-1); y7=.5[y1,y2];
if serifs:
 pos7(hair,-180); pos8(hround 7/8[hair,flare],-180); z8r=z7r;
 {{less_tense; cyrbulb(6,7,8)}};
else:
 pos7(vair,-150);
 filldraw stroke z6e{left}...{dir60}z7e; fi
%%%%%
% descender-ogonek
 path p.r;
 p.r=if serifs: pulled_arc.r(3,4)...{x5-x4,5(y5-y4)}z5r
  else: term.r(4',5,right,1,4) fi;
 def the_pen=
  if known ogonek_pen: ogonek_pen elseif serifs: tiny else: fine fi
 enddef;
 numeric tt; % the time...
 tt=if serifs: if hefty: 2.6 else: 2.5 fi else: % sansserif
    if is_bold: .6 else: .8 fi\\ fi;
 join_angle=angle((direction tt of p.r) rotated 180);
 ogonek_pos=(point tt of p.r)+.5(the_pen-if serifs: tiny else: fine fi)*
    unitvector((direction tt of p.r) rotated 90)-(ogonek_breadth-the_pen,0);
easy_ogonek(the_pen,9,10,11); % ogonek
%%%
penlabels(0,1,2,3,4,5,6,7,8, 9,10,11); endchar;

iff not concrete:%
iff not specific:%
lhchar "Lowercase Cyrillic letter k_vcrs - ka vcrossed (`roman')";
cyrchar(k_vcrs,11.5u# if not serifs:+.5width_adj# fi,
        % n_width+if serifs:1.5u else:+2u+.5tiny fi
 x_height#,0);
italcorr x_height#*slant-.2u#;
adjust_fit(serif_fit#,serif_fit#);
 numeric stem[]; stem1=max(tiny.breadth,hround(fudged.stem-stem_corr));
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:
 pickup tiny.nib;
 save slab; 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
% kv_rbowl;
  pos10(stem1,0); x10=hround(w-7u); y10=y1;
  numeric right_jut,stem[],alpha[];
  right_jut=if serifs:.6jut else:.4tiny fi; pickup tiny.nib;
%
  stem1=max(tiny.breadth,hround(fudged.hair if hefty:-\\4stem_corr fi));
  stem2=max(tiny.breadth,fudged.stem-3stem_corr);
  x3r=(hround(r-letter_fit-.7u-right_jut)-.5tiny+eps);
  x6r=(hround(r-letter_fit-.3u-right_jut)-.5tiny+eps);
  y4=.7bar_height; top y3=h; bot y6=0; x4=x10;
  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),y10-y6,x6r-x10);
  forsuffixes $=l,r: y3'$=h; y6'$=0; z4$=z3'$+whatever*(z3-z4);
   z5$=z6'$+whatever*(z10-z6)=z3'$+whatever*(z4-z3); 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 z5r--diag_end(5r,3'r,1,.5,3'l,5l)--z5l--cycle;  % upper diagonal
  fill z5l--diag_end(5l,6'l,.5,1,6'r,5r)--z5r--cycle;  % lower diagonal
  if (2(y5l-y5r)>(.6[thin_join, vair]-eps)) or (y5l<y5r):
   y7r=vround (y5l+.5(.6[thin_join, vair])-eps);
   else:y7r=vround (y5r+.5(.6[thin_join, vair])-eps); fi
  y7r=y8r; y7r-y7l=y8r-y8l=(.6[thin_join, vair]); x7l=x7r=x1; x8l=x8r=x5r;
  fill stroke z7e--z8e; % middle cross
%%%
if serifs:
 numeric inner_jut,up_inner_jut;
 if rt x2r+.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
% vcross
pickup if serifs: crisp.nib else: fine.nib fi;
numeric middle_weight;
middle_weight=max(currentbreadth+eps,.6[thin_join,vair]);
pos9(middle_weight,0); pos11(middle_weight,0);
lft x9l=lft x11l=
    hround max(tiny.rt x1r+1,max(x5l-middle_weight,.5[tiny.rt x1r,x5l]));
top y11-bot y9=.5x_height; .52[y9,y11]=.5[y7l,y7r];
filldraw stroke z9e--z11e; % cross bar
penlabels(1,2,3,4,5,6,7,8,9,10,11); endchar;

iff not concrete:%
iff not specific:%
lhchar "Lowercase Cyrillic letter k_hcrs - ka hcrossed (`roman')";
cyrchar(k_hcrs,10u#,asc_height#,0); % n_width
italcorr x_height#*slant-.2u#;
adjust_fit(serif_fit#,serif_fit#); full_h:=h; h:=x_height;
% lower_hk;
% long k_stem;
numeric stem[]; stem1=max(tiny.breadth,hround(fudged.stem-stem_corr));
stem2=max(tiny.breadth,hround(fudged.stem-2stem_corr));
pickup tiny.nib; pos1(stem1,0); pos2(stem2,0);
lft x1l=lft x2l=hround (2.5u-.5stem1); top y1=h; bot y2=0;
x11'=x1; top y11'=asc_height; pos11'(stem1,0);
filldraw stroke z11'e--z2e; % stem
pos0(stem1,0); pos0'(stem2,0); y0=y0'; x0=x11'; x0'=x2;
rt z0r=whatever[((w-.7u-jut-hair),x_height),(x1,.7bar_height)];
filldraw stroke z11'e..z0e--z0'e..z2e; % stem
if serifs:
 sloped_serif.l(11',0,a,1/3,jut,serif_drop); % upper stem serif
 save slab; 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
%%%
%%%%%
% hcross
h:=full_h;
pickup crisp.nib;
pos7(bar,90); pos8(bar,90);
top y7r=top y8r=vround (min(.5[x_height,h]+.5bar,h-max(bracket,1.2slab))-eps);
rt x8=x1r+if serifs: max(limit_dist,1.1jut) else: 1.7u fi;
lft x7=hround 1/3u-serif_fit;
filldraw stroke z7e--z8e; % cross bar
penlabels(1,2,3,4,5,6, 7,8); endchar;

iff not concrete:%
lhchar "Lowercase Cyrillic letter l_dsc - el descender";
cyrchar(l_dsc,10u# % if not serifs:+.5width_adj# fi % dl_width;n_width
 ,x_height#,if is_ogonek: desc_depth# else: sbeak# fi); %ldesc/og_depth
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
begingroup
% 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
%%%
save slab; % lower.slab
if serifs:
 x0=x3; y0=0;
 numeric inner_jut; inner_jut=min(.5(lft x1l-rt x3r)-eps,.5jut);
 if is_ogonek:
    slab:=vair; % lower.slab
    dish_serif(2,1,a,1/3,jut,b,1/3,jut);    %!!! % lower right serif
 fi
 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); % upper left serif
 filldraw z.c0--z.c1--z.f1--z.f0--cycle; fi % upper inter_serif bar
%%%%%
% lowercase descender/saam tail
slab:=vair; % lower.slab
numeric right_jut;
right_jut=if serifs: max(limit_dist,1.1jut) else: hround (r-rt x2r-.5u) fi;
if unic:
   %saam tail
    serif(2,1,v,1/3,-jut);
    siam_serif(2,1,w,1/3,right_jut);
else:
   r_serif(2,1,o,1/3,jut,p,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
fi
endgroup;
penlabels(1,2,3,4,5,6, 7,8,9);endchar;

lhchar "Lowercase Cyrillic letter m_dsc - m descender";
cyrchar(m_dsc,12u# if not serifs:+width_adj# fi,x_height#,
 if is_ogonek: desc_depth# else: sbeak# fi); %ldesc/og_depth
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
begingroup
% 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
%%%
save slab; % lower.slab
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
 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
 if is_ogonek:
    dish_serif(4,3,e,1/3,jut,f,1/3,jut); %!!! % lower right serif
 fi
fi
%%%%%
% lowercase descender/saam tail
slab:=vair; % lower.slab
numeric right_jut;
right_jut=if serifs: max(limit_dist,1.1jut) else: hround (r-rt x4r-.5u) fi;
if unic:
   %saam tail
    serif(4,3,v,1/3,-jut);
    siam_serif(4,3,w,1/3,right_jut);
else:
   r_serif(4,3,o,1/3,jut,p,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
fi
endgroup;
penlabels(0,1,1',2,3,3',4,5,6,7,8, 9,10,11); endchar;

lhchar "Lowercase Cyrillic letter abh_ha - Abkhazian ha";
cyrchar(abh_ha,9u#,x_height#,desc_depth#); %o
italcorr .7x_height#*slant;
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi); pickup fine.nib;
numeric right_curve,mid_curve;
right_curve=.7[.7[thin_join,vair],curve] if hefty:-stem_corr fi;
mid_curve=.5[.7[thin_join,vair],curve] if hefty:-2stem_corr fi;
penpos1(vair,90); penpos3(vair',-90);
penpos2(curve,180); penpos4(right_curve,0);
interim superness:=hein_super;
x2r=hround max(.5u,1.25u-.5curve); %o
x4r=w-x2r; x1=x3=x6=.5w; y1r=h+vround 1.5oo; y3r=-oo;
y2=y4=.5h-vair_corr; y2l:=.52h;
y7=vround -1/3d-eps; rt x7=hround(w-.5u)+eps; penpos7(.7[thin_join,vair],270);
penpos6(mid_curve,180);
x5=if serifs:.5[x6,x4]else:.5[x6,x4]fi;
y5r=vround max(.5[y4,y1],y4+.7[thin_join,vair])+eps; 
penpos5(.7[thin_join,vair],90);
y6=vround min(.5y5r,y5l-.5)-eps;
fill stroke pulled_super_arc.e(1,2)(.5superpull)
 & pulled_super_arc.e(2,3)(.5superpull)
 & pulled_super_arc.e(3,4)(.5superpull) % 3/4 bowl
 & pulled_super_arc.e(4,5)(.25superpull)
 & pulled_super_arc.e(5,6)(.75superpull)
 & pulled_super_arc.e(6,7)(.5superpull); %6/4 bowl
fill z7l--z7r{right}..{up}
 if fine.top y7r>fine.bot y7l: (fine.rt x7,y7)
  else: (fine.rt x7,fine.top y7r)--(fine.rt x7,fine.bot y7l) fi
 {up}..{left} cycle;
z1'=z1; z4'=z4; pos1'(vair,90); pos4'(.75[.7[thin_join,vair],curve],0);
forsuffixes e=l,r: path p.e;
p.e=pulled_super_arc.e(1',4')(.5superpull); endfor
filldraw stroke subpath (0,.67) of p.e; %quart
penlabels(1,2,3,4,5,6,7); endchar;

lhchar "Lowercase Cyrillic letter p_tl - pe tail";
cyrchar(p_tl,10u# if not serifs:+.5width_adj# fi, % n_width
 x_height#,desc_depth#); % n_width
italcorr (.7x_height#-bar_height#)*slant; %o.7h-bar_height
adjust_fit(if monospace:-.15u# else:serif_fit# fi,
 if serifs:if monospace: 2.6u# else: 4u# fi else: 3u#+.5curve# fi); %tail_adj
% 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_jut1=jut; % stay for tail serif
  else: rt x1r+inner_jut1+.5u+1=lft x3l-inner_jut1; fi
 save slab; slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut1);    % lower left serif
 %dish_serif(4,3,g,1/3,inner_jut1,h,1/3,jut);   %!!!  % lower right serif
 inner_jut2=min(.5(lft x3l-rt x1r)-eps,.5jut);
 slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,jut,b,1/3,inner_jut2);  % upper left serif
 nodish_serif(3,4,e,1/3,inner_jut2,f,1/3,jut);  % upper right serif
 filldraw z.b0--z.b1--z.e1--z.e0--cycle; % upper inter_serif bar
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
%%%%%
w:=w+if (not serifs) or monospace: 3u+.5curve else: 4u fi;
% tail_part(4);
_zero:=4;
_one:=5; _two:=6; _three:=7; _four:=8; _five:=9;
_six:=10; _seven:=11; _eight:=12; _nine:=13;
%
pickup tiny.nib;
numeric bulb_diam;
bulb_diam=max(currentbreadth+eps,min(.82d-1-eps,hround 7/8[hair,flare]));
set_bar_axis; y[_one]r=y[_two]r=y2.bh; y[_one]l=y[_two]l=y1.bh;
penpos[_three](max(currentbreadth+eps,curve if hefty:-3stem_corr fi),0);
y[_three]=.5[y[_one]r,-d];
x[_two]l=x[_two]r=w-4.75u; x[_one]l=x[_one]r=x[_zero];
x[_three]r=hround(w-u); x[_two]l:=x[_four]l:=x[_two]r-.25curve;
{{interim superness:=more_super;
 fill stroke super_arc.e([_three],[_two])..z[_one]e}};  % lobe
if serifs:
 z[_five]=z[_three]; pos[_five](curve if hefty:-3stem_corr fi,0);
 pos[_six](vair,-90); bot y[_six]r=-d-oo; y[_seven]-.5flare=-.85d;
 pos[_seven](hair,-180); pos[_eight](bulb_diam,-180);
 rt x[_eight]l=max(lft x[_zero]l-jut+bulb_diam,
  floor x[_three]-3.5u if monospace: / expansion_factor fi);
 z[_seven]r=z[_eight]r;
 x[_six]=max(rt x[_eight]l,.6[x[_five],x[_seven]r]);
 (x,y[_six]r)=whatever[z[_six]l,z[_five]l];
 x[_six]r:=max(x,.5[x[_seven]r,x[_six]]);
 filldraw stroke super_arc.e([_five],[_six]);
 bulb([_six],[_seven],[_eight]); % bulb
else:
 pickup fine.nib; z[_five]=z[_three];
 pos[_five](max(fine.breadth,curve if hefty:-3stem_corr fi),0);
 pos[_nine](vair',-90); pos[_six](.6[vair',flare],-105);
 rt x[_six]r=x[_three]-4.5u; bot y[_six]r=-d;
 bot y[_nine]r=-d-oo; x[_nine]=.35[x[_six]r,x[_three]r];
 filldraw stroke super_arc.e([_five],[_nine])
  & term.e([_nine],[_six],left,.75,4); fi
%%%
if serifs:
 if rt x2r+jut+.5u+1<=x[_three]r: inner_jut3=jut;
  else: rt x2r+inner_jut3+.5u=x[_three]r; fi
 slab:=vair; % lower.slab
 dish_serif(4,3,g,1/3,inner_jut1,h,1/3,inner_jut3); fi % lower right serif
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13); endchar;

lhchar "Lowercase Cyrillic letter r_dsc (looks like p)";
cyrchar(r_dsc,10u#+serif_fit#,x_height#,
        max(1.6desc_depth#,paren_depth#));%r_ddepth
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
adjust_fit(serif_fit#,0); full_d:=d;
d:=vround min(desc_depth,max(vair+slab+oo+1+eps,full_d-max(.4desc_depth,.55beak)-slab));%r_dscs
% 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
 if is_ogonek:
    dish_serif(2,0,b,1/3,jut,c,1/3,jut); fi  %!!! % lower serif
fi
%%%%%
% r_descender/ogonek
if is_ogonek:
   d:=d+desc_depth;
   def the_pen=
       if known ogonek_pen: ogonek_pen elseif serifs: tiny else: fine fi
   enddef;
   % |stem| was drawn by |tiny| pen, hence |tiny| in the following equation:
   ogonek_pos=(x2 if not serifs: l fi,tiny.bot y2+.5the_pen)
       if serifs and not is_egyptian: +(.5xvair,0) fi;
   ogonek_move=bot y2;
   easy_ogonek(the_pen,9,10,11); % ogonek
   chardp:=d/hppp;
else:
   d:=full_d;
   numeric right_jut;
   right_jut=if serifs: 1.414jut else: .5stem+.5u fi;
   r_serif(2,0,o,1/3,jut,p,1/3,beak_darkness,right_jut,.5beak_jut); % lower left serif
fi
penlabels(0,1,2,3,4,5,6,7,8, 9,10,11); endchar;

lhchar "Lowercase Cyrillic letter lat_q";
cyrchar(lat_q,10u#+serif_fit#,x_height#,desc_depth#);
italcorr x_height#*slant-serif_fit#+.5stem#-2u# if serifs:+.5u# fi;
adjust_fit(0,serif_fit# if serifs: -.5u# fi);
pickup tiny.nib; pos1(stem',0); pos2(stem,0);
pos0'(stem',0); pos0(stem,0); z0r=z0'r; x0'=x1; x0=x2;
rt x1r=hround(w-2.5u+.5stem');
numeric edge; edge=lft x2l;
pickup fine.nib; pos3(if hefty:thin_join else: hair fi,0);
pos4(vair',90); pos5(curve,180); pos6(vair,270); penpos7(x3r-x3l,360);
lft x3l=min(lft x3l-(rt x3r-tiny.rt x2r),2/3[lft x2,edge]); y3=bar_height;
x4l=.5(w-serif_fit)-.3u; top y4r=x_height+oo;
lft x5r=hround max(1.35u-.5curve,.6u); y5=.5x_height;
x6l=x4l-.2u; bot y6r=-oo; y7=min(y3,y6+y4-y3+.6vair);
lft x7l=min(lft x7l-(rt x7r-tiny.rt x2r),1/3[lft x2,edge]);
(x,y4r)=whatever[z3l,z4l]; x4r:=max(x,.5[x5r,x4]);
(x',y6r)=whatever[z7l,z6l]; x6r:=max(x',.5[x5r,x6]);
filldraw stroke z3e{up}...{left}z4e&super_arc.e(4,5)
 &super_arc.e(5,6)&z6e{right}...{up}z7e;  % bowl
y1=ypart(((edge,h)--(edge,0))intersectionpoint(z3l{up}...{left}z4l));
y0=ypart(((edge,h)--(edge,0))intersectionpoint(z6l{right}...{up}z7l));
pickup tiny.nib; bot y2=-d;
filldraw stroke z1e--z0'e--z0e--z2e;  % stem
pickup crisp.nib;
pos8(hround(hair-stem_corr),0); pos7'(stem',0);
z7'=z1; x8r=x7'r; top y8=h+oo;
filldraw stroke z7'e--z8e;  % point
if serifs:
 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 Cyrillic letter t_dsc - te descender";
cyrchar(t_dsc,9u#-width_adj#,x_height#,
 if is_ogonek: desc_depth# else: sbeak# fi); %ldesc/og_depth
italcorr x_height#*slant-beak_jut#+.35u#; %Gamma->x_height+.65u#
adjust_fit(0,0);
begingroup
% 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
%%%
save slab; % lower.slab
if serifs:
 if is_ogonek: slab:=vair; % lower.slab
    dish_serif(2,1,c,1/3,1.414jut,d,1/3,1.414jut); %!!! % lower serif
 fi
 slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,.5jut,b,1/3,.5jut); fi  % upper bracketing
%%%%%
% lowercase descender/ogonek
if is_ogonek:
   endgroup;
   def the_pen=
       if known ogonek_pen: ogonek_pen elseif serifs: tiny else: fine fi
   enddef;
   % |stem| was drawn by |tiny| pen, hence |tiny| in the following equation:
   ogonek_pos=(x2 if not serifs: l fi,.5the_pen)
       if serifs and not is_egyptian: +(.5xvair,0) fi;
   easy_ogonek(the_pen,6,7,8); % ogonek
else:
   slab:=vair; % lower.slab
   numeric right_jut;
   right_jut=if serifs: 1.414jut else: .5stem+.5u fi;
   r_serif(2,1,g,1/3,1.414jut,h,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
   endgroup;
fi
penlabels(1,2,3,4,5, 6,7,8); endchar;

lhchar "Lowercase Cyrillic letter tetse - ligature tetse";
cyrchar(tetse,10.5u# if not serifs:+.5width_adj# fi, % n_width+.5
 x_height#,sbeak#);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(1.8u#-.5width_adj#,
 serif_fit# if not serifs:+.5(stem#-u#) fi) %dl_adj
% lower_c;tetse
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
pos3(fudged.stem,0); pos4(fudged.stem,0);
lft x1l=lft x2l=hround (2u-.5fudged.stem-eps) if monospace:-.35u fi;
rt x3r=rt x4r=w-hround (2.5u-.5fudged.stem-eps); %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:=min(.5(lft x3l-rt x1r)-eps,.5jut);
 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 % lower_bar
% lowercase descender
slab:=vair; % lower.slab
inner_jut:=min(.5(lft x3l-rt x1r)-eps,.5jut);
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 right descender
if serifs:
 filldraw z.d0--z.d1--z.g1--z.g0--cycle; fi % lower inter_serif bar
% T part
pickup crisp.nib; pos5(vair,90); pos6(hair,180); pos7(hair,0);
x5=x1; x5-x6=x7-x5;
lft x6r=l+letter_fit+hround if monospace:.1u else:.45u fi;
top y5r=h; y6=good.y(y5l-beak/1.4)-eps; y7=y6;
arm(5,6,q,beak_darkness,-.35beak_jut); arm(5,7,r,beak_darkness,.35beak_jut);
penlabels(1,2,3,4,5,6,7); endchar;

lhchar "Lowercase Cyrillic letter ch_vcrs - che vcrossed";
cyrchar(ch_vcrs,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
%%%%%
% vcross
pickup if serifs: crisp.nib else: fine.nib fi;
numeric middle_weight;
middle_weight=max(currentbreadth+eps,.6[thin_join,vair]);
pos7(middle_weight,0); pos8(middle_weight,0);
lft x7l=lft x8l=hround (.5[x1,x3]-.5middle_weight);
top y8-bot y7=.5x_height; .5[y7,y8]=y6;
filldraw stroke z7e--z8e; % cross bar
penlabels(1,2,3,4,5,6,7,8); endchar;

lhchar "Lowercase Cyrillic letter lat_w";
cyrchar(lat_w,13u#,x_height#,0);
italcorr x_height#*slant+.25u#;
adjust_fit(serif_fit#,serif_fit#);
numeric stem[],outer_jut,upper_notch,alpha,mid_corr;
outer_jut=.7jut; x1l=w-x8r=l+letter_fit+outer_jut+.25u;
stem1=fudged.stem-stem_corr;
stem4=min(fudged.hair if hefty:-2stem_corr fi,stem1);
stem2=if hefty:.1[vair,stem4] else: stem4 fi;
stem3=max(stem2,stem1-3stem_corr);
x2-x1=x4-x3=x6-x5=x8-x7; x2l+apex_corr=x3l; x6l+apex_corr=x7l;
y1=y8=h; y2=y3=y6=y7=-apex_oo;
y4=y5=if monospace: vround .6 fi\\ h; upper_notch=y4-notch_cut;
mid_corr=if monospace or hefty:-.3apex_corr else: .5jut fi;
alpha=diag_ratio(4,stem2-stem3+stem4,y1-y2,x8r-x1l+mid_corr-2apex_corr);
penpos1(alpha*stem1,0); penpos2(alpha*stem1,0);
penpos3(alpha*stem2,0); penpos4(alpha*stem2,0);
penpos5(alpha*stem3,0); penpos6(alpha*stem3,0);
penpos7(alpha*stem4,0); penpos8(alpha*stem4,0);
x4l-x1l=floor(x4l-x1l+.5(x5r+mid_corr-x4r)); % |x5r| $\approx$ |x4r+mid_corr|
z23=whatever[z1r,z2r]=whatever[z3l,z4l];
z45=whatever[z3r,z4r]=whatever[z5l,z6l];
z67=whatever[z5r,z6r]=whatever[z7l,z8l];
fill diag_end(1l,2l,1,1,3r,4r){z4-z3}
 ...if y45<upper_notch:(x45,upper_notch)+.5left{up}
   --(x45,upper_notch)+.5right{down} else: z45&z45 fi
 ...{z6-z5}diag_end(5l,6l,1,1,7r,8r)--diag_end(7r,8r,1,1,8l,7l){z7-z8}
 ...if y67>notch_cut:(x67,notch_cut)+.5right{down}
   --(x67,notch_cut)+.5left{up} else: z67&z67 fi
 ...{z5-z6}special_diag_end(6,5,4,3){z3-z4}
 ...if y23>notch_cut:(x23,notch_cut)+.5right{down}
   --(x23,notch_cut)+.5left{up} else: z23&z23 fi
 ...{z1-z2}diag_end(2r,1r,1,1,1l,2l)--cycle;  % diagonals
if serifs:
 numeric inner_jut[]; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(5,6); prime_points_inside(8,7);
 if monospace: inner_jut1=inner_jut4=1.5jut;
 elseif hefty: inner_jut1=inner_jut4=jut;
 else: fill diag_end(6r,5r,1,1,5l,6l)--.9[z5l,z6l]
   ..{z5-z6}.1[z5r,z6r]--cycle; % middle stem
  inner_jut2=.7inner_jut1; inner_jut4=1.1inner_jut3;
  if rt x1'r+jut+.5u+1<=lft x5'l-.7jut: inner_jut1=jut;
  else: rt x1'r+inner_jut1+.5u+1=lft x5'l-inner_jut2; fi
  if rt x5'r+jut+.5u+1<=lft x8'l-1.1jut: inner_jut3=jut;
  else: rt x5'r+inner_jut3+.5u+1=lft x8'l-inner_jut4; fi
% cyrillic lowercase thickness
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(5',6,e,1/3,inner_jut2,f,1/2,inner_jut3); fi % upper middle serif
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut1);     % upper left serif
 dish_serif(8',7,c,.6,inner_jut4,d,1/2,outer_jut)(dark); fi % upper right serif
penlabels(0,1,2,3,4,5,6,7,8,23,45,67); endchar;

lhchar "Lowercase Cyrillic letter n_ltl - en with left tail";
cyrchar(n_ltl,10u# if not serifs:+.5width_adj# fi,x_height#,desc_depth#); % n_width
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
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
%%%%%
% l_tail(2)x;
_zero:=2;
_one:=7; _two:=8; _three:=9; _four:=10; _five:=11;
%
pickup fine.nib;
pos[_five](tiny.rt x[_zero]r-tiny.lft x[_zero]l,0);
pos[_one](tiny.rt x[_zero]r-tiny.lft x[_zero]l,0);
z[_five]=z[_zero]; x[_one]r=x[_five]r;
bot y[_one]=max(-1/3d,-d+vair'+eps);
if serifs:
 numeric bulb_diam;
 bulb_diam=max(currentbreadth+eps,min(.82d-1-eps,hround 7/8[hair,flare]));
 pos[_two](vair',-90); pos[_three](hair,-180);
 pos[_four](bulb_diam,-180);
 x[_two]=.5[x[_one],x[_three]r];
 bot y[_two]r=-d-oo; y[_three]-.5bulb_diam=vround max(-.85d,y[_two]r+eps)+eps;
 z[_three]r=z[_four]r;
 %rt x[_four]l=floor x[_zero]-1.5u if monospace: / expansion_factor fi); %2.5u
 lft x[_four]r=-1/6u if monospace: / expansion_factor fi; %2.5u
 (x,y[_two]r)=whatever[z[_two]l,z[_one]l];
 x[_two]r:=max(x,.5[x[_three]r,x[_two]]);
 forsuffixes e=l,r:
 z[_one]'e=((0,y[_four])--(w,y[_four])) intersectionpoint
    (z[_five]e--pulled_arc.e([_one],[_two])); endfor
 if lft x[_one]'l>rt x[_four]l+max(1,1/3vair+.5):
    filldraw stroke z[_five]e--pulled_arc.e([_one],[_two]);
 else:
    x[_one]'l:=min(rt x[_four]l+max(1,hround(1/3vair+.5)),rt x[_one]'r-vair)+.5fine-eps;
    filldraw z[_five]r--pulled_arc.r([_one],[_two])--z[_two]l{right}
             ..z[_one]'l{up}..{up}z[_five]l--cycle;
 fi
 bulb([_two],[_three],[_four]); % bulb
else:
 pos[_two](vair',-90); pos[_three](.6[vair',flare],-105);
 rt x[_three]r=x[_zero]-2u; bot y[_three]r=-d;%3u
 bot y[_two]r=-d-oo; x[_two]=.4[x[_three]r,x[_zero]r];
 filldraw stroke z[_five]e--super_arc.e([_one],[_two])
  & term.e([_two],[_three],left,.8,4); fi
%%%
penlabels(1,2,3,4,5,6, 7,8,9,10,11,[_one]'); endchar;

iff serifs:
lhchar "Lowercase Cyrillic letter delta - Lowercase Greek delta";
cyrchar(delta,8u#,asc_height#,0);
italcorr .9asc_height#*slant+.5hair#-1.5u#;
adjust_fit(0,0); pickup fine.nib;
x0=-u; y0=1.1h;
numeric light_flare; light_flare=2/3[vair,flare];
x1=w-2u-.5light_flare; y1=h-.5light_flare;
numeric theta; theta=angle (z1-z0);
pos1(light_flare,theta-90); pos2(.2[vair,light_flare],-90); pos3(vair,theta);
x2=x3+u; y2=h;
x4=.5w+.5u; x6=.55[x7,x5]; top y8r=x_height+oo; z4=z8;
pos6(vair,-90); pos7(stem,-180); pos8(vair,-270);
pos4(stem,angle(z4-z0)+90); pos5(stem,30);
z3=.5[.5[z1,z4],z0];
y5+.1x_height=y7=.5[y6,y8]; bot y6=-oo;
lft x7r=hround(1.4u-.5stem); rt x5r=hround(w-u);
filldraw stroke z1e{z0-z1e}....z2e....z3e{(z0-z1)rotated 90}
 ...z4e{z4e-.8[z4,z0]}
 ....z5e{down}...pulled_arc.e(6,7) & pulled_arc.e(7,8);  % hook and bowl
filldraw z1r{z1r-z0}...z1l{z0-z1l}--cycle; % bulb
math_fit(-.3x_height#*slant+.5curve#-u#,.7x_height#*slant-.5u#);
penlabels(0,1,2,3,4,5,6,7,8); endchar;

iff not serifs:
lhchar "Lowercase Cyrillic letter delta - Lowercase Greek delta";
cyrchar(delta,8u#,asc_height#,0);
italcorr .9asc_height#*slant+.5hair#-1.5u#;
adjust_fit(0,0); pickup fine.nib;
x0=-u; y0=1.1h;
numeric light_flare; light_flare=2/3[vair,flare];
x1=w-2u-.5light_flare; y1=h-.5light_flare;
numeric theta; theta=angle (z1-z0);
pos1(light_flare,theta-90); pos2(.2[vair,light_flare],-90);
x2=x3+u; y2=h;
x4=.5w+.5u; x6=.5[x7,x5]; top y8r=x_height+oo; z4=z8;
pos6(vair,-90); pos7(stem,-180); pos8(vair,-270);
pos4(.5[vair,stem],angle(z4-z0)+90); pos5(fudged.stem,0); pos3(vair,angle(z4-z0)+90);%theta
z3=.4[z4,(x0,.5[y0,h])];
y5=y7=.5[y6,y8]; bot y6=-oo;
lft x7r=hround(1.4u-.5stem); rt x5r=hround(w-1.4u+.5stem);
z35=point 1.5 of (z1{z0-z1}...z2....z3{z4-z0});
pos35(vair,angle(.5[z4,z1]-z0));
filldraw stroke z1e{z0-z1e}...z2e....z3e{z4e-z0}
 ...z4e{z4-.8[z4,(x0,h)]}
 ...%z5e{down}...
{{interim superness:=more_super;
pulled_arc.e(5,6) & pulled_arc.e(6,7) & pulled_arc.e(7,8)}};  % hook and bowl
math_fit(-.3x_height#*slant+.5curve#-u#,.7x_height#*slant-.5u#);
penlabels(0,1,2,3,35,4,5,6,7,8); endchar;

lhchar "Lowercase Cyrillic letter m_tl - m tail";
cyrchar(m_tl,12u# if not serifs:+width_adj# fi,x_height#,desc_depth#);
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); fi  % lower left serif
 %dish_serif(4,3,e,1/3,jut,f,1/3,jut); fi   %!!! % lower right serif
%%%%%
% l_tail(4);
_zero:=4;
_one:=9; _two:=11; _three:=12; _four:=13; _five:=14;
%
pickup fine.nib;
pos[_five](tiny.rt x[_zero]r-tiny.lft x[_zero]l,0);
pos[_one](tiny.rt x[_zero]r-tiny.lft x[_zero]l,0);
z[_five]=z[_zero]; x[_one]r=x[_five]r;
bot y[_one]=max(-1/3d,-d+vair'+eps);
if serifs:
 numeric bulb_diam;
 bulb_diam=max(currentbreadth+eps,min(.82d-1-eps,hround 7/8[hair,flare]));
 pos[_two](vair',-90); pos[_three](hair,-180);
 pos[_four](bulb_diam,-180);
 x[_two]=.5[x[_one],x[_three]r];
 bot y[_two]r=-d-oo; y[_three]-.5bulb_diam=vround max(-.85d,y[_two]r+eps)+eps;
 z[_three]r=z[_four]r;
 rt x[_four]l=max(x[_zero]l-bulb_diam,
  floor x[_zero]-2.5u if monospace: / expansion_factor fi);
 (x,y[_two]r)=whatever[z[_two]l,z[_one]l];
 x[_two]r:=max(x,.5[x[_three]r,x[_two]]);
 filldraw stroke z[_five]e--pulled_arc.e([_one],[_two]);
 bulb([_two],[_three],[_four]); % bulb
else:
 pos[_two](vair',-90); pos[_three](.6[vair',flare],-105);
 rt x[_three]r=x[_zero]-3u; bot y[_three]r=-d;
 bot y[_two]r=-d-oo; x[_two]=.4[x[_three]r,x[_zero]r];
 filldraw stroke z[_five]e--super_arc.e([_one],[_two])
  & term.e([_two],[_three],left,.8,4); fi
%%%
penlabels(0,1,1',2,3,3',4,5,6,7,8,10, 9,11,12,13,14); endchar;

lhchar "Lowercase Cyrillic letter r_gcrs - r grave crossed";
cyrchar(r_gcrs,10u#+serif_fit#,x_height#,desc_depth#);
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#);
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
%%%%%
path p; numeric unbalance,outer_jut;
p=z5{(x5,y6)-z5}...superness[(x6,y5),(x5,y6)]{z6-z5}...{z6-(x5,y6)}z6;
z9=point.75 of p;
numeric unbalance,outer_jut;
unbalance=if monospace: 1 else: 1.1 fi;
% some funny fonts have an extremally small |jut|:
outer_jut=.5stem+if serifs: max(limit_dist,if hefty: .8 fi\\ jut) else: 1.7u fi;
put_cyrcross(x9,(y9-bar_height),-outer_jut,-unbalance*outer_jut);
%%%
penlabels(0,1,2,3,4,5,6,7,8, 9); endchar;

lhchar "Lowercase Cyrillic letter s_acrs - s acute crossed";
cyrchar(s_acrs,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;  % arc and lower terminal
fi
%%%%%
pair outer_point; path p; numeric unbalance,outer_jut;
outer_point=superness[(x4r,y3r),(x3r,y4r)];
p=z3{(x3,y4)-z3}
 ... (.5superpull)[superness[(x4,y3),(x3,y4)],outer_point]{z4-z3}...{z4-(x3,y4)}z4;
z6=point.75 of p;
unbalance=.95; %if monospace: 1 else: 1.1 fi;
% some funny fonts have an extremally small |jut|:
outer_jut=.5stem+if serifs: max(limit_dist,if hefty: .8 fi\\ jut) else: 1.7u fi;
put_cyrcross(x6,(y6-bar_height),unbalance*outer_jut,outer_jut);
%%%
penlabels(0,1,2,3,4,5, 6); endchar;

lhchar "Lowercase Cyrillic letter g_crsdsc - ghe hcrossed descender";
cyrchar(g_crsdsc,8u#-.5width_adj#,x_height#,
 if is_ogonek: desc_depth# else: sbeak# fi); %ldesc/og_depth
italcorr x_height#*slant-beak_jut#+.25u#; %Gamma->x_height+.5u#
adjust_fit(serif_fit#,-.25u#);
begingroup
% 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
save slab; % lower.slab
if serifs:
 slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,a,1/3,jut,b,1/3,.5jut);   % upper serif
 if is_ogonek:
    slab:=vair; % lower.slab
    dish_serif(2,1,c,1/3,jut,d,1/3,1.25jut); fi %!!! % lower serif
fi
%%%%%
% lowercase descender/ogonek
if is_ogonek:
   endgroup;
   def the_pen=
       if known ogonek_pen: ogonek_pen elseif serifs: tiny else: fine fi
   enddef;
   % |stem| was drawn by |tiny| pen, hence |tiny| in the following equation:
   ogonek_pos=(x2 if not serifs: l fi,.5the_pen)
       if serifs and not is_egyptian: +(.5xvair,0) fi;
   easy_ogonek(the_pen,7,8,9); % ogonek
else:
   slab:=vair; % lower.slab
   numeric right_jut;
   right_jut=if serifs: 1.414jut else: 1.7u fi;
   r_serif(2,1,o,1/3,jut,p,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
   endgroup;
fi
% hstroke
bar_stroke(hround 1/3u-serif_fit,x1r+1.7u); % bar
penlabels(1,2,3,4, 5,6,7); endchar;

lhchar "Lowercase Cyrillic letter h_hcrs - kha (looks like X)";
cyrchar(h_hcrs,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
%%%%%
% hstroke
bar_stroke(hround 1/3u-serif_fit,w-hround 1/3u+serif_fit);
penlabels(0,1,2,3,4,12,13,24,34, 5,6); endchar;

lhchar "Lowercase Cyrillic letter semi soft sign";
cyrchar(semisn,9u#,x_height#+acc_height#,0);
italcorr .5x_height#*slant+min(.5curve#-u#,-.25u#);
adjust_fit(if serifs: serif_fit# else: 0 fi,if monospace:.5u# else:0 fi);
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
 sloped_serif.l(1,2,a,1/3,outer_jut,serif_drop);    % 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
%%%
% hcross
pickup crisp.nib; pos8(bar,90); pos9(bar,90);
lft x8=hround 1/3u if serifs:-serif_fit fi; x9=w-2.5u;
top y8r=top y9r=vround x_height+eps;
filldraw stroke z8e--z9e; % cross bar
%%%%%
penlabels(0,1,2,3,4,5,6,7,8,9,10,11); endchar;

lhchar "Lowercase Russian letter i_shdsc - short i with descender";
cyrchar(i_shdsc,10u# if not serifs:+.5width_adj# fi, % n_width
  x_height#+acc_height#,if is_ogonek: desc_depth# else: sbeak# fi); %ldesc/og_depth
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;
begingroup
% 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: numeric upper_notch,lower_notch;
 stem1=fudged.hair-2stem_corr;
 upper_notch=y6-cap_notch_cut-eps; lower_notch=y5+cap_notch_cut+eps;
 if monospace:
  x5r =rt x1r; x6l =lft x3l; y5=vround(vair'+eps); y6=vround(h-vair-eps);
  alpha1=diag_ratio(1,stem1,y5-y6,x5r-x6l);
  penpos5(min(2fudged.stem,alpha1*stem1),0);
  penpos6(min(2fudged.stem,alpha1*stem1),0);
  x5'=lft x1l; z5'=whatever[z5l,z6l]; x6'=rt x4r; z6'=whatever[z5r,z6r];
  x5l:=x5'; x6r:=x6'; y5l:=y5'; y6r:=y6';
 else:
  y5l=0; y6r=h; x5=x1r; x6=x3l; penpos5(stem1,0); penpos6(stem1,0);
 fi
 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
%%%
numeric inner_jut;
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
 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
 if is_ogonek:
    dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut); fi % lower right serif
fi
% lowercase descender
if not serifs: inner_jut:=0; fi
slab:=vair; % lower.slab
right_jut:=if serifs: max(limit_dist,1.1jut) else: hround (r-rt x4r-.5u) fi;
if unic:
   %saam tail
    serif(4,3,v,1/3,-jut);
    siam_serif(4,3,w,1/3,right_jut);
else:
   r_serif(4,3,g,1/3,inner_jut,h,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
fi
endgroup;
%%%%%
% 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;

lhchar "Lowercase Cyrillic letter r_tl (looks like p)";
cyrchar(r_tl,10u#+serif_fit#,x_height#,
        max(1.6desc_depth#,paren_depth#));%r_ddepth
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
adjust_fit(serif_fit#,0); full_d:=d;
d:=vround min(desc_depth,max(vair+slab+oo+1+eps,full_d-max(.4desc_depth,.55beak)-slab));%r_dscs
% 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);  %!!! % lower serif
fi
%%%%%
% tail_part(2);%!!!
_zero:=2;
_one:=9; _two:=10; _three:=11; _four:=12; _five:=13;
_six:=14; _seven:=15; _eight:=16; _nine:=17;
%
pickup tiny.nib;
numeric bulb_diam;
bulb_diam=max(currentbreadth+eps,
        min(full_d-d-.18desc_depth-1-eps,hround 7/8[hair,flare]));%!!!
y[_one]l=y[_two]l=vround min(if serifs:-.5d else: -d+vair fi,-oo-.6[thin_join,vair]-eps);%!!!
y[_one]r-y[_one]l=y[_two]r-y[_two]l=.6[thin_join,vair];%!!!
penpos[_three](max(currentbreadth+eps,curve if hefty:-3stem_corr fi),0);
y[_three]=.5[y[_one]r,-full_d];%!!!
x[_two]l=x[_two]r=w-4.75u; x[_one]l=x[_one]r=x[_zero];
x[_three]r=hround(w-2u); x[_two]l:=x[_four]l:=x[_two]r-.25curve;%!!!
{{interim superness:=more_super;
 fill stroke super_arc.e([_three],[_two])..z[_one]e}};  % lobe
if serifs:
 z[_five]=z[_three]; pos[_five](curve if hefty:-3stem_corr fi,0);
 pos[_six](vair,-90); bot y[_six]r=-full_d-oo; %!!!
 y[_seven]-.5flare=-full_d+.15desc_depth;%!!!
 pos[_seven](hair,-180); pos[_eight](bulb_diam,-180);
 rt x[_eight]l=max(lft x[_zero]l-jut+bulb_diam,
  floor x[_three]-2.5u if monospace: / expansion_factor fi);%!!!
 z[_seven]r=z[_eight]r;
 x[_six]=max(rt x[_eight]l,.6[x[_five],x[_seven]r]);
 (xx,y[_six]r)=whatever[z[_six]l,z[_five]l];%!!!
 x[_six]r:=max(xx,.5[x[_seven]r,x[_six]]);%!!!
 filldraw stroke super_arc.e([_five],[_six]);
 bulb([_six],[_seven],[_eight]); % bulb
else:
 pickup fine.nib; z[_five]=z[_three];
 pos[_five](max(fine.breadth,curve if hefty:-3stem_corr fi),0);
 pos[_nine](vair',-90); pos[_six](.6[vair',flare],-105);
 rt x[_six]r=x[_three]-3.5u; bot y[_six]r=-full_d;%!!!
 bot y[_nine]r=-full_d-oo; x[_nine]=.35[x[_six]r,x[_three]r];%!!!
 filldraw stroke super_arc.e([_five],[_nine])
  & term.e([_nine],[_six],left,.75,4); fi
%%%
penlabels(0,1,2,3,4,5,6,7,8, 9,10,11,12,13,14,15,16,17); endchar;

endinput;
%end of file
