%
% lgt2upl.mf
%
%% Cyrillic font container with T2 encoding beta-support
%
% This file is future part of lxfonts package
% Version 3.4 // 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 authors are entitled to modify this file
% and to save it under the same name.
%
% Content:
%
% Lowercase Cyrillic letters 128--255 for T2 encoding
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% List of letternames and their codes in T2
%
%                X2  T2A  T2B  T2C
%
% g_hcrs        "a1  "a1   -    -    Ghe horisontally crossed
% g_dsc         "a2   -   "a2   -    Ghe with descender
% g_tl          "a3   -   "a3   -    Ghe tail
% shha          "a4  "a4  "a4  "a4   Shha (same as lower h)
% zh_dsc        "a5  "a5  "a5   -    Zhe with descender
% z_dsc         "a6  "a6   -    -    Ze with descender (cedilla)
% abh_dze       "a7   -   "a7  "a7   Abkhasian dze
% k_dsc         "a9  "a9  "a9  "a9   Ka with descender
% k_beak        "aa  "aa   -    -    Ka with reversed beak
% k_tl          "ab   -   "ab   -    Ka with tail
% l_tl          "ac   -   "ac   -    El with tail
% n_dsc         "ad  "ad  "ad  "ad   En with descender
% n_tl          "af   -   "af  "af   En with tail
%
% s_dsc         "b1  "b1   -    -    Es with descender (cedilla)
% y             "b3  "b3  "b3   -    Straingt u (as upper Y)
% y_hcrs        "b4  "b4   -    -    Straingt u horisontally crossed
% h_dsc         "b5  "b5  "b5  "b5   Kha with descender
% h_tl          "b6   -   "b6   -    Kha with tail
% ch_ldsc       "b7   -   "b7   -    Che with left descender
% ch_rdsc       "b8  "b8  "b8  "b8   Che with right descender
% schwa         "ba  "ba  "ba  "ba   Schwa
%

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

lhchar "Lowercase Cyrillic letter g_hcrs - ghe hcrossed";
cyrchar(g_hcrs,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
%%%%%
% hstroke
bar_stroke(hround 1/3u-serif_fit,tiny.rt x1r+1.8u);
penlabels(0,1,2,3,4,5,6); endchar;

lhchar "Lowercase Cyrillic letter g_dsc - ghe descender";
cyrchar(g_dsc,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# if monospace:+\\.5u#,.5u#+ else:,fi\\ 0);
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 bracketing
 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,5,6,7); % ogonek
else:
   slab:=vair; % lower.slab
   numeric right_jut;
   right_jut=if serifs: 1.414jut else: .5stem+.5u fi;
   r_serif(2,1,o,1/3,jut,p,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
   endgroup;
fi
penlabels(0,1,2,3,4, 5,6,7); endchar;

lhchar "Lowercase Cyrillic letter g_tl - ghe tail";
cyrchar(g_tl,if monospace:8u#-.5width_adj# else:10u# fi,x_height#,desc_depth#);
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ 0);
full_w:=w; w:=8u-.5width_adj;
% 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-if monospace: beak/1.4 else:.5beak fi)-eps; %!!!
arm(3,4,e,beak_darkness,.35beak_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); fi % upper serif
 %slab:=vair; % lower.slab
 %dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut); fi % lower serif
%%%%%
pickup tiny.nib;
w:=full_w if monospace:+u fi;
% tail_part(2);
_zero:=2;
_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:
 numeric inner_jut;
 if rt x2r+jut+.5u+1<=x[_three]r: inner_jut=jut;
  else: rt x2r+inner_jut+.5u+1=x[_three]r; fi
 slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut); fi % lower serif
penlabels(0,1,2,3,4,5,6,7,8,9,10,11,12,13); endchar;

lhchar "Lowercase Cyrillic letter shha (as lower h)";
cyrchar(shha,10u#,asc_height#,0);
italcorr .5[bar_height#,x_height#]*slant-serif_fit#+.5stem#-2u#;
adjust_fit(serif_fit#+stem_shift#,serif_fit#-stem_shift#);
pickup tiny.nib; pos1(stem,0); pos2(stem,0);
pos1'(stem',0); pos2'(stem',0); pos3(stem,0);
lft x1l=hround(2.5u-.5stem); x1l=x1'l=x2l=x2'l; x3=w-x1;
top y1=h; bot y2=0; y1=y1'; y2=y2';
filldraw stroke z1'e--z2'e;  % left stem
h_stroke(2,a,3,4);  % arch and right stem
if serifs:
 sloped_serif.l(1',2',b,1/3,jut,serif_drop); % upper left serif
 numeric inner_jut; pickup tiny.nib;
 if rt x2r+jut+.5u+1<=lft x4l-jut: inner_jut=jut;
  else: rt x2r+jut+.5u+1=lft x4l-inner_jut; fi
 save slab; slab:=vair; % lower.slab
 dish_serif(2,1,c,1/3,jut,d,1/3,jut);	% lower left serif
 dish_serif(4,3,e,1/3,inner_jut,f,1/3,jut); fi % lower right serif
penlabels(1,2,3,4); endchar;

iff not specific:%
lhchar "Lowercase Cyrillic letter zh_dsc - zhe descender (`roman')";
cyrchar(zh_dsc,if serifs:10u# else:9.5u# fi % zhk_width: n_width;keng_width
 ,x_height#,if is_ogonek: desc_depth# else: sbeak# fi); %ldesc/og_depth
italcorr x_height#*slant-.2u#;
adjust_fit(w#-5u#+ %zhr_adj
	if monospace: 0 else: serif_fit# fi, %wlett_adj
 if monospace: 0 else: serif_fit# fi); %wlett_adj
begingroup
% 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
 if is_ogonek:
    slab:=vair; % lower.slab
    dish_serif(6,5,g,1/2,inner_jut,h,1/3,right_jut)(dark); fi % lower diagonal serif
fi
%%%
% 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
%%%%%
% lowercase descender/ogonek
if is_ogonek:
   endgroup;
   def the_pen=
       if known ogonek_pen: ogonek_pen elseif serifs: tiny else: fine fi
   enddef;
   % |diag_end| refers to |tiny| pen, hence |tiny| in the following equation:
   ogonek_pos=(x6 if not serifs: l fi,.5the_pen)
       if serifs and not is_egyptian: +(.5xvair,0) fi;
   easy_ogonek(the_pen,11,12,13); % ogonek
else:
   slab:=vair; % lower.slab
   r_serif(6,1,o,1/3,jut,p,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
   endgroup;
fi
penlabels(1,2,3,4,5,6,7,8,9,10, 11,12,13); endchar;

lhchar "Lowercase Cyrillic letter z_dsc - ze descender (cedilla)";
cyrchar(z_dsc,8u#,x_height#,desc_depth#);
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
%%%%%
% lowercase cedilla/ogonek
if is_ogonek:
   def the_pen=
       if known ogonek_pen: ogonek_pen elseif serifs: tiny else: fine fi
   enddef;
   ogonek_pos=(x8r,0);
   easy_ogonek(the_pen,11,12,13); % ogonek
else:
   lowercase_cedilla(x8,0, 11,12,13,14,15);
fi
penlabels(0,1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15); endchar;

lhchar "Lowercase Cyrillic letter abh_dze - Abkhazian dze";
cyrchar(abh_dze,8u#,x_height#,desc_depth#); %+1.75dot_size#
italcorr x_height#*slant-.5serif_fit#-.3u#;
adjust_fit(0,.5serif_fit#);
pickup if serifs: tiny.nib else: fine.nib fi;
numeric arm_thickness,z_stem[];
z_stem1=max(currentbreadth,hround(if hefty: vair else:fudged.hair fi));
arm_thickness=if hefty: .5 else:2/3 fi[vair,stem];
if z_stem1<currentbreadth+eps: z_stem1:=currentbreadth+eps; fi
rt x1r=rt x2r=hround(w-.8u)+eps;
lft x3l=lft x4l=good.x(.28[.5u,w-.8u])-eps;
top y1=h; bot y2=min(bot y1,good.y(h-arm_thickness));
bot y4=good.y (.28h)-eps;
y3=max(y4,good.y(.28h+.6[thin_join,vair]-.5currentbreadth)-eps);
numeric alpha; alpha=diag_ratio(1,.5(z_stem1-currentbreadth),y2-y4,x2r-x3l);
z_stem2=alpha*(z_stem1-currentbreadth);
if z_stem2<eps: z_stem2:=eps; fi
penpos1(z_stem2,0); penpos2(z_stem2,0);
penpos3(z_stem2,0); penpos4(z_stem2,0);
pair delta; delta=penoffset z3-z2 of currentpen;
fill top z1l--z2l+delta---z3l+delta..lft z3l---lft z4l..bot z4l
 ---bot z4r--z3r-delta---z2r-delta..rt z2r---rt z1r..top z1r
 ---cycle;  % diagonal
pos7(curve,0); pos8(vair',-90); pos12(rt x4r-lft x4l,180); pos13(vair,90);
x12r=x4l; y12=y4; rt x7r=hround(w-.75u); y7=.5[bot y13l,top y8l];
bot y8r=-d-oo; x8=hround.5[.5u,w-.8u]; x13=max(x8,rt x12l+eps);
y13=.1[y4,h]; y13l:=min(y13l,.5[y4,y13l]);
filldraw stroke z12e{z2l-z3l}...{right}z13e; %link
filldraw stroke pulled_arc.e(13,7) & pulled_arc.e(7,8);  % bowl
if serifs:
 numeric bulb_diam[]; bulb_diam2=hround 7/8[hair,flare];
 pos10(bulb_diam2,-180); pos9(cap_hair,-180);
 lft x10r=hround .75u; y10=-.3d;
 {{less_tense; bulb(8,9,10)}};  % lower bulb
else:
 pos9(.6[vair',flare],angle(-2u,-h));
 lft x9r=hround .75u; top y9l=vround -.3d;
 y9r:=good.y y9r-eps; x9l:=good.x x9l;
 filldraw stroke term.e(8,9,left,1,4); fi  % lower terminal
pickup crisp.nib;
pos5(max(h-bot y2l-.5crisp-vair_corr,crisp.breadth),90); pos6(hair,180);
top y5r=h; x5=x1; lft x6r=hround .75u;
y6=max(good.y(if serifs: h-Vround(vair-vair_corr)-beak/1.4 else: y5l-vair_corr fi)-eps,y3+1);
arm(5,6,a,beak_darkness,-.4beak_jut);  % upper arm and beak
penlabels(1,2,3,4,5,6,7,8,9,10,12,13); endchar;

% Ukrainian i moved up for LH font

iff not specific:%
lhchar "Lowercase Cyrillic letter k_dsc - ka descender (`roman')";
cyrchar(k_dsc,if serifs:10u# else:9.5u# fi % zhk_width: n_width;keng_width
 ,x_height#,if is_ogonek: desc_depth# else: sbeak# fi); %ldesc/og_depth
italcorr x_height#*slant-.2u#;
adjust_fit(serif_fit#,serif_fit#);
begingroup
% 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
 if is_ogonek:
    slab:=vair; % lower.slab
    dish_serif(6,5,g,1/2,inner_jut,h,1/3,right_jut)(dark); fi % lower diagonal 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;
   % |diag_end| refers to |tiny| pen, hence |tiny| in the following equation:
   ogonek_pos=(x6 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
   r_serif(6,1,x,1/3,jut,y,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
   endgroup;
fi
penlabels(1,2,3,4,5,6); endchar;

iff not specific:%
lhchar "Lowercase Cyrillic letter k_beak - ka beak (`roman')";
cyrchar(k_beak,if serifs:10u# else:9.5u# fi % zhk_width: n_width;keng_width
 ,x_height#,0);
italcorr x_height#*slant-.2u#;
adjust_fit(2u#-.5width_adj#, % beak_adj
 serif_fit#);
% lowerr_k;beak
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
 nodish_serif(1,2,a,1/3,.5jut,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
%%%
%%%%%
% lower left beak
pickup crisp.nib; pos7(vair,90); pos8(hair,180);
top y7r=h; x7=x1; lft x8r=l+letter_fit+hround.45u; y8=good.y(y7l-beak/1.4)-eps;
arm(7,8,q,beak_darkness,-.4beak_jut);
penlabels(1,2,3,4,5,6, 7,8); endchar;

iff not specific:%
lhchar "Lowercase Cyrillic letter k_tl - ka tail (`roman')";
cyrchar(k_tl,10u#,x_height#,desc_depth#); % n_width
italcorr x_height#*slant-.2u#;
adjust_fit(serif_fit#,serif_fit#);
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
numeric right_jut,stem[],alpha[],tailstem,bulb_diam;
bulb_diam=hround 7/8[hair,flare];
right_jut=if serifs:.6jut else:.4tiny fi;
% tail_part(2);
_zero:=2;
_one:=7; _two:=8; _three:=9; _four:=10; _five:=11;
_six:=12; _seven:=13; _eight:=14; _nine:=15;
%
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
%%%
% diagonal;
pickup tiny.nib; numeric right_jut,stem[],alpha[];
right_jut=if serifs:.6jut else:.4tiny fi;
stem1=max(tiny.breadth,hround(fudged.hair if hefty:-\\4stem_corr fi));
top y3=h; rt x3r=hround(r-letter_fit-.7u-right_jut)+eps;
x4=x1; y4=.7bar_height;
alpha1=diag_ratio(1,.5(stem1-tiny),y3-y4,x3r-x4);
penpos3(alpha1*(stem1-tiny),0); penpos4(whatever,-90);
forsuffixes $=l,r: y3'$=h; y4'$=y1.bh;
 z4$=z3'$+whatever*(z3-z4); z4'$=z3'$+whatever*(z3-z4); endfor
z3'r=z3r+penoffset z3-z4 of currentpen+whatever*(z3-z4);
fill z4'r--diag_end(4r,3'r,1,.5,3'l,4l)--z4'l--cycle; % upper diagonal
%%
if serifs:
 numeric inner_jut,up_inner_jut;
 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
 if rt x2r+jut+.5u+1<=x[_three]r: inner_jut=jut;
  else: rt x2r+inner_jut+.5u+1=x[_three]r; fi
 save slab; 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
 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,inner_jut); fi % lower stem serif
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); endchar;

lhchar "Lowercase Cyrillic letter l_tl - el tail";
cyrchar(l_tl,10u# % if not serifs:+.5width_adj# fi % dl_width;n_width
 ,x_height#,desc_depth#);
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=min(.5(lft x1l-rt x3r)-eps,.5jut);
 %dish_serif(2,1,a,1/3,jut,b,1/3,jut);	   %!!! %lower right serif
 save slab; 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
%%%%%
% l_tail(2);
_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=-.85d;
 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(1,2,3,4,5,6, 7,8,9,10,11);endchar;

lhchar "Lowercase Cyrillic letter n_dsc - en descender";
cyrchar(n_dsc,10u# if not serifs:+.5width_adj# fi,x_height#, % n_width
 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# if not serifs:+.5(stem#-u#) fi) %dl_adj
begingroup
% 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
%%%
numeric inner_jut,right_jut; % for cyr_serif
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; % lower.slab
if serifs:
 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/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=(x4 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
   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 right descender
   endgroup;
fi
penlabels(1,2,3,4,5,6, 7,8,9); endchar;

lhchar "Lowercase Cyrillic letter n_tl - en tail";
cyrchar(n_tl,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); fi	% lower left serif
 %dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut); fi %!!! % lower right serif
%%%%%
% l_tail(4);
_zero:=4;
_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=-.85d;
 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(1,2,3,4,5,6, 7,8,9,10,11); endchar;

lhchar "Lowercase Cyrillic letter s_dsc - es descender (cedilla)";
cyrchar(s_dsc,8u#,x_height#,desc_depth#); % eng
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
%%%%%
% lowercase cedilla/ogonek
if is_ogonek:
   path p_.r;
   p_.r=if serifs: pulled_super_arc.r(3,4)(.5superpull)
       ..tension .9 and 1..{x5-x4,5(y5-y4)}z5r
       else:      p.r 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,6,7,8); % ogonek
else:
   lowercase_cedilla(x4,0, 6,7,8,9,10);
fi
penlabels(0,1,2,3,4,5, 6,7,8,9,10); endchar;

% Short U moved up for LH fonts

lhchar "Lowercase Cyrillic letter y - straight u (as upper Y)";
cyrchar(y,if serifs: 9.5u# else: 9u# fi,x_height#,desc_depth#);
italcorr x_height#*slant+.25u#;
adjust_fit(serif_fit#,serif_fit#);
% lower_y;
numeric left_stem,right_stem,outer_jut,dy,alpha; left_stem=stem-stem_corr;
right_stem=min(hair if hefty:-2stem_corr fi,left_stem); outer_jut=.75jut;
x1l=w-x4r=l+letter_fit+outer_jut+.05u;
x2l=x5l=hround(.5w-.5left_stem); x3r=x5r; y1=y4=h;
y2=y3=y5=0; dy=y1-y2; alpha=((x2l-x1l)++dy)/dy;
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*right_stem,0);
penpos5(left_stem,0); penpos6(left_stem,0); x5=x6; y6=-d;
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
if y0>y2+notch_cut:
 y0:=y2+notch_cut;
 fill z0+.5right{up}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)--z5r
  --diag_end(5r,6r,1,1,6l,5l)--z5l--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{down}z0+.5left--cycle; % diagonals and stem
else:
 fill z0--diag_end(0,4l,1,1,4r,3r)--z5r
  --diag_end(5r,6r,1,1,6l,5l)--z5l
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi  % diagonals and stem
if serifs:
 numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(4,3); prime_points_inside(6,5);
 if rt x1'r+jut+.5u+1<=lft x4'l-jut: inner_jut=jut;
  else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
 dish_serif(6',5,e,1/3,jut,f,1/3,jut);	% lower serif
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut);	   % upper left serif
 dish_serif(4',3,c,.6,inner_jut,d,1/2,outer_jut)(dark);	fi % upper right serif
%%%%%
penlabels(0,1,2,3,4,5,6); endchar;

lhchar "Lowercase Cyrillic letter y_hcrs - straight u hcrossed";
cyrchar(y_hcrs,if serifs: 9.5u# else: 9u# fi,x_height#,desc_depth#);
italcorr x_height#*slant+.25u#;
adjust_fit(serif_fit#,serif_fit#);
% lower_y;
numeric left_stem,right_stem,outer_jut,dy,alpha; left_stem=stem-stem_corr;
right_stem=min(hair if hefty:-2stem_corr fi,left_stem); outer_jut=.75jut;
x1l=w-x4r=l+letter_fit+outer_jut+.05u;
x2l=x5l=hround(.5w-.5left_stem); x3r=x5r; y1=y4=h;
y2=y3=y5=0; dy=y1-y2; alpha=((x2l-x1l)++dy)/dy;
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*right_stem,0);
penpos5(left_stem,0); penpos6(left_stem,0); x5=x6; y6=-d;
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
if y0>y2+notch_cut:
 y0:=y2+notch_cut;
 fill z0+.5right{up}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)--z5r
  --diag_end(5r,6r,1,1,6l,5l)--z5l--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{down}z0+.5left--cycle; % diagonals and stem
else:
 fill z0--diag_end(0,4l,1,1,4r,3r)--z5r
  --diag_end(5r,6r,1,1,6l,5l)--z5l
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi  % diagonals and stem
if serifs:
 numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(4,3); prime_points_inside(6,5);
 if rt x1'r+jut+.5u+1<=lft x4'l-jut: inner_jut=jut;
  else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
 dish_serif(6',5,e,1/3,jut,f,1/3,jut);	% lower serif
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut);	   % upper left serif
 dish_serif(4',3,c,.6,inner_jut,d,1/2,outer_jut)(dark);	fi % upper right serif
%%%%%
% hcross
pickup crisp.nib; pos7(bar,90); pos8(bar,90);
x7=.25w; x8=.75w; top y7r=top y8r=vround -eps;
filldraw stroke z7e--z8e;
penlabels(0,1,2,3,4,5,6, 7,8); endchar;

lhchar "Lowercase Cyrillic letter h_dsc - kha descender";
cyrchar(h_dsc,if serifs:9.5u# else:9u# fi,x_height#,
 if is_ogonek: desc_depth# else: sbeak# fi); %ldesc/og_depth
italcorr x_height#*slant-.05u#;
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ serif_fit#);
begingroup
% 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
%%%
numeric inner_jut[]; pickup tiny.nib; %moved for cyr_serif
prime_points_inside(3,2);prime_points_inside(4,1);
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; % lower.slab
if serifs:
 prime_points_inside(1,4); prime_points_inside(2,3);
 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
 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
 if is_ogonek:
    dish_serif(4',1,c,2/3,inner_jut2,d,1/3,outer_jut);	% lower right serif
 fi
 dish_serif(3',2,g,1/2,outer_jut+xjut,h,2/3,inner_jut2+xjut)(dark); fi % lower left serif
%%%%%
% lowercase descender/ogonek
if is_ogonek:
   endgroup;
   def the_pen=
       if known ogonek_pen: ogonek_pen elseif serifs: tiny else: fine fi
   enddef;
   % |diag_end| refers to |tiny| pen, hence |tiny| in the following equation:
   ogonek_pos=(x4 if not serifs: l fi,.5the_pen)
       if serifs and not is_egyptian: +(.5xvair,0) fi;
   easy_ogonek(the_pen,5,6,7); % ogonek
else:
   slab:=vair; % lower.slab
   numeric right_jut;
   right_jut=if serifs: 1.1 outer_jut else: .4tiny fi;
   r_serif(4',1,x,1/3,inner_jut2,y,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
   endgroup;
fi
penlabels(0,1,2,3,4,12,13,24,34, 5,6,7); endchar;

lhchar "Lowercase Cyrillic letter h_tl - kha (looks like X)";
cyrchar(h_tl,if serifs:9.5u# else:9u# fi,x_height#,desc_depth#);
italcorr x_height#*slant-.05u#;
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ serif_fit#);
% lower_h_tail;
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);
numeric t; t=slab+bracket;
forsuffixes e=l,r: z54e=(((0,t)--(w,t)) intersectionpoint (z4e--z1e)); endfor;
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'--z54l--z54r--z24' %!!!
  --diag_end(24',2r,1,.5,2l,12)--z12--cycle; % diagonals
else:
 fill diag_end(4r,1r,.5,1,1l,4l)--
   z54l--z54r--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(3,2); prime_points_inside(4,1);
 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
 prime_points_inside(1,4); prime_points_inside(2,3);
 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
 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
%%%%%
%%%%%
% l_tail(4);x_tail
_zero:=4;
_one:=7; _two:=8; _three:=9; _four:=10;
%
% x_
pickup fine.nib;
stem3=hround (max(fine.breadth,.5[stem1,x[_zero]r-x[_zero]l]));
x[_one]'r=x4r;
penpos[_one]'(stem3,0); pos[_one](stem3,0); z[_one]=z[_one]';
bot y[_one]=max(-1/3d,-d+vair')-eps;
(x[_one]'l,y54')=whatever[z4l,z4l+dir angle(z4l-if serifs:z1l else:z34'fi)];
z54'=(x[_one]'l,y54');
fill z54l{z4r-z1r}
        ..controls (z54')..
        {down}z[_one]'l--z[_one]'r{up}
        ..controls (z4r)..
        {z1r-z4r}z54r--cycle; %link
% _x
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=-.85d;
 z[_three]r=z[_four]r;
 rt x[_four]l=max(x[_one]l-bulb_diam,%!!!
  floor x[_one]-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 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[_one]-3u; bot y[_three]r=-d;%!!!
 bot y[_two]r=-d-oo; x[_two]=.4[x[_three]r,x[_one]r];%!!!
 filldraw stroke super_arc.e([_one],[_two])%!!!
  & term.e([_two],[_three],left,.8,4); fi
%%%
penlabels(0,1,2,3,4,54,54',5,6,7',8); endchar;

lhchar "Lowercase Cyrillic letter ch_ldsc - che left descender";
cyrchar(ch_ldsc,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#);
% lower_ch;
pickup tiny.nib; save slab; %!!!lower.slab
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
%%%
 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
%%%%%
% lower left descender
slab:=vair; % lower.slab
numeric right_jut;
right_jut=
   if serifs: max(limit_dist,1.1jut)
   else:      hround (w+serif_fit+.5(stem-u)-rt x4r-.5u) fi;
l_serif(4,3,o,1/3,beak_darkness,right_jut,.6beak_jut,p,1/3,inner_jut); % lower left descender
penlabels(1,2,3,4,5,6); endchar;

lhchar "Lowercase Cyrillic letter ch_rdsc - che right descender";
cyrchar(ch_rdsc,10u# if not serifs:+.5width_adj# fi,x_height#, % n_width
 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# if not serifs:+.5(stem#-u#) fi) %dl_adj
begingroup
% lower_ch;
pickup tiny.nib; save slab; %!!! lower.slab
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
%%%
 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
 if is_ogonek:
    slab:=vair; % lower.slab
    dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut); %!!! % lower right serif
 fi
else:
 fill stroke pulled_arc.e(2',5) & z5e{right}...{right}z6e; fi % arc
%%%%%
% 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=(x4 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: max(limit_dist,1.1jut)
      else:      hround (w+serif_fit+.5(stem-u)-rt x4r-.5u) fi;
   r_serif(4,3,o,1/3,jut,p,1/3,beak_darkness,right_jut,.6beak_jut); % lower right descender
   endgroup;
fi
penlabels(1,2,3,4,5,6, 7,8,9); endchar;

lhchar "Lowercase Cyrillic letter schwa";
cyrchar(schwa,8.25u#,x_height#,0); %erev
italcorr .5[bar_height#,x_height#]*slant+.5min(curve#-1.5u#,0);
adjust_fit(if monospace: .25u#,.5u# else: 0,0 fi);
% lower_schwa;
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,-180); pos2(vair',-90); pos3(left_curve,0);
set_bar_axis; bot y2r=-oo; y0l=top y1=h-y1.bh;
lft x1r=hround max(.5u,u-.5right_curve);
rt x3r=hround min(w-.5u,w-1.25u+.5left_curve); x2=.5w-.25u;
{{interim superness:=more_super;
 filldraw stroke super_arc.e(1,2)}};  % right bowl
y3=.5[y2,y4]; top y4r=h+oo; x4=x2;% if not serifs:-.25u fi;
if serifs:
 pos4(vair,90); pos5(hair,180);
 y5=min(bar_height+.25flare+2vair'+2,.9[bar_height,h]-.75flare); %z
 lft x5r=hround(lft x1r+1/3u)+eps;
 (x,y4l)=whatever[z4r,z5]; x4l:=max(x,x4l-.5u);
 filldraw stroke pulled_arc.e(2,3) & pulled_arc.e(3,4); % left bowl, arc,
 pickup fine.nib; pos4'(vair,90); z4'=z4; x4'r:=x4r;
 filldraw stroke z4'e{left}...{x5-x4,5(y5-y4)}z5e; % and terminal
 path upper_arc; upper_arc=z5{x4-x5,5(y4-y5)}..z4{right};
 pos6(.3[fine.breadth,hair],180); x6r=x5r; top y6=h+oo;
 x5'-x5r=2curve-fine; y5'=y5;
 numeric t; t=xpart(upper_arc intersectiontimes (z6l--z5'));
 filldraw z5r--z6r--z6l--subpath(t,0) of upper_arc--cycle; % barb
else:
 pos4(vair,90);
 filldraw stroke super_arc.e(2,3) & super_arc.e(3,4);  % left bowl and arc
 pickup fine.nib; pos4'(vair,90); z4=z4'; pos5(4/7[vair',flare],100);
 lft x5r=hround(tiny.lft x1r+2/3u)+eps;
 top y5r=vround min(top y4r,max(.82[bar_height,top y4r],
   y2.bh+.5(y2.bh-y1.bh)-4/7[vair',flare]*sind 280+eps));
 filldraw stroke term.e(4',5,left,.8,4); fi  % terminal
pickup tiny.nib; path testpath; testpath=super_arc.r(2,3) & super_arc.r(3,4);
y1'l=y0l; x1'l=x1'r=x1; y1'r=y0r=y0l-.6[thin_join,vair];%y1.bh;
forsuffixes $=l,r:
x0$=xpart(((w,y0$)--(x1,y0$)) intersectionpoint testpath); endfor
fill stroke z0e--z1'e;  % crossbar
%%%%%
penlabels(0,1,2,3,4,5,5',6); endchar;

endinput;
%end of file
