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

% List of letternames and their codes in T2
%
%                X2      T2A  T2B  T2C
%
% ae            "61  a   "ac   -    -    Ligature AE
% tshe          "62  b   "a2   -    -    Tshe
% dje           "63  c   "a3   -    -    Dje
% abh_ch        "64  d    -    -   "b1   Abkhasian che (same as lower e with hook)
% abh_ch_dsc    "65  e    -    -   "b2   Abkhasian che descender
% k_vcrs        "66  f   "ab   -    -    Ka vertically crossed
% k_hcrs        "67  g    -    -   "ab   Ka horisontally crossed
% l_dsc         "68  h    -   "aa  "aa   El with descender
% lat_i         "69  i    -    -    -    Latin letter I (goes first for LH font)
% lat_j         "6a  j    -    -    -    Je - Latin letter J
% lje           "6b  k   "a7  "a8   -    Lje
% m_dsc         "6c  l    -    -   "a8   Em with descender
% nje           "6d  m   "bb  "b9   -    Nje
% abh_ha        "6e  n    -    -   "b7   Abkhasian kha
% p_tl          "6f  o    -    -   "a0   Pe with tail
%
% r_dsc         "70  p    -    -   "a5   Er with descender
% lat_q         "71  q    -    -    -    Latin letter Q
% t_dsc         "72  r    -    -   "a2   Te with descender
% lat_s         "73  s   "af   -    -    Dze - Latin letter S
% tetse         "74  t    -    -   "a1   Ligature Te-Tse
% dzhe          "75  u   "b6   -   "b6   Dzhe
% ch_vcrs       "76  v   "b7   -    -    Che vertically crossed
% lat_w         "77  w    -    -    -    Latin letter W
% yat           "78  x    -    -   "b3   Yat
% b_yus         "79  y    -    -   "bb   Big Yus
% izh           "7a  z    -    -   "b4   Izhitsa
%
% n_ltl         "1d       -    -   "b9   En with left tail
% delta         "1f       -   "a6   -    Delta
% m_tl           -        -    -   "ae   Em with tail
% r_gcrs         -        -    -   "a6   Er crossed
% s_acrs         -        -    -   "b1   Es crossed
% g_crsdsc       -        -   "a0   -    Ghe crossed with descender
% h_hcrs         -        -   "b4   -    Kha horisontally crossed
%

LHver_check(3,2);

% Latin I goes first for LH font
lhchar "Italic Cyrillic letter lat_i - Ukrainian letter i (as latin i)";
cyrchar(lat_i,5u#,min(asc_height#,10/7x_height#+.5flare#),0);
italcorr max(1/3x_height#*slant+.5hair#+.5u#,h#*slant+.5flare#-2u#); %i
adjust_fit(if monospace:u#,u# else: 0,0 fi); pickup fine.nib;
x0=0; x5=w; x2=.5w+.25u; x3=.5w-.25u;
hook_in(0,1,2)(skewed); hook_out(3,4,5)(skewed);  % hooks
filldraw stroke z2e--z3e;  % stem
pos8(flare,0); pos9(flare,90);
x8=.5w if not monospace:-.4(h-x_height)*slant fi; top y9r=h+1;
if bot y9l-top y1<slab: y9l:=min(y9r-eps,y1+fine+slab); fi
x8=x9; y8=.5[y9l,y9r]; dot(8,9);  % dot
penlabels(0,1,2,3,4,5,8,9); endchar;

if not more_letters: endinput \\; fi

iff knuthian_ae:%
lhchar "Italic Cyrillic letter ae - ligature ae";
cyrchar(ae,13u#,x_height#,0);
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#);
adjust_fit(if monospace:-u#,-u# else: 0,0 fi); pickup fine.nib;
forsuffixes $=hair,stem: shaved$:=mfudged$; save $; $=shaved$; endfor
%numeric heavy_hair; heavy_hair=hround .2[hair,stem];%defined in lxpseudo
numeric light_stem; light_stem=hround .75[hair,stem];
pos0(vair,-90); pos1(heavy_hair,0); pos2(vair,90);
pos3(light_stem,180); pos4(vair,270); pos5(hair,320);
x0=rt x3l; rt x1r=hround(w-1.5u+.5heavy_hair); x2=x4=.5(w+6u);
lft x3r=hround(.5w-.5light_stem); x5r=good.x(w-.5u); x6=x5;
y0=y3=y6=bar_height; y1=.5[y0,y2]; top y2r=h+oo; bot y4r=-oo;
top y5l=vround(.5bar_height+.5); path p; p=z4{right}..z5..z6;
filldraw stroke z0e{right}...z1e{up}...pulled_arc.e(2,3)
 & pulled_arc.e(3,4)...{direction 1 of p}z5e;  % arc of e
pos7(light_stem,0); pos8(light_stem,0);
x7=x8=x3; y7+.5light_stem=h+oo; y8-.5light_stem=-oo;
pos7'(vair,-225); pos11(curve,-180); z7'=z7;
pos12(vair,-90); pos3'(hair,0); z3'=z3;
lft x11r=hround(1.5u-.5curve); x12=.5[x11,x3];
y11=.3[y12,y7]; bot y12r=-oo;
filldraw stroke z7'e{3(x11-x7),y11-y7}...pulled_arc.e(11,12)
 & pulled_arc.e(12,3');  %  bowl of a
filldraw z7l---z8l..z8r---z7r..cycle;  % stem
penlabels(0,1,2,3,4,5,6,7,8,11,12); endchar;

iff not knuthian_ae: % borrowed from ec
lhchar "Italic Cyrillic letter ae - ligature ae";
cyrchar(ae,13u#,x_height#,0);
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#);
adjust_fit(if monospace:-u#,-u# else: 0,0 fi); pickup fine.nib;
forsuffixes $=hair,stem: shaved$:=mfudged$; save $; $=shaved$; endfor
numeric light_stem; light_stem=hround .75[hair,stem];
pos0(vair,-90); pos1(heavy_hair,0); pos2(vair,90);
pos3(light_stem,180); pos4(vair,270); pos5(hair,320);
x0=rt x3l; rt x1r=hround(w-1.5u+.5heavy_hair); x2=x4=.5(w+6u);
lft x3r=hround(.5w-.5light_stem); x5r=good.x(w-.5u); x6=x5;
y0=y3=y6=bar_height; y1=.5[y0,y2]; top y2r=h+oo; bot y4r=-oo;
top y5l=vround(.5bar_height+.5); path p; p=z4{right}..z5..z6;
filldraw stroke z0e{right}...z1e{up}...pulled_arc.e(2,3)
 & pulled_arc.e(3,4)...{direction 1 of p}z5e;  % arc of e
pos7(light_stem,0);
x7=x3; y7+.5light_stem=h+oo;
pos7'(vair,-225); pos10(vair,-270);
pos11(curve,-180); z7'=z7;
pos12(vair,-90); pos3'(hair,0); z3'=z3;
lft x11r=hround(1.5u-.5curve); x10=x12=.5[x11,x3];
top y10r=h+oo; y11=.52h; bot y12r=-oo;
filldraw stroke pulled_arc.e(3',10) & pulled_arc.e(10,11)
 & pulled_arc.e(11,12) & pulled_arc.e(12,3');  %  bowl of a
filldraw z7l---z3r..z3l---z7r..cycle;  % stem
penlabels(0,1,2,3,4,5,6,7,10,11,12); endchar;

lhchar "Italic Cyrillic letter tshe (soft t - looks like barred h)";
cyrchar(tshe,9u#,asc_height#,0);
italcorr 1/3x_height#*slant+.5hair#+.5u#; %h
adjust_fit(1.5u#,0); pickup tiny.nib;
pos1(stem,0); pos2(stem,0); x1=x2;
lft x1l=hround(1.5u-.5stem); top y1=h; y2-.5stem=-oo;
filldraw circ_stroke z2e--z1e;  % left stem
sloped_serif.l(1,2,a,1/3,jut,serif_drop);  % serif
pickup fine.nib; x4+.5stem=hround(w-2.5u+.5stem);
x5=x4-.25u; ital_arch(2,3,4);  % arch
x7=w; hook_out(5,6,7)(skewed);  % closing hook
filldraw stroke z4e{down}..{-u,-x_height}z5e;  % right stem
% hcross
pickup crisp.nib; pos8(bar,90); pos9(bar,90);
top y8r=top y9r=vround (min(.5[x_height,h]+.5bar,h-max(bracket,1.2slab))-eps);
lft x8=hround(l+letter_fit-.75u); x9=x4;
filldraw stroke z8e--z9e; % cross bar
penlabels(1,2,3,4,5,6,7,8,9); endchar;

lhchar "Italic Cyrillic letter dje (soft dj - barred h with tail)";
cyrchar(dje,8u#,asc_height#,desc_depth#);
italcorr (.5x_height#+.5asc_height#)*slant-2u#+.5
	if hefty:stem# else:rule_thickness# fi; %] to cross height
italcorr .7x_height#*slant; %o
adjust_fit(1.5u#,0); pickup tiny.nib;
pos1(stem,0); pos2(stem,0); x1=x2;
lft x1l=hround(1.5u-.5stem); top y1=h; y2-.5stem=-oo;
filldraw circ_stroke z2e--z1e;  % left stem
sloped_serif.l(1,2,a,1/3,jut,serif_drop);  % serif
pickup fine.nib; x4+.5stem=hround(w-.75u+.5stem);
x5=x4; ital_arch(2,3,4);  % arch
pos7(hair,-90); x7=.45[x2,x4]; bot y7r=-d;
filldraw stroke pulled_arc.e(4,7); % tail
% hcross
pickup crisp.nib; pos8(bar,90); pos9(bar,90);
top y8r=top y9r=vround (min(.5[x_height,h]+.5bar,h-max(bracket,1.2slab))-eps);
lft x8=hround(l+letter_fit-.75u); x9=x4;
filldraw stroke z8e--z9e; % cross bar
penlabels(1,2,3,4,5,6,7,8,9); endchar;

lhchar "Italic Cyrillic letter abh_ch - lower e hook";
cyrchar(abh_ch,8u#,x_height#,0);
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#);
adjust_fit(max(2u#,1.5u#+.5flare#),0);
% ital_e;
pickup fine.nib; %numeric heavy_hair; heavy_hair=hround .2[hair,stem];%defined in lxpseudo
pos0(vair,-90); pos1(heavy_hair,0); pos2(vair,90);
pos3(curve,180); pos4(vair,270); pos5(hair,320);
x0=rt x3l; rt x1r=hround(w-1.5u+.5heavy_hair); x2=x4=.5(w+u);
lft x3r=hround(1.5u-.5curve); x5r=good.x(w-eps); x6=x5;
y0=y3=y6=bar_height; y1=.5[y0,y2]; top y2r=h+oo; bot y4r=-oo;
top y5l=vround .5bar_height; path p; p=z4{right}..z5..z6;
filldraw stroke z0e{right}...z1e{up}...pulled_arc.e(2,3)
 & pulled_arc.e(3,4)...{direction 1 of p}z5e;  % arc
% bulb
y7=y3; x7=x3r; pos7(vair,-90); y9=.5[y3,y2];
lft x9r=l+letter_fit+hround (.5u-.5); %l+.5u;
pos9(flare,-180); z8r=z9r; pos8(hair,-180);
cyrbulb(7,8,9);
penlabels(1,2,3,4,5,6,7,8,9); endchar;

lhchar "Italic Cyrillic letter abh_ch_dsc - lower e hook ogonek";
cyrchar(abh_ch_dsc,8u#,x_height#,desc_depth#);
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#);
adjust_fit(max(2u#,1.5u#+.5flare#),0);
% ital_e;
pickup fine.nib;
%numeric heavy_hair; heavy_hair=hround .2[hair,stem];%defined in lxpseudo
pos0(vair,-90); pos1(heavy_hair,0); pos2(vair,90);
pos3(curve,180); pos4(vair,270); pos5(hair,320);
x0=rt x3l; rt x1r=hround(w-1.5u+.5heavy_hair); x2=x4=.5(w+u);
lft x3r=hround(1.5u-.5curve); x5r=good.x(w-eps); x6=x5;
y0=y3=y6=bar_height; y1=.5[y0,y2]; top y2r=h+oo; bot y4r=-oo;
top y5l=vround .5bar_height; path p; p=z4{right}..z5..z6;
filldraw stroke z0e{right}...z1e{up}...pulled_arc.e(2,3)
 & pulled_arc.e(3,4)...{direction 1 of p}z5e;  % arc
% bulb
y7=y3; x7=x3r; pos7(vair,-90); y9=.5[y3,y2];
lft x9r=l+letter_fit+hround (.5u-.5); %l+.5u;
pos9(flare,-180); z8r=z9r; pos8(hair,-180);
cyrbulb(7,8,9);
% descender-ogonek
 path p.r; p.r=pulled_arc.r(3,4)...{direction 1 of p}z5r;
 def the_pen=
     if known ogonek_pen: ogonek_pen else: fine fi
 enddef;
 ogonek_breadth:=xvair;
 numeric tt; % the time...
 tt=if hefty: 2.8 else: 2.6 fi+eps;
 join_angle=angle((direction tt of p.r) rotated 180);
 ogonek_pos=point tt of p.r+.5(the_pen-fine)*
    unitvector((direction tt of p.r) rotated 90)-(ogonek_breadth-the_pen,0);
easy_ogonek(the_pen,10,11,12); % ogonek
penlabels(1,2,3,4,5,6,7,8,9, 10,11,12); endchar;

lhchar "Italic Cyrillic letter k_vcrs - ka vcrossed";
cyrchar(k_vcrs,10u#,x_height#,0); %k+2u
italcorr x_height#*slant;
adjust_fit(if monospace:-1.5u# else: 0 fi,0);
pickup fine.nib; x2-.5stem=hround(2.5u-.5stem);
%ihalfstem;
if monospace:
 pos2(stem,0); top y2=h;
else:
 x0=0; hook_in(0,1,2); fi % opening hook
z2'=z2; pos2'(stem,0); x11=x2'; y11-.5stem=-oo; pos11(stem,0);
filldraw circ_stroke z11e--z2'e;  % left stem
pos3(vair,90); pos3'(vair,90); x3=x11; y3=y3'=bar_height; x3'=.5[x11,x7];
pos4(vair,90); x4=w-2u; top y4r=x_height+oo;
pos5(hair,0); pos6(flare,0);
rt x5r=hround(w-.5u); y5+.5flare=vround(bot y4l-.03x_height);
pos7(stem,0); pos8(vair,90); pos9(hair,180);
x9+.5hair=hround(w+.5hair-eps); y9=1/3x_height;
lft x7l=hround(w-2.75u-.5stem); y7=1/2y3; x8=w-1.2u; bot y8l=-oo;
filldraw stroke z3e{right}--z3'e{right}..{right}z4e;  % upper diagonal
bulb(4,5,6);  % bulb
filldraw stroke z3e{right}--z3'e{right}...z7e{down}
 ...z8e{right}...{up}z9e;  % lower diagonal
% vcross
pickup fine.nib; numeric middle_weight;
middle_weight=max(fine.breadth,.6[thin_join,vair]);
pos10(middle_weight,0); pos12(middle_weight,0);
lft x10l=lft x12l=hround(max(x3',.5[x3,x3'])-.5middle_weight+eps);
top y12-bot y10=.5x_height; .52[y10,y12]=y3;
filldraw stroke z10e--z12e;
penlabels(1,2,3,4,5,6,7,8,9); endchar;

lhchar "Italic Cyrillic letter k_hcrs - ka hcrossed";
cyrchar(k_hcrs,8u#,asc_height#,0);
italcorr x_height#*slant;
adjust_fit(0,0);
% ital_k;long stem
pickup tiny.nib; pos1(stem,0); pos2(stem,0); x1=x2;
lft x1l=hround(1.5u-.5stem); top y1=h; y2-.5stem=-oo;
filldraw circ_stroke z2e--z1e;  % left stem
sloped_serif.l(1,2,a,1/3,jut,serif_drop);  % serif
pickup fine.nib; pos3(vair,90); x3=x1; y3=bar_height;
pos4(vair,90); x4=w-2u; top y4r=x_height+oo;
filldraw stroke z3e{right}..{right}z4e;  % upper diagonal
pos5(hair,0); pos6(flare,0);
rt x5r=hround(w-.5u); y5+.5flare=vround(bot y4l-.03x_height);
bulb(4,5,6);  % bulb
pos7(stem,0); pos8(vair,90); pos9(hair,180);
x9+.5hair=hround(w+.5hair-eps); y9=1/3x_height;
lft x7l=hround(w-2.75u-.5stem); y7=1/2y3; x8=w-1.2u; bot y8l=-oo;
filldraw stroke z3e{right}...z7e{down}
 ...z8e{right}...{up}z9e;  % lower diagonal
% hcross
pickup crisp.nib; numeric outer_jut;
outer_jut=max(limit_dist,1.1jut);
pos10(bar,90); pos11(bar,90);
top y11r=top y10r=vround (min(.5[x_height,h]+.5bar,h-max(bracket,1.2slab))-eps);
x11=x1r+1.15outer_jut; lft x10=hround-.75u;
filldraw stroke z10e--z11e; % cross bar
penlabels(1,2,3,4,5,6,7,8,9, 10,11); endchar;

lhchar "Italic Cyrillic letter l_dsc - el descender";
cyrchar(l_dsc,9u#,x_height#,desc_depth#);
italcorr 1/3x_height#*slant+.5hair#+.5u#;
adjust_fit(.5u#,.1u#); %iserif_adj
% ital_l;dsc
pickup fine.nib;
pos1(vair,-90); pos2(stem,180); pos3(hair,0); pos10(stem,0);
pos4(vair,-90); pos5(hair,-180); pos6(flare,-180);
top y1l=h+oo; x1=.5[x3,x2];
x3=3u; y3=.35h;
y6-.5flare=.1h; lft x6r=-.25u; z5r=z6r;
bot y4r=-oo; x4=max(.4[lft x6r,rt x3r],lft x6r+.5flare-eps);
y10=.8h; lft x10l=lft x7l=hround(w-2.5u-.5stem); z10=z2;
bulb(4,5,6); % bulb
filldraw stroke pulled_arc.e(4,3)
 & super_arc.e(3,1) & super_arc.e(1,2); % left stem
pos8(vair,90); pos9(vair,180); pos7(stem,0);
x9=w; y9=y7=.4bar_height; x8=.5[x7,x9]; bot y8l=-oo;
filldraw circ_stroke z7e{-.5u,-x_height}...z8e{right}...{up}z9e; %closing hook
filldraw stroke z10e--z7e;  % stem tail
%%%
% italic descender/ogonek
if is_ogonek:
   def the_pen=
       if known ogonek_pen: ogonek_pen else: fine fi
   enddef;
   path p.l;
   p.l=z7l{-.5u,-x_height}...z8l{right}...{up}z9l;
   ogonek_breadth:=xvair;
   ogonek_pos=point .9 of p.l;
   easy_ogonek(the_pen,11,12,13); % ogonek
else:
   i_serif(9,x);
fi
penlabels(1,1',2,3,4,5,6,7,8,9,10, 11,12,13); endchar;

% Latin I goes first for LH font

lhchar "Italic Cyrillic letter lat_j (as latin j)";
cyrchar(lat_j,5u#,min(asc_height#,10/7x_height#+.5flare#),desc_depth#);
italcorr h#*slant+.5stem#-u#; %j
adjust_fit(if monospace:2u#,.5u# else: 0,0 fi); pickup fine.nib;
x0=0; x2=x3; pos3(stem,0); lft x3l=hround(w-1.5u-.5stem);
hook_in(0,1,2);  % opening hook
pos4(vair,-90); pos5(hair,-180); pos6(flare,-180);
bot y3=-1/3d; bot y4r=-d-oo; y6-.5flare=-vround.9d;
x4=1/3(w-u); lft x5r=min(hround-.5u,lft x5r+x4-x5l-eps);
filldraw stroke z2e---z3e...{left}z4e;  % stem and arc
bulb(4,5,6);  % bulb
pos8(flare,0); pos9(flare,90);
rt x8r=rt x2r if not monospace:-.6(h-x_height)*slant fi; top y9r=h+1;
if bot y9l-top y1<slab: y9l:=min(y9r-eps,y1+fine+slab); fi
x8=x9; y8=.5[y9l,y9r]; dot(8,9);  % dot
penlabels(0,1,2,3,4,5,6,8,9); endchar;

lhchar "Italic Cyrillic letter lje (soft l)";
cyrchar(lje,12u#,x_height#,0);
italcorr .7x_height#*slant+.5curve#-u# if math_fitting:-.5u# fi; %"Weierstrass p"
adjust_fit(if monospace:-.5u#,-.35u# else:.5u#,0 fi); %wbulb_adj&bowl_adj
full_w:=w; w:=9u;
% ital_l;lje
pickup fine.nib;
pos1(vair,-90); pos2(stem,180); pos3(hair,0); %!!!
pos4(vair,-90); pos5(hair,-180); pos6(flare,-180);
top y1l=h+oo; x1=.5[x3,x2];
x3=3u; y3=.35h;
y6-.5flare=.1h; lft x6r=-.25u; z5r=z6r;
bot y4r=-oo; x4=max(.4[lft x6r,rt x3r],lft x6r+.5flare-eps);
y2=.8h; lft x2r=lft x7r=hround(w-2.5u-.5stem); %!!!
bulb(4,5,6); % bulb
filldraw stroke pulled_arc.e(4,3)
 & super_arc.e(3,1) & super_arc.e(1,2); % left stem
pos7(stem,180); y7=.6bar_height;
filldraw stroke z2e--z7e; % right stem
w:=full_w;
pos15(hair,180); z15=z7;
pos12(vair,-90); pos13(curve,0); pos14(vair,90);
x12=x14=.5[x7,x13]; rt x13r=hround(w-u+.5curve);
bot y12r=-oo; top y14r=1.2bar_height+oo; y13=y7;
filldraw stroke pulled_arc.e(7,12) & pulled_arc.e(12,13)
 & pulled_arc.e(13,14) & super_arc.e(14,15);  % bowl
penlabels(0,1,2,3,4,5,6,8,9,10,11,12,13,14,15); endchar;

lhchar "Italic Cyrillic letter m_dsc - m descender";
cyrchar(m_dsc,13u#,x_height#,desc_depth#);
italcorr 1/3x_height#*slant+.5hair#+.5u#; %u
adjust_fit(if monospace:-.5u# else:.5u# fi, %wbulb_adj
 .1u#); %iserif_adj
%ital_m;dsc
pickup fine.nib;
pos1(hair,0); pos6(stem,0);
pos2(hair,0); pos3(vair,-90); pos4(hair,-180); pos5(flare,-180);
x1=x2=3u; y2=.35h; top y1=h; bot y3r=-oo; lft x5r=-.25u; z4r=z5r;
x3=min(lft x5r+flare,lft x2l-eps); y5-.5flare=.1h;
bulb(3,4,5); % bulb
filldraw stroke pulled_arc.e(3,2) & z2e--z1e; % left stem
rt x7r=hround(w-2.5u+.5stem); %!!! x9=w; hook_out(7,8,9); % closing hook
pos7(stem,0); pos8(vair,90); pos9(vair,180); %!!!
x9=w; y9=y7=.4bar_height; x8=.5[x7,x9]; bot y8l=-oo;
filldraw circ_stroke z7e{-.5u,-x_height}...z8e{right}...{up}z9e; % closing hook
x6=x7; top y6=h;
filldraw stroke z6e--z7e; % right stem
% diagonals;m
numeric stem[]; % thicknesses of the strokes
stem1=hround(fudged.stem-stem_corr);
stem2=min(stem1,hround(fudged.hair-stem_corr));
penpos10(stem1,0); penpos11(stem1,0); penpos12(stem2,0); penpos13(stem2,0);
x10l=lft x1l; x11l=x12l; x13l=lft x7l; x11-x10=x13-x12;
y10=y13=top y6; y11=y12;
if hefty:
 y11=if monospace: vround 1/3h-.5stem1 else: oo fi;
 numeric upper_notch,lower_notch;
 upper_notch=h-notch_cut; lower_notch=y11+notch_cut;
 x1'=rt x1r; z1'=whatever[z10l,z11l];
 x6'=lft x6l; z6'=whatever[z12r,z13r];
 z0=whatever[z10r,z11r]=whatever[z12l,z13l];
 fill z10l..
  if y1'<upper_notch: {right}(x1'+1,upper_notch){down}... fi
  {z11-z10}diag_in(10l,11l,1,11r)..diag_out(12l,1,12r,13r){z13-z12}
  if y6'<upper_notch: ...{up}(x6'-1,upper_notch){right} fi
  ..z13r--diag_out(13r,1,13l,12l){z12-z13}
  if y0<=lower_notch: ..{z12-z13}z0{z10-z11}..
   else: ...{down}(x0+.5,lower_notch)--(x0-.5,lower_notch){up}... fi
  {z10-z11}diag_in(11r,10r,1,10l)--cycle;  % diagonals
else:
 y11=0; z0=whatever[z10r,z11r]=whatever[z12l,z13l];
 fill z10l..{z11-z10}diag_in(10l,11l,1,11r)..diag_out(12l,1,12r,13r){z13-z12}
  ..z13r--diag_out(13r,1,13l,12l){z12-z13}..{z12-z13}z0{z10-z11}
  ..{z10-z11}diag_in(11r,10r,1,10l)--cycle; fi  % diagonals
% italic descender/ogonek
if is_ogonek:
   def the_pen=
       if known ogonek_pen: ogonek_pen else: fine fi
   enddef;
   path p.l;
   p.l=z7l{-.5u,-x_height}...z8l{right}...{up}z9l;
   ogonek_breadth:=xvair;
   ogonek_pos=point .9 of p.l;
   easy_ogonek(the_pen,14,15,16); % ogonek
else:
   i_serif(9,x);
fi
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13, 14,15,16);
endchar;

lhchar "Italic Cyrillic letter nje (soft n - looks like nb)";
cyrchar(nje,6.5u#,x_height#,0);
italcorr .7x_height#*slant+.5curve#-u# if math_fitting:-.5u# fi; %"Weierstrass p"
adjust_fit(if monospace:5u#,-.35u# else:6.5u#,0 fi); %ipart_adj&bowl_adj
% soft sign part
pickup tiny.nib; pos1(stem,0); pos2(stem,0); x1=x2;
lft x1l=hround(u-.5stem); y1+.5stem=h+oo; y2=.6bar_height;
filldraw circ_stroke z1e--z2e;  % stem
pickup fine.nib; pos2'(stem,-180); pos3(vair,-90);
pos4(curve,0); pos5(vair,90); pos0(hair,180);
z0=z2=z2'; x3=x5=.5[x2,x4]; rt x4r=hround(w-u+.5curve);
bot y3r=-oo; top y5r=1.2bar_height+oo; y4=y2;
filldraw stroke pulled_arc.e(2',3) & pulled_arc.e(3,4)
 & pulled_arc.e(4,5) & super_arc.e(5,0);  % bowl
% i half;
_one:=6; _two:=7; _three:=8; _four:=9; _five:=10; _six:=11;
%
pos[_four](stem,0);
lft x[_four]l=l+letter_fit if not monospace: +hround(2.5u-.5stem) fi;
y[_four]-.5stem=-oo; x[_three]=x[_four];
if monospace:
 pos[_three](stem,0); top y[_three]=h;
else:
 x[_one]=l+letter_fit; hook_in([_one],[_two],[_three]); fi % opening hook
filldraw circ_stroke z[_four]e--z[_three]e; % stem
pos[_five](vair,90); pos[_six](vair,90); %!!!
x[_five]=x[_four]; x[_six]=x2; y[_five]=y[_six]=bar_height; %!!!
filldraw stroke z[_five]e--z[_six]e; % bar %!!!
%%%
penlabels(0,1,2,3,4,5,6,8,9,10,11,12); endchar;

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

lhchar "Italic Cyrillic letter p_tl - pe tail";
cyrchar(p_tl,13u#,x_height#,desc_depth#); %13.5
italcorr (-.3x_height#+bar_height#)*slant; %o:.7h-(h-bar_height)
adjust_fit(if monospace:-1.5u#,-1.5u# else: 0,0 fi);
pickup fine.nib;
numeric shaved_stem; shaved_stem=mfudged.stem; save stem; stem=shaved_stem;
pos2(stem,0); x1=x2;
if monospace:
 pos1(stem,0); lft x1l=hround(2.5u-.5stem); top y1=h;
else:
 x0=0; lft x2l=hround(2.5u-.5stem);
 hook_in(0,a,1); fi  % opening hook
y2-.5stem=-oo; filldraw circ_stroke z2e--z1e;  % left stem
x4+.5stem=hround(7u+.5stem); ital_arch(2,3,4);  % left arch
pos5(stem,0); y5=y2; x5=x4;
filldraw circ_stroke z5e--z4e;  % middle stem
% hook(4);
pos3'(vair,90); x3'=x4; y3'=bar_height;
lft x7l=hround(w-1.5u-.5stem); y7=.45y3'; pos7(stem,0);
pos9(vair,-90); pos10(hair,-180); pos11(flare,-180); pos8(stem,0); x8=x7;
bot y8=-1/3d; bot y9r=-d-oo; y11-.5flare=-vround.9d;
x9=w-11/3u; lft x10r=min(x7-4u,lft x10r+x9-x10l+4u-eps);
filldraw stroke z3'e{right}...z7e{down}---z8e...{left}z9e;
bulb(9,10,11);  % bulb
penlabels(0,a,1,2,3,4,5,6,7,8,9,10,11); endchar;

lhchar "Italic Cyrillic letter r_dsc (looks like p)";
cyrchar(r_dsc,if monospace: 9u# else: 9.25u# fi,x_height#,
 max(desc_depth#,paren_depth#)); % rusw
italcorr .7x_height#*slant+.5curve#-u# if math_fitting:-.5u# fi; %p
adjust_fit(0,if monospace:0 else:-.35u# fi);
full_d:=d; d:=vround (max(1.15vair'+eps,.65d-.5vair'));
% ital_r;
pickup fine.nib;
x0=0; x2-.5stem=hround(2.5u-.5stem); hook_in(0,1,2);  % opening hook
pos4(hair,-180); pos5(vair,-90); pos6(curve,0); pos7(vair,90);
x4=x2; rt x6r=hround(w-1.5u+.5curve); x5=x7=.5[x4,x6];
bot y5r=-oo; top y7r=h+oo; y4=y6=.5[y5,y7];
filldraw stroke super_arc.e(4,5) & pulled_arc.e(5,6)
 & pulled_arc.e(6,7) & super_arc.e(7,4);  % bowl
pickup tiny.nib; pos2'(stem,0); pos3(stem,0);
z2=z2'; x3=x2; bot y3=-d; filldraw stroke z2'e--z3e;  % stem
%%%
if is_ogonek:
   dish_serif(3,2',a,1/3,.75jut,b,1/3,jut);  % serif
fi
%%%
% r_descender/ogonek
if is_ogonek:
   d:=d+desc_depth;
   def the_pen=
       if known ogonek_pen: ogonek_pen else: fine fi
   enddef;
   ogonek_breadth:=xvair;
   ogonek_pos=(x3,y3+.5the_pen) if not is_egyptian: +(.5xvair,0) fi;
   ogonek_move=bot y3;
   easy_ogonek(the_pen,8,9,10); % ogonek
   chardp:=d/hppp;
else:
   d:=full_d;
   numeric right_jut; right_jut=1.414jut;
   r_serif(3,2',o,1/3,.75jut,p,1/3,beak_darkness,right_jut,.35beak_jut); % lower left serif
fi
penlabels(0,1,2,3,4,5,6,7, 8,9,10); endchar;

lhchar "Italic Cyrillic letter lat_q";
cyrchar(lat_q,8u#,x_height#,desc_depth#);
italcorr x_height#*slant+.5stem#-u#;
adjust_fit(0,0); pickup fine.nib;
pos0(hair,0); pos1(vair,90); pos2(curve,180); pos3(vair,270);
x0=x4; x1=x3=.5[x0,x2]; lft x2r=hround(1.5u-.5curve);
x4+.5stem=hround(w-1.5u+.5stem)+eps;
top y1r=h+oo; bot y3r=-oo; y0=y2=.5[y1,y3];
filldraw stroke super_arc.e(0,1) & pulled_arc.e(1,2)
 & pulled_arc.e(2,3) & super_arc.e(3,0);  % bowl
pickup tiny.nib; pos4(stem,0); pos5(stem,0);
x4=x5; x6=x5r; top y6=h+oo; bot y4=-d;
y5=ypart(((x4l,0)--(x4l,y6))intersectionpoint super_arc.r(0,1));
filldraw z6{2(x5l-x6),y5-y6}...z5l---z4l--z4r--cycle;  % stem
dish_serif(4,5,a,1/3,jut,b,1/3,jut);  % serif
penlabels(0,1,2,3,4,5,6,7,8); endchar;

lhchar "Italic Cyrillic letter t_dsc - te descender";
cyrchar(t_dsc,15u#,x_height#,desc_depth#);
italcorr 1/3x_height#*slant+.5hair#+.5u#;
adjust_fit(if monospace:-1.5u# else: 0 fi,.1u#); %lstem_adj&iserif_adj
% ital_t;
begingroup
pickup fine.nib; numeric shaved_stem; shaved_stem=mfudged.stem;
save stem; stem=shaved_stem; pos2(stem,0); x1=x2;
% left stem_hook;
if monospace:
 pos1(stem,0); lft x1l=hround(2.5u-.5stem); top y1=h;
else:
 x0=0; lft x2l=hround(2.5u-.5stem);
 hook_in(0,a,1); fi % opening hook
y2-.5stem=-oo; filldraw circ_stroke z2e--z1e;  % left stem
x4+.5stem=hround(.5w+.5stem); ital_arch(2,3,4);  % left arch
pos5(stem,0); y5=y2; x5=x4;
filldraw circ_stroke z5e--z4e;  % middle stem
x7+.5stem=hround(w-2.5u+.5stem); ital_arch(5,6,7);  % right arch
x8=x7-.25u; x9=w; y8=1/4x_height; y9=.4bar_height;
x8'=.5[x8,x9]-.25u; bot y8'l=-oo;
pos8(stem,0); pos8'(vair,90); pos9(vair,180);
filldraw stroke z7e{down}..{-u,-x_height}z8e...z8'e{right}...{up}z9e; % hook (7,8,9)(skewed)
endgroup;
% italic descender/ogonek
if is_ogonek:
   def the_pen=
       if known ogonek_pen: ogonek_pen else: fine fi
   enddef;
   path p.l;
   p.l=z8l{-u,-x_height}...z8'l{right}...{up}z9l;
   ogonek_breadth:=xvair;
   ogonek_pos=point .9 of p.l;
   easy_ogonek(the_pen,10,11,12); % ogonek
else:
   z10=z9; pos10(hair,180);
   i_serif(10,x);
fi
penlabels(0,a,1,2,3,4,5,6,7,8,9, 10,11,12); endchar;

lhchar "Italic Cyrillic letter lat_s -- dze";
cyrchar(lat_s,5.25u#+max(1.75u#,flare#),x_height#,0);
italcorr x_height#*slant-.5u#; %s
adjust_fit(0,0); pickup fine.nib;
numeric theta; theta=90-angle(40u,h); slope:=-h/40u;  % angle at middle
pos2(vair,-90); pos0(max(fine.breadth,ess),theta); pos7(vair,-90);
x2l=x0=x7=.5w; top y2l=h+oo; bot y7r=-oo;
y0-.5ess=y7l+.55(y2r-y7l-ess);
lft x3l=hround u-eps; rt x6r=hround(w-.5u)+eps;
x3r-x3l=x6r-x6l=hround .5[vair,ess]-fine;
ellipse_set(2l,3l,4l,0l); ellipse_set(2r,3r,4r,0r); y3=y3r;
ellipse_set(7l,6l,5l,0l); ellipse_set(7r,6r,5r,0r); y6=y6r;
interim superness:=more_super;
filldraw stroke super_arc.e(2,3) & z3e{down}
 ..z4e---z5e..z6e{down} & super_arc.e(6,7);  % main stroke
pos1(hair,0); pos10(hround .75[hair,flare],0);
pos2'(vair,90); z2'=z2;
pos8(hair,-180); pos9(flare,-180);
rt x10r=hround(w-u)+2eps; lft x9r=hround .5u-2eps; y10=.78h; y9=.25h;
bulb(2',1,10); bulb(7,8,9);  % bulbs
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Italic Cyrillic letter tetse - ligature tetse";
cyrchar(tetse,10.75u#,x_height#,desc_depth#);
italcorr 1/3x_height#*slant+.5hair#+.5u#;
adjust_fit(max(2u#,u#+stem#),.1u#); %iserif_adj
pickup fine.nib; interim superness:=more_super;
x0=0; x2=x3; top y2=h; pos3(stem,-180); lft x3r=hround(2.5u-.5stem);
pos2'(stem,-180); z2'=z2; pos4(vair,-90); pos5(hair,0); x4=.5[x3,x5];
pos6(stem,0); rt x6r=hround(w-2.5u+.5stem);
x5=x6=x7; y3=.7[y4,y5]; bot y4r=-oo; y5=.57h; y6+.5stem=h;
filldraw stroke
 z2'e--super_arc.e(3,4)...{up}z5e; % left stem and arc
x9=w; y9=y7=.4bar_height; x8=.5[x7,x9]; bot y8l=-oo;
pos8(vair,90); pos9(vair,180); pos7(stem,0);
filldraw circ_stroke z6e--z7e;  % right stem
filldraw circ_stroke z7e{-.5u,-x_height}...z8e{right}...{up}z9e; % hook(7,8,9)
% italic descender
i_serif(9,x);
% italic beak
pickup fine.nib;
pos10(stem,180); pos11(stem,180); pos12(vair,90); pos13(vair,90);
lft x10r=l+letter_fit  if monospace:-.5stem else:+.25u fi;
y10-.5stem=2/3x_height-.5fine;
x13=0.6[x3,x7]; top y13r=top y12r=x_height; x11=x10; y11=bot y12l-.25flare;
x12-.25flare=rt x10l; x12r:=lft x10r+(top y12r-y11);
filldraw circ_stroke z10e{up}--z11e{up}...z12e{right}--z13e; % ital_beak;
penlabels(0,1,2,3,4,5,6,7,8,9,10,11,12,13); endchar;

lhchar "Italic Cyrillic letter dzhe (hard dj)";
cyrchar(dzhe,9.5u#,x_height#,desc_depth#);
italcorr 1/3x_height#*slant+.5hair#+.5u#; %u
adjust_fit(0,0);
% ital_i;
pickup fine.nib; interim superness:=more_super;
x2=x3+.25u; pos3(stem,-180); lft x3r=hround(2.5u-.5stem);
% left shstem;
if monospace: pos0(vair,90); x0=good.x .5[0,x2]; top y0l=h; y2=2/3h;
 pos2(stem,0); filldraw stroke z2e{u,x_height}...{left}z0e; % terminal
else: x0=0;  hook_in(0,1,2)(skewed); fi % opening hook
pos2'(stem,-180); z2'=z2;
pos4(vair,-90); pos5(hair,0); x4=.5[x3,x5];
pos6(stem,0); rt x6r=hround(w-2.5u+.5stem);
x5=x6=x7; x9=w; hook_out(7,8,9);  % closing hook
y3=.7[y4,y5]; bot y4r=-oo; y5=.57h; y6+.5stem=h;
filldraw stroke z2'e{-u,-x_height}
 ...super_arc.e(3,4)...{up}z5e; % left stem and arc
filldraw circ_stroke z6e--z7e;  % right stem
%%%
% dzhe middle descender
path p.r; numeric t; t=if hefty: 2.3 else: 2.2 fi;
p.r=super_arc.r(3,4)...{up}z5r;
_zero:=10; _one:=11; _two:=12; _three:=13;
penpos[_zero](xvair,0); z[_zero]r=point t of p.r;
penpos[_one](xvair,0); x[_one]=x[_zero]+2/3u; y[_one]=-1/3d;
penpos[_two](2/3[bar,fudged.stem-2stem_corr],-90);
x[_two]=.5[x[_one],x[_three]]; y[_two]=-.8d;
penpos[_three](xvair,-180);
x[_three]=x[_one]-5u; y[_three]=y[_two]+ypart the_tip_pos;
pickup pencircle scaled 1;
fill circ_stroke z[_three]e{down}
     ...{right}z[_two]e...z[_one]e..{dir (360-the_pre_angle)}z[_zero]e; % middle descender
penlabels(0,1,2,3,4,5,6,7,8,9, 10,11,12,13); endchar;

lhchar "Italic Cyrillic letter ch_vcrs - che vcrossed";
cyrchar(ch_vcrs,9.5u#,x_height#,0);
italcorr 1/3x_height#*slant+.5hair#+.5u#;
adjust_fit(0,0);
% ital_ch;
pickup fine.nib; interim superness:=more_super;
x2=x3; pos3(stem,-180); lft x3r=hround(2.5u-.5stem);
% left shstem;
if monospace:
 pos0(vair,90); x0=good.x .5[0,x2]; top y0l=h; y2=2/3h; pos2(stem,0);
 filldraw stroke z2e{u,x_height}...{left}z0e; % terminal
else:
 x0=0;  hook_in(0,1,2)(skewed); fi % opening hook
pos2'(stem,-180); z2'=z2;
pos4(vair,-90); pos5(hair,0); x4=.5[x3,x5];
pos6(stem,0); rt x6r=hround(w-2.5u+.5stem);
x5=x6=x7; x9=w; hook_out(7,8,9);  % closing hook
bot y4r=.75bar_height; y5=.75h; y3=min(y2-eps,.7[y4,y5]); y6+.5stem=h;
filldraw stroke z2'e...super_arc.e(3,4)...{up}z5e; % left stem and arc
filldraw circ_stroke z6e--z7e;  % right stem
%%%
% vcross
pickup fine.nib; numeric middle_weight;
middle_weight=max(fine.breadth,.6[thin_join,vair]);
pos10(middle_weight,0); pos11(middle_weight,0);
lft x10l=lft x11l=hround (x4-.5middle_weight);
top y11-bot y10=.5x_height; .5[y10,y11]=y4;
filldraw stroke z10e--z11e;
penlabels(0,1,2,3,4,5,6,7,8,9, 10,11); endchar;

lhchar "Italic Cyrillic letter lat_w";
cyrchar(lat_w,12u#,x_height#,0);
italcorr x_height#*slant;
adjust_fit(if monospace:-1.5u#,-u# else: 0,0 fi);
pickup fine.nib; interim superness:=more_super; begingroup
forsuffixes $=hair,stem: shaved$:=mfudged$; save $; $=shaved$; endfor
x0=0; x2=x3+.25u; pos3(stem,-180); lft x3r=hround(2.5u-.5stem);
if monospace:
 pos1(vair,90); x1=good.x .5[x0,x2]; top y1r=h; y2=2/3h; pos2(stem,0);
 filldraw stroke z1e{right}...{-u,-x_height}z2e;
else:
 hook_in(0,1,2)(skewed); fi  % opening hook
pos2'(stem,-180); z2'=z2;
pos4(vair,-90); pos5(hair,0);
x4=.6[x2,x5]; x5=x6=x7; pos6(stem,-180); pos7(stem,-180);
y3=.7[y4,y5]; bot y4r=-oo; y5=.57h;
rt x6l=hround(rt x6l+.5w+.75u-x6); y6+.5stem=h; y7=y3;
pos8(vair,-90); pos9(hair,0);
x8=w-2.75u; rt x9r=hround(w-.5u); bot y8r=-oo; y9=y5;
filldraw stroke z2'e{-u,-x_height}
 ...super_arc.e(3,4)...{up}z5e; % left stem and arc
filldraw circ_stroke z6e..super_arc.e(7,8)...{up}z9e;  % middle stem and arc
v_bulb(9,10);  % closing bulb
endgroup;
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Italic Cyrillic letter yat";
cyrchar(yat,13u#,x_height#,0);
italcorr .7x_height#*slant+.5curve#-u# if math_fitting:-.5u# fi; %"Weierstrass p"
adjust_fit(if monospace:-1.5u#,-.35u# else:0,0 fi); %lstem_adj&bowl_adj
full_w:=w; w:=10u;
% ital_yat;
pickup fine.nib; x1=x2; pos2(stem,0);
if monospace:
 pos1(stem,0); lft x1l=hround(2.5u-.5stem); top y1=h;
else:
 x0=0; lft x2l=hround(2.5u-.5stem);
 hook_in(0,a,1); fi  % opening hook
y2-.5stem=-oo;
filldraw circ_stroke z2e--z1e;  % left stem
x4+.5stem=hround(w-2.5u+.5stem); x5=x4; ital_arch(2,3,4);  % arch
y5=.6bar_height; pos5(stem,0);
filldraw stroke z4e--z5e;  % right stem
w:=full_w;
pos6(stem,-180); pos10(hair,180); z6=z5; z10=z5;
pos7(vair,-90); pos8(curve,0); pos9(vair,90);
x7=x9=.5[x5,x8]; rt x8r=hround(w-u+.5curve);
bot y7r=-oo; top y9r=1.2bar_height+oo; y8=y5;
filldraw stroke pulled_arc.e(6,7) & pulled_arc.e(7,8)
 & pulled_arc.e(8,9) & super_arc.e(9,10);  % bowl
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Italic Cyrillic letter b_yus - big yus";
cyrchar(b_yus,9u#,x_height#,0);
italcorr 1/3x_height#*slant+.5hair#+.5u#; %h
adjust_fit(w#-5u#if monospace:-1.5u# fi,if monospace:-1.5u# else:0 fi);
% ital_yus;
% itop_yus;
pickup fine.nib;
penpos1(fudged.stem,0); penpos2(fudged.hair,0);
penpos3(fudged.stem,0); penpos4(fudged.hair,0);
w-x2r=.24w; x2-x3=x3-x1; y1=h; y2=y1; y3=y4=bar_height;
x3l=hround(2.5u-.5stem); x3r=x4r;
z0=whatever[z4l,z2l]=whatever[z1r,z3r];
if hefty:
 y0:=bar_height+.5fine;
 fill z3l--diag_end(3l,1l,1,1,1r,3r){z3r-z1r}
  ...{down}(x0-.5,y0)..(x0+.5,y0){up}...
  {z2l-z4l}diag_end(4l,2l,1,1,2r,4r)--z4r--cycle; % diagonals
else:
 fill z3l--diag_end(3l,1l,1,1,1r,3r)--z0--
  diag_end(4l,2l,1,1,2r,4r)--z4r--cycle; fi % diagonals
penpos5(fudged.stem,0); x5=x3; y5-.5stem=-oo;
fill circ_stroke z5e--z3e; %middle stem
z6=whatever[z4,z2]; z7=whatever[z1,z3]; y6=y7=good.y(y1-vair);
fill z1--z7--z6--z2--cycle; % upper bar
% bowls
pos8(vair,90); pos9(stem,0); pos10(vair,90); pos11(hair,180);
pos12(stem,180); pos13(vair,90); pos14(hair,0); z8=z3;
x11=hround(w+.5hair-eps)-.5hair; x11-x3=x3-x14; y11=y14=1/3x_height;
lft x9l=hround(w-2.75u-.5stem); x9-x3=x3-x12; y9=y12=1/2y8;
x10=hround(w-1.2u); x10-x3=x3-x13; bot y10l=bot y13l=-oo;
filldraw stroke
 if not monospace:z14e{down}... fi
 z13e{right}...z12e{up}...z8e{right}...z9e{down}...z10e{right}
 if not monospace:...{up}z11e fi;  % left lower diagonal
%%%
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13,14); endchar;

lhchar "Italic Cyrillic letter izh - izhitsa (looks like v)";
cyrchar(izh,9.5u#,x_height#,0);
italcorr x_height#*slant+.25u#;
adjust_fit(.25u#,max(u#,.5u#+.5flare#)); %izhy_adj
% ital_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); penpos6(hair,0); penpos7(flare,0);
x5=if serifs:.5[x4'',rt x6r] else: rt x6r fi; top y5r=h+oo;
y4''=min(.9x_height,y5l-vair); z4''=whatever[z3,z4];
rt x6r=hround(r-.5u-.5);
y6=max(vround(top y5r-.5hair)-1-.5flare,
 min(bar_height+.5flare+2vair'+2,.9[bar_height,h]-.5flare));
cyrbulb(5,6,7); % bulb
penpos1'(alpha*left_stem,0); y1'=3/4x_height; z1'=whatever[z1,z2];
x10=l+letter_fit; x10:=hround(x10-.5hair)+.5hair; y10=2/3x_height;
penpos9(vair,90); y9r=x_height+oo; x9=min(x1l-.5,x10+u);
if y0>cap_notch_cut:
 y0:=cap_notch_cut;
 fill z0+.5right{up}...{z4-z3}z4''l...{right}z5r--z5l{left}
  ...z4''r{z3-z4}--diag_end(4r,3r,1,1,2l,1l)--
   z1'l{z1-z2}...{left}z9l--z9r{right}
   ..tension atleast .75 and 1..{z2-z1}z1'r
  ...{down}z0+.5left--cycle; % left and right diagonals
else:
 pickup pencircle scaled1;
 fill z0--z4''l{z4-z3}...{right}z5r--z5l{left}...{z3-z4}z4''r
  --diag_end(4r,3r,1,1,2l,1l)--
   z1'l{z1-z2}...{left}z9l--z9r{right}
   ..tension atleast .75 and 1..{z2-z1}z1'r
  --cycle; fi % left and right diagonals
pickup fine.nib;
pos9'(vair,90); z9'=z9; pos10(hair,180);
filldraw stroke z10e{up}...z9'e{right};  % hook
%%%
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

lhchar "Italic Cyrillic letter n_ltl - en with left tail";
cyrchar(n_ltl,10u#,x_height#,desc_depth#);
italcorr 1/3x_height#*slant+.5hair#+.5u#; %u
adjust_fit(0,0);
pickup fine.nib; x2=x3; pos3(stem,0); lft x3l=hround(2.5u-.5stem);
%ihalfstemx;
if monospace:
 pos2(stem,0); top y2=h;
else:
 x0=0; hook_in(0,1,2); fi % opening hook
y3-.5stem=-oo;
filldraw stroke z3e--z2e; % left stem
x10=x3l; y10=y11=bar_height; pos10(vair,90); pos11(vair,90);
pos6(stem,0); rt x6r=hround(w-2.5u+.5stem); y6+.5stem=h;
x7=x6; x9=w; hook_out(7,8,9); % closing hook
z7'=z7; pos7'(stem,0); x11=x6l;
filldraw circ_stroke z6e--z7'e; % right stem
filldraw stroke z10e--z11e; % bar
%%%
pos12(vair,-90); pos13(hair,-180); pos14(flare,-180); pos5(stem,0);
x5=x3; bot y5=-1/3d; bot y12r=-d-oo; y14-.5flare=-vround.9d;
%x6=w-11/3u; lft x7r=min(x4-4u,lft x7r+x6-x7l+5u-eps);
%x12=(x3+2.5u-.5stem)-10/3u; lft x13r=min(x3-10/3u,lft x13r+x12-x13l+13/3u-eps);%!!!
x12=(x3+2.5u-.5stem)-9/3u; lft x14r=min(x3-8/3u,lft x13r+x12-x13l+11/3u-eps);%!!!
%filldraw circ_stroke z3e--z5e{down}...{left}z12e; % right stem and hook
 forsuffixes e=l,r:
 z12'e=((0,y14)--(w,y14)) intersectionpoint
	(z5e{down}...{left}z12e); endfor
 if lft x12'l>rt x14l+max(1,hround(1/3vair+.5)):
    filldraw stroke z3e--z5e{down}...{left}z12e; % right stem and hook
 else:
    x12'l:=min(rt x14l+max(1,1/3vair+.5),rt x12'r-vair)+.5fine-eps;
    filldraw z3r--z5r{down}...{left}z12r--z12l{right}
             ..z12'l{up}..{up}z3l--cycle;
 fi
bulb(12,13,14);  % bulb
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

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

lhchar "Italic Cyrillic letter m_tl - m tail";
cyrchar(m_tl,12u#,x_height#,desc_depth#);
italcorr 1/3x_height#*slant+.5hair#+.5u#; %u
adjust_fit(if monospace:-.5u#,-u# else:.5u#,0 fi); %wbulb_adj
%ital_m;tl
pickup fine.nib;
pos1(hair,0); pos2(hair,0); pos3(vair,-90); pos4(hair,-180);
pos5(flare,-180); pos6(stem,0);
x1=x2=3u; top y1=h; y2=.35h; bot y3r=-oo; lft x5r=-.25u; z4r=z5r;
x3=min(lft x5r+flare,lft x2l-eps); y5-.5flare=.1h;
bulb(3,4,5); % bulb
filldraw stroke pulled_arc.e(3,2) & z2e--z1e; % left stem
pos7(stem,0); lft x7l=hround(w-1.5u-.5stem); %!!! % x9=w; hook_out(7,8,9); %!!! % closing hook
x6=x7; top y6=h;
%filldraw stroke z6e--z7e; %!!! % right stem
% diagonals;m
numeric stem[]; % thicknesses of the strokes
stem1=hround(fudged.stem-stem_corr);
stem2=min(stem1,hround(fudged.hair-stem_corr));
penpos10(stem1,0); penpos11(stem1,0); penpos12(stem2,0); penpos13(stem2,0);
x10l=lft x1l; x11l=x12l; x13l=lft x7l; x11-x10=x13-x12;
y10=y13=top y6; y11=y12;
if hefty: y11=if monospace: vround 1/3h-.5stem1 else: oo fi;
 numeric upper_notch,lower_notch;
 upper_notch=h-notch_cut; lower_notch=y11+notch_cut;
 x1'=rt x1r; z1'=whatever[z10l,z11l];
 x6'=lft x6l; z6'=whatever[z12r,z13r];
 z0=whatever[z10r,z11r]=whatever[z12l,z13l];
 fill z10l..
  if y1'<upper_notch: {right}(x1'+1,upper_notch){down}... fi
  {z11-z10}diag_in(10l,11l,1,11r)..diag_out(12l,1,12r,13r){z13-z12}
  if y6'<upper_notch: ...{up}(x6'-1,upper_notch){right} fi
  ..z13r--diag_out(13r,1,13l,12l){z12-z13}
  if y0<=lower_notch: ..{z12-z13}z0{z10-z11}..
   else: ...{down}(x0+.5,lower_notch)--(x0-.5,lower_notch){up}... fi
  {z10-z11}diag_in(11r,10r,1,10l)--cycle;  % diagonals
else: y11=0; z0=whatever[z10r,z11r]=whatever[z12l,z13l];
 fill z10l..{z11-z10}diag_in(10l,11l,1,11r)..diag_out(12l,1,12r,13r){z13-z12}
  ..z13r--diag_out(13r,1,13l,12l){z12-z13}..{z12-z13}z0{z10-z11}
  ..{z10-z11}diag_in(11r,10r,1,10l)--cycle; fi  % diagonals
% hook;
pos8(vair,-90); pos9(hair,-180); pos9'(flare,-180);
bot y7=-1/3d; bot y8r=-d-oo; y9'-.5flare=-vround.9d;
x8=w-11/3u; lft x9r=min(x7-4u,lft x9r+x8-x9l+5u-eps);
filldraw stroke z6e--z7e{down}...{left}z8e;
bulb(8,9,9');  % bulb
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13); endchar;

lhchar "Italic Cyrillic letter r_gcrs - r crossed (looks like p)";
cyrchar(r_gcrs,if monospace:9u#else:9.25u#fi,x_height#,desc_depth#); % the Russian width
italcorr .7x_height#*slant+.5curve#-u# if math_fitting:-.5u# fi; %p
adjust_fit(0,if monospace:0 else:-.35u#fi);
% ital_r;
pickup fine.nib;
x0=0; x2-.5stem=hround(2.5u-.5stem); hook_in(0,1,2);  % opening hook
pos4(hair,-180); pos5(vair,-90); pos6(curve,0); pos7(vair,90);
x4=x2; rt x6r=hround(w-1.5u+.5curve); x5=x7=.5[x4,x6];
bot y5r=-oo; top y7r=h+oo; y4=y6=.5[y5,y7];
filldraw stroke super_arc.e(4,5) & pulled_arc.e(5,6)
 & pulled_arc.e(6,7) & super_arc.e(7,4);  % bowl
pickup tiny.nib; pos2'(stem,0); pos3(stem,0);
z2=z2'; x3=x2; bot y3=-d; filldraw stroke z2'e--z3e;  % stem
save slab; slab:=vair; % lower.slab
dish_serif(3,2',a,1/3,.75jut,b,1/3,jut);  % serif
%%%%%
path p; numeric unbalance,outer_jut;
p=z5{(x6,y5)-z5}...superness[(x5,y6),(x6,y5)]{z6-z5}...{z6-(x6,y5)}z6;
z8=point1.25 of p;
numeric unbalance,outer_jut;
unbalance=if monospace: 1 else: 1.1 fi;
% some funny fonts have an extremally small |jut|:
outer_jut=.5stem+if serifs: max(limit_dist,if hefty: .8 fi\\ jut) else: 1.7u fi;
put_cyrcross(x8,(y8-bar_height),-outer_jut,-unbalance*outer_jut);
%%%
penlabels(0,1,2,3,4,5,6,7, 8); endchar;

lhchar "Italic Cyrillic letter s_acrs - s crossed (looks like c)";
cyrchar(s_acrs,8u#,x_height#,0);
italcorr if math_fitting:1/3x_height#*slant else:x_height#*slant-u# fi; %c
adjust_fit(if monospace:0 else:-.35u#fi,0);
% ital_s;
pickup fine.nib; pos0(flare,0); pos1(hair,0); pos2(vair,90);
pos3(curve,180); pos4(vair,270); pos5(hair,320);
x2=x4=.5(w+u); rt x1r=max(rt x2,hround(w-u))+eps;
lft x3r=hround(1.5u-.5curve); x5r=good.x(w-eps); x6=x5;
y1=.5[bar_height,h]; top y2r=h+oo; bulb(2,1,0);  % bulb
bot y4r=-oo; y3=.5[y2,y4]; top y5l=vround .5bar_height; y6=bar_height;
path p; p=z4{right}..z5..z6;
filldraw stroke pulled_arc.e(2,3)
 & pulled_arc.e(3,4)...{direction 1 of p}z5e;  % arc
%%%%%
pair outer_point; path p; numeric unbalance,outer_jut;
outer_point=superness[(x4r,y3r),(x3r,y4r)];
p=z3{(x3,y4)-z3}
 ...superpull[superness[(x4,y3),(x3,y4)],outer_point]{z4-z3}...{z4-(x3,y4)}z4;
z7=point.75 of p;
unbalance=.95; %if monospace: 1 else: 1.1 fi;
% some funny fonts have an extremally small |jut|:
outer_jut=.5stem+if serifs: max(limit_dist,if hefty: .8 fi\\ jut) else: 1.7u fi;
put_cyrcross(x7,(y7-bar_height),unbalance*outer_jut,outer_jut);
%%%
penlabels(0,1,2,3,4,5,6, 7); endchar;

lhchar "Italic Cyrillic letter g_crsdsc - ghe hcrossed descender";
cyrchar(g_crsdsc,6.25u#,x_height#,desc_depth#);
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#); %e
adjust_fit(if monospace:u#,u# else: 0.5u#,0.5u# fi);
% ital_g;
pickup fine.nib; x0l=hround eps; x0'=x0; x5r=good.x(w-eps); x6=x5;
x2=.5w+2u; x3=.5w-2u; x1=x4=x7=.5[x3l,x2r]; y7=.5[y2,y3];
h-y0=y5; top y5l=vround .5bar_height; y6=bar_height; y0'=h-bar_height;
h-y2=y3=1/4x_height; h-y1=y4; bot y4r=-oo;
pos0(hair,320); pos1(vair,270); pos2(stem,180);
pos3(stem,180); pos4(vair,270); pos5(hair,320); pos7(stem,135);
path p,p_; p=z0'..z0..z1{right}; p_=z4{right}..z5..z6;
filldraw stroke z0e{direction 1 of p}
 ...z1e{right}...{down}z2e...z7e...z3e{down}...z4e{right}
 ...{direction 1 of p_}z5e; % main stroke
%%%
% italic descender/ogonek
if is_ogonek:
   def the_pen=
       if known ogonek_pen: ogonek_pen else: fine fi
   enddef;
   p_.r=z3r{down}...z4r{right}...{direction 1 of p_}z5e;
   ogonek_breadth:=xvair;
   numeric tt; % the time...
   tt=if hefty: 2.8 else: 2.6 fi;
   join_angle=angle((direction tt of p_.r) rotated 180);
   ogonek_pos=point tt of p_.r+.5(the_pen-fine)*
       unitvector((direction tt of p_.r) rotated 90);
   easy_ogonek(the_pen,10,11,12); % ogonek
else:
   z10=z5; pos10(hair,180); i_serif(10,x);
fi
% hstroke
bar_stroke(x0l+.05u,w-(x0l+.05u));
penlabels(0,1,2,3,4,5,6,7,8,9, 10,11,12); endchar;

lhchar "Italic Cyrillic letter h_hcrs - kha (looks like x)";
cyrchar(h_hcrs,if monospace:6.5u# else:7.5u# fi+max(1.5u#,flare#), % !rusw
 x_height#,0);
italcorr max(1/3x_height#*slant+.5hair#+.5u#,x_height#*slant+.25u#); %x
adjust_fit(if monospace: 0,0 else:0.25u#,0.25u#fi);
% ital_h;
pickup fine.nib; pos0(hair,180); pos1(vair,90); pos2(stem,0);
pos3(stem,-180); pos4(vair,-90); pos5(hair,0);
y0=y2=2/3h; y3=y5=1/3h; top y1r=h+oo; bot y4r=-oo;
rt x2r=hround(.5w+.5stem-eps); x2=x3;
x0-.5hair=hround-.5hair; x5+.5hair=hround(w+.5hair-eps);
x1=.5[x0,x2]; x4=.5[x3,x5];
filldraw stroke z0e{up}...pulled_arc.e(1,2); % opening hook
filldraw z2l--z3r--z3l--z2r--cycle;  % stem
filldraw stroke pulled_arc.e(3,4)...{up}z5e;  % closing hook
pos3'(hair,180); pos6(hair,180); pos7(vair,90); pos8(hair,0); pos9(flare,0);
x3'l=x6l=x3l; y3'=y3; y6=3/4h; x7=.5[x8,x2]; top y7r=h+oo;
rt x8r=hround(w-.25u); y8+.5flare=vround(bot y7l-.03x_height);
filldraw stroke z3'e---z6e...{right}z7e; bulb(7,8,9);  % upper link and bulb
pos2'(hair,0); pos16(hair,0); pos17(vair,-90);
pos18(hair,-180); pos19(flare,-180);
x2'l=x16l=x2l; y2'=y2; y16=1/4h; x17=.5[x18,x3]; bot y17r=-oo;
lft x18r=hround.25u; y18-.5flare=vround(top y17l+.03x_height);
filldraw stroke z2'e---z16e...{left}z17e; bulb(17,18,19); % lower link and bulb
%%%
% hstroke
bar_stroke(u,w-u); % bar
penlabels(0,1,2,3,4,5,6,7,8,9,16,17,18,19, 10,11); endchar;

endinput;
% end of file
