%
% lgcyrsym.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:
%
% Glyphs for ec and Cyrillic symbols used with floating codes
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% List of signs  X2  T2*
%
% palochka	"0d "0d	symbol Palochka
% openq		       	Single German opening quote (looks like ,)
% angle_left	"0e "0e Single left angle bracket
% lguillemet	       	Single left guillemet
% angle_right	"0f "0f	Single right angle bracket
% rguillemet	       	Single right guillemet
%
% dash		"16 "16	Em dash/if monospace Hyphen
% wordmark          "17 Compound word mark
% pmzero        "18 "18 Zero for p mille sign (ec: "17)
%
% dbl_quotes    "22 "22 Straight double quotes
%
% No		"9d "9d Cyrillic symbol `Number'
% currency	"9e "9e Cyrillic Currency sign
% section	"9f "9f Section sign
%
% baseqq        "bd "bd German Opening quotes   (looks like ,,)  (ec: "12)
% flqq          "be "be Cyrillic Opening Quotes (looks like <<)  (ec: "13)
% frqq          "bf "bf Cyrillic Closing Quotes (looks like >>)  (ec: "14)
%
% T1/T2-outsiders:
%
% pound         ("bf)	Sterling sign
%

LHver_check(3,2);

lhchar "Cyrillic sign palochka (as latin I)";
cyrchar(palochka,max(6u#,4u#+cap_stem#),cap_height#,0);
italcorr cap_height#*slant-.25u#;
adjust_fit(cap_serif_fit#,cap_serif_fit#);
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround(.5w-.5cap_stem); top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs: dish_serif(1,2,a,1/3,1.05cap_jut,b,1/3,1.05cap_jut); % upper serif
 dish_serif(2,1,c,1/3,1.05cap_jut,d,1/3,1.05cap_jut);  fi % lower serif
penlabels(1,2); endchar;

lhchar "Cyrillic `German opening comma'";
cyrchar(openq,5u#,pdot_diam#,comma_depth#);
adjust_fit(0,0);
x1-.5pdot_diam=hround(.5w-.5pdot_diam); y1-.5pdot_diam=0;
comma(1,a,pdot_diam,.2u,comma_depth);  % dot and tail
penlabels(1); endchar;

if unknown math_anglebrackets:
   boolean math_anglebrackets; math_anglebrackets:=false;
fi

lhchar "Single left angle bracket";
cyrchar(angle_left,7u# if monospace: -u# fi,body_height#,paren_depth#);
italcorr body_height#*slant-.5u#;
adjust_fit(0,0); pickup fine.nib;
if math_anglebrackets:
   left_angle(rule_thickness);
else:
   pickup fine.nib;
   pos1(fudged.hair,0); pos2(fudged.stem,0); pos3(fudged.hair,0);
   x1=x3=hround(w-u)+eps; lft x2=hround(u)-eps;
   top y1=h+eps; .5[y1,y3]=y2=good.y .5[-d+eps,h];
   filldraw stroke z1e--z2e--z3e;
fi
endchar;

lhchar "Single right angle bracket";
cyrchar(angle_right,7u# if monospace: -u# fi,body_height#,paren_depth#);
italcorr math_axis#*slant-.5u#;
adjust_fit(0,0); pickup fine.nib;
if math_anglebrackets:
   right_angle(rule_thickness);
else:
   pickup fine.nib;
   pos1(fudged.hair,0); pos2(fudged.stem,0); pos3(fudged.hair,0);
   x1=x3=hround(u)-eps; x2=hround(w-u)+eps;
   top y1=h+eps; 0.5[y1,y3]=y2=good.y 0.5[-d+eps,h];
   filldraw stroke z1e--z2e--z3e; % right >
fi
labels(1,2,3); endchar;

lhchar "Single left guillemet"; % jk
cyrchar(lguillemet,8u#,2bar_height#,0);
italcorr h#*slant-u#;
adjust_fit(0,0);
 pickup fine.nib;
 pos1(qvair,0); pos2(if monospace: qvair else: stem fi,0); pos3(qvair,0);
 rt x1r=rt x3r=w-2u-eps;
 lft x2l=hround(if not monospace: 2 fi\\ u)-eps;
 bot y3=0; y2=good.y(h/2); top y1=2y2;
 if not serifs or monospace:
  filldraw stroke z1e--z2e--z3e;
 else:
  filldraw stroke
   z1e{(x2e-x1e),1.8(y2e-y1e)}..{curl1}z2e{curl1}..
   {(x3e-x2e),1.8(y3e-y2e)}z3e;
 fi
 penlabels(1,2,3);
endchar;

lhchar "Single right guillemet"; % jk
cyrchar(rguillemet,8u#,2bar_height#,0);
italcorr h#*slant-u#;
adjust_fit(0,0);
 pickup fine.nib;
 pos1(qvair,0); pos2(if monospace: qvair else: stem fi,0); pos3(qvair,0);
 lft x1l=lft x3l=2u+eps;
 rt x2r=w-hround(if not monospace: 2 fi\\ u)+eps;
 bot y3=0; y2=good.y(h/2); top y1=2y2;
 if not serifs or monospace:
  filldraw stroke z1e--z2e--z3e;
 else:
  filldraw stroke
   z1e{(x2e-x1e),1.8(y2e-y1e)}..{curl1}z2e{curl1}..
   {(x3e-x2e),1.8(y3e-y2e)}z3e;
 fi
penlabels(1,2,3); endchar;


if unknown cyrdash: boolean cyrdash; cyrdash:=true; fi

lhchar "Cyrillic Em dash";%oct"026"
cyrchar(dash,if cyrdash: 14.5u#%.8*18u#
		else:    18u# fi
 ,x_height#,0);
italcorr .61803x_height#*slant+.5u#;
adjust_fit(letter_fit#,letter_fit#);
pickup crisp.nib; pos1(vair,90); pos2(vair,90);
top y1r=top y2r=vround(.61803h+.5vair);
if cyrdash:
   lft x1=.25u-eps; rt x2=w-.25u+eps;
else:
   lft x1=-eps; rt x2=w+eps;
fi
filldraw stroke z1e--z2e;  % bar
penlabels(1,2); endchar;

iff monospace:
lhchar "Hyphen (instead of Cyrillic Em dash)";%oct"026"
cyrchar(dash,6u#,x_height#,0);
italcorr .5x_height#*slant-.5u#;
adjust_fit(0,0);
numeric thickness; thickness=if hefty:bar else:.75[hair,stem] fi;
pickup crisp.nib; pos1(thickness,90); pos2(thickness,90);
top y1r=top y2r=vround(.5h+.5thickness); rt x2=hround(w-u)+eps;
if monospace: x2=w-x1 else: lft x1=hround .2u-eps fi;
filldraw stroke z1e--z2e;  % bar
penlabels(1,2); endchar;

lhchar "Zero for p mille sign";
cyrchar(pmzero,if serifs:
   if monospace: 9u#+max(6u#,2fudge*(hair#+stem#)) else: 7u# fi else: 8u# fi,
  body_height#,body_height#-asc_height#);
italcorr if hefty: .4asc_height#*slant-.5u# else: h#*slant-u# fi;
adjust_fit(0,0); pickup fine.nib;
numeric left_curve,right_curve;
left_curve=hround 5/6[fudged.hair,fudged.stem];
right_curve=max(fine.breadth,hround(fudged.hair if hefty:-2stem_corr fi));
pos1(vair,90);
pos2(left_curve,180);
pos3(vair,270);
pos4(right_curve,360);
bot y3r=-d;
rt x4r=hround(.5w +2.5u );
lft x2r=hround(.5w -2.5u ) ;
top y1r=vround(if monospace: .3 else: .5 fi\\ asc_height);
x1=x3=.5[x2,x4]; y2=y4=.5[y1,y3];
filldraw stroke pulled_super_arc.e(1,2)(superpull)
 & pulled_super_arc.e(2,3)(superpull);  % left half of lower bowl
filldraw stroke super_arc.e(3,4) & super_arc.e(4,1); % right half of lower bowl
penlabels(1,2,3,4); endchar;

lhchar "Compound word mark";
cyrchar(wordmark,0,x_height#,0);
zero_width;
endchar;

%

lhchar "Straight double quotes";
cyrchar(dbl_quotes,9u#,asc_height#,0);
numeric top_width#,spread#;
top_width#=if serifs: flare# else: stem# fi;
spread#=max(3u#,top_width#+.5u#); define_pixels(spread);
italcorr asc_height#*slant+.5top_width#+.5spread#-4u#;
adjust_fit(0,0);
x1=x2; x3=x4=w-x1; x3-x1=spread+2; y1=y3;
y2=y4=max(.5[bar_height,x_height]+.5vair,h-x_height);
if serifs: pickup crisp.nib; pos1(flare,0); pos2(vair,0);
 pos3(flare,0); pos4(vair,0);
 y1+.5stem=h; filldraw circ_stroke z1e--z2e;  % left stem and bulb
 filldraw circ_stroke z3e--z4e;  % right stem and bulb
else: pickup fine.nib; pos1(stem,0); pos2(vair,0);
 pos3(stem,0); pos4(vair,0);
 top y1=h; filldraw stroke z1e--z2e;  % left stem
 filldraw stroke z3e--z4e; fi  % right stem
penlabels(1,2,3,4); endchar;

%

lhchar "Cyrillic symbol No."; %common
cyrchar(No,14.5u#+width_adj#,cap_height#,0);
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#
  if serifs: +.5(flare#+(cap_stem#-stem#))-.25u#,cap_serif_fit# else:,0 fi);
full_w:=w; w:=if serifs: 10u else: 11.5u fi;
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=h;
if serifs: top y3=.79h; bot y2=.21h; else: top y3=h; bot y2=0; fi
bot y4=0;
x1=x2; x3=x4; x1l=w-x3r;
rt x3r=hround min(w-2u,w-3u+.5fudged.cap_stem);
if serifs: numeric bulb_diam; bulb_diam=flare+(cap_stem-stem);
 pos21(thin_stem,-90); pos22(cap_hair,-180); pos23(bulb_diam,-180);
 pos31(thin_stem,-90); z31'=z31;
 pos31'(thin_stem,90); pos32(cap_hair,0); pos33(bulb_diam,0);
 y23=vround max(.05fig_height+.5bulb_diam,.1fig_height-.5flare)-o;%
 lft x23r=l+letter_fit+.15u; x33=w-x23; y33=h-y22;
 x21=max(lft x23r+.5bulb_diam,.45[lft x23r,rt x2r]);
 x31=w-x21; bot y21r=-oo; top y31l=h+oo;
 bulb(21,22,23); bulb(31',32,33);
 filldraw stroke z1e--z2e & pulled_arc.e(2,21); % left stem
 filldraw stroke z4e--z3e & pulled_arc.e(3,31); % right stem
else: filldraw stroke z1e--z2e; filldraw stroke z4e--z3e; fi
if hefty: penpos5(fudged.cap_stem,0); penpos6(fudged.cap_stem,0);
 x5l=x1; x6r=x4; y5=h; y6=0;
 numeric upper_notch,lower_notch;
 upper_notch=h-cap_notch_cut; lower_notch=cap_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,cap_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: if hefty: serif(1,2,a,1/3,-cap_jut); % upper left serif
 else: serif(5,6,a,1/3,-cap_jut); fi  % upper left serif
fi
w:=full_w;
penpos71(vair,90); penpos73(vair',-90);
if serifs: x72r=x33+hround max(.25u,u-.4curve); x74r=hround(w-.5u);
else: x72r=x3+1.25u+hround max(0,.75u-.4curve); x74r=hround(w-u); fi
penpos72(min(1/3(x74r-x72r),.8curve),180);
penpos74(min(1/3(x74r-x72r),.8curve),0);
x71=x73=.5[x72r,x74r]; y71r=h-3u+vround 1.5oo; y73r=x_height-3u-oo;
y72=y74=.5[h,x_height]-3u-vair_corr; y72l:=y74l:=.52[h,x_height]-3u;
penstroke pulled_arc.e(71,72) & pulled_arc.e(72,73)
 & pulled_arc.e(73,74) & pulled_arc.e(74,71) & cycle;  % bowl
pickup fine.nib; pos81(bar,90); pos82(bar,90);
lft x81=x72r-.25fine; rt x82=x74r+.25fine; y81=y82=.8x_height-3u;
filldraw stroke z81e--z82e;
penlabels(1,1',2,3,4,4',5,6,7); endchar;

lhchar "Cyrillic Currency sign"; % from ec ... from rsym (wasy)
cyrchar(currency,1.13 min(asc_height#,9/7x_height#)+2u#,
 min(asc_height#,9/7x_height#),0);
italcorr x_height#*slant;
adjust_fit(if monospace: u#,u# else: 0,0 fi);
pickup rule.nib; autorounded;
x4 = good.x .5w; x2-x6=y8-y4; y2=good.y .5h; bot y4=-oo;
circle_points;
z9 = 1.30[z5,z1];
z10 = 1.30[z7,z3];
z11 = 1.30[z1,z5];
z12 = 1.30[z3,z7];
draw_circle;
draw z1--z9;
draw z3--z10;
draw z5--z11;
draw z7--z12;
labels(1,2,3,4,5,6,7,8,9,10,11,12); endchar;

lhchar "Section sign"; % taken from DC/EC
cyrchar(section,6.5u#+max(1.5u#,stem#),asc_height#,desc_depth#);
adjust_fit(0,0); pickup fine.nib;
numeric s_slab; s_slab=if serifs:slab else:vround .2[slab,cap_stem] fi;
numeric ess'; ess'=max(fine.breadth,cap_ess);
numeric sstem; sstem=hround .5[s_slab,ess']-fine;
if sstem < fine.breadth: sstem:=fine.breadth; fi
pos2(vair,90); pos3(sstem,180);
pos4(ess',270); pos4'(vair,270);
pos5'(sstem,0); pos5(sstem,180);
pos6(ess',90); pos6'(vair,90); pos7(sstem,0);
pos8(vair,-90);
top y2r=h+oo; bot y8r=-d-oo;
y3=.52[y4,y2]; y5=.52[y4,y6]; y7=.52[y6,y8]; y5'=.52[y6,y4];
y2-y4=y4-y6=y6-y8;
bot z4'=bot z4; top z6'=top z6;
lft x3r=hround 1.25u;
x2=x4=x6=x8=.5w; x5=x7=w-x3; x5'=x3;
if serifs:
 pos0(stem,0); pos1(hair,0); pos9(hair,-180); pos10(stem,-180);
 rt x1r=hround(w-1.5u); x9=w-x1; y2-y1=y9-y8=(y2-y8)/8;
 bulb(2,1,0); bulb(8,9,10);  % bulbs
else:
 pos1(.6[slab,flare],-100); pos9(flare,-100); pos2'(vair,-90);
 rt x1l=hround(w-1.3u); lft x9r=hround .8u; z2'=z2;
 top y1l=vround .92asc_height+oo; bot y9r=vround .1asc_height-d-oo;
 filldraw stroke term.e(2',1,right,.9,4);  % upper arc and terminal
 filldraw stroke term.e(8,9,left,.9,4);   % lower arc and terminal
fi
filldraw stroke z2e{left}...z3e{down}...z4e{3(x5-x3),y5-y3}
 ...z5e{down}...{left}z6'e;  % upper stroke
filldraw stroke z4'e{left}...z5'e{down}...z6e{3(x7-x5'),y7-y5'}
 ...z7e{down}...{left}z8e;  % upper stroke
penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

%

lhchar "Cyrillic `German Opening quotes' (looks like ,,)";
cyrchar(baseqq,3u#+max(2u#,pdot_diam#),pdot_diam#,comma_depth#);
italcorr asc_height#*slant+pdot_diam#-4.1u#;
adjust_fit(.5u#,.5u#);
x2+.5pdot_diam=hround(w-.6u+.5pdot_diam); y2-.5pdot_diam=0;
x1=w-x2; y2=y1;
comma(1,a,pdot_diam,.25u,comma_depth); % left dot and tail
comma(2,b,pdot_diam,.25u,comma_depth); % right dot and tail
penlabels(1,2); endchar;

lhchar "Cyrillic `French Opening Quotes' (looks like <<)";
cyrchar_twice( % compilation of A.Shen's and ec (polish: pl_cud) quotes
 if not hefty: flqq,10u#,2bar_height#,0 % ec metrics
 else:         flqq,12u#,2bar_height#,0
 fi);
adjust_fit(0,0);
pickup fine.nib;
numeric the_shift,shift_corr;
the_shift=hround(max(3u,1.7stem)); shift_corr=the_shift-3u;
pos1(max(fine.breadth,
	 if serifs: qvair else: 7/8[vair,fudged.hair]-3stem_corr fi),0);
pos2(max(fine.breadth,if serifs:
    if monospace: qvair else: stem fi else:7/8[vair,fudged.hair] fi),0);
pos3(max(fine.breadth,
	 if serifs: qvair else: 7/8[vair,fudged.hair]-3stem_corr fi),0);
rt x1r=rt x3r=
    hround(if hefty: .6 else: 2/3 fi w-shift_corr)-eps;
lft x2l=hround(if not monospace: 2 fi\\ u-shift_corr)-eps;
y2=good.y min(bar_height,.5x_height); top y1=vround 2y2;
y1-y2=y2-y3;
if hefty:
   for i:=1,2,3:
       forsuffixes $:=r, ,l: z[i]'$=z[i]$ + the_shift*right; endfor
   endfor
   filldraw stroke z1e--z2e--z3e;    % outer <
   filldraw stroke z1'e--z2'e--z3'e; % inner <
else:
   pos1'(qvair,0);
   pos2'(7/8 [hair,stem],0);
   pos3'(qvair,0);
   z2'=z2+the_shift*right;
   y1'-y2'=y2'-y3'=.8(y1-y2);
   z1'=z2'+whatever*(z1r-z2r); z3'=z2'+whatever*(z2r-z3r);
   filldraw stroke
       z1e{(x2e-x1e),1.2(y2e-y1e)}..{curl1}z2e{curl1}..
       {(x3e-x2e),1.2(y3e-y2e)}z3e;      % outer <
   filldraw stroke
       z1'e{(x2'e-x1'e),1.2(y2'e-y1'e)}..{curl1}z2'e{curl1}..
       {(x3'e-x2'e),1.2(y3'e-y2'e)}z3'e; % inner <
fi
% italic correction is set to |0| in |beginchar|, so let's correct it
corrital z1'r;
repeat_once;
penlabels(1,2,3,1',2',3'); endchar;

lhchar "Cyrillic `French closing quotes'";
cyrchar_twice( % compilation of A.Shen's and ec (polish: pl_cud) quotes
 if not hefty: frqq,10u#,2bar_height#,0 % ec metrics
 else:         frqq,12u#,2bar_height#,0
 fi);
adjust_fit(0,0);
pickup fine.nib;
numeric the_shift,shift_corr;
the_shift=hround(max(3u,1.7stem)); shift_corr=the_shift-3u;
pos1(max(fine.breadth,
	 if serifs: qvair else: 7/8[vair,fudged.hair]-3stem_corr fi),0);
pos2(max(fine.breadth,if serifs:
    if monospace: qvair else: stem fi else:7/8[vair,fudged.hair] fi),0);
pos3(max(fine.breadth,
	 if serifs: qvair else: 7/8[vair,fudged.hair]-3stem_corr fi),0);
lft x1l=lft x3l=w-
    hround(if hefty: .6 else: 2/3 fi w-shift_corr)+eps;
rt x2r=w-hround(if not monospace: 2 fi\\ u-shift_corr)+eps;
y2=good.y min(bar_height,.5x_height); top y1=vround 2y2;
y1-y2=y2-y3;
if hefty:
   for i:=1,2,3:
       forsuffixes $:=r, ,l: z[i]'$=z[i]$ + the_shift*left; endfor
   endfor
   filldraw stroke z1e--z2e--z3e;    % outer <
   filldraw stroke z1'e--z2'e--z3'e; % inner <
else:
   pos1'(qvair,0);
   pos2'(7/8 [hair,stem],0);
   pos3'(qvair,0);
   z2'=z2+the_shift*left;
   y1'-y2'=y2'-y3'=.8(y1-y2);
   z1'=z2'+whatever*(z1l-z2l); z3'=z2'+whatever*(z2l-z3l);
   filldraw stroke
       z1e{(x2e-x1e),1.2(y2e-y1e)}..{curl1}z2e{curl1}..
       {(x3e-x2e),1.2(y3e-y2e)}z3e;      % outer <
   filldraw stroke
       z1'e{(x2'e-x1'e),1.2(y2'e-y1'e)}..{curl1}z2'e{curl1}..
       {(x3'e-x2'e),1.2(y3'e-y2'e)}z3'e; % inner <
fi
% italic correction is set to |0| in |beginchar|, so let's correct it
corrital z2r;
repeat_once;
penlabels(1,2,3,1',2',3'); endchar;

lhchar "Sterling sign"; % from ec
cyrchar(pound,12u#,asc_height#,0);
adjust_fit(0,.75asc_height#*slant-.5u#); pickup fine.nib;
pos0(flare,0); pos1(hair,0); pos2(vair,90); pos3(stem,180);
pos4(stem,180); pos4'(stem,0); pos5(vair,-90); z4'=z4;
x2=2/3w-.5u; rt x3l=rt x4l=hround(.5w-u+.5stem); x5=2.5u;
y1=y3=.75h; top y2=h+oo; y4=.25h; bot y5r=-oo;
rt x1r=hround(w-1.5u); bulb(2,1,0);  % bulb
filldraw stroke pulled_arc.e(2,3)..z4e;  % stem
numeric light_stem; light_stem=2/3[vair,vstem];
pos6(.5[hair,light_stem],-180); pos7(light_stem,-300);
pos8(light_stem,-300); pos9(hair,-180);
lft x6r=hround u; x7=3u; x8=w-3.5u; rt x9l=hround(w-u);
y6=.4[y5,y7]; top y7r=vround .2h; bot y8l=-oo; y9=good.y .2h;
filldraw stroke pulled_arc.e(4',5)...z6e{up}...z7e{right}
 ..{right}z8e...{up}z9e;  % loop and arm
pos10(bar,90); pos11(bar,90); x10=3u; x11=w-4.5u;
top y10r=top y11r=vround(.5h+.5bar); filldraw stroke z10e--z11e;  % bar
penlabels(1,2,3,4,5,6,7,8,9,10,11); endchar;

endinput;
% end of file
