% fgeit.mf : fge italic characters
% J.J. Green 2006

mode_setup;
font_setup;

proofing := 2;

slantfont slantfge;

% This is an inverted f, but an italic f with a straight
% descending stem rather than the more usual tail.
% As with the inverted d (below) a hook is attached to
% the left.   

cmchar "inverted f with hook";
beginchar("f", 7.5u#, asc_height#, desc_depth#); 
  italcorr h#*slant + 0.5stem# - 2.5u#;
  adjust_fit(serif_fit# + 2stem_shift#, serif_fit# - 2stem_shift#);

  pickup tiny.nib;

  % stem
  
  pos1(stem', 0); pos2(stem', 0);

  rt.x1r = hround(w/2 + 5u/4 + stem'/2);
  x1 = x2;
  top y1 = h;
  bot y2 = -1/3d;

  filldraw stroke z1e--z2e;

  % bar
  
  pos3(bar, 90);
  pos4(bar, 90);
  bot y3l = bot y4l = 0;

  rt x4 = hround(w - 1/3u);
  x2 - x3 = x4 - x2;
  
  filldraw stroke z3e--z4e;
  
  % arc and bulb

  pos5(vair', -90);
  pos6(hair, -180);
  pos7(flare, -180);

  x5 = 1/2[x2, x6r];
  bot y5r = -d-oo;
  y6 = 1/2flair = -0.88d;
  z6r = z7r;
  rt x7l = floor 11/4u;

  (x, y5r) = whatever[z5l, z2l];
  x5r := max(x, 1/2[x6r, x5]);
  
  filldraw stroke z2e{down}...z5e{left};
  bulb(5, 6, 7);

  % hook

  pos8(0.5[hair, curve], 0);
  rt x8r = lft x1l;
  y8 = 0.5x_height;

  pos9(curve, 90);
  top y9r = x_height + oo;
  x9 = 0.4[0, x8l];

  pos10(hair, 180);
  pos11(hair, -90);

  z9 - z10 = 2.0u*dir(45);
  z8 - z11 = 2.0u*dir(55);
  
  filldraw stroke z11e{right}...z8e{up}...{left}z9e...{down}z10e;
  
  penlabels(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);

endchar;

% I'm convinced this is a rotated d, which would explain the
% right serif on the stem. I take the code from itall.mf's p
% but replace the flat serif with the slanted serif of the d.
% This looks a little different to the original, but then the
% d's of the original *do* have a flat serif -- so this is
% needed for consistency with computer modern's d. 

cmchar "inverted d with hook";
beginchar("p", 13u#, asc_height#, desc_depth#);
  italcorr 0.7x_height#*slant - u# + 0.5curve#;
  adjust_fit(0, 0);
  
  numeric hook_jut;
  hook_jut = w - 9u;
  
  pickup fine.nib;
  x0 = hook_jut;
  x2 - 0.5stem - hook_jut = hround(2.5u-.5stem);
  hook_in(0, 1, 2);  % opening hook

  pos4(hair, -180);
  pos5(vair, -90);
  pos6(curve, 0);
  pos7(vair, 90);
  x4=x2;
  rt x6r=hround(w-1.5u+.5curve);
  x5=x7=.5[x4, x6];
  bot y5r=-oo;
  top y7r=x_height+oo;
  y4=y6=.5[y5, y7];

  filldraw stroke super_arc.e(4, 5) & pulled_arc.e(5, 6)
  & pulled_arc.e(6, 7) & super_arc.e(7, 4);  % bowl

  pickup tiny.nib;
  pos2'(stem, 0);
  pos3(stem, 0);
  z2=z2';
  x3=x2;
  bot y3=-d;

  filldraw stroke z2'e--z3e;  % stem
  sloped_serif.r(3, 2', a, 1/3, jut, serif_drop);  % serif

  math_fit(-min(2/3x_height#*slant-.5hair#-.5u#, 
      2u#-.5stem#-desc_depth#*slant), ic#);

  % bit ad-hoc this
  
  pos8(hair, 0);
  z8r=z0l;

  pos9(curve, 90);
  pos10(hair, 180);
  
  x9   = 1/2[x8, x10];
  y9r  = 1/2[x_height, h];
  y10r = 1/4[y9l, y8];
  x8l - lft x10r = hook_jut;

  % filldraw stroke z8e{up}...{left}z9e...{down}z10e;
  filldraw stroke super_arc.e(8, 9) & super_arc.e(9, 10);
  
  penlabels(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

endchar;

cmchar "Overturned lb ligature";
beginchar(oct "021", 12u#, x_height#, desc_depth#); 
  italcorr 0.7x_height#*slant - 0.5u#;
  adjust_fit(0, 0);
  
  pickup crisp.nib;
  
  slope  := 20;
  obstem := stem/cosd(slope);
  tsep   := 3.75*stem;
  thair  := 0.3[hair, obstem];
  
  % 1-2-11-4-5-6 is the left trunk and flourish, 3 is a utility point
  
  pos1(stem, 0);
  pos2(obstem, 0);
  pos4(hair, 180-slope);
  pos5(hair, -slope);
  pos11(thair, 90);
  
  %x1l = 0.5u;
  x2  = x1;
  bot y1  = y3 = -d;
  y2  = 0.70*x_height;

  z2-z3 = whatever*dir(180-slope);

  z4 = 1.13[z3, z2];
  z5 = whatever[z3, z2];

  x5r = w-0.5u;
  x4r = 0.5u;
  
  % z11 lifts the left stroke

  z11  = 0.5[z2, z4] + whatever*dir(90);
  top y11r = x_height + o;
  
  % z6 might be better half-way between the trunks

  z6 = 0.89[z3, z2];
  pos6(hair, angle(z6-z1)+90);
    
  filldraw stroke z1e--z2e{z2-z1}..z11e..{z1-z2}z4e..tension(1.0)..z5e{z2-z1}..z6e{z1-z6};
  
  penlabels(1, 2, 3, 11, 4, 5, 6);
  
  % the right trunk with foot

  pos7(stem, 0);
  pos8(hair, 90);
  pos9(obstem, 0);
  pos10(hair, 180-slope);

  x7-x1 = x9-x2 = tsep;
  y7 = y1;
  y9 = y2;

  % the vertical lift point
  
  x8  = 0.3[x9, x2];
  top y8r = x_height + o;
  
  z10l = 0.8[z1r, z2r];
  
  filldraw stroke z7e--z9e{z9-z7}...z8e{left}..tension(2.0)..{z7-z9}z10e;

  % serif(7, 9, a, 1/3, cap_jut);
  sloped_serif.r(7, 9, a, 1/3, jut, serif_drop);  % serif
  
  penlabels(7, 8, 9, 10);
  
endchar;

cmchar "inverted F";
beginchar("F", 11.5u#-width_adj#, x_height#, desc_depth#);
  italcorr x_height#*slant-cap_jut#+0.5u#;
  adjust_fit(0, cap_serif_fit#);

  h := vround(h-stem_corr);
  
  pickup tiny.nib;

  pos1(cap_stem, 0);
  pos2(cap_stem, 0);

  rt x1r = rt x2r = hround w - max(2u, 3u-0.5cap_stem);
  top y1 = x_height;
  bot y2 = -desc_depth;
  
  filldraw stroke z1e--z2e; % stem
  
  pickup crisp.nib;
  
  pos3(slab, -90);
  pos4(hair, 180);
  
  bot y3r = -desc_depth;
  x3 = x1;
  rt x4r = hround(0.75u);
  y4 = good.y(y3r+beak)-eps;
  
  arm(3, 4, e, beak_darkness, beak_jut);  % upper arm and beak

  pos5(cap_bar, -90);
  pos6(hair, 180);
  
  top y5l = vround(.5[y2, y1]+.5cap_bar);
  x5 = x1;
  pos0(cap_bar, 90);
  
  pos7(hair, 180);
  z0 = z5;
  x6 = x7;
  y6-y5l = y0l-y7;
  
  rt x6r = hround(4u-.5hair);
  y6 = good.y(y5l+.6beak) + eps;
  rt x9r = hround(w-.5u);

  arm(5, 6, f, beak_darkness, 0);
  arm(0, 7, g, beak_darkness, 0);  % middle arm and serif
  
  nodish_serif(1, 2, a, 1/3, cap_jut, b, 1/3, .5cap_jut);  % upper serif
  dish_serif(2, 1, c, 1/3, cap_jut, d, 1/3, 1.25cap_jut);  % lower serif
  
  math_fit(0, ic#-2.5u#);
  penlabels(0, 1, 2, 3, 4, 5, 6, 7);

endchar;

end