%
% lgslavu.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:
%
% Uppercase Old Slav letters included in Unicode
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% List of letternames and their codes in Unicode
%
% OMGA          "60
% I_E           "64
% L_YUS         "66
% IL_YUS        "68
% IB_YUS        "6c
% KSI           "6e
% PSI           "70
% FITA          "72
% IZH_dgr       "74
% UK            "76
% OMGA_rnd      "78
% OMGA_tlo      "7a
% OT            "7c
% KOPPA         "7e
%

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

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

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

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

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

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

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

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

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

%WNCYR shape
lhchar "Uppercase Cyrillic letter FITA (looks like Theta)";
cyrchar(FITA,14u#,cap_height#,0);
if is_small_cap: getcharcode(fita); fi
italcorr .7cap_height#*slant-.5u#;
adjust_fit(0,0);
numeric light_curve; light_curve=hround(cap_curve-2stem_corr);
penpos1(vair,90); penpos3(vround(vair+.5vair_corr),-90);
penpos2(light_curve,180); penpos4(light_curve,0);
if monospace: x2r=hround min(3u,.5u+1.5hair+eps);
 interim superness:=sqrt superness;  % make |"O"|, not |"0"|
else: x2r=hround 2.5u; fi
x4r=w-x2r; x1=x3=.5w; y1r=h+o; y2=y4=.5h-vair_corr; y3r=-o;
penstroke pulled_super_arc.e(1,2)(.5superpull)
 & pulled_super_arc.e(2,3)(.5superpull)
 & pulled_super_arc.e(3,4)(.5superpull)
 & pulled_super_arc.e(4,1)(.5superpull) & cycle;  % bowl
% fita_bar;
pickup crisp.nib; pos5(cap_vstem,90); pos6(cap_vstem,90);
lft x5=w-rt x6=hround.5u; y5=y6=.5[y1l,y3l];
filldraw stroke z5e--z6e;  % bar
% bar serifs;
if serifs: pos7(hair,0); pos8(hair,0); pos9(hair,0); pos10(hair,0);
 x7l=x8l=x5; x9r=x10r=x6;
 y7=y5r; y9=y6r; y5l-y8=y6l-y10=vround .075h;
 filldraw stroke z7e--z8e;  % left serif
 filldraw stroke z9e--z10e; fi  % right serif
penlabels(1,2,3,4,5,6,7,8,9,10); endchar;

% for shape, see Knizhnay Shrift p 58  Bodoni, Parma 1818
lhchar "Uppercase Cyrillic letter IZH_dgr - IZHITSA double grave";
cyrchar_twice(IZH_dgr,13u#,cap_height#+acc_height#,0);
if is_small_cap: getcharcode(izh_dgr); fi
italcorr cap_height#*slant+.25u#;
adjust_fit(cap_serif_fit#,
 if serifs: min(1.5u#,.5u#+(flare#+(cap_stem#-stem#))) %ccL_adj
 else:.5u#fi);
full_h:=h; h:=cap_height;
% upper_izh;
numeric left_stem,right_stem,outer_jut,alpha;
left_stem=cap_stem-stem_corr;
right_stem=min(cap_hair if hefty:-2stem_corr fi,left_stem);
outer_jut=.75cap_jut; x1l=w-x4r=l+letter_fit+outer_jut+.25u; 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];
x6=if serifs:.5[x5,x7r] else:x7r fi;
penpos6(vair,90); y6r=h if serifs:+o fi;
penpos5(alpha*right_stem,0);
y5=min(.9cap_height,bot y6l-.5vair); z5=whatever[z3,z4];
x7r=hround(r-.5u); penpos7(hair,0);
y7=h-vround max(.05fig_height+.5flare,.1fig_height-.5flare)+o; z8r=z7r;
penpos8(flare,0); if serifs: cyrbulb(6,7,8); fi
if y0>cap_notch_cut: y0:=cap_notch_cut;
 fill z0+.5right{up}...{z4-z3}z5l...{right}
      if serifs: z6r--z6l
      else:
         (.5[x4,x4r],y6r)--(fine.lft x6r,y6r)..(x6r,fine.bot y6r)--
         (x6l,fine.top y6l)..(fine.lft x6l,y6l) fi
  {left}
  ....z5r{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--z5l{z4-z3}...{right}z6r--z6l{left}...{z3-z4}z5r
  --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+cap_jut+.5u+1<=x4l-cap_jut: inner_jut=cap_jut;
  else: rt x1'r+inner_jut+.5u+1=x4l-inner_jut; fi
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut); fi % left serif
%%%%%
% the accent
if monospace:
 hpos_corr=-2u; put_gravis(cyrcaph);
 hpos_corr=2u; put_gravis(cyrcaph);
else: hpos_corr=-1.5u; put_gravis(cyrcaph);
 hpos_corr=1.5u; put_gravis(cyrcaph); fi
repeat_once;
penlabels(0,1,2,3,4,5,6,7); endchar;

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

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

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

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

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