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

% List of letternames
%
% Vl_yus
% izh_uml
% i_a
% Olg
% Ong
% Oery
% Ohrdsgn
% Och
% Oshch
% Oo_cdot
% Oo_cddot
% Oe
% Ou
% On
%
% Vfita
% Vkoppa
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

lhchar "Lowercase Cyrillic letter Vl_yus - like crossed Delta";
cyrchar(Vl_yus,10u#+2stem#,x_height#,0);
adjust_fit(serif_fit#,serif_fit#);
numeric left_stem,right_stem,outer_jut,alpha;
right_stem=fudged.stem-stem_corr;
left_stem=min(fudged.hair if hefty:-2stem_corr fi,right_stem);
outer_jut=.75jut; x1l=w-x4r=l+letter_fit+.25u; y1=y4=0; %+outer_jut
x2-x1=x4-x3; x3r=x2r+apex_corr; y2=y3=h+apex_o+apex_oo;
alpha=diag_ratio(2,left_stem,y2-y1,x4r-x1l-apex_corr);
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*right_stem,0);
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
if y0<h-notch_cut: y0:=h-notch_cut;
 fill z0+.5right{down}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)
  --diag_end(4r,3r,1,1,2l,1l)--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{up}z0+.5left--cycle; % left and right diagonals
else: fill z0--diag_end(0,4l,1,1,4r,3r)--diag_end(4r,3r,1,1,2l,1l)
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
penpos5(whatever,angle(z2-z1)); z5=whatever[z1,z2];
penpos6(whatever,angle(z3-z4)); z6=whatever[z3,z4]; y6=y5;
if hefty: y5r else: y5 fi =.5y0;
y5r-y5l=y6r-y6l=.6[thin_join,vair];
penstroke z5e--z6e; % middle bar line
penpos5'(whatever,angle(z2-z1)); z5'=whatever[z1,z2];
penpos6'(whatever,angle(z3-z4)); z6'=whatever[z3,z4]; y6'=y5';
bot y5'l=0; y5'r-y5'l=y6'r-y6'l=if hefty:max(.7slab,y5r-y5l) else: slab fi;
penstroke z5'e--z6'e; % bar line
penlabels(0,1,2,3,4,5,5',6,6'); endchar;

% for shape, see Knizhnay Shrift p 58  Bodoni, Parma 1818
lhchar "Lowercase Cyrillic letter izh_uml - izhitsa umlaut";
cyrchar(izh_uml,if serifs: 9.5u# else:9u# fi,lc_trema_height#,0);
italcorr x_height#*slant+.25u#;
adjust_fit(serif_fit# if monospace:+.5u# fi,
 if serifs: max(.75u#,.25u#+.5flare#) else:max(0,.5stem#-.5u#) fi); % lizh_adj
full_h:=h; h:=x_height;
% lower_izh;
numeric left_stem,right_stem,outer_jut,alpha,bulb_diam;
left_stem=stem-stem_corr; bulb_diam=7/8[hair,flare];
right_stem=min(hair if hefty:-2stem_corr fi,left_stem);
outer_jut=.75jut; x1l=l+letter_fit+outer_jut+.25u; x4r=w-x1l; y1=y4=h;
x2-x1=x4-x3; x2l+apex_corr=x3l; y2=y3=-apex_o;
alpha=diag_ratio(2,right_stem,y1-y2,x4r-x1l-apex_corr);
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*right_stem,0);
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
penpos4'(alpha*right_stem,0); penpos5(vair,90);
x5=if serifs: .5[x4',x6r] else:x6r fi; y5r=h+oo;
x6r=hround(r-.35u);
y6=max(vround(y5r-.25tiny-.5flare),
  min(bar_height+.5flare+2vair'+2,.9[bar_height,h]-.5flare)); %zh bulb h
z4'=whatever[z3,z4]; y4'=min(y6-.5hair,8/5bar_height)-eps;
if serifs: penpos6(hair,0); penpos7(flare,0);
 cyrbulb(5,6,7); fi % bulb
if y0>cap_notch_cut: y0:=cap_notch_cut;
 fill z0+.5right{up}...{z4-z3}z4'l...{right}
      if serifs: z5r--z5l
      else:
         (.5[x4,x4r],y5r)--(fine.lft x5r,y5r)..(x5r,fine.bot y5r)--
         (x5l,fine.top y5l)..(fine.lft x5l,y5l) fi
  {left}...z4'r{z3-z4}
  --diag_end(4r,3r,1,1,2l,1l)--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{down}z0+.5left--cycle; % left and right diagonals
else: fill z0--z4'l{z4-z3}...{right}z5r--z5l{left}...{z3-z4}z4'r
  --diag_end(4r,3r,1,1,2l,1l)
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
if serifs: numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2);
 if rt x1'r+jut+.5u+1<=lft x4l-jut+.5tiny: inner_jut=jut;
  else: rt x1'r+inner_jut+.5u+1=lft x4l-inner_jut+.5tiny; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut); fi % left serif
%%%%%
% the accent
lowercase_umlaut(.5[x1,x4]-.5w,0, 8,9,10,11);
penlabels(0,1,2,3,4); endchar;

lhchar "Lowercase Cyrillic letter ligature i_a - iot a";
cyrchar(i_a,9u#,x_height#,0);
italcorr x_height#*slant-serif_fit#+.5stem#-2u#; %d->x_height
adjust_fit(if monospace: 4u# else: 4.75u# fi +serif_fit#,
 serif_fit#);
pickup fine.nib; begingroup
forsuffixes $=hair,stem: shaved$:=mfudged$; save $; $=shaved$; endfor
% a_part of italic_ae;
pickup tiny.nib;
numeric light_stem; light_stem=fudged.stem;
numeric light_vair; light_vair=vair if hefty: -vround 2vair_corr fi;
if light_vair<fine.breadth: light_vair:=fine.breadth; fi
pos1(light_stem,0); pos2(light_stem,0);
penpos6(max(eps,vair-fine),-225); penpos4(curve-fine,-180);
rt x1r=rt x2r=hround(w-2.5u+.5light_stem);
if serifs: top y1=h+min(oo,serif_drop); bot y2=-min(oo,serif_drop);
 else: top y1=h; bot y2=0; fi
y3=2/3bar_height; x6=x1;
y6+vair=hround min(8x_height,h-max(bracket,.5slab))-eps;
penpos5(max(eps,light_vair-fine),-90); penpos3(thin_join-fine,0);
pickup fine.nib; lft x3l=tiny.lft x1l;
lft x4r=hround(1.5u-.5curve); x5=.5[x4,x3];
y4=.3[y5,y1]; bot y5r=-oo;
filldraw stroke z6e{3(x4-x1),y4-y1}...pulled_arc.e(4,5)
 & pulled_arc.e(5,3);  %  bowl of a
pickup tiny.nib;
filldraw stroke z1e--z2e;  % stem
if serifs: sloped_serif.l(1,2,a,1/3,jut,serif_drop);  % upper serif
 sloped_serif.r(2,1,c,1/3,jut,min(oo,serif_drop)); fi % lower serif
% i_part(1);
_zero:=6;
_one:=7; _two:=8; _three:=9; _four:=10;
%
pickup tiny.nib; pos[_one](stem,0); pos[_two](stem,0);
lft x[_one]l=lft x[_two]l=
	l+letter_fit+if not monospace: serif_fit+ fi hround(2.5u-.5stem-eps);
top y[_one]=h; bot y[_two]=0;
filldraw stroke z[_one]e--z[_two]e; % stem
if serifs:
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif([_one],[_two],s,1/3,jut,t,1/3,jut);	% upper stem serif
 slab:=vair; % lower.slab
 dish_serif([_two],[_one],u,1/3,jut,v,1/3,jut); fi % lower stem serif
x[_three]=x[_zero]; x[_four]=x[_one];
y[_three]=y[_four]=y[_zero]; pickup fine.nib;
penpos[_three](.6[thin_join,vair],90);
penpos[_four](.6[thin_join,vair],90); %fi
fill stroke z[_three]e--z[_four]e; % bar
endgroup;
%%%
penlabels(0,1,2,3,4,5,6,7); endchar;

lhchar "Lowercase Cyrillic letter ligature Olg - old soft el (elghe)";
cyrchar(Olg,10u# % if not serifs:+.5width_adj# fi % dl_width;n_width
 ,x_height#,0);
italcorr x_height#*slant-beak_jut#+.25u#; %Gamma->x_height+.5u#
adjust_fit(serif_fit# if not serifs:+.5(stem#-u#) fi, %dl_adj
 if serifs: 2u# else: 3u# fi-.5width_adj#); % old_beak_adj
% lower_l;
pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0);
rt x1r=rt x2r=w-hround (2.5u-.5fudged.stem-eps); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; %stem
numeric light_hair,bot_vair,bulb_diam,left_jut;
light_hair=if hefty:.5[vair,fudged.hair] else: fudged.hair fi;
bot_vair=Vround(.5[vair,light_hair]);
bulb_diam=hround 7/8[hair,flare];
left_jut=
   if serifs: max(limit_dist,1.1jut) else: hround (w+serif_fit-rt x2r-.5u) fi;
x3=1/3[w-rt x1r-(1/8left_jut),rt x1r] if not serifs: -.5(stem-u) fi +eps;
if serifs:
 pos3(light_hair,0); pos4(light_hair,-90);
 pos6(bulb_diam,-180); pos5(hair,-180);
 top y3=h; y6-.5bulb_diam=.12desc_depth-eps; z6r=z5r;
 lft x6r=l+letter_fit+hround(.35u-.5);
 x4=max(lft x5r+.5bulb_diam,.4[lft x5r,rt x3r]);
 bot y4r=-1.5oo-eps; {{less_tense; bulb(4,5,6)}}; %bulb
 filldraw stroke z4e{right}
  ..controls (min(15/16[x4,x3],max(x4,lft x6r+1.75bulb_diam))+(x3e-x3),y4e)
  and (x3e,max(y4l,min(y6-.5,1/3h+eps))+1/3(y4e-y4))..{up}z3e; % left tail
else:
 pos3'(vair,90); pos1'(vair,90);
 lft x3'=x3-.5light_hair; rt x1'=x1r; top y3'r=top y1'r=h;
 filldraw stroke z3'e--z1'e; % upper bar
 pickup fine.nib; pos3(light_hair,0); pos4(bot_vair,-90); pos5(bot_vair,-90);
 bot y5r=0; x4=.67[x3l,x5];
 lft x5=l+letter_fit+hround(.35u-.5); bot y4r=bot y5r; y3=y3';
 filldraw stroke z3e{down}..controls (x3e,y5e+.35h)
  and (min(7/8[x4e,x3e],x4e+2light_hair+eps),y4e-eps)..{left}z4e--z5e; fi % left stem
%%%
if serifs:
 x0=x3; y0=0;
 numeric inner_jut; inner_jut=.5(x1l-x3r)+.5crisp+eps;
 save slab; slab:=vair; % lower.slab
 dish_serif(2,1,a,1/3,jut,b,1/3,jut);          %lower right serif
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 nodish_serif(1,2,c,1/3,inner_jut,d,1/3,.5jut); %!!! %upper right serif
 nodish_serif(3,0,e,1/3,1.05jut,f,1/3,inner_jut); fi % upper left serif
%%%%%
% old lower right beak(2);
pickup if serifs: crisp.nib; else: tiny.nib; fi
pos7(vair,90); top y7r=h; x7=x2; rt x8r=hround(r-.45u);
if serifs: pos8(hair,0); y8=good.y(y7l-beak/1.4)-eps;
 arm(7,8,i,beak_darkness,.4beak_jut);  % upper arm and beak
else: pos8(vair,90); y8=y7;
 filldraw stroke z7e--z8e; % horisontal
 pickup fine.nib; pos9(slab,0); pos10(slab,0);
 rt x9r=rt x10r=tiny.rt x8r; y9=y8r; bot y10=y8l-.7sbeak;
 filldraw stroke z9e--z10e; fi %vertical
%%%
penlabels(1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Lowercase Cyrillic letter ligature Ong - old soft n (enghe)";
cyrchar(Ong,10u# if not serifs:+.5width_adj# fi,x_height#,0);
italcorr x_height#*slant-beak_jut#+.25u#; %Gamma->x_height+.5u#
adjust_fit(serif_fit#,
 if serifs: 2u# else: 3u# fi-.5width_adj#); % old_beak_adj
% 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
 nodish_serif(3,4,e,1/3,inner_jut,f,1/3,.5jut);	%!!! % upper rt 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 rt serif
%%%%%
% old lower right beak(4);
pickup if serifs: crisp.nib; else: tiny.nib; fi
pos7(vair,90); top y7r=h; x7=x4; rt x8r=hround(r-.45u);
if serifs:
 pos8(hair,0); y8=good.y(y7l-beak/1.4)-eps;
 arm(7,8,i,beak_darkness,.4beak_jut);  % upper arm and beak
else:
 pos8(vair,90); y8=y7;
 filldraw stroke z7e--z8e; % horisontal
 pickup fine.nib; pos9(slab,0); pos10(slab,0);
 rt x9r=rt x10r=tiny.rt x8r; y9=y8r; bot y10=y8l-.7sbeak;
 filldraw stroke z9e--z10e; fi %vertical
%%%
penlabels(1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Lowercase Cyrillic letter Oery - old ery";
cyrchar(Oery,9u#,x_height#,0); % v_witdh
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(if serifs: 2u# else: 3u# fi-.5width_adj#, % old_beak_adj
 serif_fit#+4u#);
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
 nodish_serif(1,2,a,1/3,.5jut,b,1/3,.5jut);	% upper serif
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,jut,d,1/3,.5jut); fi	% lower serif
% lsftsn_bowl(2);
_zero:=2;
_one:=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
%%%
% old lower left beak(2);
pickup if serifs: crisp.nib; else: tiny.nib; fi
pos8(vair,90); top y8r=h; x8=x2; lft x9r=l+letter_fit+hround.45u;
if serifs: pos9(hair,180); y9=good.y(y8l-beak/1.4)-eps;
 arm(8,9,i,beak_darkness,-.4beak_jut);  % upper arm and beak
else: pos9(vair,90); y9=y8;
 filldraw stroke z8e--z9e;  % horisontal
 pickup fine.nib; pos10(slab,0); pos11(slab,0);
 lft x10l=lft x11l=tiny.lft x9l; y10=y9r; bot y11=y8l-.7sbeak;
 filldraw stroke z10e--z11e; fi % vertical
% I
w:=w+4u; pickup tiny.nib; rt x12r=rt x13r=w-lft x1l; top y12=h; bot y13=0;
pos12(fudged.stem,0); pos13(fudged.stem,0);
filldraw stroke z12e--z13e; % stem
if serifs:
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(12,13,e,1/3,jut,f,1/3,jut);		% upper serif
 slab:=vair; % lower.slab
 dish_serif(13,12,g,1/3,jut,h,1/3,jut); fi	% lower serif
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13); endchar;

lhchar "Lowercase Cyrillic letter Ohrdsn - old hard sign";
cyrchar(Ohrdsn,9u#,x_height#,0); % v_witdh
italcorr .5x_height#*slant+min(.5curve#-.85u#,-.1u#); %p
adjust_fit(if serifs: 2u# else: 3u# fi-.5width_adj#, % old_beak_adj
 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
 nodish_serif(1,2,a,1/3,.5jut,b,1/3,.5jut);	% upper serif
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,jut,d,1/3,.5jut); fi	% lower serif
% lsftsn_bowl(2);
_zero:=2;
_one:=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
%%%
% old lower left beak(2);
pickup if serifs: crisp.nib; else: tiny.nib; fi
pos8(vair,90); top y8r=h; x8=x2; lft x9r=l+letter_fit+hround.45u;
if serifs: pos9(hair,180); y9=good.y(y8l-beak/1.4)-eps;
 arm(8,9,i,beak_darkness,-.4beak_jut);  % upper arm and beak
else: pos9(vair,90); y9=y8;
 filldraw stroke z8e--z9e;  % horisontal
 pickup fine.nib; pos10(slab,0); pos11(slab,0);
 lft x10l=lft x11l=tiny.lft x9l; y10=y9r; bot y11=y9l-.7sbeak;
 filldraw stroke z10e--z11e; fi % vertical
penlabels(1,2,3,4,5,6,7,8,9,10,11); endchar;

lhchar "Lowercase Cyrillic letter Och - old che";
cyrchar(Och,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#);
pickup tiny.nib; penpos1(fudged.stem,0); penpos2(fudged.stem,0);
penpos3(fudged.stem,0); penpos4(fudged.stem,0);
penpos5(.6[thin_join,vair],90); penpos6(.6[thin_join,vair],-90);
x1l=x2l=hround(2.5u-.5fudged.stem-eps); x3=x4=w-x1;
y1=y3=h; y2=y4=.3[y6,h]; x5=x6=x7=.5[x1,x3]; z5=z6;
y6=good.y (h-.52h if serifs: -.15(.5[hair,.7stem]) fi);
fill z2l--diag_end(2l,1l,1,1,1r,2r)--z2r & pulled_arc.r(2,5) & z5r--z5l
 & pulled_arc.l(5,2) & cycle;
fill z4l--diag_end(4l,3l,1,1,3r,4r)--z4r & pulled_arc.r(4,6) & z6r--z6l
 & pulled_arc.l(6,4) & cycle; %U
pos6'(stem,0); pos7(stem,0); top z6'=z6; bot y7=0;
filldraw stroke z6'e--z7e; % stem
if serifs: pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(3,4);
 numeric inner_jut;
 if rt x1r+jut+.5u+1<=lft x3r-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x3r-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 left serif
 slab:=vair; % lower.slab
 dish_serif(7,6,g,1/3,inner_jut,h,1/3,jut); fi	% lower left serif
penlabels(1,2,3,4,5,6); endchar;

lhchar "Lowercase Cyrillic letter Oshch - old shcha";
cyrchar(Oshch,14u#+.5width_adj#,x_height#,sbeak#);
italcorr x_height#*slant-serif_fit#+jut#-2u#+.5stem#; %d->x_height+jut
adjust_fit(serif_fit#,serif_fit#);
if odd(fudged.stem-w): change_width; fi % symmetric & all three equal
pickup tiny.nib;
pos1(fudged.stem,0); pos2(fudged.stem,0); pos3(fudged.stem,0);
pos4(fudged.stem,0); pos5(fudged.stem,0); pos6(fudged.stem,0);
lft x1l=lft x2l=hround(2.5u-.5fudged.stem-eps); x3=x4=w-x1;
top y1=top y3=h; bot y2=bot y4=0; z5=.5[z1,z3]; z6=.5[z2,z4];
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
filldraw stroke z5e--z6e; % center stem
if serifs: numeric inner_jut;
 if rt x1r+jut+.5u+1<=lft x5l-jut: inner_jut=jut;
  else: rt x1r+inner_jut+.5u+1=lft x5l-inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);	% upper left serif
 dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);	% upper right serif
 dish_serif(5,6,i,1/3,inner_jut,j,1/3,inner_jut); % upper center serif
 inner_jut:=.5(x3l-x5r)+.5crisp+eps;
 slab:=vair; % lower.slab
 nodish_serif(2,1,c,1/3,jut,d,1/3,inner_jut);	% lower left serif
 nodish_serif(6,5,k,1/3,inner_jut,m,1/3,inner_jut); % lower center serif
 nodish_serif(4,3,g,1/3,inner_jut,h,1/3,jut);	% lower right serif
else: lft x2'= lft x2l; bot y2'l=0; pos2'(vair',90);
 rt x4'=rt x4r; y4'=y2'; pos4'(vair',90);
 filldraw stroke z2'e--z4'e; fi
pickup tiny.nib; x7=x6; bot y7=-d;
% middle_serif;
if serifs: numeric light_hair;
 light_hair=min(fudged.stem,fudged.hair if hefty:-4stem_corr fi);
 pos7(light_hair,0);
 filldraw stroke z6e....{down}z7e;
else: pos7(fudged.stem,0); filldraw stroke z6e--z7e; fi
penlabels(1,2,3,4,5,6,7); endchar;

lhchar "Lowercase Cyrillic letter Oo_cdot - old o cdot";
cyrchar(Oo_cdot,10u#,x_height#,0); %f width-u
italcorr .7x_height#*slant;
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi);
penpos1(vair,90); penpos3(vair',-90); penpos2(curve,180); penpos4(curve,0);
if serifs: interim superness:=1.05 superness;
 else: interim superness:=1.075 superness; fi
x2r=hround max(.5u,1.25u-.5curve);
x4r=w-x2r; x1=x3=.5w; y1r=h+vround 1.5oo; y3r=-oo;
y2=y4=.5h-vair_corr; y2l:=y4l:=.52h;
penstroke pulled_arc.e(1,2)
 & pulled_arc.e(2,3) & pulled_arc.e(3,4) & pulled_arc.e(4,1) & cycle;  % bowl
% dot
pickup tiny.nib;
dot_diam:=min((lft x4l-rt x2l)-1,
 max(tiny.breadth,hround(max(dot_size,cap_curve)-2stem_corr)));
pos5(dot_diam,0); pos5'(dot_diam,90);
z5=z5'; x5=x1; y5=.5[y1,y3]; dot(5,5'); % dot
penlabels(1,2,3,4); endchar;

lhchar "Lowercase Cyrillic letter Oo_cddot - old o double cdot";
cyrchar(Oo_cddot,11u#,x_height#,0); %f width - eps
italcorr .7x_height#*slant;
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi);
penpos1(vair,90); penpos3(vair',-90); penpos2(curve,180); penpos4(curve,0);
if serifs: interim superness:=1.05 superness;
 else: interim superness:=1.075 superness; fi
x2r=hround max(.5u,1.25u-.5curve);
x4r=w-x2r; x1=x3=.5w; y1r=h+vround 1.5oo; y3r=-oo;
y2=y4=.5h-vair_corr; y2l:=y4l:=.52h;
penstroke pulled_arc.e(1,2)
 & pulled_arc.e(2,3) & pulled_arc.e(3,4) & pulled_arc.e(4,1) & cycle;  % bowl
% dots
_one:=5; _two:=6; _three:=7; _four:=8;
dot_diam:=min(.5(lft x4l-rt x2l)-1,
 max(tiny.breadth,hround(max(dot_size,cap_curve)-2stem_corr)));
pickup tiny.nib;
pos[_one](dot_diam,0); pos[_two](dot_diam,90);
x[_one]=x[_two]=.5w-1.375u; y[_one]=y[_two]=.5[y1,y3];
dot([_one],[_two]);  % left dot
pos[_three](dot_diam,0);
penpos[_four](y[_two]r-y[_two]l,90);
y[_three]=y[_four]=y[_one]; x[_three]=x[_four]=x[_one]+2.75u;
dot([_three],[_four]);  % right dot
penlabels(1,2,3,4); endchar;

lhchar "Lowercase Cyrillic letter Oe - old e narrow (C with mid-line)";
cyrchar(Oe,7u#,x_height#,0); % eng
italcorr x_height#*slant-.2u#;
adjust_fit(if monospace: .5u#,-1.5u# else: 0,-u# fi);
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+2vair'+2,.9[bar_height,h]-flare);
 pos5(hair,0); rt x1r=rt x5r=hround(w-.5u);
 y5=max(good.y(.5bar_height-.9),y4l+vair');
 (x,y4l)=whatever[z4r,z5l]; x4l:=min(x,x4l+.5u);
 x6r=x6l+(x1r-x1l)=.5[x2r,x1r]+eps; x7r=x7l+(x5r-x5l)=.5[x4r,x5r]+eps;
 forsuffixes e=l,r: path pt.e,pb.e; numeric tt.e,tb.e;
  pt.e=z1e{x2-x1,5(y2-y1)}...{left}z2e;
  pb.e=z4e{right}..tension .9 and 1..{x5-x4,5(y5-y4)}z5e;
  tt.e=ypart(((x6e,0)--(x6e,h)) intersectiontimes pt.e);
  tb.e=ypart(((x7e,0)--(x7e,h)) intersectiontimes pb.e); endfor
 filldraw stroke subpath(tt.e,1) of pt.e &
  pulled_super_arc.e(2,3)(.7superpull) & pulled_super_arc.e(3,4)(.5superpull)
  & subpath(0,tb.e) of pb.e;  % arc and lower terminal
else: pos1(4/7[vair',flare],80);
 rt x1r=hround(w-.6u); top y1r=vround .82[bar_height,top y2r];
 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;
 x6r=x6l+.7(x1r-x1l)=.5[x2r,x1r]+eps; x7r=x7l+.7(x5r-x5l)=.5[x4r,x5r]+eps;
 forsuffixes e=l,r: path p.e,pt.e; numeric tt.e,tb.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
  pt.e=term.e(2,1,right,.8,4); % upper terminal
  tt.e=ypart(((x6e,0)--(x6e,h+o+eps)) intersectiontimes pt.e);
  tb.e=ypart(((x7e,0)--(x7e,h+o+eps)) intersectiontimes p.e); endfor
 filldraw stroke subpath(0,tt.e) of pt.e;  % upper terminal
 filldraw stroke pulled_super_arc.e(2,3)(.7superpull)
  & pulled_super_arc.e(3,4)(.5superpull) & subpath(0,tb.e) of p.e; fi  % arc and lower terminal
% hstroke
bar_stroke(x3l,0.85[x3l,x7l]-eps); %bar
penlabels(1,1',2,3,4,5,6,7,8,9); endchar;

lhchar "Lowercase Cyrillic letter Ou - old u";
cyrchar(Ou,if serifs:9.5u# else:9u# fi,x_height#,desc_depth#);
italcorr x_height#*slant+.25u#;
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ serif_fit#);
%letter_old_u;
numeric left_stem,right_stem,bot_stem,bot_vair,outer_jut;
left_stem=fudged.stem-stem_corr; right_stem=fudged.hair if hefty:-2stem_corr fi;
bot_stem=fudged.hair if hefty:-8stem_corr fi;
bot_vair=Vround(if serifs: vair else:.5[vair,bot_stem] fi); outer_jut=.75jut;
x1l=w-x4r=l+letter_fit+outer_jut+.25u; y1=y4r=h; y2=y3=0; x2l=x3l;
numeric alpha,alpha[]; x9=3u; y9=bot_vair-d-oo;
alpha1=diag_ratio(2,bot_stem,y1-y3,x4r-x1l-apex_corr);
alpha2=diag_ratio(1,bot_stem,y1-y9,x4r-x9);
if alpha1<alpha2: x2l-x1l=x4r-x3r+apex_corr; alpha=alpha1;
else: alpha=alpha2; z3l=whatever[z9,z4r-(alpha*bot_stem,0)]; fi
penpos3(alpha*bot_stem,0); penpos4(alpha*right_stem,0);
alpha3=(y1++(x2l-x1l))/y1;
penpos1(alpha3*left_stem,0); penpos2(alpha3*left_stem,0);
z0=whatever[z1r,z2r]=z4l+whatever*(z3r-z4r);
if y0>notch_cut: y0:=notch_cut;
 fill z0+.5right{up}...{z4r-z3r}diag_end(0,4l,1,1,4r,3r)
  --z3r--z2l--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{down}z0+.5left--cycle; % left and right diagonals
else: fill z0--diag_end(0,4l,1,1,4r,3r)--z3r--z2l
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
penpos5(alpha*bot_stem,0); z5r=whatever[z3r,z4r]; bot y5=-d;
if serifs: fill stroke z3e---z5e; % straight arc
 numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(4,3); prime_points_inside(5,3);
 if rt x1'r+jut+.5u+1<=lft x4'l-jut: inner_jut=jut;
 else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut);	% left serif
 dish_serif(4',3,c,.6,inner_jut,d,1/2,outer_jut)(dark);	% right serif
 slab:=vair; % lower.slab
 dish_serif(5',3,e,1/2,jut,f,.6,jut)(dark);	% lower serif
else:
 fill z3r---diag_end(3r,5r,.75,.75,5l,3l)---z3l--cycle; fi % straight arc
penlabels(0,1,2,3,4,5,6,7,8,9); endchar;

lhchar "Lowercase Cyrillic letter On - old en";
cyrchar(On,10u#+width_adj#,x_height#,0); % n_width
italcorr x_height#*slant-beak_jut#-.25u#;
adjust_fit(serif_fit#,serif_fit#);
numeric thin_stem; thin_stem=hround(fudged.hair+stem_corr);
pickup tiny.nib; pos1(thin_stem,0); pos2(thin_stem,0);
pos3(thin_stem,0); pos4(thin_stem,0);
pickup tiny.nib; top y1=top y3=h; bot y2=bot y4=0;
x1=x2; x3=x4; x1l=w-x3r;
rt x3r=hround min(w-2u,w-3u+.5fudged.stem);
filldraw stroke z1e--z2e; % left stem
filldraw stroke z3e--z4e; % right stem
if hefty: penpos5(fudged.stem,0); penpos6(fudged.stem,0);
 x5l=x1; x6r=x4; y5=h; y6=0;
 numeric upper_notch,lower_notch;
 upper_notch=h-notch_cut; lower_notch=notch_cut;
 x1'=rt x1r; z1'=whatever[z5l,z6l]; x4'=lft x4l; z4'=whatever[z5r,z6r];
 fill z5l..
  if y1'<upper_notch: {right}(x1'+1,upper_notch){down}... fi
  {z6-z5}diag_in(5l,6l,1,6r)--z6r..
  if y4'>lower_notch: {left}(x4'-1,lower_notch){up}... fi
  {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonal
else: penpos5(whatever,0); penpos6(whatever,90);
 z5l=z1l; z6l=z4l;
 z7=z6l+(max(eps,stem-3stem_corr-tiny),0) rotated (angle(z5l-z6l)-90);
 z5r=z7+whatever*(z5l-z6l); z6r=z7+whatever*(z5l-z6l);
 filldraw stroke z5e..z6e; fi  % diagonal
if serifs:
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 if hefty: serif(1,2,a,1/3,-jut);	% upper left serif
  else: serif(5,6,a,1/3,-jut); fi	% upper left serif
 dish_serif(3,4,e,1/2,jut,f,1/2,jut)(dark); % upper right serif
 slab:=vair; % lower.slab
 dish_serif(2,1,b,1/2,jut,c,1/2,jut)(dark); fi % lower left serif
penlabels(1,1',2,3,4,4',5,6,7); endchar;

% like tilded o
lhchar "Lowercase Cyrillic letter Vfita - variant fita";
cyrchar(Vfita,9u#,x_height#,0);
italcorr .7x_height#*slant;
adjust_fit(if monospace: .5u#,.5u# else: 0,0 fi);
% lower_o;tld
penpos1(vair,90); penpos3(vair',-90); penpos2(curve,180); penpos4(curve,0);
x2r=hround max(.5u,1.25u-.5curve);
x4r=w-x2r; x1=x3=.5w; y1r=h+vround 1.5oo; y3r=-oo;
y2=y4=.5h-vair_corr; y2l:=y4l:=.52h;
penstroke pulled_arc.e(1,2) & pulled_arc.e(2,3)
 & pulled_arc.e(3,4) & pulled_arc.e(4,1) & cycle;  % bowl
%%%
% oltilde;
if (serifs=true) and (bar#<=.5curve#):
   numeric bar[];
   set_bar_axis;
   x5r=x2l; x6r=x4l;
   y5r=y6r=y2.bh; y5l=y6l=y1.bh; x5r=x5l; x6l=x6r;
   bar2=2/3[bar,fudged.stem];
   penpos7(bar2,45); z7=.5[z5l,z6l];
   fill stroke z6e{-2,-1}..{-2,1}z7e..{-2,-1}z5e;
else:
   bar_stroke(x2,x4);
fi
%%%%%
penlabels(1,2,3,4); endchar;

lhchar "Lowercase Cyrillic letter Vkoppa - Variant koppa (c with tail)";
cyrchar(Vkoppa,8u#,x_height#,sbeak#);
italcorr x_height#*slant-.2u#;
adjust_fit(if monospace: .5u#,.5u# else: -.1u#,0 fi);
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;
if serifs: pickup tiny.nib; pos0(stem,0); pos7(stem,0);
 rt x0r=rt x1r+eps; x7=x0; pickup fine.nib;
 bot y7=-d; x5=x0; top y5=tiny.top y0;
 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); top y5=vround .75bar_height;
 (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
 pickup tiny.nib; filldraw stroke z0e--z7e;  % stem
 save slab; slab:=Vround(vair-vair_corr); % lower.slab
 serif(0,7,a,1/3,-max(jut,1.5u));	% upper stem serif
 slab:=vair; % lower.slab
 dish_serif(7,0,c,1/3,jut,d,1/3,.7jut);	% lower stem serif
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
 pos0(fudged.stem,0); pos7(fudged.stem,0);
 x7r=x5r; y7=-d; x0=x7; top y0=vround bar_height;
 filldraw stroke z0e--z7e;  % stem
 pos8(vair',90); pos9(vair',90); z0r=z9r; y8=y9; lft x8=hround x4;
 filldraw stroke z8e--z9e; fi  % bar
penlabels(0,1,2,3,4,5,6,7,8,9); endchar;
