% grlower.mf v.2.1b 2000/01/12
% Copyright (C) 1997, 1998, 1999, 2000 Claudio Beccari
%
% Most of the following definitions come from Silvio Levy.
% CB added the small caps variants and made some `corrections' in order to
% work also with sans serif, bold, inclined, small caps,..., proportional
% and monospaced, text and slides fonts.
%
% CB added also the cursive or italic variants.
%
% Thanks to the  sigma  ligatures  the  layout  of  the accented letters are
% different from Silvio's ones; the layout includes also the Greek numerals
% (not included in this file; see cbdigits.mf)
% lowercase and uppercase digamma, uppercase iota and upsilon with diaeresis.
%
% The sigma ligatures are performed according to the new ligature commands
% that were introduced in METAFONT (and in TeX) after 1988; they were not
% available to Silvio; if they were, probably he'd had chosen the same
% approach as I did.
%
% (1999/10/25) CB added the adscript iota for the small cap alpha, eta
% and omega -- this was done on the explicit request of Apostolos Syropoulos
% and his classicist friend Efthimios.

 currentbreadth:=0;

% alpha

def width = if small_caps: 11 else:  9 fi u enddef;
def height = if small_caps: sclc* fi x_height enddef;
def dims = width#,height#,0 enddef;
def ital = 0 enddef;
def fit_params = 0,.5u# enddef;

def gen_letter =
  if small_caps:
    numeric left_stem,right_stem,outer_jut,alpha;
    right_stem=stem-stem_corr;
    left_stem=min(hair if hefty: -3stem_corr fi,right_stem);
    outer_jut=.8jut; x1l=w-x4r=l+letter_fit+outer_jut+.5u; 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-notch_cut: y0:=h-notch_cut;
     fill z0+.5right{down}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)
      --diag_end(4r,3r,1,1,2l,1l)--diag_end(2l,1l,1,1,1r,2r){z2-z1}
      ...{up}z0+.5left--cycle; % left and right diagonals
    else: fill z0--diag_end(0,4l,1,1,4r,3r)--diag_end(4r,3r,1,1,2l,1l)
      --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
    penpos5(whatever,angle(z2-z1)); z5=whatever[z1,z2];
    penpos6(whatever,angle(z3-z4)); z6=whatever[z3,z4]; y6=y5;
    if hefty: y5r else: y5 fi =5/12y0;
    y5r-y5l=y6r-y6l=cap_band;
    penstroke z5e--z6e; % bar line
    if serifs: numeric inner_jut; pickup tiny.nib;
     prime_points_inside(1,2); prime_points_inside(4,3);
     if rt x1'r+jut+.5u+1<=lft x4'l-jut: inner_jut=jut;
     else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
     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); fi  % right serif
      numeric pos_stem;                                     %iota reference
      pos_stem=rt x4r if serifs or slitex: -.5slab + outer_jut fi +.5(tiny+.5[vair,stem])+u;
  else:
    if cursive:
      adjust_fit(0,0);
      if slitex or monospace:pickup fine.nib; else: pickup pencircle; fi
      pos1(stem,0); top y1=x_height+oo;  x1l=x5l;           %top right
      pos2(hair,-90); pos4(hair,90); x4=x2=.5[x3l,x5l];
      bot y2r=-oo; top y4r=x_height+oo;                     %bottom and top bulges
      pos3(vstem,-180); lft x3r=hround 3/4u; y3=.5[y2,y4];  %left bulge
      pos6(vstem,90); x5=.55[x2,x6]; y6l=y2r; x6=w-2u;    %bottom right
      pos5(hair,0); y5=y3; pos8(.5[hair,stem],0); z8l=z5l;
      alpha_tail(6,7);                                      %hook
      filldraw stroke z5e{down}..z2e{left}..z3e{up}..z4e{right}..{down}z5e;
      filldraw stroke z1e{down}..z8e...z6e{right}...{up}z7e; %vertical and hook
      numeric x_baryctr; x_baryctr=.25[x4,x1];              %accent reference
      numeric pos_stem;                                     %iota reference
      pos_stem=x5l;
    else:
      adjust_fit(0,0);
      pickup fine.nib;
      pos1(stem,0); top y1=x_height+oo; rt x1r=hround(w-.5u);       %top right
      pos2(vstem,-90); pos4(vstem,-270); x4=x2=.5w-u;
      bot y2r=-oo; top y4r=x_height+oo;                     %bottom and top bulges
      pos3(hair,-180); lft x3r=hround .75u; y3=.5[y2,y4];   %left bulge
      pos6(vstem,90); x6=w-u; y6=y2;                        %bottom right
      numeric theta; theta=angle((x4-x6),2.5(y4-y6))-90;
      pos5(hair,theta); x5=.55[x4,x6]; y5=y3;               %point of inflection
      alpha_tail(6,7);                                      %hook
      filldraw stroke z1e{(x2-x1,2(y2-y1))}...              %diagonal
       pulled_arc.e(2,3) & pulled_arc.e(3,4)                %bowl
       ...z5e{(x6-x4,2.5(y6-y4))}...z6e{right}...{up}z7e;   %diagonal and hook
      numeric x_baryctr; x_baryctr=.25[x4,x1];              %accent reference
      numeric pos_stem; pos_stem=x_baryctr;                 %iota reference
    fi
  fi
enddef;



cmchar "Lowercase alpha";
beginchar("a",dims);
this_letter; penlabels(1,2,3,4,5,6,7); endchar;

iff(not barebones):
cmchar "Lowercase alpha with grave";
beginchar(oct"200",width#,acc_ht#,0);
this_letter; if not small_caps: grave(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with rough breathing";
beginchar(oct"201",width#,acc_ht#,0);
this_letter; if not small_caps: spirit(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with smooth breathing";
beginchar(oct"202",width#,acc_ht#,0);
this_letter; if not small_caps: spirit(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with grave and iota subscript";
beginchar(oct"204",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; grave(x_baryctr);
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with rough breathing and iota subscript";
beginchar(oct"205",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; spirit(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with smooth breathing and iota subscript";
beginchar(oct"206",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; spirit(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with acute";
beginchar(oct"210",width#,acc_ht#,0);
this_letter; if not small_caps: acute(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with rough breathing and acute";
beginchar(oct"211",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_acute(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with smooth breathing and acute";
beginchar(oct"212",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_acute(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with rough breathing and grave";
beginchar(oct"203",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with smooth breathing and grave";
beginchar(oct"213",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with rough breathing and grave and iota subscript";
beginchar(oct"207",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; spirit_grave(x_baryctr)<;
fi
iota_sub(pos_stem);  endchar;

iff(not barebones):
cmchar "Lowercase alpha with smooth breathing and grave and iota subscript";
beginchar(oct"217",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; spirit_grave(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with acute and iota subscript";
beginchar(oct"214",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; acute(x_baryctr);
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with rough breathing, acute and iota subscript";
beginchar(oct"215",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; spirit_acute(x_baryctr)<;
fi
iota_sub(pos_stem);  endchar;

iff(not barebones):
cmchar "Lowercase alpha with smooth breathing and acute and iota subscript";
beginchar(oct"216",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; spirit_acute(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with circumflex";
beginchar(oct"220",width#,circ_ht#,0);
this_letter; if not small_caps:
squeeze:=false; circumflex(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with rough breathing and circumflex";
beginchar(oct"221",width#,Circ_ht#,0);
this_letter; if not small_caps:
squeeze:=true;  spirit_circumflex(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with smooth breathing and circumflex";
beginchar(oct"222",width#,Circ_ht#,0);
this_letter; if not small_caps: squeeze:=true; spirit_circumflex(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase alpha with circumflex and iota subscript";
beginchar(oct"224",width#,if small_caps:height#else:circ_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; squeeze:=false; circumflex(x_baryctr);
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with rough breathing, circumflex and iota subscript";
beginchar(oct"225",width#,if small_caps:height#else:Circ_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter;squeeze:=true; spirit_circumflex(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with smooth breathing, circumflex and iota subscript";
beginchar(oct"226",width#,if small_caps:height#else:Circ_ht#fi,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter; squeeze:=true; spirit_circumflex(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase alpha with iota subscript";
beginchar(oct"370",width#,height#,iota_dp#);
if small_caps:
  adjust_fit(0,serif_fit#+.5[vair#,stem#]+
    if serifs:.4jut#elseif not slitex: .5*(.5[vair#,stem#])fi
       +if monospace:1.8elseif slitex:1.5else:.5fi tiny#+1.3u#);
gen_letter;
else:
this_letter;
fi
iota_sub(pos_stem); endchar;

%picture pic.iota;
picture savedpicture; currentbreadth:=0;


def dims = if small_caps: 10u#, sclc*x_height#,0 %          lowercase beta
           else: 9u#,asc_height#,desc_depth# fi enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;

def gen_letter=
  if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(serif_fit#,0);
    numeric left_stem,right_curve,middle_weight;
    left_stem=stem-hround 2stem_corr; middle_weight=.6vair+.5;
    pickup tiny.nib; pos1(left_stem,0); pos2(left_stem,0);
    lft x1l=lft x2l=hround max(2u,3u-.5left_stem); top y1=h; bot y2=0;
    filldraw stroke z1e--z2e; % stem
    penpos3(.7cap_band,90); penpos4(.7cap_band,90);
    penpos6(middle_weight,-90); penpos7(middle_weight,-90);
    penpos8(middle_weight,90); penpos9(middle_weight,90);
    penpos5(right_curve-stem_corr,0); penpos10(right_curve,0);
    penpos11(cap_band,-90); penpos12(cap_band,-90);
    z3r=top z1; y4=y3; y5=.5[y4,y6]; y6=y7; y7l-y8l=vair;
    z12r=bot z2; y11=y12; y10=.5[y11,y9]; y8=y9; .5[y7l,y8l]=.52h;
    x4=x6; x9=x11=x4+.5u; x7=x8=x1; x9l:=x4+.25u;
    x5r=hround(w-1.5u); x10r=hround(w-u);
    if serifs: right_curve=curve-stem_corr; x4=.5[x1,w-1.5u];
    else: right_curve=curve-3stem_corr; x4=.5[x1,w-2.5u];
     x4l:=x4l-.5u; x9l:=x9l-.5u; fi
    x6l:=x6l-.5u; x11l:=x11l-.5u;
    fill stroke z3e..super_arc.e(4,5) & super_arc.e(5,6)..z7e;  % upper lobe
    fill stroke z8e..super_arc.e(9,10) & super_arc.e(10,11)..z12e;  % lower lobe
    if serifs: if not monospace:dish_serif(1,2,a,1/3,jut,b,1/3,.5jut)  % upper serif
     else: serif(1,2,a,1/3,-jut) fi;
     dish_serif(2,1,c,1/3,jut,d,1/3,.5jut); fi  % lower serif
    math_fit(0,.5ic#);
  else:
   italcorr .8*asc_height#*slant-.5u#;
   if cursive:
    if monospace or slitex: pickup fine.nib; fi
    numeric bstem; bstem=.7[hair,stem];
    pos1(bstem,0); lft x1l=3/4u; bot y1=-d;
    pos2(bstem,0); x2r=x1r; y2=bar_height;
    pos3(bstem,-45); x3r=x1r; y3r=if serifs:if monospace:.3 else:.55fi
                                  else: if slitex:.4 else:.5fi fi[bar_height,h];
    pos5(hair,-90); x5=w/2; top y5l=h+oo;
    pos7(stem,180); x7l=w-7/5x1l; y7=3/4h;
    pos8(hair,90); x8=x5; y8=y9;
    pos9(max(hair,9/10bstem),90);  x9-.5bstem=rt x1r+.15u; y9=1/2h;
    filldraw stroke z1e{up}..z2e..z3e..{right}z5e..{down}z7e..{left}z8e;
    filldraw circ_stroke z9e..{right}z8e;
    pos12(stem,0); x12r=w-x1l; y12=1/4h;
    pos14(hair,-90); x14=x5; bot y14r=-oo;
    pos15(bstem,-135); x15l=x1r; y15=x_height-y9;
    filldraw stroke z8e{right}..{down}z12e..{left}z14e..z15e;
    numeric bstem;
   else:
    pickup fine.nib;
    numeric thin_stem; thin_stem=.6[hair,stem];           %for upper bowl
    numeric tilt; tilt=min(2*otilt,.5);                   %for both bowls
    pos1(stem,180); y1-.5stem=-d-o;               %bottom left
    pos2(hair,180); y2=.5bar_height;              %self-intersection (cf. z15)
    x1=x2; lft x1r=hround(.75u+.5(hair-stem));    %i.e., lft x2r ~ .75u
    x3r=x2r;                                      %beginning of curve
    top y5r=h+oo; bot y14r=-oo; x5r=x14r;         %top and bottom bulges
    if monospace or slitex:
     top y10r=x_height; z9=z10;
     pos9(stem,-90); pos10(stem,90);
    else:
     top y10r=vstem+bot y9r=x_height; x9r=x10r;    %top and bottom of cusp
    fi
    rt x12r=hround(w-.75u);                       %lower right bulge
    x5r=.5[lft x2r,rt x12r]; x9r-.5vstem=hround(x5r-.5u-.5vstem);
    % we want to simulate the following relations, to make slopes consistent
    % (where z7 is the upper right bulge):
    % z5r-z3r=whatever*(z9r-z7r)=whatever*(z14r-z12r);
    % z7r-z5r=whatever*(z12r-z10r)=whatever*(z5r-z3r) yscaled -1;
    numeric slope;
    slope=((y10r-y12r)+(y12r-y14r))/((x12r-x10r)+(x12r-x14r));
    z7'r=z9r+whatever*(1,slope); z7'r=z5r+whatever*(1,-slope);
    y7r=y7'r; rt x7r=hround rt x7'r;
    z12r=z14r+whatever*(1,slope); z3r=z5r+whatever*(1,slope);
    if monospace or slitex:
     pos7(stem,0); pos5(stem,90); pos3(stem,180);                 %top and left
     filldraw circ_stroke z1e--z2e..z3e{up}..{right}z5e...{down}z7e;
    else:
     filldraw double_circ_stroke gr_arc.e(7,6,5)(hair,thin_stem,tilt)..
      gr_arc.e(5,4,3)(hair,thin_stem,tilt)..{down}z2e..z1e;
    fi
    z2=z15; pos15(hair,slope-90);         %intersection pt
    numeric slope;
    slope=angle((z14r-z15)yscaled 2);
    filldraw stroke z15e{dir slope}...gr_arc.e(14,13,12)(hair,stem,tilt); %bottom
    if not (monospace or slitex):
     forsuffixes e=r,l:
       path curv[]e; numeric S[]e;
       curv1e=reverse gr_arc.e(9,8,7)(hair,thin_stem,tilt);        %cusp bottom
       curv2e=gr_arc.e(12,11,10)(hair,stem,tilt); endfor           %cusp top
      (S1r,S2r)=curv1r intersectiontimes curv2r;
      (whatever,S2l)=curv1r intersectiontimes curv2l;
      (S1l,whatever)=curv1l intersectiontimes curv2r;
      if S1l=-1 : S1l:=2; fi
      if S2l=-1 : S2l:=2; fi
      filldraw stroke subpath(0,S1e+eps) of curv1e;                 %fill in cusp
      filldraw stroke subpath(0,S2e+eps) of curv2e;
      filldraw subpath (S1r+eps,2) of curv1r...subpath(2,S2r+eps) of curv2r..cycle;
    else:
      if slitex:
      filldraw double_circ_stroke z12e{up}...{left}z10e;
      else:
      filldraw stroke z12e{up}...{left}z10e;
      fi
      filldraw stroke z9e{right}...{up}z7e;
    fi
   fi
  fi
enddef;

cmchar "Lowercase beta";
beginchar("b",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); endchar;

picture savedpicture; currentbreadth:=0;



def dims = if small_caps: 9u#, sclc*x_height#,0
           else:
           10u#,x_height#,desc_depth# fi enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;



def gen_letter=
  if small_caps: sc_beak_jut:=.7beak_jut; sc_beak:=.7beak; sc_jut:=.9jut;
    italcorr height#*slant-beak_jut#-.25u#;
    h:=vround(h-stem_corr);
    pickup tiny.nib; pos1(stem,0); pos2(stem,0);
    lft x1l=lft x2l=hround 2u+sc_beak_jut; top y1=h; bot y2=0;
    filldraw stroke z1e--z2e; % stem
    pickup crisp.nib; pos3(slab,90); pos4(hair,0);
    top y3r=h; x3=x1; rt x4r=hround(w-if serifs:.75fi u); y4=good.y(y3l-sc_beak)-eps;
    arm(3,4,e,beak_darkness,sc_beak_jut);  % arm and beak
    if serifs: dish_serif(1,2,a,1/3,sc_jut,b,1/3,.5sc_jut);  % upper serif
     dish_serif(2,1,c,1/3,sc_jut,d,1/3,1.25sc_jut); fi  % lower serif
    math_fit(0,ic#-2.5u#);
  else:
   if cursive and serifs and not monospace:
    adjust_fit(.5stem#,0);
    pos1(hair,90); pos2(stem,45);
    lft x1r=0; top y1=bot y2l; top y2r= h+oo; x2l-x1r=5/4u;
    pos3(stem,0); x3l=x2r+2/3u; y3=3/4h;
    pos4(hair,0); y4=-o; x4=w/2;
    filldraw stroke z1e..z2e..z3e..{down}z4e;
    pos7(hair,-45); z7=z4;
    pos5(stem,0); bot y5-.5stem=-d-oo; z4-z5=whatever*dir(70);
    filldraw z4r{down}..z5r...z5l{up}...{dir(45)}z7l--cycle;
    numeric tilt; tilt=20;
    pos6(stem,30); top y6=h+oo-.5stem; rt x6r=w-3/4u;
    filldraw circ_stroke z6e{dir(tilt-90)}..{dir(225)}z7e;
    numeric tilt;
   else:
    pickup fine.nib; superness__:=superness;
    begingroup
      save t; t:=superness__;
      superness:=.95t;
      pos2(curve,90); top y2r=h+oo;         %top of left branch
      pos1(hair,180); bot y1=top y2r-4/3curve;      %tip of hook
      lft x1r=hround .5u; x2-x1=y2-y1;          %central arc is round
      pos5(curve,-270); top y5r=h+oo; x5+.5curve=hround(w-.75u); %right branch
      pos5'(curve,0); z5'=z5;
      filldraw stroke z1e{up}...z2e{right};
      if serifs and (not monospace):
        rt x3r-lft x4r= stem;                           %bottom of cusp
      else:
        x3-x4=abs(if (not monospace): 1.2stem-vair else: 0 fi);
      fi
      pos3(hair,0); pos4(hair,-180);
      y4=y3; .5[x3,x4]=.5w;
      if monowidth:
        y3=0 else: y3-.5stem=vround(-.8d)
      fi;
      drawloop(2,3,4,5);                                    %hook and cusp
      filldraw z5l{right}...z5'r{up}...z5r{left}--cycle;    %right branch
      if monowidth:                                         %complete stem
        x3'=x3r; x4'=x4r; y3'=y4'; y3'-.5stem=vround(-.8d);
        filldraw z3r--z3'{down}...{up}z4'--z4r--cycle;
      fi
    endgroup;
    superness:=superness__;
   fi
  fi
enddef;


cmchar "Lowercase gamma";
beginchar("g",dims);
if small_caps: adjust_fit(serif_fit#,0)else: adjust_fit(0,0)fi;
this_letter; penlabels(1,2,3,3',4,4',5,6,7); endchar;

picture savedpicture; currentbreadth:=0;



def dims = if small_caps: 11u#, sclc*x_height#,0
           else: 8.5u#,asc_height#,0
           fi enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;


def gen_letter =
  if small_caps:
    numeric left_stem,alpha;
    left_stem=hair if hefty: -3stem_corr fi;
    x1l=w-x4r=.75u; 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*stem,0); penpos4(alpha*stem,0);
    fill diag_end(2l,1l,1,1,4r,3r)--diag_end(4r,3r,1,1,2l,1l)--cycle;  % triangle
    z0=whatever[z1r,z2r]=whatever[z3l,z4l];
    y5=y6=vstem; z5=whatever[z1r,z2r]; z6=whatever[z3l,z4l];
    if y0<h-notch_cut: y0:=h-notch_cut;
     unfill z0+.5right{down}...{z4-z3}z6--z5{z2-z1}
      ...{up}z0+.5left--cycle; % counter
    else: unfill z0--z5--z6--cycle; fi  % counter
  else:
   if cursive and serifs and not monospace:             % regular, outline and cursive
     pos1(hair,-90); y1l=x_height+o; x1=w/2;
     pos2(stem,0); lft x2l=3/4u; y2=y1/2;
     pos3(hair,90); bot y3l=-oo; x3=x1;
     pos4(stem,180); y4=y2; x4l=w-x2l;
     pos5(stem,180); z5=z1;
     pair zd,ze; zd=(-w,h-x_height);
     pos6(hair,angle(zd));
     z6-(w,x_height)=whatever*zd; x6r=.1[x2l,x1];
     ze=zd rotated -90; pos7(.5[hair,stem],90);
     x7= x4; y7=.6[y5,y6];
     filldraw stroke z1e{left}..z2e..z3e..z4e..z5e...z6e{ze}...{-zd}z7e;
   else:                                                % sanserif, typewriter, slides
    pickup fine.nib;
    top y1r=vround(if not monowidth:.95 fi x_height+oo); x1r=.5w; %top of loop
    x5r=.5w; bot y5r=-oo;                                 %bottom of ditto
    lft x3r=w-rt x7r=hround(.75u); y3r=y7r=.5[y1r,y5r];   %left and right bulge
    filldraw stroke gr_arc.e(1,2,3)(vair,stem,.5otilt)    %three quadrants of loop
      & gr_arc.e(3,4,5)(vair,stem,.5otilt) & gr_arc.e(5,6,7)(vair,stem,.5otilt);

    %we now draw the hook z8..z9..z10.  It must satisfy the following constraints:
    %its outer contour is symmetric with respect to some axis containing z9l;
    %one end is known, the width there is thin_stem, and the width at z10
    %is, ideally, stem.  (But since we may have to change that we call it Stem.)
    z8l=z1l; numeric thin_stem, med_stem; thin_stem=.7[hair,Stem];
    %the aperture, measured perpendicular to the axis, equals Stem
    numeric apert; apert=2Stem+thin_stem-currentbreadth;  %apert=length(z10l-z8l);
    numeric left_goal; lft left_goal=vround(lft x3r+.5u); %leftmost tangent known
    numeric top_goal; top top_goal=h+oo;                  %highest tangent known

    %if by taking Stem=stem we got apert > top_goal-y1l, the problem might
    %not have a solution with a horizontal tangent; in that case the
    %constraint is on apert:
    if 2stem+.7[hair,stem]-currentbreadth>top_goal-y8l: apert=top_goal-y8l;
    else: Stem=stem; fi

    %we first estimate the slope of the axis by imagining that, in the vicinity
    %of z9l, the hook looks like a semicircle of diameter apert/2.
    %(this value is empiric, but reasonable because the tension is high)
    z0l=(left_goal+.25apert,top_goal-.25apert);           %center of semicircle
    numeric axis; axis=angle(z0l-z8l)+angle(length(z0l-z8l)+-+.5apert,.5apert);
    z9l=z0l+(.25apert,0)rotated(axis); z10l=z8l+(0,-apert)rotated(axis);

    %we now iterate, correcting z9l until the tangencies are satisfied
    path hook; numeric left_real; numeric top_real;
    forever:

      hook:=z8l{dir(axis)}..tension 1.5..z9l..tension 1.5..{-dir(axis)}z10l;
      if directiontime up of hook=-1:
        left_error:=0; message "hook has no vertical tangent!";
      else: left_error:=xpart directionpoint up of hook-left_goal; fi
      if directiontime right of hook=-1:
        top_error:=0; message "hook has no horizontal tangent!";
      else: top_error:=ypart directionpoint right of hook-top_goal; fi

  %message "top_error:"; show top_error; message "left_error:"; show left_error;

      exitif (abs(left_error)<.05) and (abs(top_error)<.05);
      x9l:=x9l-left_error; y9l:=y9l-top_error;
      axis:=angle(z9l-z8l)+angle(length(z9l-z8l)+-+.5apert,.5apert);
      x10l:=x8l+apert*sind axis; y10l:=y8l-apert*cosd axis;
    endfor

    y10l:=y10l+.5*(x7r-x10l)*(sind axis)/(cosd axis);
    x10l:=x7r;

    pos8(max(thin_stem,fine+eps),axis-90);
    pos10(max(Stem,fine+eps),axis+90);
    pos9(max(.3[hair,Stem],fine+eps),axis+180);
    filldraw stroke
      z7e{z7'e}..{dir axis}z8e..tension 1.5..z9e..tension 1.5..{-dir axis}z10e;
   fi
  fi
enddef;


cmchar "Lowercase delta";
beginchar("d",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8,9,10); endchar;

picture savedpicture; currentbreadth:=0;



def width = if small_caps: 9.5 else:7.75fi u enddef;
def height = if small_caps: sclc* fi x_height enddef;
def dims = width#,height#,0 enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;

def gen_letter =
  if small_caps:
    sc_beak#:=.7beak#; sc_beak_jut#:=.7beak_jut#;
    define_pixels(sc_beak,sc_beak_jut);
    adjust_fit(serif_fit#,0);
    italcorr slant*height#-sc_beak_jut#-.5u#;
    h:=vround(h-stem_corr);
    pickup tiny.nib; pos1(stem,0); pos2(stem,0);
    lft x1l=lft x2l=hround max(2u,3u-.5stem); top y1=h; bot y2=0;
    filldraw stroke z1e--z2e;                                      % stem
    pickup crisp.nib; pos3(slab,90); pos4(hair,0);
    top y3r=h; x3=x1; rt x4r=hround(w-u); y4=good.y(y3l-sc_beak)-eps;
    arm(3,4,e,beak_darkness,sc_beak_jut);            % upper arm and beak
    pos5(cap_bar,-90); pos6(hair,0);
    top y5l=vround(.52[y2,y1]+.5cap_bar); x5=x1;
    pos0(cap_bar,90); pos7(hair,0);
    z0=z5; x6=x7; y6-y5l=y0l-y7;
    if serifs:
     rt x6r=hround(.5[x3r,x4r+sc_beak_jut]);
     y6=good.y(y5l+.6*sc_beak)+eps;
     rt x9r=hround(w-.5u);
    else: rt x6r=hround(w-1.5u); y6=y5l+eps; rt x9r=hround(w-.75u); fi
    arm(5,6,f,beak_darkness,0); arm(0,7,g,beak_darkness,0);
                                                    % middle arm and serif
    pos8(slab if not serifs:+2stem_corr fi,-90); pos9(hair,0);
    bot y8r=0; x8=x2; y9=good.y(y8l+7/6sc_beak)+eps;
    arm(8,9,h,beak_darkness,1.5sc_beak_jut);         % lower arm and beak
    if serifs: dish_serif(1,2,a,1/3,jut,b,1/3,.5jut);  % upper serif
     dish_serif(2,1,c,1/3,jut,d,1/3,.5jut); fi  % lower serif
    math_fit(0,.5ic#);
  else:
   if cursive:
    if slitex or monospace: pickup fine.nib; fi
    pos1(hair,90); pos2(stem,180); pos3(hair,270);
    lft x2r=3/4u; rt x1=rt x3=w-u;
    h-top y1r=bot y3r=-oo; y2=bar_height;
    filldraw stroke z1e{left}..z2e..{right}z3e;
    numeric ehair; ehair=.3[hair,stem];
    pos4(ehair,90); pos5(hair,90);
    x4=x2; x5=x1-min(hair,u); y4=y5=y2;
    filldraw stroke z4e..z5e;
    numeric x_baryctr; x_baryctr=w/2;
   else:
    pickup fine.nib;
    pos2(vstem,90); x2=.5w; top y2r=x_height+o;           %top point
    pos7(vstem,-90); x2=x7; bot y7r=-o;                   %bottom point
    rt x1r=hround(w-.75u); bot y1l=.3[bot y2l,bar_height];        %top end
    z1'=(x1r,y1l+.5(flare-currentbreadth));               %approximation to z1
    numeric slope; slope=angle((z2-z1')yscaled 2); pos1(flare,slope-90);
    bar_height=.5[y1,y8]; x8=x1; pos8(flare,slope+90);    %bottom end
    pos3(vstem,120); lft x3r=hround .75u; y3=.5[y4r,y2r]; %top left bulge
    pos6(vstem,-120); x6=x3; .5[y6,y3]=bar_height;        %bottom left bulge
    y6:=y6r;y3:=y3r;                      %for the benefit of pulled_arc
    y5-y4=abs(curve-min(hair,vair));
    y5+y4=2bar_height; x5=x4=x2;   %loop
    pos4(vair,-90); pos5(vair,90);
    filldraw stroke z1e{dir slope}...pulled_arc.e(2,3);   %top
    drawloop(3,4,5,6);                                    %loop and bottom
    forsuffixes e=l,r:
      path foo.e; foo.e= z8e...pulled_arc.e(7,6);
      if angle(direction 0 of foo.e) > angle(z8r-z8l):
      foo.e:= z8e{z8r-z8l}...pulled_arc.e(7,6); fi
    endfor;
    filldraw stroke foo.e;
    numeric x_baryctr; x_baryctr=x2;                      %accent reference
   fi
  fi
enddef;

cmchar "Lowercase epsilon";
beginchar("e",dims);
adjust_fit(fit_params);
this_letter; penlabels(1,2,3,4,5,6,7,8,9); endchar;


iff(not barebones):
cmchar "Lowercase epsilon with grave";
beginchar(oct"340",width#,acc_ht#,0); this_letter;
if not small_caps: grave(x_baryctr); fi
endchar;


iff(not barebones):
cmchar "Lowercase epsilon with rough breathing";
beginchar(oct"341",width#,acc_ht#,0);
this_letter; if not small_caps: spirit(x_baryctr)<; fi endchar;


iff(not barebones):
cmchar "Lowercase epsilon with smooth breathing";
beginchar(oct"342",width#,acc_ht#,0);
this_letter; if not small_caps: spirit(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase epsilon with acute";
beginchar(oct"350",width#,acc_ht#,0);
this_letter; if not small_caps: acute(x_baryctr); fi endchar;


iff(not barebones):
cmchar "Lowercase epsilon with rough breathing and acute";
beginchar(oct"351",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_acute(x_baryctr)<; fi endchar;


iff(not barebones):
cmchar "Lowercase epsilon with smooth breathing and acute";
beginchar(oct"352",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_acute(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase epsilon with rough breathing and grave";
beginchar(oct"343",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase epsilon with smooth breathing and grave";
beginchar(oct"353",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)>; fi endchar;

picture savedpicture; currentbreadth:=0;


def dims = if small_caps:
           9u#,sclc*x_height#,0
           else:
           8.5u#,asc_height#,desc_depth#
           fi enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;


def gen_letter=
  if small_caps:
    italcorr height#*slant-.5u#;
    adjust_fit(0,0);
    numeric arm_thickness[],z_stem;
    if hefty: arm_thickness1=Vround(slab-vair_corr); arm_thickness2=slab;
     z_stem=.8[vair,stem];
    else: arm_thickness1=slab; arm_thickness2=vround(slab+vair_corr);
     z_stem=.9[vair,stem]; fi
    pickup tiny.nib; x3l=x4l=w-x1r=w-x2r; lft x3l=hround u;
    top y1=h; y2=min(y1,h-2/3arm_thickness1);
    bot y4=0; y3=max(y4,2/3arm_thickness2);
    numeric alpha; alpha=diag_ratio(1,z_stem-tiny,y2-y3,x2r-x3l);
    penpos1(alpha*(z_stem-tiny),0); penpos2(alpha*(z_stem-tiny),0);
    penpos3(alpha*(z_stem-tiny),0); penpos4(alpha*(z_stem-tiny),0);
    pair delta; delta=penoffset z3-z2 of currentpen;
    fill top lft z1l--z2l+delta---z3l+delta..lft z3l---lft z4l..bot z4l
     ---bot rt z4r--z3r-delta---z2r-delta..rt z2r---rt z1r..top z1r
     ---cycle;  % diagonal
    pickup crisp.nib; pos5(arm_thickness1,90); pos6(hair,180);
    top y5r=h; x5=x1; lft x6r=hround 1.25u; y6=good.y(y5l-beak)-eps;
    arm(5,6,a,beak_darkness**.8,-.4beak_jut);  % upper arm and beak
    pos7(arm_thickness2,-90); pos8(hair,0);
    bot y7r=0; x7=x4; rt x8r=hround(w-.9u); y8=good.y(y7l+1.2beak)+eps;
    arm(7,8,b,beak_darkness**.9,.6beak_jut);  % lower arm and beak
    math_fit(0,.5ic#);
  else:
   if cursive and serifs and not monospace:
    pos4(stem,-180); y4=.8bar_height; lft x4r=hround(.75u);         %left bulge
    pos6(hair,-180); rt x6l=hround(w-.75u); y6=-.5stem;           %bottom right
    y3+.5stem=h+o; x3+.5stem=hround(rt x6l-.25u);                 %top right
    numeric slope; slope=angle((z3-z4)xscaled 2);
    pos3(.5[hair,stem],slope+90);
    pos5(stem,-135); bot y5r=0; x5=.5w;                            %inflection pt
    pos7(vstem,-270); y6=.5[y7r,y5r]; x7-.5vstem=hround x5;
    filldraw double_circ_stroke                                   %bowl and tail
      z7e{right}...z6e{up}...z5e{left}...z4e{up}...z3e{dir slope};
    pos2(hair,slope+90); z2r=z3r;                         %where handle attaches
    pos0(hair,0); y0=h; x0=x1r;
    pos1(stem,0); lft x1l=hround(lft x4r+.25u); y1+.5stem=h;  %end of handle
    filldraw stroke z0e..z1e{down}...z2e{dir slope};
   else:
    pickup fine.nib;
    pos4(hair,-180); y4=bar_height; lft x4r=hround(.75u);         %left bulge
    pos6(hair,-180); rt x6l=hround(w-.75u); y6=-.5stem;           %bottom right
    y3+.5stem=h+o; x3+.5stem=hround(rt x6l-.25u);                 %top right
    numeric slope; slope=angle((z3-z4)xscaled 2); pos3(stem,slope+90);
    pos5(stem,-90); bot y5r=0; x5=.5w;                            %inflection pt
    pos7(vstem,-270); y6=.5[y7r,y5r]; x7-.5vstem=hround x5;
    filldraw double_circ_stroke                                   %bowl and tail
      z7e{right}...z6e{up}...z5e{left}...z4e{up}...z3e{dir slope};
    pos2(hair,slope+90); z2r=z3r;                         %where handle attaches
    pos1(curve,0); lft x1l=hround(lft x4r+.25u); y1+.5curve=h+o;  %end of handle
    filldraw circ_stroke z1e{down}...z2e{dir slope};
   fi
  fi
enddef;


cmchar "Lowercase zeta";
beginchar("z",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8); endchar;

picture savedpicture; currentbreadth:=0;



% eta
def width = if small_caps: if serifs: 11 else: 9 fi
            elseif cursive and serifs and not monospace: 9.5
            else: 8.5
            fi u enddef;
def dims = width#,if small_caps:sclc* fi x_height#,%
           desc_depth#  enddef;
def ital = 0 enddef;
def fit_params = if small_caps: 0 else: if straight: .75 else: .5 fi u# fi,0 enddef;

def gen_letter =
 if small_caps:
   pickup tiny.nib; pos1(stem,0); pos2(stem,0);
   pos3(stem,0); pos4(stem,0);
   lft x1l=lft x2l=hround (u+jut); x3=x4=w-x1;
   top y1=top y3=h; bot y2=bot y4=0;
   filldraw stroke z1e--z2e; % left stem
   filldraw stroke z3e--z4e; % right stem
   penpos5(cap_bar,90); penpos6(cap_bar,90);
   x5=x1; x6=x3; y5=y6=.52h;
   fill stroke z5e--z6e;  % bar
   if serifs: numeric inner_jut;
    if rt x1r+jut+.5u+1<=lft x3l-jut: inner_jut=jut;
    else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
    dish_serif(1,2,a,1/3,jut,b,1/3,inner_jut);  % upper left serif
    dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut); % lower left serif
    dish_serif(3,4,e,1/3,inner_jut,f,1/3,jut);  % upper left serif
    dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut); fi  % lower left serif
   math_fit(0,.5ic#);
   numeric pos_stem;
   pos_stem=rt x4r if serifs or slitex:+jut+if slitex:.7else:.9fi u fi + if slitex:1.2*fi.5[vair,stem]+.1u;
 else:
  if cursive and serifs and not monospace:
   pos1(hair,90); pos2(stem,45); pos3(stem,0);
   x1=0; y1=y2l; y2r=x_height+oo; x2=.5[x1,x3]; y3=3/4y2r; x3l=x1+stem;
   pos4(stem,0); x4=x3; y4=0;
   filldraw stroke z1e..{right}z2e..{down}z3e..z4e;
   pos5(hair,135);  z5l=z3r;
   pos6(stem,45); pos7(stem,0); pos8(stem,0);
   x7r=x8r=w-u; y7=3/5y2r; y8=-d; x6l=.5[x5l,x7l]; y6r=y2r;
   filldraw stroke z5e..{right}z6e..{down}z7e..z8e;
   numeric x_baryctr; x_baryctr=.4[x3,x7];                %accent reference
   numeric pos_stem; pos_stem=x3;                         %iota reference
  else:
   pickup fine.nib;
   y1r-.5stem=-d-o; pos1(stem,0);                                 %bottom right
   rt x2r=hround(w-.75u); y2r=.5x_height; pos2(hair,0);           %right bulge
   lft x5r=hround(1.5u); y5-.5stem=-o; pos5(stem,-180);           %bottom left
   top y4r=x_height+o; x4r=.5[lft x2l,rt x5l];                    %top of arch
   pos6(hair,180); y6=y2;                                 %where handle attaches
   if straight:
    x1=x2; x5=x6; pos4(stem,90);                          %yawn...
    filldraw double_circ_stroke z1e--pulled_arc.e(2,4)&pulled_arc.e(4,6)--z5e;
   else:
    if serifs:                                     %%<< aggiunto questo if
      rt x1r=hround (rt x2r-.25);
    else:
      rt x1r= rt x2r-u;
    fi
    z2'l=z2'r=up;                    %%<< e mossa questa assegn.
    filldraw circ_stroke z1e{up}...gr_arc.e(2,3,4)(hair,stem,.8); %right leg
    filldraw circ_stroke z5e{(z4-z5) yscaled 3}...z4e{-z4'e};     %left leg
    z9=((0,y6)--(w,y6)) intersectionpoint (z5r{(z4-z5) yscaled 3}...z4r{-z4'r});
    x6r=x9;
   fi
   pos8(vstem,0); rt x8r=hround(lft x6r-.75u);            %end of handle
   pos7(vstem,-90); top y7l=x_height+o; z8r=z7r;          %top of handle
   filldraw circ_stroke z8e{up}...z7e{right}...z6e{down};
   numeric x_baryctr; x_baryctr=.1[x4,x7];                %accent reference
   numeric pos_stem; pos_stem=x5;                         %iota reference
  fi
 fi
enddef;


cmchar "Lowercase eta";
beginchar("h",dims);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if serifs: adjust_fit(serif_fit#,serif_fit#); fi
fi
this_letter; penlabels(1,2,3,4,5,6,7,8); endchar;



iff(not barebones):
cmchar "Lowercase eta with grave";
beginchar(oct"230",width#,acc_ht#,desc_depth#);
this_letter; if not small_caps: grave(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase eta with rough breathing";
beginchar(oct"231",width#,acc_ht#,desc_depth#);
this_letter; if not small_caps: spirit(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase eta with smooth breathing";
beginchar(oct"232",width#,acc_ht#,desc_depth#);
this_letter; if not small_caps: spirit(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase eta with grave and iota subscript";
beginchar(oct"234",width#,if small_caps:height#else:acc_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; grave(x_baryctr);
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with rough breathing and iota subscript";
beginchar(oct"235",width#,if small_caps:height#else:acc_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; spirit(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with smooth breathing and iota subscript";
beginchar(oct"236",width#,if small_caps:height#else:acc_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; spirit(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with acute";
beginchar(oct"240",width#,acc_ht#,desc_depth#);
this_letter; if not small_caps: acute(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase eta with rough breathing and acute";
beginchar(oct"241",width#,acc_ht#,desc_depth#);
this_letter; if not small_caps: spirit_acute(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase eta with smooth breathing and acute";
beginchar(oct"242",width#,acc_ht#,desc_depth#);
this_letter; if not small_caps: spirit_acute(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase eta with acute and iota subscript";
beginchar(oct"244",width#,if small_caps:height#else:acc_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; acute(x_baryctr);
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with rough breathing and grave";
beginchar(oct"243",width#,acc_ht#,desc_depth#);
this_letter; if not small_caps: spirit_grave(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase eta with smooth breathing and grave";
beginchar(oct"253",width#,acc_ht#,desc_depth#);
this_letter; if not small_caps: spirit_grave(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase eta with rough breathing and grave and iota subscript";
beginchar(oct"247",width#,if small_caps:height#else:acc_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#);% +u#
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; spirit_grave(x_baryctr)<;
fi
iota_sub(pos_stem);  endchar;

iff(not barebones):
cmchar "Lowercase eta with smooth breathing and grave and iota subscript";
beginchar(oct"257",width#,if small_caps:height#else:acc_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; spirit_grave(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with rough breathing, acute and iota subscript";
beginchar(oct"245",width#,if small_caps:height#else:acc_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; spirit_acute(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with smooth breathing and acute and iota subscript";
beginchar(oct"246",width#,if small_caps:height#else:acc_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; spirit_acute(x_baryctr)>;
fi
iota_sub(pos_stem);
endchar;

iff(not barebones):
cmchar "Lowercase eta with circumflex";
beginchar(oct"250",width#,if small_caps:height#else:circ_ht#fi,desc_depth#);
this_letter; if not small_caps:
squeeze:=false; circumflex(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase eta with rough breathing and circumflex";
beginchar(oct"251",width#,Circ_ht#,desc_depth#);
this_letter; if not small_caps:
squeeze:=true; spirit_circumflex(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase eta with smooth breathing and circumflex";
beginchar(oct"252",width#,Circ_ht#,desc_depth#);
this_letter; if not small_caps:
squeeze:=true; spirit_circumflex(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase eta with circumflex and iota subscript";
beginchar(oct"254",width#,if small_caps:height#else:circ_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; squeeze:=false; circumflex(x_baryctr);
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with rough breathing, circumflex and iota subscript";
beginchar(oct"255",width#,if small_caps:height#else:Circ_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; squeeze:=true; spirit_circumflex(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with smooth breathing, circumflex and iota subscript";
beginchar(oct"256",width#,if small_caps:height#else:Circ_ht#fi,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter; squeeze:=true; spirit_circumflex(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase eta with iota subscript";
beginchar(oct"371",width#,height#,desc_depth#);
if small_caps:
   italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
   if slitex:
     adjust_fit(0,.5[vair#,stem#]+.7(.5[vair#,stem#])+.3tiny#+u#);
   elseif serifs:
     adjust_fit(serif_fit#,serif_fit#+.5[vair#,stem#]+.7(jut#+u#)if monospace:+tiny# fi+.5u#);
   else:
     adjust_fit(0,+.5[vair#,stem#]+.7u#);
   fi
gen_letter;
else:
this_letter;
fi
iota_sub(pos_stem); endchar;

%picture pic.iota;
picture savedpicture; currentbreadth:=0;



if monospace:
def dims = 8.5u#,asc_height#,0 enddef;
else:
def dims = if small_caps: 10 else: 9 fi u#,%
           if small_caps: sclc*x_height# else: asc_height# fi,0 enddef;
fi
def ital = 0 enddef;
def fit_params = 0,0 enddef;


def gen_letter=
if small_caps:
  italcorr .7*height#*slant-.5u#;
  adjust_fit(0,0);
  numeric light_curve; light_curve=hround(curve-2stem_corr);
  penpos1(vair,90); penpos3(vround(vair+.5vair_corr),-90);
  penpos2(light_curve,180); penpos4(light_curve,0);
  if monospace: x2r=hround 1.5u;
   interim superness:=sqrt superness;  % make |"O"|, not |"0"|
  else: x2r=hround u; 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
  pickup crisp.nib; pos5(vstem,90); pos6(vstem,90);
  lft x5=w-rt x6=hround(x2l+u)+1; y5=y6=.5[y1l,y3l];
  filldraw stroke z5e--z6e;  % bar
  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 .05h;
   filldraw stroke z7e--z8e;  % left serif
   filldraw stroke z9e--z10e; fi  % right serif
  math_fit(-.3*height#*slant-.5u#,ic#-.5u#);
else:
  if (monospace or monotoniko):
    pickup fine.nib;
    lft x4r=w-rt x8r=hround .75u; y4r=y8r=.5h;            %left and right bulges
    x2r=x6r=.5w; top y2r=h+o; bot y6r=-o;                 %top and bottom
    pos4(stem,180); pos8(stem,0); pos2(stem,90); pos6(stem,-90);
    filldraw stroke z6e{right}...z8e{up}...z2e{left}...z4e{down}...{right}z6e;
    pos4`(bar,90); pos8`(bar,90); x4`=x4; x8`=x8; y4`=y8`=.05[y4,y2];
    filldraw stroke z4`e--z8`e;                           %bar
  else:
   if cursive:
    if slitex: pickup fine.nib; fi
    pos0(hair,90); pos1(stem,45); pos2(stem,0);
    lft x0=0; y0=y1l; x2l=stem; y2l=3/4x_height;
    x1l=.5[x0,x2l];top y1r=x_height+oo;
    pos3(stem,0); pos4(hair,90); pos5(stem,180);
    x3=x2; y3=bar_height; x4=w/2=.5[x1l,x5l]; bot y4l=-oo; y5=y3;
    pos6(stem,180); pos7(if not serifs: .7 fi hair,270);
    pos8(stem,if (slitex or not serifs):-25 else:0 fi); pos9(hair,90);
    x6=x5; h-y6=y5; x7=x4; top y7l=h+oo;
    if slitex: x8l=x3r else: if serifs: x8=x3 else: x8=x3r fi fi;
    y8=.5[y7l,y1r]; rt x9=w;
    if (slitex or not serifs): y9r=y1l else: y9l=y1r fi;
    filldraw stroke z0e..{right}z1e..{down}z2e..{down}z3e
      ..{right}z4e..{up}z5e..{up}z6e..{left}z7e..{down}z8e..{right}z9e;
   else:
    adjust_fit(.5u#,.75u#);
    pickup fine.nib;
    numeric light_curve; light_curve=hround .5[stem,curve];
    x0=0; x2-.5stem=hround(2.5u-.5stem); hook_in(0,1,2);  % opening hook
    pos2'(stem,-180); z2'=z2; pos3(stem,-180); pos4(vair,-90);
    pos5(light_curve,0); pos6(vair,90); pos7(hair,180); pos8(vair,270);
    x3=x2; x4=x6=.5[x3,x5]; rt x5r=hround(w-1.5u+.5light_curve);
    lft x7r=hround(3.25u-.5hair); x8+.5vair=hround(w+.5vair-epsilon);
    y3=.4x_height; bot y4r=-oo; y5=.5[y4,y6]; top y6r=h+oo;
    y7=.5[x_height,h]; y8=.5[bar_height,x_height];
    filldraw stroke z2'e..{{interim superness:=hein_super; super_arc.e(3,4)}}
     & pulled_arc.e(4,5) & pulled_arc.e(5,6)
     ...{down}z7e...{4(x8-x7),y8-y7}z8e;  % bowl and loop
    math_fit(-2/3x_height#*slant+.5hair#+.5u#,ic#);
   fi
  fi
fi
enddef;

cmchar "Lowercase theta";
beginchar("j",dims);
this_letter; penlabels(0,a,1,2,3,4,4`,5,6,7,8,8`,9);
endchar;


picture savedpicture; currentbreadth:=0;


% lowercase iota

def width = if slitex and (not monospace): 6.3u
        else: 4.5u fi enddef;
def dims = width#,if small_caps:sclc*fi x_height#,0 enddef;
def ital = 0 enddef;
def fit_params = if small_caps:serif_fit#,serif_fit# else:0,0fi enddef; %  < ------

def gen_letter=
  if small_caps:
    italcorr height#*slant-.25u#;
    pickup tiny.nib; pos1(stem,0); pos2(stem,0);
    lft x1l=lft x2l=hround(.5w-.5stem); top y1=h; bot y2=0;
    filldraw stroke z1e--z2e; % stem
    if serifs:
     dish_serif(1,2,a,1/3,1.05jut,b,1/3,1.05jut);  % upper serif
     dish_serif(2,1,c,1/3,1.05jut,d,1/3,1.05jut);  % lower serif
    else:
     if slitex:
      dish_serif(1,2,a,1/3,.71u,b,1/3,.71u); % upper serif
      dish_serif(2,1,c,1/3,.71u,d,1/3,.71u); % lower serif
     fi
    fi
    math_fit(0,.5ic#);
    numeric x_baryctr; x_baryctr=x1;
  else:
   if cursive and serifs and not monospace:
    numeric angolo; angolo=angle((hair,stem));
    pos1(hair,90); pos2(stem,angolo); pos3(stem,0);
    x1=0; x2=x3l; x3=w/2;
    y1=y2l; y2r=h+oo; y3=2/3h;
    pos4(stem,0); x4=x3; y4=y3/2;
    pos5(stem,angolo); x5=x4r; bot y5l=-oo;
    pos6(hair,90); x6l=w; y6=y5r;
    filldraw z1l...z2l..{down}z3l..{down}z4l..{right}z5l..z6l--%<>
                z6r...z5r..z4r{up}..{up}z3r..{left}z2r..z1r--cycle;
    numeric angolo;
    numeric x_baryctr; x_baryctr=x3;
   else:
    pickup fine.nib;
    pos1(flare,180); lft x1r=hround u; top y1=x_height+oo;        %top
    numeric neck; neck=min(flare,.2[hair,stem]);
    pos2(neck,180);                                               %neck
    pos3(curve,-90); bot y3r=-oo;                                 %bottom
    .2[lft x2r,rt x2l]=.2[lft x1r,rt x1l];
    if monowidth:
      y2r=2[bot y3r,top y3l];
      lft x4l-rt x2l=u;
      y4r+.5neck=vround y2r; x3=.5[x2,x4]; pos4(neck,0);          %tip of hook
      filldraw stroke z4e{down}...z3e...z2e---z1e;
    elseif slitex:
      y2r=2/3math_axis;
      x2+x4=w;
      y4r=vround y2r; x3=.5[x2,x4]; pos4(neck,0);          %tip of hook
      filldraw stroke z4e{down}...z3e...z2e---z1e;
    else:
      y2r=1.5[bot y3r,top y3l];
      z4l=z4r=z4; top y4r=y2r; x4r=w-x2r; x3=.5[x2,x4];
      path p.r, p.l;
      forsuffixes e=r,l: p.e=z1e---z2e...z3e...z4e; endfor
      rt x3.5r=hround(rt xpart directionpoint up of p.r);
      z4'r=direction 3 of p.r; z3'r=direction 2 of p.r;
      forever:                 %avoid bad vertical tangent between 2l and 3l
        a_:=directiontime down of p.l;
        exitif a_<0;           % exit if vert. tang. does not exist
        x2.5l:= rt xpart point a_ of p.l;
        exitif abs(hround(x2.5l)-x2.5l)<.05;
        x2l:=x2l+hround(x2.5l)-x2.5l; p.l:=(z1l---z2l...z3l...z4l);
      endfor
      p.r:=z1r---z2r...club.r(3,3.5,4);
                               %avoid bad vertical tangent between 3r and 4r
      filldraw stroke p.e;
    fi
   if monospace: currentpicture:=currentpicture shifted (.5w-x3,0); fi
   numeric x_baryctr; x_baryctr=x1 if monospace:+.5w-x3 fi;
   fi
  fi
enddef;


cmchar "Lowercase iota";
beginchar("i",dims);
adjust_fit(fit_params);
this_letter; penlabels(1,2,3,4,5,6); endchar;



iff(not barebones):
cmchar "Lowercase iota with grave";
beginchar(oct"310",width#,acc_ht#,0);
this_letter; if (not small_caps): grave(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase iota with rough breathing";
beginchar(oct"311",width#,acc_ht#,0);
this_letter; if (not small_caps):
spirit(x_baryctr if serifs: +.25u fi)<;fi endchar;

iff(not barebones):
cmchar "Lowercase iota with smooth breathing";
beginchar(oct"312",width#,acc_ht#,0);
this_letter; if (not small_caps):
spirit(x_baryctr if serifs: -.25u fi)>; fi endchar;

iff(not barebones):
cmchar "Lowercase iota with acute";
beginchar(oct"320",width#,acc_ht#,0);
this_letter; if (not small_caps): acute(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase iota with rough breathing and acute";
beginchar(oct"321",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit_acute(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase iota with smooth breathing and acute";
beginchar(oct"322",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit_acute(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase iota with rough breathing and grave";
beginchar(oct"313",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase iota with smooth breathing and grave";
beginchar(oct"323",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase iota with circumflex";
beginchar(oct"330",width#,circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=false; circumflex(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase iota with rough breathing and circumflex";
beginchar(oct"331",width#,Circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=true; spirit_circumflex(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase iota with smooth breathing and circumflex";
beginchar(oct"332",width#,Circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=true; spirit_circumflex(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase iota with diaeresis";
beginchar(oct"360",width#,circ_ht#,0);
this_letter;  diaeresis(x_baryctr);  endchar;

iff(not barebones):
cmchar "Lowercase iota with diaeresis and grave";
beginchar(oct"361",width#,acc_ht#,0);
this_letter;
if (not small_caps):
  diaeresis_grave(x_baryctr);
else:
  diaeresis(x_baryctr);
fi
endchar;

iff(not barebones):
cmchar "Lowercase iota with diaeresis and acute";
beginchar(oct"362",width#,acc_ht#,0);
this_letter;
if (not small_caps):
  diaeresis_acute(x_baryctr);
else:
  diaeresis(x_baryctr);
fi endchar;

iff(not barebones):
cmchar "Lowercase iota with diaeresis and circumflex";
beginchar(oct"363",width#,Circ_ht#,0);
this_letter;
if (not small_caps):
  squeeze:=true;
  diaeresis_circumflex(x_baryctr);
else:
  diaeresis(x_baryctr);
fi endchar;

picture savedpicture;  currentbreadth:=0;


def dims = if small_caps:
             11u#,sclc*x_height#,0
           elseif monotoniko:
             8.5u#,x_height#,0
           else:
             9.5u#,x_height#,0
           fi enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;

def gen_letter=
 if small_caps: %                       maiuscoletto
   italcorr height#*slant-.5u#;
   adjust_fit(serif_fit#,serif_fit#);
   numeric right_jut,stem[],alpha[];
   if serifs: right_jut=.6jut;
   else: right_jut=.4tiny; fi
   pickup tiny.nib; pos1(fudged.stem,0); pos2(fudged.stem,0); % old: cap_stem
   lft x1l=lft x2l=hround max(2u,3u-.5fudged.stem); top y1=h; bot y2=0;% idem
   filldraw stroke z1e--z2e; % stem
   stem2=max(tiny.breadth,fudged.stem-3stem_corr);%                    idem
   stem1=max(tiny.breadth,fudged.hair if hefty:-3stem_corr fi);
   top y3=h; rt x3r=hround(r-letter_fit-u-right_jut);
   bot y6=0; rt x6r=hround(r-letter_fit-.75u-right_jut);
   x4=x1; y4=1/3h;
   alpha1=diag_ratio(1,.5(stem1-tiny),y3-y4,x3r-x4);
   penpos3(alpha1*(stem1-tiny),0); penpos4(whatever,-90);
   alpha2=diag_ratio(1,.5(stem2-tiny),y1-y6,x6r-x1);
   penpos6(alpha2*(stem2-tiny),0);
   forsuffixes $=l,r: y3'$=h; y6'$=0; z4$=z3'$+whatever*(z3-z4);
    z5$=z6'$+whatever*(z1-z6)=whatever[z3,z4]; endfor
   z5=.5[z5l,z5r];
   z3'r=z3r+penoffset z3-z4 of currentpen+whatever*(z3-z4);
   % we have also |z3'l=z3l+penoffset z4-z3 of currentpen+whatever*(z3-z4)|;\]
   z6'r=z6r+penoffset z1-z6 of currentpen+whatever*(z1-z6);
   z6'l=z6l+penoffset z6-z1 of currentpen+whatever*(z1-z6);
   fill z4r--diag_end(4r,3'r,1,.5,3'l,4l)--z4l--cycle;  % upper diagonal
   fill z5l--diag_end(5l,6'l,.5,1,6'r,5r)--z5r--cycle;  % lower diagonal
   if serifs: numeric inner_jut;
    if rt x2r+jut+.5u+1<=lft x6l-jut: inner_jut=jut;
    else: rt x2r+jut+.5u+1=lft x6l-inner_jut; fi
    dish_serif(1,2,a,1/3,jut,b,1/3,jut); % upper stem serif
    dish_serif(2,1,c,1/3,jut,d,1/3,jut);  % lower stem serif
    dish_serif(3,4,e,2/3,1.2jut,f,1/2,right_jut)(dark); % upper diagonal serif
    dish_serif(6,5,g,1/2,inner_jut,h,1/3,right_jut)(dark);  % lower diagonal serif
   fi
   math_fit(0,.5ic#);
 else: %                              minuscolo
   adjust_fit(0,0);
   if cursive: %                      corsivo minuscolo
     if serifs and not monospace:%    corsivo minuscolo normale
       pos0(hair,90); pos1(stem,45); pos2(stem,0); pos3(1.2stem,0);
       top y1r=h+oo; y3=0; y2l=5/6y1;
       x1=x2l; x2r=x3r; lft x0=.5u; y0=y1l; x3l=min(x0+.8stem,1.5u);
       filldraw stroke z0e{(z1r-z0l) yscaled 2}..{right}z1e..{z3-z2}z2e--z3e;                    % left bar
       s_a:=85; s_c:=12;
       pos4(vair,180); pos5(stem,90); pos8(hair,80);
       x4l=x3r; bot y4=y3; rt x8r=w-x0; x5=.2[x8l,x1r];
       top y5r=h; top y8r=.8*(top y5r);
       filldraw stroke z8e...z5e{left}...{-dir s_a}z4e;     % ascending stroke
       s_b:=60; path gamba; gamba=z4{dir s_a}...{right}z5;
       pos6(stem,s_b); pos7(.3stem,45); pos9(.5hair,70);
       z6=directionpoint (dir s_b) of gamba; path gamba;
       bot y7l=0; x7r=x9l-.3stem; rt x9r=w-x0; y9l=y7r;
       pos10(stem,-15); y10r=y9; x10r=x7r-.3stem;
       z11-z6=whatever*(z10l-z6); y11=0; z12=.5[z11,z7l]; z13=.5[z11,z10l];
       filldraw  z9r{(z7l-z9r) yscaled 2}..z7r{left}...z10r--z6r--z6l--z10l
       ..controls z13 and z12..z7l{right}..{z9r-z9l}z9l--cycle;          % descending stroke
     else: %                       corsivo minuscolo monospace, sans e slides
       if monospace or slitex: %   corsivo minuscolo monospace e slides
        pickup fine.nib;
       else:               %   corsivo minuscolo sans
        pickup pencircle;
       fi
       pos1(1.2stem,180); pos2(stem,180); pos3(1.2stem,180);
       top y1 = h = 2y2; bot y3=0;
       lft x2r=u; x1l=x2l=x3l;
       filldraw stroke z1e..z2e..z3e;                        % left bar
       s_a:=90; s_c:=12;
       pos4(vair,180); pos5(stem,90-s_c);
       x4l=x3l; bot y4=bot y3; rt x5=w-x3r+o; top y5r=h;
       filldraw stroke z5e{dir(180-s_c)}...{-dir s_a}z4e;     % ascending stroke
       s_b:=60; path gamba; gamba=z4{dir s_a}...{dir-s_c}z5;
       pos6(if not monospace: 0.7fi stem,s_b); pos7(.5[vair,stem],90);
       z6=directionpoint (dir s_b) of gamba; path gamba;
       bot y7l=0; rt x7=w-x3r;
       x10=.7[x4,x7l]; y10=0;
       filldraw stroke z7e{left}...{z6-z10}z6e;          % descending stroke
     fi
   elseif (not serifs) or monospace: % minuscolo regolare sans, slides e typewriter
     pos1(1.2stem,180); pos2(stem,180); pos3(1.2stem,180);
     y1+(1.2stem)/2=h+o=2y2; y3-(1.2stem)/2=-o;
     lft x2r=u; x1l=x2l=x3l;
     filldraw double_circ_stroke z1e..z2e..z3e;                        % left bar
     s_a:=90; s_c=12;
     pos4(vair,180); pos5(stem,90-s_c);
     x4l=x3l; bot y4=y3; x5+.5stem=w-x2r+o; top y5r=h;
     filldraw circ_stroke z5e{dir(180-s_c)}...{-dir s_a}z4e;     % ascending stroke
     s_b:=70; path gamba; gamba=z4{dir s_a}...{dir-s_c}z5;
     pos6(.7stem,s_b); pos7(.5[vair,stem],90);
     z6=directionpoint (dir s_b) of gamba; path gamba;
     bot y7l=0; rt x7+.5*(.5[vair,stem])=w-x3r;
     filldraw circ_stroke z7e{left}..{dir(s_b+90)}z6e;          % descending stroke
   else: % minuscolo regolare
   %% versione Didot
     pickup fine.nib;
     x1-.5stem=hround .75u; y1-.5stem=-o;                   %lower left
     z1+z3=(w,h); z2=.5[z1,z3];                             %upper right and middle
     z1'=(z3-z1) if monowidth: xscaled 1/2 fi;              %slope at 1 and 3
     pos1(stem,angle z1'+90); pos2(.6[hair,stem],angle z1'+90);
     pos3(stem,angle z1'+90);
     filldraw double_circ_stroke z1e{z1'}..z2e..{z1'}z3e;   %diagonal stroke
     z4=if monowidth: z1 else: 1/4[z1,z3] fi; z4+z7=z3+z1;  %handle attachments
     z4'=if monowidth: z1' else: (z3-z1) xscaled .25 fi;    %slope at 4 and 7
     pos4(hair,angle z4'-90); pos7(hair,angle z4'+90);
     pos5(vstem,90); top y5r=h+o; pos6(vstem,180); z6l=z5l;
     lft x6r=hround(x1-.5stem-.25u);
     filldraw circ_stroke z6e{up}...z5e{right}...z4e{-z4'};         %left handle
     pos8(.5[vstem,stem],-90); bot y8r=-o; rt x9r=hround(x3+.5stem+.25u);
     pos9(.5[vstem,stem],0); z9l=z8l;
     filldraw circ_stroke z9e{down}...z8e{left}...z7e{z4'}; %right handle
   fi
 fi
enddef;


cmchar "Lowercase kappa";
beginchar("k",dims);
this_letter; penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

picture savedpicture; currentbreadth:=0;


def dims = if small_caps:
           10u#,sclc*x_height#,0
           else:
           9.5u#,asc_height#,0
           fi enddef;
def ital = 0 enddef;
def fit_params = -.25u#,-.25u# enddef;
def krn = -.75u# enddef;


def gen_letter=
  if small_caps:
    adjust_fit(serif_fit#,serif_fit#);
    numeric left_stem,outer_jut,alpha;
    left_stem=hair if hefty: -3stem_corr fi;
    outer_jut=.7jut; x1l=w-x4r=l+letter_fit+outer_jut+.5u; 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*stem,0); penpos4(alpha*stem,0);
    z0=whatever[z1r,z2r]=whatever[z3l,z4l];
    if y0<h-notch_cut: y0:=h-notch_cut;
      fill z0+.5right{down}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)
        --diag_end(4r,3r,1,1,2l,1l)--diag_end(2l,1l,1,1,1r,2r){z2-z1}
        ...{up}z0+.5left--cycle; % left and right diagonals
    else: fill z0--diag_end(0,4l,1,1,4r,3r)--diag_end(4r,3r,1,1,2l,1l)
        --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
    if serifs: numeric inner_jut; pickup tiny.nib;
     prime_points_inside(1,2); prime_points_inside(4,3);
     if rt x1'r+jut+.5u+1<=lft x4'l-jut: inner_jut=jut;
     else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
     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); fi  % right serif
  else:
   if cursive and serifs and not monospace:
     adjust_fit(0,0);
     pos1(hair,0); pos2(stem,0); pos3(stem,45); pos4(hair,90);
     x1l=0; y1=h; x4=w; y4l=hair;
     z2-z4=whatever*(z1l-z4l); y2=x_height;
     x3r=x4l-stem/2-blacker; y3l=-oo;
     filldraw stroke z1e..z2e...z3e{right};
     filldraw  z3l{right}..{1,1}z4l--z4r{-1,-1}...{left}z3r--cycle;
     pos5(hair,0); z5l=z2l;
     pos6(stem,0); x6l=x1l; y6=0;
     filldraw stroke z6e{dir(80)}..z5e;
   else:
    pickup fine.nib;
    x1-.5stem=hround .75u; y1+.5stem=h;                   %top left
    z1'=(1,.2); pos1(stem,angle z1'+90);                  %direction at z1
    x3+x1=w; y3-.5stem=-oo; pos3(stem,-angle z1'+90);     %bottom right
    y2=x_height; x2=.5[x1,x3];                            %attachment
    z2'=(z3-z1)yscaled 2; pos2(hair,angle z2'+90);        %direction at z4
    filldraw double_circ_stroke z1e{z1'}...
      z2e{(z3-z1)yscaled 2}...{z1' yscaled -1}z3e;                %diagonal
    lft x4l=hround.75u; bot y4l=0;                                %bottom left
    numeric stem'; stem'=stem-currentbreadth; numeric slope;      %from z4 to z4
    slope=angle(z2-z4l)+angle(length(z2-z4l)+-+.5stem',.5stem');
    x4r=x4l+(stem'/sind slope); y4r=y4l; z4=.5[z4r,z4l];
    path p; p=z1{z1'}...z2{(z3-z1)yscaled 2}...{z1' yscaled -1}z3;
    forsuffixes e=r,l: z5e=(z4e--(z4e+2(z2-z4))) intersectionpoint p; endfor
    filldraw stroke z4e{(z2-z4)if not monowidth: xscaled 1.2 fi}..z5e;
   fi
  fi
enddef;

cmchar "Lowercase lambda";
beginchar("l",dims);
this_letter; penlabels(1,2,3,4,5,6); endchar;


picture savedpicture; currentbreadth:=0;

% lowercase mu
def dims = if small_caps:
           13u#,sclc*x_height#,0
           elseif cursive:
           9u#,x_height#,desc_depth#
           else:
           8u#,x_height#,desc_depth#
           fi enddef;
def ital = 0 enddef;
def fit_params = 0,.5stem# enddef;




def gen_letter=
  if small_caps:
    italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
    adjust_fit(serif_fit#,serif_fit#);
    numeric stem[]; % thicknesses of the four strokes
    stem1=hround(fudged.hair+stem_corr);
    stem2=hround(fudged.stem-4stem_corr);
    stem3=hround(fudged.hair-stem_corr);
    stem4=hround(fudged.stem-3stem_corr);
    if stem4<stem1: stem4:=stem1; fi
    pickup tiny.nib; pos1(stem1,0); pos2(stem1,0);
    pos3(stem4,0); pos4(stem4,0);
    x1=x2; x3=x4; x1l=w-x3r; rt x3r=hround min(w-2u,w-3u+.5stem4);
    top y1=top y3=h; bot y2=bot y4=0;
    filldraw stroke z1e--z2e; % left stem
    filldraw stroke z3e--z4e; % right stem
    penpos5(stem2,0); penpos6(stem2,0); penpos7(stem3,0); penpos8(stem3,0);
    x5l=x1; x6l=x7l; x8=lft x3l; x6-x5=x8-x7; y5=y8=h; y6=y7;
    if hefty: y6=if monospace: vround 1/3h else: o fi;
     numeric upper_notch,lower_notch;
     upper_notch=h-notch_cut; lower_notch=y6+notch_cut;
     x1'=rt x1r; z1'=whatever[z5l,z6l]; x3'=lft x3l; z3'=whatever[z7r,z8r];
     z0=whatever[z5r,z6r]=whatever[z7l,z8l];
     fill z5l..
      if y1'<upper_notch: {right}(x1'+1,upper_notch){down}... fi
      {z6-z5}diag_in(5l,6l,1,6r)..diag_out(7l,1,7r,8r){z8-z7}
      if y3'<upper_notch: ...{up}(x3'-1,upper_notch){right} fi
      ..z8r--diag_out(8r,1,8l,7l){z7-z8}
      if y0<=lower_notch: ..{z7-z8}z0{z5-z6}..
      else: ...{down}(x0+.5,lower_notch)--(x0-.5,lower_notch){up}... fi
      {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonals
    else: y6=0; z0=whatever[z5r,z6r]=whatever[z7l,z8l];
     fill z5l..{z6-z5}diag_in(5l,6l,1,6r)..diag_out(7l,1,7r,8r){z8-z7}
      ..z8r--diag_out(8r,1,8l,7l){z7-z8}..{z7-z8}z0{z5-z6}
      ..{z5-z6}diag_in(6r,5r,1,5l)--cycle; fi  % diagonals
    if serifs: serif(1,2,a,1/3,-jut);  % upper left serif
     dish_serif(2,1,b,1/2,jut,c,1/2,jut)(dark); % lower left serif
     serif(3,4,d,1/3,jut); %  upper right serif
     dish_serif(4,3,e,1/3,jut,f,1/3,jut); fi  % lower right serif
    math_fit(0,max(.5ic#-.5u#,0));
  else:
   if cursive and serifs and not monospace:
     adjust_fit(.5stem#,.5stem#);
     pos1(hair,90); pos2(stem,45); pos3(stem,0); pos4(stem,0); %left stroke
     lft x1=0;  y1=y2l; top y2r=h; x2l=5/4u; x2=x3l=x4l;
     bot y4 =-d; y3=3/4h;
     filldraw stroke z1e..z2e..z3e--z4e;
     pos5(stem,0); pos6(stem,0); pos7(stem,45); pos8(hair,90); %right stroke
     rt x8=w; y8=y7r; bot y7l=0; x7r=w-x2l; x7=x6r=x5r;
     top y5=h; y6=1/4h;
     filldraw stroke z8e..z7e..z6e--z5e;
     pos9(vair,90); pos10(hair,0); pos11(.4[vair,stem],180); % bowl
     x9=.5[x10r,x11r]; bot y9l=0;
     x10r=x3r; x11r=x6l; y10=y11=4/10h;
     filldraw stroke z10e{down}...z9e...{up}z11e;
   else:
    adjust_fit(fit_params);
    pickup fine.nib;
    y6+.5stem=h+o; pos6(stem,0); rt x6r=hround(w-vstem);          %top right
    x5r=.5[x1,x6]; bot y5r=-oo;                                   %bottom of bowl
    if straight:
      lft x1r=hround .75 u; y1+.5stem=h+o; pos1(stem,180);        %top left
      x4=x1; x9=x6; y9=y4=.5x_height; pos4(stem,180); pos9(stem,0);
      pos5(vstem, 270);
      filldraw double_circ_stroke z1e..pulled_arc.e(4,5)&pulled_arc.e(5,9)..z6e;
      y8-.5stem=-d-oo; x8=x1; pos8(stem,180);                     %end of handle
      filldraw circ_stroke z8e..z4e;
    else:
      lft x2r=rt x2l-stem=hround .75u;            %vertical tangents of left bulb
      top y1r=h+o; x1r=.5[x2r,x2l]; z1=z1l=z1r; z1'r=-z1'l=left;  %top left
      y3r=.4[y1r,y5r];
      lft x3r=max(x1r-.5hair,lft x2r+eps);                        %middle left
      numeric tilt; tilt:=.6; path p.r, p.l;
      p.l=gr_arc.l(3,4,5)(hair,.4[hair,stem],tilt)...{up}z6l;
      p.r=subpath (2(1-tilt),2) of gr_arc.r(3,4,5)(fie,fo,fum)...{up}z6r;
      z3.5r=z4r; z3.5'r=z4'r; z3.5l=z3l; z3.5'l=z3'l;             %a hybrid
      filldraw double_circ_stroke club.e(1,2,3.5) & p.e;          %bowl
      x8=lft x2r+stem; y8-.5stem=-d-oo;                           %end of handle
      if serifs:
        pos8(stem,angle(z4'l xscaled 2)-90); z8'r=z8'l=z4'l xscaled 2;
        assign_z3'r(z3'l);                                        %so club.r won't get confused
        lft x7r=rt x7l-max(.2[hair,stem],2)=lft x2r;              %vertical tangents of handle
        filldraw double_circ_stroke club.e(3,7,8);                %handle
      else:
        x3r:=x3r-1;
        pos8(1.2vstem,angle(z4'l xscaled 2)-90); z8'=z4'l xscaled 2;
        fill z3l{down}...{z8'}z8l...z8r{-z8'}...{up}z3r--cycle;
      fi
      y9r=max(y4r+epsilon,-oo+2vstem);            %where hook attaches
      x9r=xpart(((0,y9r)--(w,y9r)) intersectionpoint p.r); pos9(hair,0);
    fi
    pos10(vstem,90); y10l=y5r; x10-x9=vstem;              %bottom of hook
    pos11(hair,180); top y11=bot y10l+4/3vstem;           %tip of hook
    rt x11l=hround(x10+(y11-y10)+.5hair);                 %central arc is round
    filldraw stroke z9e{down}..z10e{right}..{up}z11e;     %hook
   fi
  fi
enddef;


cmchar "Lowercase mu";
beginchar("m",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8,9,10,11); endchar;

picture savedpicture; currentbreadth:=0;



def dims = if small_caps:
           10.5u#,sclc*x_height#,0
           else:
           8.5u#,x_height#,0
           fi enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;


def gen_letter =
  if small_caps:
    italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
    numeric thin_stem; thin_stem=hround(fudged.hair+stem_corr);
    pickup tiny.nib; pos1(thin_stem,0); pos2(thin_stem,0);
    pos3(thin_stem,0); pos4(thin_stem,0);
    pickup tiny.nib; top y1=top y3=h; bot y2=bot y4=0;
    x1=x2; x3=x4; x1l=w-x3r;
    rt x3r=hround min(w-2u,w-3u+.5fudged.stem);
    filldraw stroke z1e--z2e; % left stem
    filldraw stroke z3e--z4e; % right stem
    if hefty: penpos5(fudged.stem,0); penpos6(fudged.stem,0);
     x5l=x1; x6r=x4; y5=h; y6=0;
     numeric upper_notch,lower_notch;
     upper_notch=h-notch_cut; lower_notch=notch_cut;
     x1'=rt x1r; z1'=whatever[z5l,z6l]; x4'=lft x4l; z4'=whatever[z5r,z6r];
     fill z5l..
      if y1'<upper_notch: {right}(x1'+1,upper_notch){down}... fi
      {z6-z5}diag_in(5l,6l,1,6r)--z6r..
      if y4'>lower_notch: {left}(x4'-1,lower_notch){up}... fi
      {z5-z6}diag_in(6r,5r,1,5l)--cycle;  % diagonal
    else: penpos5(whatever,0); penpos6(whatever,90);
     z5l=z1l; z6l=z4l;
     z7=z6l+(max(eps,stem-3stem_corr-tiny),0) rotated (angle(z5l-z6l)-90);
     z5r=z7+whatever*(z5l-z6l); z6r=z7+whatever*(z5l-z6l);
     filldraw stroke z5e..z6e; fi  % diagonal
    if serifs: if hefty: serif(1,2,a,1/3,-jut); % upper left serif
     else: serif(5,6,a,1/3,-jut); fi  % upper left serif
     dish_serif(2,1,b,1/2,jut,c,1/2,jut)(dark); % lower left serif
     dish_serif(3,4,e,1/2,jut,f,1/2,jut)(dark); fi  % upper right serif
    math_fit(0,max(.5ic#-.5u#,0));
  else:
   if cursive and serifs and not monospace:
     adjust_fit(.5stem#,0);
     pos1(hair,90); pos2(stem,45); pos3(stem,0); pos4(stem,45);
     lft x1l=0; x2l=5/4u; x2=x3l=x4l;
     y1= y2l; y2r=h; y3=3/4h; y4l=-o;
     filldraw stroke z1e..z2e..z3e--z4e;
     pos5(hair,135); pos6(stem,180);
     z5l=z4r; x6l=w-x2l; y6+.5stem=h+.5o;
     filldraw circ_stroke z6e{down}..{dir(225)}z5e;
   else:
    adjust_fit(fit_params);
    pickup fine.nib;
    rt x4r=hround(w-.75u); lft x4l-rt x4r=hround -.2[hair,stem];  %vert tangents
    x5=lft x4l; y5+.5hair=h+oo; z5'l=z5'r=(u,-.2h);               %right tip
    pos5(hair,angle z5'l+90);
    pos3(whatever,-90); bot y3r=-oo; x3=.5w; z3'l=z3'r=z5'l xscaled -2;   %bottom
    z3l+whatever*z3'l=z3r+(stem-currentbreadth)*(dir(angle z3'l-90)); %width=stem
    filldraw circ_stroke club.e(5,4,3);                           %right stroke
    y1+.5stem=h+oo; x1-.5stem=hround.75u;                         %left tip
    z1'=(9u,-h); pos1(stem,angle z1'-90);
    z2r=z3r;  z2l=z2r+(hair-currentbreadth)*(dir(angle z1'+90));
    filldraw circ_stroke z1e{z1'}...{down}z2e;                    %left stroke
   fi
  fi
enddef;


cmchar "Lowercase nu";
beginchar("n",dims);
this_letter; penlabels(1,2,3,4,5,6); endchar;

picture savedpicture; currentbreadth:=0;


if small_caps:
  def dims = 9.5u#,sclc*x_height#,desc_depth# enddef;
else:
  def dims = 8.5u#,asc_height#,desc_depth# enddef;
fi
def ital = 0 enddef;
def fit_params = 0,0 enddef;



def gen_letter=
  if small_caps:
    italcorr height#*slant-.35u#;
    adjust_fit(0,0);
    h:=vround(h-2stem_corr);
    numeric shaved_stem; shaved_stem=hround .9[vair,.85stem];
    pickup crisp.nib; pos1(shaved_stem,90); pos2(hair,0);
    top y1r=h; x1=.5w; rt x2r=hround(w-.85u); y2=good.y(y1l-4/9beak)-eps;
    arm(1,2,a,.4beak_darkness,.3beak_jut);       % upper right arm and beak
    pos3(hair,180); x3=w-x2; y3=y2;
    arm(1,3,b,.4beak_darkness,-.3beak_jut);       % upper left arm and beak
    pos4(shaved_stem,-90); pos5(hair,0);
    bot y4r=0; x4=.5w; rt x5r=hround(w-.75u); y5=good.y(y4l+.5beak)+eps;
    arm(4,5,c,.4beak_darkness,.3beak_jut);       % lower right arm and beak
    pos6(hair,180); x6=w-x5; y6=y5;
    arm(4,6,d,.4beak_darkness,-.3beak_jut);       % lower left arm and beak
    pos7(shaved_stem,90); pos8(shaved_stem,90);
    lft x7=w-rt x8=hround if serifs: 2.5 else: 2 fi\\ u;
    top y7r=top y8r=vround(.52h+.5shaved_stem);
    filldraw stroke z7e--z8e;                                  % middle bar
    if serifs: numeric xjut;
     if bot y2>top y7r+.75jut:
      xjut=.5jut;
     else:
      bot y2=top y7r+1.5xjut;
     fi
     pos11(hair,0); pos12(hair,0); y11=y12;
     pos13(hair,0); pos14(hair,0); y13=y14;
     lft x11l=lft x13l=w-rt x12r=w-rt x14r=hround 2.5u;
     top y11-bot y13=shaved_stem+2xjut; .5[y11,y13]=y7;
     filldraw stroke z11e--z13e; filldraw stroke z12e--z14e;   % middle serifs
    fi
    math_fit(0,.5ic#);
  else:
   if cursive and serifs and not monospace:
    pos7(stem,180);
    lft x7r=hround(.75u); y7=1/3x_height;                         %big bulge
    pos8(stem,-135);  bot y8r=0; x8=.5w; z8'r=z8'l=left;          %inflection pt
    pos9(hair,-180); rt x9l=hround(w-.75u);                       %bottom right
    y6+.5hair=x_height+o; x6+.5hair=hround(rt x9l-.5u);           %middle right
    numeric slope; slope=angle(5(x6-x7),y6-y8); pos6(hair,slope+90);
    z6'r=z6'l=dir slope;
    pos10(.5[hair,stem],90); y10l=-d+oo; y9=.5[y10r,y8r]; x10=hround x8r;
    filldraw double_circ_stroke                                   %bowl and tail
    z10e{right}..z9e{up}..{left}z8e..{up}z7e..{dir(slope)}z6e;
    pos5(hair,1.5slope-90); z5=z6;                                 %attachment
    z4=.5[z3,z5]+whatever*dir slope;                              %small bulge
    pos4(stem,-180);  lft x4r=hround(lft x7r+.5u);
    pos3(hair,slope+90); top y3r=h-o; rt x3r=hround(rt x9l-.5u);    %top rt
    filldraw double_circ_stroke z3e{-dir slope}..z4e{down}...z5e{dir 1.5slope};
    pos2(hair,1.5slope+90); z2=z3;                         %where handle attaches
    pos1(stem,slope); lft x1l=hround(lft x7r+.5u); y1r+hair=h;  %end of handle
    pos0(hair,0); x0=x1r; y0=h;
    filldraw circ_stroke z2e{-dir9/8slope}...z1e{up}...z0e;
   else:
    pickup fine.nib;
    lft x7r=rt x7l-  hair=hround(.75u); x7=.5[x7r,x7r];            %big bulge
    pos8(stem,-90);  bot y8r=0; x8=.5w; z8'r=z8'l=left;            %inflection pt
    pos9(hair,-180); rt x9l=hround(w-.75u); y9=-.5stem;           %bottom right
    y6+.5stem=x_height+o; x6+.5stem=hround(rt x9l-1.5u);          %middle right
    numeric slope; slope=angle(5(x6-x7),y6-y8); pos6(stem,slope+90);
    z6'r=z6'l=dir slope;
    pos10(vstem,-270); y9=.5[y10r,y8r]; x10-.5vstem=hround x8;
    filldraw double_circ_stroke                                   %bowl and tail
      z10e{right}...z9e{up}...club.e(8,7,6);
    pos5(hair,slope-90); z5l=z6r;                                 %attachment
    z4=.5[z3,z5]+whatever*dir slope;                              %small bulge
    if serifs: pos4(vair,-180); else: pos4(.5vair,-180); fi lft x4r=hround(lft x7r+1.5u);
    y3+.5stem=h+o; x3+.5stem=hround(rt x9l-.25u); pos3(stem,slope+90);    %top rt
    filldraw circ_stroke z3e{-dir slope}..z4e{down}...z5e{dir slope};
    pos2(hair,slope+90); z2r=z3r;                         %where handle attaches
    pos1(curve,0); lft x1l=hround(lft x7r+.25u); y1+.5curve=h+o;  %end of handle
    filldraw circ_stroke z1e{down}...z2e{dir slope};
   fi
  fi
enddef;



cmchar "Lowercase xi";
beginchar("x",dims);
this_letter; penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;


picture savedpicture; currentbreadth:=0;



if small_caps:
  def width = 10u enddef;
  def dims = width#,sclc*x_height#,0 enddef;
else:
  def width = if cursive:8.5else:9.5fi u  enddef;
  def dims = width#,x_height#,0 enddef;
fi
def ital = 0 enddef;
def fit_params = 0,0 enddef;

def gen_letter =
  if small_caps:
    italcorr .7*height#*slant-.5u#;
    adjust_fit(0,0);
    penpos1(vair',90); penpos3(vround(vair+1.5vair_corr),-90);
    penpos2(curve,180); penpos4(curve,0);
    if monospace: x2r=hround 1.5u;
     interim superness:=sqrt superness;  % make |"O"|, not |"0"|
    else: 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
    math_fit(-.3*height#*slant-.5u#,ic#-.5u#);
  else:
   if cursive:
    pos1(hair,90); pos2(stem,180); pos3(hair,270); pos4(stem,0);
    x1=x3=w/2; lft x2r=w- rt x4r=.75u;
    bot y3r = h-top y1r= -oo; y2=y4=h/2;
    filldraw stroke z1e{left}..z2e..z3e..z4e..{left}z1e;
    numeric x_baryctr; x_baryctr=x1;
   elseif monospace:
    spess:=max(hair,fine+eps);
    pos1(spess,90); pos2(spess,180); pos3(spess,270); pos4(spess,0);
    x1=x3=w/2; lft x2r=w- rt x4r=.75u;
    bot y3r = h-top y1r= -oo; y2=y4=h/2;
    filldraw stroke z1e{left}..z2e..z3e..z4e..{left}z1e;
    numeric x_baryctr; x_baryctr=x1;
  else:
    pickup fine.nib;
    lft x4r=hround .75u; x8r=w-x4r; y4r=y8r=.5x_height;   %top and bottom
    top y2r=x_height+oo; bot y6r=-oo; x2r=x6r=.5w;        %right and left
    filldraw stroke
      gr_arc.e(8,1,2)(vair,curve,otilt) & gr_arc.e(2,3,4)(vair,curve,otilt) &
      gr_arc.e(4,5,6)(vair,curve,otilt) & gr_arc.e(6,7,8)(vair,curve,otilt) ;
    numeric x_baryctr; x_baryctr=x2;                      %accent reference
   fi
  fi
enddef;


cmchar "Lowercase omicron";
beginchar("o",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8); endchar;




iff(not barebones):
cmchar "Lowercase omicron with grave";
beginchar(oct"344",width#,acc_ht#,0);
this_letter; if (not small_caps): grave(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase omicron with rough breathing";
beginchar(oct"345",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase omicron with smooth breathing";
beginchar(oct"346",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase omicron with acute";
beginchar(oct"354",width#,acc_ht#,0);
this_letter; if (not small_caps): acute(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase omicron with rough breathing and acute";
beginchar(oct"355",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit_acute(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase omicron with smooth breathing and acute";
beginchar(oct"356",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit_acute(x_baryctr)>; fi endchar;
iff(not barebones):

iff(not barebones):
cmchar "Lowercase omicron with rough breathing and grave";
beginchar(oct"347",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase omicron with smooth breathing and grave";
beginchar(oct"357",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)>; fi endchar;


picture savedpicture; currentbreadth:=0;


def dims = if small_caps:
           11.5u#,sclc*x_height#,0
           else:
           9.5u#,x_height#,0
           fi enddef;
def ital = 0 enddef;
def fit_params = -.25u#,0 enddef;


def gen_letter =
  if small_caps:
    italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
    adjust_fit(serif_fit#,serif_fit#); pickup tiny.nib;
    h:=vround(h-stem_corr);
    pos1(stem,0); pos2(stem,0); pos3(stem,0); pos4(stem,0);
    lft x1l=lft x2l=hround max(2u,3u-.5stem); x3=x4=w-x1;
    top y1=top y3=h; bot y2=bot y4=0;
    filldraw stroke z1e--z2e; % left stem
    filldraw stroke z3e--z4e; % right stem
    penpos5(cap_bar,90); penpos6(cap_bar,90);
    x5=x1; x6=x3; y5r=y6r=h;
    fill stroke z5e--z6e;  % bar
    if serifs: numeric inner_jut;
     if rt x1r+jut+.5u+1<=lft x3l-jut: inner_jut=jut;
     else: rt x1r+inner_jut+.5u+1=lft x3l-inner_jut; fi
     dish_serif(1,2,a,1/3,jut,b,1/3,eps);           % upper left serif
     dish_serif(2,1,c,1/3,jut,d,1/3,inner_jut);     % lower left serif
     dish_serif(3,4,e,1/3,eps,f,1/3,jut);           % upper right serif
     dish_serif(4,3,g,1/3,inner_jut,h,1/3,jut); fi  % lower right serif
    math_fit(0,.5ic#);
  else:
   if cursive:
    adjust_fit(fit_params);
    if monospace or slitex: pickup fine.nib; fi
    pi_bar;                                                       %bar
    pos4(.5[stem,hair],0); pos7(hair,0); y4=y7=y2;                         %attachments
    lft x4l-(x1-.5hair)=lft x7l-rt x4r=rt x3-rt x7r;
    pos5(.5[stem,hair],0); pos8(hair,0); y5=y8=.5x_height; x5=x4; x8=x7;   %midstems
    z6=whatever[z4,z5];bot y6=0; pos6(.5[stem,hair],0);
    filldraw stroke z6e...z5e---z4e;
    x9=x7+1.5u; bot y9l=-oo; pos9(.8[hair,stem],90); alpha_tail(9,10);     %right stem
    filldraw stroke z10e...z9e{left}...z8e---z7e;
   else:
    pickup fine.nib;
    pi_bar;                                                       %bar
    pos4(hair,0); pos7(hair,0); y4=y7=y2;                         %attachments
    lft x4l-(x1-.5hair)=lft x7l-rt x4r=rt x3-rt x7r;
    pos5(hair,0); pos8(hair,0); y5=y8=.5x_height; x5=x4; x8=x7;   %midstems
    x6+.5stem=hround(rt x4r if not straight:-.25u fi); y6-.5stem=-oo; %left stem
    numeric slope; slope=angle((z5-z6)xscaled2); pos6(stem,slope-90);
    filldraw circ_stroke z6e...z5e---z4e;
    x9=x7+1.5u; bot y9l=-oo; pos9(stem,90); alpha_tail(9,10);     %right stem
    filldraw stroke z10e...z9e{left}...z8e---z7e;
   fi
  fi
enddef;


cmchar "Lowercase pi";
beginchar("p",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8,9,10); endchar;

picture savedpicture; currentbreadth:=0;



if small_caps:
  def width = 9.5u enddef;
  def height = sclc*x_height enddef;
  def depth = 0 enddef;
  def dims = width#,height#,depth# enddef;
else:
  def width = 8.5u enddef;
  def height = x_height enddef;
  def depth = desc_depth enddef;
  def dims = width#,height#,depth# enddef;
fi
def ital = 0 enddef;
def fit_params = 0,0 enddef;


def gen_letter =
  if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(serif_fit#,0);
    pickup tiny.nib; penpos1(stem'-tiny,0); penpos2(stem-tiny,0);
    pos0(stem',0); pos0'(stem,0);
    lft x1l=hround max(2u,3u-.5stem'); top y1=h; bot y2=0;
    x1l=x2l=x0l=x0'l; y0=y0'=y7;
    penpos3(cap_band,90); penpos4(cap_band,90);
    penpos5(curve if hefty:-3stem_corr fi,0);
    penpos6(.5[vair,cap_band],-90); penpos7(.5[vair,cap_band],-90);
    z3r=top z1; y4=y3; y5=.5[y4l,y6l]; y6=y7;
    x7=x2; y7l=vround .5h; x4=x6=.5w+.75u; x5r=hround(w-u);
    x4l:=x6l:=x4-.25curve;
    filldraw stroke z1e--z0e--z0'e--z2e; % stem
    fill stroke z3e..pulled_arc.e(4,5) & pulled_arc.e(5,6)..z7e;  % lobe
    if serifs: dish_serif(1,0,a,1/3,jut,b,1/3,.5jut);  % upper serif
     dish_serif(2,0',c,1/3,jut,d,1/3,jut); fi  % lower serif
    math_fit(0,ic#-2.5u#);
  else:
   if cursive or monospace:
    if slitex or monospace: pickup fine.nib;spess:=max(hair,fine+eps);else: spess:=hair; fi
    pos0(stem,0); pos1(stem,0); pos2(spess,-90); pos3(stem,180);
    pos4(spess,90); pos5(spess,0);
    lft x0l= lft x1l = w - rt x3l= 3/4u; x2=x4=w/2; rt x5r = rt x1r;
    bot y0=-d; y1=y3=y5=bar_height; h-top y2l=bot y4l=-oo;
    filldraw stroke z1e{up}..{right}z2e..z3e{down}..z4e{left}..{up}z5e;
    filldraw z1l--z0l--z0r--z5--cycle;
   else:
    pickup fine.nib;
    lft x4r=hround .75u; x8r=w-x4r; y4r=y8r=.5h;          %left and right
    top y2r=h+oo; bot y6r=-oo; x2r=x6r=.5w;               %top and bottom
    filldraw stroke
      gr_arc.e(4,5,6)(curve,vair,-otilt) & gr_arc.e(6,7,8)(curve,vair,-otilt) &
      gr_arc.e(8,1,2)(curve,vair,-otilt) & gr_arc.e(2,3,4)(curve,vair,-otilt);
    if straight:
      y9-.5stem=-d-oo; x9=x4; pos9(stem,180);                     %end of handle
      filldraw circ_stroke z9e..z4e;
    else:
      y9-.5stem=-d-oo; x9=lft x4r+stem;                           %end of handle
      if serifs:
      pos9(stem,angle((z9-z4)xscaled3)-90); z9'r=z9'l=(z9-z4)xscaled3;
        rt x10l=lft x10r+vair;                      %vertical tangents of handle
        x10r=x4r-epsilon; assign_z4'r((-2eps,-1));  %so club.r won't get confused
        filldraw double_circ_stroke club.e(4,10,9);
      else:
        pos9(1.2vstem,angle((z9-z4)xscaled3)-90); z9'=(z9-z4)xscaled3;
        filldraw z4r{down}...{z9'}z9r...z9l{-z9'}...{up}z4l--cycle;
      fi
    fi
   fi
   numeric x_baryctr; x_baryctr=x2;                      %breathing placement
  fi
enddef;


cmchar "Lowercase rho";
beginchar("r",dims);
adjust_fit(fit_params);
this_letter; penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;



iff(not barebones):
cmchar "Lowercase rho with rough breathing";
beginchar(oct"373",width#,acc_ht#,depth#);
this_letter; if (not small_caps): spirit(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase rho with smooth breathing";
beginchar(oct"374",width#,acc_ht#,depth#);
this_letter; if (not small_caps): spirit(x_baryctr)>; fi endchar;

picture savedpicture; currentbreadth:=0;


def dims=if small_caps: 9.5 else: 8 fi u#,%
            if small_caps: sclc* fi x_height#,%
            if small_caps: 0 else: desc_depth# fi enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;

def gen_letter =
  if small_caps: sc_beak_jut#:=.7beak_jut#; sc_beak#:=.7beak#;
    define_pixels(sc_beak_jut,sc_beak);
    italcorr height#*slant-sc_beak_jut#-.5u#;
    numeric bot_arm_thickness;
    bot_arm_thickness=Vround .25[slab,vstem];
    pickup tiny.nib; lft x1l=hround u; x1l=x2l=x4l;
    top y1=h; bot y2=h-slab; bot y4=0; x3l-x1l=4/11(w-2u); y3=.5h;
    numeric alpha[]; alpha1=((x3l-x1l)++(y2-y3))/(y2-y3);
    penpos1(alpha1*(stem-tiny),0); penpos2(alpha1*(stem-tiny),0);
    penpos3(alpha1*(stem-tiny),0);
    alpha2=diag_ratio(1,hair-tiny,y3-y4,x3r-x4l);
    penpos4(alpha2*(hair-tiny),0);
    z0=whatever[z2l,z3l]=z4l+whatever*(z3r-z4r);
    filldraw z1l--z2l--z0--z4l--z4r--z3r--z2r--z1r--cycle;  % diagonals
    pickup crisp.nib; pos5(slab,90); pos6(hair,0);
    top y5r=h; x5=x1; rt x6r=hround(w-u); y6=good.y(y5l-sc_beak)-eps;
    arm(5,6,a,beak_darkness,sc_beak_jut);  % upper arm and beak
    pos7(bot_arm_thickness,-90); pos8(hair,0);
    bot y7r=0; z7l=whatever[z4,z3]; x7r:=x4; x8=x6;
    y8=good.y(y7l+sc_beak)+eps;
    arm(7,8,b,beak_darkness,sc_beak_jut);  % lower arm and beak
    math_fit(0,.5ic#);
  else:
   if cursive:
    if slitex or monospace: pickup fine.nib; fi
    pos1(stem,45); pos2(hair,90); pos3(stem,220); pos4(.8[hair,stem],220);
    pos6(min(hair,.5d),90);
    lft x3r=3/4u=w-rt x1r; x2=w/2; top y2r=h+oo; top y1r=h-if serifs:.7fi stem;
    y3=bar_height; if slitex:bot y4r else: y4 fi=0; rt x4l=rt x1l;
    bot y6l=-d; x6=3w/8;
    path gobba; gobba= z2l{left}..tension .75..{down}z3l; pair zA,zB;
    zB=point .5 of gobba; zA=direction .5 of gobba;
    pos0(hair,angle(zA)-if serifs:90else:60fi);z0l=zB;
    if monospace:
      path gobba; pair zA; gobba=z4r{down}..tension .8..{left}z6r;
      zA=direction .5 of gobba;
      pos5(hair,angle(zA)-90); z5r=point .5 of gobba;
    else:
      pos5(hair,180); y5=.5[y4r,y6]; rt x5l=rt x1r;
    fi
    path gobba; gobba=z1{dir110}...{left}z2..z0..z3..z4..{if monospace:zA else: down fi}z5;
    pair diag; diag=direction 3.5 of gobba;
    pos7(stem,angle(diag)-90); if monospace:z7l else: z7 fi=point 3.5 of gobba;
    path gobba; gobba=z5r{if monospace:zA else: down fi}..{left}z6r;
    pair zB; zB=direction .5 of gobba; pos8(min(hair,.5d),angle(zB)-90); z8r=point .5 of gobba;
    filldraw circ_stroke z1e{dir 110}...{left}z2e..z0e..z3e..z7e{diag}..z4e
    ..{if monospace:zA else:down fi}z5e..z8e{zB}..{left}z6e;
    path gobba; pair zA,zB,diag;
   else:
    pickup fine.nib;
    pos4(hair,-180); y4=.5h; lft x4r=hround .75u;             %left bulge
    pos6(hair,-180); rt x6l=hround(w-.75u); %y6=-.5stem;       %bottom right
    top y3r=h+oo; x3+.5stem=rt x6l; pos3(stem,90);            %top right
    pos5(vstem,-90); bot y5r=0; x5=.5w;                       %inflection pt
    pos7(vstem,-270); y6=.5[y7r,y5r]; x7-.5vstem=hround x5;
    bot y7l=-if not slitex:.5fi desc_depth;
    filldraw double_circ_stroke                               %bowl and tail
      z7e{right}...z6e...z5e{left}...z4e...z3e{right};
   fi
  fi
enddef;


cmchar "Final lowercase sigma";
beginchar("c",dims);
adjust_fit(fit_params);
this_letter; penlabels(1,2,3,4,5,6,7,8); endchar;

iff small_caps:
beginchar("s",dims);
adjust_fit(fit_params);
this_letter; penlabels(1,2,3,4,5,6,7,8); endchar;

% Initial and medial "sigma"

def dim_sigma = if small_caps: 11 else:9.5 fi u#,%
                if small_caps: sclc* fi x_height#,0 enddef;
def ital_sigma = 0 enddef;
def fit_params_sigma = 0,.75u# enddef;

def gen_mid_sigma =
  if small_caps:  sc_beak_jut#:=.7beak_jut#; sc_beak#:=.7beak#;
    define_pixels(sc_beak_jut,sc_beak);
    italcorr height#*slant-sc_beak_jut#-.5u#;
    numeric bot_arm_thickness;
    bot_arm_thickness=Vround .25[slab,vstem];
    pickup tiny.nib; lft x1l=hround u; x1l=x2l=x4l;
    top y1=h; bot y2=h-slab; bot y4=0; x3l-x1l=4/11(w-2u); y3=.5h;
    numeric alpha[]; alpha1=((x3l-x1l)++(y2-y3))/(y2-y3);
    penpos1(alpha1*(stem-tiny),0); penpos2(alpha1*(stem-tiny),0);
    penpos3(alpha1*(stem-tiny),0);
    alpha2=diag_ratio(1,hair-tiny,y3-y4,x3r-x4l);
    penpos4(alpha2*(hair-tiny),0);
    z0=whatever[z2l,z3l]=z4l+whatever*(z3r-z4r);
    filldraw z1l--z2l--z0--z4l--z4r--z3r--z2r--z1r--cycle;  % diagonals
    pickup crisp.nib; pos5(slab,90); pos6(hair,0);
    top y5r=h; x5=x1; rt x6r=hround(w-u); y6=good.y(y5l-sc_beak)-eps;
    arm(5,6,a,beak_darkness,sc_beak_jut);  % upper arm and beak
    pos7(bot_arm_thickness,-90); pos8(hair,0);
    bot y7r=0; z7l=whatever[z4,z3]; x7r:=x4; x8=x6;
    y8=good.y(y7l+sc_beak)+eps;
    arm(7,8,b,beak_darkness,sc_beak_jut);  % lower arm and beak
    math_fit(0,.5ic#);
  else:
   if cursive or monospace:
    if slitex or monospace: pickup fine.nib;spess:=max(hair,fine+eps);else: spess:=hair; fi
    pos1(stem,75); pos2(spess,90); pos3(stem,180); pos4(spess,270);
    pos5(stem,0);
    rt x1r+.3stem=w; top y1r=h+oo;
    x2=x4=.5[x3,x5]; bot y4r = h -top y2r = -oo;
    y3=y5=bar_height; lft x3r=3/4u; w-3/2u=rt x5r;
    filldraw circ_stroke z1e{dir 200}..z2e{left}..z3e..z4e..z5e..{left}z2e;
   else:
    pickup fine.nib;
    lft x4r=hround .75u; rt x8r=w-lft x4r;        %left and right bulge
    top y2r=h; bot y6r=-oo; x2r=x6r;              %top and bottom
    numeric fake; fake=y2r-(vstem-currentbreadth); %approx height of z2l
    2y4r=y2r+y6r; if serifs: 2y8r=fake+y6r else: y8r=y4r fi;
    (x8r-x6r)/(y8r-y6r)=-(x4r-x6r)/(y4r-y6r);     %determine x6r
    y1r=y2r;rt x1=hround(rt x8r+u); pos1(stem,90);       %tip
    filldraw stroke z1e..gr_arc.e(2,3,4)(vstem,vstem,otilt)
      & gr_arc.e(4,5,6)(vair,vstem,otilt)    %top stroke and left bowl
      & gr_arc.e(6,7,8)(vair,vstem,otilt);   %bottom part of right bowl
    z9l=z2l; pos9(vair,90);
    filldraw stroke z8e{z8'e}..{z2'l}z9e;    %top part of right bowl
   fi
  fi
enddef;



iff (not small_caps):
cmchar "Initial and medial lowercase sigma";
beginchar("s",dim_sigma);
adjust_fit(fit_params_sigma);
gen_mid_sigma; penlabels(1,2,3,4,5,6,7,8,9); endchar;


picture savedpicture; currentbreadth:=0;


if small_caps:
  def dims = 9.5u#,sclc*x_height#,0 enddef;
else:
  def dims = 8.5u#,x_height#,0 enddef;
fi
def ital = 0 enddef;
def fit_params = -.25u#,0 enddef;

def gen_letter=
  if small_caps:
    italcorr height#*slant-beak_jut#-.25u#;
    adjust_fit(fit_params);
    h:=vround(h-2stem_corr);
    pickup tiny.nib; pos1(stem,0); pos2(stem,0);
    lft x1l=lft x2l=hround(.5w-.5stem); top y1=h; bot y2=0;
    filldraw stroke z1e--z2e; % stem
    pickup crisp.nib; pos3(slab,90); pos4(hair,0);
    top y3r=h; x3=x1; rt x4r=hround(w-.65u); y4=good.y(y3l-beak)-eps;
    arm(3,4,e,beak_darkness,.7beak_jut);  % right arm and beak
    pos5(hair,180); x5=w-x4; y5=y4;
    arm(3,5,f,beak_darkness,-.7beak_jut);  % left arm and beak
    if serifs: dish_serif(1,2,a,1/3,.5jut,b,1/3,.5jut);  % upper bracketing
     dish_serif(2,1,c,1/3,1.414jut,d,1/3,1.414jut);      % lower serif
    fi
    math_fit(-.75*height#*slant,ic#-2.5u#);
  else:
   if cursive:
    if slitex or monospace: pickup fine.nib; fi
    pos1(hair,90); pos2(stem,90); pos3(stem,90);
    lft x1r= w- rt x3r=3/4u; lft x2=w/4;
    top y2r=top y3r=h; top y1r =bot y2l-.4(stem-hair);
    filldraw
      z1l{dir 75}..{right}z2l--z3l--z3r--z2r{left}..{down}z1r--cycle;
    pos4(if not monospace:.8fi stem,0); pos5(stem,0); pos6(.8[hair,stem],90);
    y4=y2; x4=x5+(fine+stem)/4=.5[rt x1r,rt x3r]; y5=h/3; x6=.5[rt x5r,rt x3-hair]; bot y6l=-oo;
    pos7(hair,180); top y7= y5; x7l=x3;
    filldraw stroke z4e..{down}z5e...{right}z6e...{up}z7e;
   else:
    pickup fine.nib;
    pi_bar;                                                       %bar
    pos4(hair,0); y4=y2; lft x4l-(x1-.5hair)=rt x3-rt x4r;        %attachment
    pos5(hair,0); y5=.5x_height; x5=x4;                           %midstems
    x6=x4+1.5u; bot y6l=-oo; pos6(stem,90); alpha_tail(6,7);      %stem
    filldraw stroke z7e...z6e{left}...z5e---z4e;
   fi
  fi
enddef;

cmchar "Lowercase tau";
beginchar("t",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8); endchar;


picture savedpicture; currentbreadth:=0;


if small_caps:                 % lowercase upsilon
  def width = 10u enddef;
  def dims = width#,sclc*x_height#,0 enddef;
else:
  def width = 9u enddef;
  def dims = width#,x_height#,0 enddef;
fi
def ital = 0 enddef;
def fit_params = 0,0 enddef;

def gen_letter=
  if small_caps:
    italcorr .8*height#*slant-.5u#;
    adjust_fit(0,0);
    pickup tiny.nib; pos1(stem,0); pos2(stem,0);
    lft x1l=lft x2l=hround(.5w-.5stem); y1=.5h; bot y2=0;
    filldraw stroke z1e--z2e; % stem
    penpos3(.6stem,0); penpos4(.75curve,90); penpos5(hair,180);
    z3l=lft z1l; x5r=hround u; y5=bot .8h; x4=.61803[x3l,x5l]; y4r=h+o;
    penpos5'(hair,180); x5'=x5; y5'=h;
    fill z3r{up}...z4r{left}...{down}diag_end(5'r,5r,1,1,5l,5'l){up}
     ...{right}z4l...{down}z3l--cycle;  % left arc
    penpos6(.6stem,0); penpos7(.75curve,-90); penpos8(hair,-180);
    z6r=rt z1r; x8=w-x5; y8=y5; x7=w-x4; y7=y4;
    penpos8'(hair,-180); x8'=x8; y8'=h;
    fill z6r{up}...z7r{right}...{down}diag_end(8'r,8r,1,1,8l,8'l){up}
     ...{left}z7l...{down}z6l--cycle;  % right arc
    if serifs: dish_serif(2,1,a,1/3,1.25jut,b,1/3,1.25jut); fi  % serif
    math_fit(-.8*height#*slant-.5u#,ic#-2.5u#);
    numeric x_baryctr; x_baryctr=x1;
  else:
   if cursive and serifs and not monospace:
    adjust_fit(.5stem#,0);
    pos1(hair,90); pos2(stem,45); pos3(stem,0);
    pos4(stem,10); pos5(.5[hair,stem],90); pos6(hair,180);
    numeric tip_slope; tip_slope=-70;  pos7(stem,tip_slope-90);
    x1l=0; x2l=4/3u; x2=x3l=x4l;
    y1=y2l; y2r=h; y3=3/4h; y4l=max(1/3h,3/2stem);
    x6l=w-3/4u; x7l=x6r; y7+.5stem=h+o; y6=4/10h;
    y5l=-oo; x5=.5[x3l,x6l];
    filldraw circ_stroke z7e{dir(tip_slope)}..{down}z6e..{left}z5e
       ..{up}z4e..z3e..z2e..z1e;
    numeric x_baryctr; x_baryctr=(w-u/3)/2; numeric tip_slope;
   else:
    adjust_fit(0,0);
    pickup fine.nib;
    y2+.5stem=x_height+o; x2-.5stem=hround.75u;                   %%%left tip
    lft x4r=hround(x2-.5stem+.75u); y4r=.5x_height;               %left middle
    y8r=y4r; rt x8r=hround(w-.75u);                               %right bulge
    x6r=.5[x4r,x8r]; bot y6r=-oo;                                 %bottom
    numeric tilt;
    tilt:=min(2*otilt,.5);
    if monospace:
     pos4(stem,180); pos6(stem,-90); pos8(stem,0);
     filldraw stroke z4e{down}...{right}z6e...{up}z8e;
    else:
     filldraw stroke  gr_arc.e(6,7,8)(vair,stem,tilt) ;
     filldraw stroke  gr_arc.e(4,5,6)(vair,.4[vair,stem],tilt);
    fi
    y9+.5hair=x_height+o; x9=x8-u;
    pos9(hair,angle ((z8-z9) xscaled 2)+90);
    pos2(stem,angle((z4-z2) xscaled 2)-90);
    if monospace:
     filldraw circ_stroke z9e...{down}z8e;
     filldraw circ_stroke z2e...{down}z4e;
    else:
     filldraw circ_stroke z9e...{-z8'e}z8e;
     filldraw circ_stroke z2e...{z4'e}z4e;
    fi
    numeric x_baryctr; x_baryctr=.5[x2,x9]-.15stem;
   fi
  fi
enddef;


cmchar "Lowercase upsilon";
beginchar("u",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8,9); endchar;


iff(not barebones):
cmchar "Lowercase upsilon with grave";
beginchar(oct"314",width#,acc_ht#,0);
this_letter; if (not small_caps): grave(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with rough breathing";
beginchar(oct"315",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with smooth breathing";
beginchar(oct"316",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with acute";
beginchar(oct"324",width#,acc_ht#,0);
this_letter; if (not small_caps): acute(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with rough breathing and acute";
beginchar(oct"325",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit_acute(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with smooth breathing and acute";
beginchar(oct"326",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit_acute(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with rough breathing and grave";
beginchar(oct"317",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with smooth breathing and grave";
beginchar(oct"327",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)>; fi endchar;


iff(not barebones):
cmchar "Lowercase upsilon with circumflex";
beginchar(oct"334",width#,circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=false; circumflex(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with rough breathing and circumflex";
beginchar(oct"335",width#,Circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=true; spirit_circumflex(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with smooth breathing and circumflex";
beginchar(oct"336",width#,Circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=true; spirit_circumflex(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with diaeresis";
beginchar(oct"364",width#,circ_ht#,0);
this_letter;  diaeresis(x_baryctr); endchar;

iff(not barebones):
cmchar "Lowercase upsilon with diaeresis and grave";
beginchar(oct"365",width#,Circ_ht#,0); % Circ_ht is chosen on purpose
this_letter;
if (not small_caps):
  diaeresis_grave(x_baryctr);
else:
  diaeresis(x_baryctr);
fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with diaeresis and acute";
beginchar(oct"366",width#,Circ_ht#,0); % Circ_ht is chosen on purpose
this_letter;
if (not small_caps):
  diaeresis_acute(x_baryctr);
else:
  diaeresis(x_baryctr);
fi endchar;

iff(not barebones):
cmchar "Lowercase upsilon with diaeresis and circumflex";
beginchar(oct"367",width#,Circ_ht#,0);
this_letter;
if (not small_caps):
  squeeze:=true;
  diaeresis_circumflex(x_baryctr);
else:
  diaeresis(x_baryctr);
fi endchar;

picture savedpicture; currentbreadth:=0;


def dims = if small_caps: 10u#, sclc*x_height#,0
           else: 10.5u#,x_height#,desc_depth#
       fi
           enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;


def gen_letter =
  if small_caps:
    italcorr .5*height#*slant-.5u#;
    adjust_fit(0,0);
    numeric shaved_stem,light_curve;
    shaved_stem=stem-hround 2stem_corr;
    light_curve=curve-hround stem_corr;
    pickup tiny.nib; pos1(shaved_stem,0); pos2(shaved_stem,0);
    lft x1l=lft x2l=hround(.5w-.5stem); top y1=h; bot y2=0;
    filldraw stroke z1e--z2e; % stem
    penpos3(vair,90); penpos5(vair,-90);
    penpos4(light_curve,180); penpos6(light_curve,0);
    x4r=hround u; x6r=w-x4r; x3=x5=.5w;
    y3r=vround(.85h if serifs:-slab fi); y4=y6=.5[y3,y5];
    y5r=vround(.15h if serifs:+slab fi);
    penstroke pulled_arc.e(3,4) & pulled_arc.e(4,5)
     & pulled_arc.e(5,6) & pulled_arc.e(6,3) & cycle;  % bowl
    if serifs: dish_serif(1,2,a,1/3,1.25jut,b,1/3,1.25jut);  % upper serif
     dish_serif(2,1,c,1/3,1.25jut,d,1/3,1.25jut); fi  % lower serif
    math_fit(-.5*height#*slant-.5u#,ic#);
  else:
   if cursive and serifs and not monospace:        % regular, outline and cursive
    lft x4r=w-rt x8r=hround .75u; y4r=y8r=.5h;
    x6=.5[x4r,x8r]; bot y6r=-oo;
    y10=-d; y11=y4r; x10=x11=x6;
    numeric raggio; raggio=x8r-x4r-stem;
    y2=h; .4[x2,x9]=x6;
    pos2(hair,180);
    pos4(stem,180); pos6(hair,-90); pos8(stem,0); pos9(hair,120);
    pos10(stem,180); pos11(stem,180); pos7(stem,135);
    x9r=.41[x10r,x8r]; top y9r=h+oo; x7l=x11l; y7=.5[y9r,y11r];
    filldraw stroke z2e..z4e{down}..z6e{right}..{up}z8e..{left}z9e...z7e
      ..{down}z11e--z10e;
   else:                                           % sanserif, typewriter, slides
    if monospace:
        if vair<=fine:
            pickup pencircle scaled 1.05fine;
            currentbreadth:=1.05fine;
        else:
            pickup fine.nib;
        fi
    else:
        pickup fine.nib;
    fi
    lft x4r=w-rt x8r=hround .75u; y4r=y8r=.5h;
    x6r=.5[x4r,x8r]; bot y6r=-oo;
    numeric tilt; tilt:=min(2*otilt,.5);
    if monospace:
        pos6(vair,-90); pos8(.4[vair,stem],0);
        pos4(vair,180);
        filldraw stroke z4e{down}..{right}z6e..{up}z8e;z8'l=(0,1);
    else:
        filldraw stroke gr_arc.e(6,7,8)(vair,stem,tilt) ;
        filldraw stroke gr_arc.e(4,5,6)(vair,.4[vair,stem],tilt) ;
    fi
    y2+.5stem=h+o; x2+.5stem=hround(x6-1.5u);
    pos2(stem,angle((z2-z4)xscaled 2)+90);
    filldraw circ_stroke z2e...if monospace:{down}else:{z4'e}fi z4e;
    pos10(stem,180); pos11(hair,180);
    y10-.5stem=-d-o; y11=.25h; x10=x11=x6;
    x9r=.5[x10r,x8r]; top y9r=h+o;
    filldraw stroke gr_arc.e(8,20,9)(vair,.4[vair,stem],.5tilt);
    filldraw circ_stroke z10e..z11e{up}..{-z9'e}z9e;
   fi
  fi
enddef;


cmchar "Lowercase phi";
beginchar("f",dims);
this_letter; penlabels(1,2,3,4,5,6,7,8,9,10,11,12,20,21); endchar;

picture savedpicture; currentbreadth:=0;


def ital = 0 enddef;
def fit_params = 0,0 enddef;
if small_caps:
  def dims = 10u#,sclc*x_height#,0 enddef;
else:
  def dims = 10u#,x_height#,desc_depth# enddef;
fi


def gen_letter=
  if small_caps:
    italcorr height#*slant-.25u#;
    adjust_fit(serif_fit#,serif_fit#);
    numeric stem[],outer_jut,xjut,alpha[];
    stem1=stem-2stem_corr; stem2=min(hair,stem1);
    outer_jut=.75jut; xjut= if serifs: (stem1-stem2)/4 else: 0 fi;
    x1l=l+letter_fit+.5u+outer_jut; x2r=r-letter_fit-u-outer_jut-xjut;
    x3l=l+letter_fit+.25u+outer_jut+xjut; x4r=r-letter_fit-.25u-outer_jut;
    y1=y2=h; y3=y4=0;
    alpha1=diag_ratio(1,stem1,h,x4r-x1l);
    alpha2=diag_ratio(1,stem2,h,x2r-x3l);
    penpos1(alpha1*stem1,0); penpos2(alpha2*stem2,0);
    penpos3(alpha2*stem2,0); penpos4(alpha1*stem1,0);
    if hefty: z0=whatever[z1,z4]=whatever[z2,z3];
     x12=x34=x0; y13=y24=y0;
     z12=whatever[z2l,z3l]; z13=whatever[z2l,z3l];
     z24=whatever[z2r,z3r]; z34=whatever[z2r,z3r];
     forsuffixes $=13,24,34: z$'=.1[z$,z0]; endfor
     fill diag_end(12,1r,.5,1,1l,13')--z13'--diag_end(13',3l,1,.5,3r,34')--z34'
      --diag_end(34',4l,.5,1,4r,24')--z24'
      --diag_end(24',2r,1,.5,2l,12)--z12--cycle; % diagonals
    else: fill diag_end(4r,1r,.5,1,1l,4l)
      --diag_end(1l,4l,.5,1,4r,1r)--cycle;               % left diagonal
     fill diag_end(2l,3l,.5,1,3r,2r)
      --diag_end(3r,2r,.5,1,2l,3l)--cycle; fi            % right diagonal
    if serifs: numeric inner_jut[]; pickup tiny.nib;
     prime_points_inside(1,4); prime_points_inside(2,3);
     prime_points_inside(3,2); prime_points_inside(4,1);
     if rt x1'r+jut+.5u+1<=lft x2'l-jut-xjut: inner_jut1=jut;
     else: rt x1'r+inner_jut1+.5u+1=lft x2'l-inner_jut1-xjut; fi
     if rt x3'r+jut+.5u+1<=lft x4'l-jut-xjut: inner_jut2=jut;
     else: rt x3'r+inner_jut2+.5u+1=lft x4'l-inner_jut2-xjut; fi
     dish_serif(1',4,a,1/3,outer_jut,b,2/3,inner_jut1);  % upper left serif
     dish_serif(4',1,c,2/3,inner_jut2,d,1/3,outer_jut);  % lower right serif
     dish_serif(2',3,e,2/3,inner_jut1+xjut,
      f,1/2,outer_jut+xjut)(dark);                       % upper right serif
     dish_serif(3',2,g,1/2,outer_jut+xjut,
      h,2/3,inner_jut2+xjut)(dark); fi                   % lower left serif
    math_fit(0,.5ic#);
  else:
   if cursive and serifs and not monospace:
    adjust_fit(.5stem#,.5stem#);
    x0=w/2; y0=.5[-d,h];  numeric diagon; diagon=angle(w-2u,h+d);
    pos1(hair,90); pos2(stem,.5[90,diagon]); pos3(stem,diagon);
    pos0(stem,diagon); pos4(stem,diagon); pos5(stem,.5[90,diagon]); pos6(hair,90);
    z0=.5[z1,z6]=.5[z2,z5]=.5[z3,z4];
    x1=0; x2l=u; x2r+.5
    u=x3l; y1=y2l; y2r=h; y3=y2l;
    filldraw stroke z1e..z2e..z3e--z4e..z5e..z6e;
    pos7(.8stem,0); pos8(.5stem,-diagon); pos9(.8stem,0);
    z0=z8=.5[z7,z9]; x7l=0; y7=-d;
    filldraw stroke z7e{up}...{dir(diagon-10)}z8e...{up}z9e;
   else:
    pickup fine.nib;
    x1-.5stem=hround .75u; y1+.5stem=h+oo;                %top left
    z1'=(1,.2); pos1(stem,angle z1'+90);                  %direction at z1
    x3+x1=w; y3-.5stem=-d-oo; pos3(stem,angle z1'+90);    %bottom right
    z2=.5[z1,z3];                                         %attachment
    z2'=(z3-z1)yscaled 2; pos2(hair,angle z2'+90);        %direction at z4
    filldraw double_circ_stroke z1e{z1'}... z2e{(z3-z1)yscaled 2}...{z1'}z3e;
    lft x7l=hround .75u; bot y7l=-d-oo; z2=.5[z7l,z8r]=.5[z7r,z8l];
    numeric stem'; stem'=stem-currentbreadth;
    numeric theta; theta=angle(z8r-z7l)+angle((x8r-x7l)++(y8r-y7l)+-+stem',stem');
    x7r=x7l+(stem'/sind theta); y7r=y7l;
    filldraw stroke z7e..z8e;
   fi
  fi
enddef;


cmchar "Lowercase chi";
beginchar("q",dims);
this_letter; penlabels(0,1,2,3,4,5,6,7,8,9); endchar;

picture savedpicture; currentbreadth:=0;


if small_caps:
  def dims = 11.5u#,sclc*x_height#,0 enddef;
else:
  def dims = 10.5u#,asc_height#,desc_depth# enddef;
fi
def ital = 0 enddef;
def fit_params = 0,0 enddef;

def gen_letter =
  adjust_fit(fit_params);
  if small_caps:
    italcorr .8*height#*slant-.5u#;
    numeric shaved_stem;
    shaved_stem=stem-hround 2stem_corr;
    pickup tiny.nib; pos1(shaved_stem,0); pos2(shaved_stem,0);
    lft x1l=lft x2l=hround(.5w-.5stem); 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.25jut,b,1/3,1.25jut);  % upper serif
     dish_serif(2,1,c,1/3,1.25jut,d,1/3,1.25jut); fi  % lower serif
    math_fit(-.8*height#*slant-.5u#,.4*height#*slant-1.25u#);
  else:
    if cursive and serifs and not monospace:
      pos4(hair,270); pos6(stem,-20); pos5(stem,270);
      lft x2r=w-rt x6r=.75u; y2=y6=.5[h,-d];            %left and right bulges
      x4r=.5[x2r,x6r]; bot y4r=-oo;                         %bottom
      pos7(stem,45);
      top y7r=x_height+o; x7=x6-u;          %right tip
      filldraw circ_stroke z7e{dir(-45)}..{down}z6e;
      pos10(stem,0); pos9(hair,0); pos8(stem,0);            %vertical stroke
      y10=-d; y9=y2; y8=h; x10=x9=x8=x4;
      filldraw stroke z10e..z9e{up}..z8e;
      z5-z9=(x6-x9)*dir(-45);
      filldraw stroke z4e{right}..z5e..{up}z6e;
      pos1(stem,220);pos2(stem,200); pos3(stem,270);
      z3-z9=(x9-x2)*dir(225);
      filldraw stroke z2e{down}..z3e..{right}z4e;
      top y1l=x_height+o;   %left tip
      z2-z1=whatever*down;
      pos0(hair,-90); y0=y1-.5hair; x0=0;
      path gancio; gancio= z0l..z1l..{down}z2l;
      pair za, zb;
      za= direction 0 of gancio; zb=direction 1 of gancio;
      filldraw  z0r{za}..z1r{zb}..{down}z2r--z2l{-down}..z1l..z0l--cycle;
      pair za, zb; path gancio;
    else:
      pickup fine.nib;
      lft x2r=w-rt x6r=.75u; y2r=y6r=.6x_height;            %left and right bulges
      x4r=.5[x2r,x6r]; bot y4r=-oo;                         %bottom
      numeric tilt; tilt:=min(2*otilt,.5);
      if monospace:
      pos2(stem,180); pos4(stem,-90); pos6(stem,0);
       filldraw stroke z2e{down}..z4e{right}..{up}z6e;
      else:
       filldraw stroke gr_arc.e(4,5,6)(vair,stem,tilt) ;
       filldraw stroke gr_arc.e(2,3,4)(vair,.4[vair,stem],tilt) ;
      fi
      y7+.5hair=x_height+o; x7+.5hair=hround(rt x6r-.75u);          %right tip
      pos7(hair,angle ((z6-z7) xscaled 2)+90);
      if monospace:
       filldraw circ_stroke z7e...{down}z6e;
      else:
       filldraw circ_stroke z7e...{-z6'e}z6e;
      fi
      y1+.5stem=x_height+o; x1-.5stem=hround(lft x2r+.5u);  %left tip
      pos1(stem,angle((z2-z1) xscaled 2)-90);
      if monospace:
       filldraw circ_stroke z1e...{down}z2e;
      else:
       filldraw circ_stroke z1e...{z2'e}z2e;
      fi
      pos10(stem,0); pos9(hair,0); pos8(stem,0);            %vertical stroke
      y10-.5stem=-d-o; y9=.25x_height; y8+.5stem=h+o; x10=x9=x8=x4;
      filldraw double_circ_stroke z10e..z9e{up}..z8e;
    fi
  fi
enddef;


cmchar "Lowercase psi";
beginchar("y",dims);
this_letter; penlabels(0,1,2,3,4,5,6,7,8,9,10); endchar;

picture savedpicture; currentbreadth:=0;

% omega

if small_caps:
  def width = 10u enddef;
  def height = sclc*x_height enddef;
else:
  def width = 12u enddef;
  def height = x_height enddef;
fi
def dims = width#,height#,0 enddef;
def ital = 0 enddef;
def fit_params = 0,0 enddef;

def gen_letter =
  if small_caps:
    pickup tiny.nib; pos1(vair,90); pos2(curve,180);
    pos3(vair,180); pos4(curve,0); pos5(vair,0);
    x1=.5w; top y1r=h+o; lft x2r=hround u; y2=y4=2/3h; x4=w-x2;
    rt x3l=hround(1/3(w+.5u)+.5hair); bot y3=bot y5=0; x5=w-x3;
    filldraw stroke z3e{up}...{up}z2e
     & pulled_super_arc.e(2,1)(.5superpull)
     & pulled_super_arc.e(1,4)(.5superpull)
     & z4e{down}...{down}z5e;  % bowl
    numeric arm_thickness; path p; p=z3{up}...{up}z2;
    arm_thickness=Vround(if hefty:slab+2stem_corr else:.75[slab,vstem] fi);
    pickup crisp.nib; pos6(arm_thickness,-90); pos7(fudged.hair,-180);
    bot y6r=0; x6=x3; lft x7r=hround .8u; y7=good.y(y6l+.5beak)+eps;
    (x,y)=p intersectionpoint((0,y6l)--(w,y6l)); x6l:=x;
    arm(6,7,a,.5beak_darkness,-1.2beak_jut);  % left arm and beak
    pos8(arm_thickness,-90); pos9(fudged.hair,0);
    y8=y6; y9=y7; x8+x6=x9+x7=w; x8l:=w-x6l;
    arm(8,9,b,.5beak_darkness,1.2beak_jut);  % right arm and beak
    math_fit(0,.5ic#);
    numeric pos_stem;           % iota sub position
    pos_stem=rt x9r + if serifs:.5elseif slitex:.4else:.6fi(tiny+ .5[vair,stem])+u;
  else:
   if cursive:
    if slitex or monospace: pickup fine.nib; fi
    pos2(stem,-180); pos8(stem,0); lft x2r=w-rt x8r=hround(u-o);
    y2=y8+.3slant*(x8-x2)=.9bar_height;                                   %left and right bulges
    if serifs:
      pos4(hair,0); pos6(hair,180); %left and right of loop
    else:
      pos4(.7vair,0); pos6(.7vair,180);
    fi
    y4=y6=.2[bar_height,h]; .5[x4,x6]=.5w;
    x4r-x6r=stem; %.5[flare,vair];
    bot y3r=bot y7r=-oo; x3=.5[x2,x4];
    x7 =.5[x6,x8];
    numeric ang; ang= if serifs:45 else:20 fi;
    numeric omegaloop; omegaloop=if not serifs: .7 fi stem;
    pos3(omegaloop,-90-ang); pos7(omegaloop,-90+ang);     %left and right bottom
    top y1r=x_height=top y9r;                           %left tip
    x1=.6[x2,.5w]; pos1(hair,180);     %left tip
    x9=.6[x8,.5w]; pos9(hair,0);       %right tip
    filldraw stroke z1e{(z2-z1) xscaled 3}...z2e{down}...z3e{right};
    filldraw stroke z7e{right}...{up}z8e...{(z9-z8) xscaled 3}z9e;
    drawloop(3,4,6,7);
   else:
    pickup fine.nib;
    pos2(stem,-180); pos8(stem,0); lft x2r=w-rt x8r=hround(u-o);
    y2=y8=.8bar_height;                                   %left and right bulges
    if serifs:
      pos4(hair,0); pos6(hair,180); %left and right of loop
    else:
      pos4(.7vair,0); pos6(.7vair,180);
    fi
    y4=y6=bar_height; .5[x4,x6]=.5w;
    x4r-x6r=.5[flare,vair];
    bot y3r=bot y7r=-oo; x3=.5[x2,x4];
    x7 =.5[x6,x8];
    numeric ang; ang= 60;
    numeric omegaloop; omegaloop=if not serifs: .7 fi stem;
    pos3(omegaloop,-90-ang); pos7(omegaloop,-90+ang);     %left and right bottom
    top y1r=x_height+o=top y9r;                           %left tip
    x1=.5[x2,.5w]; pos1(.2[stem,hair],angle(-.5w,y2-x_height)-90);     %lft tip
    x9=.5[x8,.5w]; pos9(.8[stem,hair],angle(-.5w,x_height-y2)-90);     %rt tip
    filldraw stroke z1e{(z2-z1) xscaled 2}...z2e{down}...z3e{right};
    filldraw stroke z7e{right}...{up}z8e...{(z9-z8) xscaled 2}z9e;
    drawloop(3,4,6,7);
   fi
   numeric x_baryctr; x_baryctr=.5[x4,x6];
   numeric pos_stem; pos_stem=x_baryctr;        % iota sub position
  fi
enddef;


cmchar "Lowercase omega";
beginchar("w",dims);
this_letter; penlabels(0,1,2,3,4,5,6,7,8,9); endchar;


iff(not barebones):
cmchar "Lowercase omega with grave";
beginchar(oct"260",width#,acc_ht#,0);
this_letter; if (not small_caps): grave(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase omega with rough breathing";
beginchar(oct"261",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase omega with smooth breathing";
beginchar(oct"262",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase omega with grave and iota subscript";
beginchar(oct"264",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; grave(x_baryctr);fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with rough breathing and iota subscript";
beginchar(oct"265",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; spirit(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with smooth breathing and iota subscript";
beginchar(oct"266",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; spirit(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with acute";
beginchar(oct"270",width#,acc_ht#,0);
this_letter; if (not small_caps): acute(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase omega with rough breathing and acute";
beginchar(oct"271",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit_acute(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase omega with smooth breathing and acute";
beginchar(oct"272",width#,acc_ht#,0);
this_letter; if (not small_caps): spirit_acute(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase omega with rough breathing and grave";
beginchar(oct"263",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase omega with smooth breathing and grave";
beginchar(oct"273",width#,acc_ht#,0);
this_letter; if not small_caps: spirit_grave(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase omega with rough breathing and grave and iota subscript";
beginchar(oct"267",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; spirit_grave(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with smooth breathing and grave and iota subscript";
beginchar(oct"277",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; spirit_grave(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with acute and iota subscript";
beginchar(oct"274",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; acute(x_baryctr);
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with rough breathing, acute and iota subscript";
beginchar(oct"275",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; spirit_acute(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with smooth breathing and acute and iota subscript";
beginchar(oct"276",width#,if small_caps:height#else:acc_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; spirit_acute(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with circumflex";
beginchar(oct"300",width#,circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=false; circumflex(x_baryctr); fi endchar;

iff(not barebones):
cmchar "Lowercase omega with rough breathing and circumflex";
beginchar(oct"301",width#,Circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=true; spirit_circumflex(x_baryctr)<; fi endchar;

iff(not barebones):
cmchar "Lowercase omega with smooth breathing and circumflex";
beginchar(oct"302",width#,Circ_ht#,0);
this_letter; if (not small_caps):
squeeze:=true; spirit_circumflex(x_baryctr)>; fi endchar;

iff(not barebones):
cmchar "Lowercase omega with circumflex and iota subscript";
beginchar(oct"304",width#,if small_caps:height#else:circ_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; squeeze:=false; circumflex(x_baryctr);
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with rough breathing, circumflex and iota subscript";
beginchar(oct"305",width#,if small_caps:height#else:Circ_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; squeeze:=true; spirit_circumflex(x_baryctr)<;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with smooth breathing, circumflex and iota subscript";
beginchar(oct"306",width#,if small_caps:height#else:Circ_ht#fi,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter; squeeze:=true; spirit_circumflex(x_baryctr)>;
fi
iota_sub(pos_stem); endchar;

iff(not barebones):
cmchar "Lowercase omega with iota subscript";
beginchar(oct"372",width#,height#,iota_dp#);
if small_caps:
    italcorr .75*height#*slant-.5u#;
    adjust_fit(0,serif_fit#+.5[vair#,stem#]+tiny#
       if (slitex or (not serifs)):+.5*(.5[vair#,stem#])
         else:+.7jut# fi+.7u#);
gen_letter;
else:
this_letter;
fi
iota_sub(pos_stem); endchar;

%picture pic.iota;
picture savedpicture; currentbreadth:=0;


% digamma
def dims = if small_caps:
             10u#,sclc*x_height#,0
           else:
             9u#,x_height#,desc_depth#
           fi enddef;
def ital = 0 enddef;
def fit_params = if small_caps: serif_fit#,0 else:0,0 fi enddef;

def gen_letter =
  adjust_fit(fit_params);
  if small_caps:
    italcorr height#*slant-serif_fit#+jut#-2.5u#+min(.5stem#,u#);
    h:=vround(h-stem_corr);
    pickup tiny.nib; pos1(stem,0); pos2(stem,0);
    lft x1l=lft x2l=hround max(2u,3u-.5stem); top y1=h; bot y2=0;
    filldraw stroke z1e--z2e; % stem
    pickup crisp.nib; pos3(slab,90); pos4(hair,0);
    top y3r=h; x3=x1; rt x4r=hround(w-.75u); y4=good.y(y3l-0.6beak)-eps;
    arm(3,4,e,beak_darkness,beak_jut);  % upper arm and beak
    pos5(bar,-90); pos6(hair,0);
    top y5l=vround(.5[y2,y1]+.5bar); x5=x1;
    pos0(bar,90); pos7(hair,0);
    z0=z5; x6=x7; y6-y5l=y0l-y7;
    if serifs:
      rt x6r=hround(w-4u+.5hair);
      y6=good.y(y5l+.6beak)+eps;
      rt x9r=hround(w-.5u);
    else:
      rt x6r=hround(w-1.5u);
      y6=y5l+eps;
      rt x9r=hround(w-.75u);
    fi
    arm(5,6,f,beak_darkness,0);
    arm(0,7,g,beak_darkness,0);  % middle arm and serif
    if serifs:
      nodish_serif(1,2,a,1/3,jut,b,1/3,.5jut);  % upper serif
      dish_serif(2,1,c,1/3,jut,d,1/3,1.25jut);  % lower serif
    fi
  else:
   if cursive:
    if slitex or monospace: pickup fine.nib; fi
    pos1(stem,0); bot y1=-d; lft x1l=u;
    pos2(hair,-90); rt x2 + lft x1l=w;  top y2l=h;
    pos3(hair,-90);
    x3=x1+stem;
    y3= y2;
    pos7(.3[hair,stem],0); rt x7r=rt x1r; z3-z7=whatever*(1,1);
    pos5(hair,90); x5=.5[x1,x7]; pos6(hair,90);
    y6=y5; top y6r=bar_height;
    z6-z1=whatever*(z2-z1);
    filldraw stroke z1e..z7e{up}..{right}z3e..z2e;
    filldraw stroke z6e..z5e;
   else:
    if serifs: pickup crisp.nib; else: pickup fine.nib; fi
    pos1(stem,0); bot y1-.5(stem-currentbreadth)=-d; lft x1l=u;
    pos2(.2[stem,hair],-90); x2+.5stem + lft x1l=w;  top y2l=h;
    pos3(.2[hair,stem],-90); % x3=max(.5[x1,x2],x1+stem);
    x3=x1+stem;
    y3= y2;
    pos7(.2[hair,stem],0); rt x7r=rt x1r; z3-z7=whatever*(1,1);
    pos4(.2[hair,stem],0); pos5(hair,90); x5=x4; pos6(.2[stem,hair],90);
    rt x4r=rt x1r; y4=.5[bot y6l,y1]; y6=y5; top y6r=bar_height;
    z6-z1=whatever*(z2-z1);
    filldraw double_circ_stroke z1e..z4e{up}..z7e{up}..{right}z3e..z2e;
    filldraw circ_stroke z6e..{left}z5e;
   fi
  fi
enddef;

cmchar "Lowercase digamma";
beginchar(oct"223",dims);
gen_letter;
penlabels(0,1,2,3,4,5,6,7,8,9);
endchar;

currentbreadth:=0;

endinput;
