%*****************************************************************************
%        Copyright (c) 1989 by N. N. Billawala
%*****************************************************************************
 

% fligs.mf  ligatures with the "f" character

% 5 characters; iff OK "f": for testing

% Only the ff,fi,fl ligatures have a fixed pitch ligature.
% The reason being that combining two stems might look reasonable; but
% combining three stems would generally create the undesirable type of 
% darkness found in the lowercase m


iff OK "f":  "The ff ligature";  
  beginchar(11,(n_w+r_w-stem.lc#/(width#+mono#))*width#+b_mono#,ascender#,0); 

  if mono=0: bot lft z4l=(round (.2r_w*width),0);  
             bot lft z14l=(round (x4l+n_w*width-stem.lc),0);  
    else: bot lft z4l=(0,0); bot rt z14r=(w,0);    fi
  top z1l=(x4l,h)//;           multpos(1,4,11,14)(stem.lc,0); 
  top z11l=(x14l,h)//;
  onaline(1l,4l)(2l,3l);       y2l=max(xheight,.75xheight+(r_arch*(h-xheight)));
  onaline(1r,4r)(2r,3r,22r);   y2r=max(xheight,.75xheight+(l_arch*(h-xheight)));
  onaline(11l,14l)(12l,13l);   y12l=y2l; y12r=y2r;
  onaline(11r,14r)(12r,13r);   y3l=y3r=y13l=y13r=x_bracket_h;
  rt z16=(if mono<>0:w+abs(x14l-x4r)else:max(w,x14r+.95abs(x14l-x4r))fi,.99h)//;
  rt z6=(x14l,y5r-y15r+y16)//;
  save_num(knob)=min(bulb_thickness,.6(x16-x14r));    
  top y15r=bot y15l+minor_curve.lc=round(.5[h+ov_t.lc,maxheight]); 
  top y5r=inlimit(.9[xheight,h+ov_t.lc])(xheight+2minor_curve.lc,h+ov_t.lc);
  bot y5l+minor_curve.lc=top y5r;
  good_x_for(5r)(z3l,z6,.5)a;  
  good_x_for(5l)(z3r,z6-(bulb_thickness,0),.5)b;
  good_x_for(15r)(z13l,z16,.6)c;
  good_x_for(15l)(z13r,z16-(knob,0),.6)d;

  top rt z21=(w if mono<>0:+max(1,.75stem.lc)fi,xheight)//;
  y22r=y21;                    multpos(22,23)(max(1,.8thin_stem.lc),90);        
  lft z23r=(0 if mono<>0:-max(1,.75stem.lc)fi,y21)//; 

  p1=fullserif(z4,z1,z3l,z3r,.5hs,.5hs)--z2r{upward} i_t
     bulb.tr(z6,z5l,z5r,.75cs,bulb_thickness,90) o_t z2l{downward}--cycle;
  p2=fullserif(z14,z11,z13l,z13r,.5hs,.75hs)--z12r{upward} i_t
     bulb.tr(z16,z15l,z15r,.75cs,knob,90) o_t z12l{downward}--cycle;

  min_limit(join_radius)(.5*min(.8thin_stem.lc,serif_thickness));
  p3=(arm.tr(z21,z22l,z22r,.15as,.25tip_thickness,90)
      soften(z23r,z23l) z22l)--cycle;

  showpoints(1,2,3,4,5,6,11,12,13,14,15,16,21,22,23);
adjust(v_a*fitbasis.lc#-.25r_w*width#+m_a*b_mfit#,0*fitbasis.lc#+m_a*b_mfit#);
show_character; endchar;

% This character is based on 2 "f"; the width is determined by the "n" width
% plus the width of the single "f" minus one stem. The crossbar has been
% extended. The right "f" should be like the single one; the top of the
% left "f" extended to overlap the right one.
% Placement of the curved arm on first "f" slightly altered



iff OK "f":  "The fi ligature";  
  beginchar(12,(n_w+.2r_w)*width#+b_mono#,ascender#,0); 

  bot lft z4l=(round (.2r_w*width),0);  multpos(1,4,11,14)(stem.lc,0);
  bot rt z14r=(w,0);
  top z1l=(x4l,h)//;
  top z11l=(x14l,xheight)//;
  onaline(1l,4l)(2l,3l);       y2l=max(xheight,.75xheight+(r_arch*(h-xheight)));
  onaline(1r,4r)(2r,3r);       y2r=max(xheight,.75xheight+(l_arch*(h-xheight)));
  onaline(11l,14l)(13l);   
  onaline(11r,14r)(13r);       y3l=y3r=y13l=y13r=x_bracket_h;
  rt z6=(x14l,.5[y5r,y5l])//;        
  top y5r=bot y5l+minor_curve.lc=h+ov_t.lc; 
  good_x_for(5r)(z3l,z6,.5)a;  
  good_x_for(5l)(z3r,z6-(bulb_thickness,0),.5)b;
  bot z21l=(0 if mono<>0:-max(1,.75stem.lc)fi,top y11l-max(1,.8thin_stem.lc))//;
  z22r=z11l; 
  multpos(21,22)(max(1,.8thin_stem.lc),90);

  min_limit(join_radius)(.5*min(.8thin_stem.lc,serif_thickness));
  p1=fullserif(z4,z1,z3l,z3r,.5hs,.5hs)--z2r{upward} i_t
     bulb.tr(z6,z5l,z5r,.75cs,bulb_thickness,90) o_t z2l{downward}--cycle;
  p2=(fullserif(z14,z11,z13l,z13r,.5hs,.75hs) soften(z11r,z21r,z21l,z22l) 
     z13l)--cycle;

  showpoints(1,2,3,4,5,6,11,13,14,21,22);
adjust(v_a*fitbasis.lc#-.25r_w*width#+m_a*b_mfit#,v_a*fitbasis.lc#+m_a*b_mfit#);
show_character; endchar;

% This character is based on the "f" and "i"; the width is determined 
% by the "n" width plus the width of the left part of the "f" arm.
% Placement of the curved arm on the "f" slightly altered



iff OK "f":  "The fl ligature";  
  beginchar(13,(n_w+.2r_w)*width#+b_mono#,ascender#,0); 

  bot lft z4l=(round (.2r_w*width),0);  multpos(1,4,11,14)(stem.lc,0); 
  bot rt z14r=(w,0);
  top z1l=(x4l,h)//;
  top z11r=(x14r,.98h)//;
  onaline(1l,4l)(2l,3l);       y2l=max(xheight,.75xheight+(r_arch*(h-xheight)));
  onaline(1r,4r)(2r,3r);       y2r=max(xheight,.75xheight+(l_arch*(h-xheight)));
  onaline(11l,14l)(13l);   
  onaline(11r,14r)(13r);       y3l=y3r=y13l=y13r=x_bracket_h;
  top y5r=bot y5l+minor_curve.lc=h+ov_t.lc;
  good_x_for(5r)(z3l,z11r,.5)a;
  good_x_for(5l)(z3r,z11r-(bulb_thickness,0),.5)b;

  top rt z21r=(x14,xheight)//; multpos(21,22)(max(1,.8thin_stem.lc),90);
  lft z22r=(0 if mono<>0:-max(1,.75stem.lc)fi,y21r)//; 
  z23=.5[z21r,z22r];

  min_limit(join_radius)(.5*min(.8thin_stem.lc,serif_thickness));
  p1=fullserif(z4,z1,z3l,z3r,.5hs,.5hs)--z2r{upward} i_t
     bulb.tr(z11r,z5l,z5r,.75cs,bulb_thickness,90)soft o_t z2l{downward}--cycle;
  p2=fullserif(z14,z11,z13l,z13r,.5hs,.75hs)--z11r--z11l--cycle;
  p3=(z23 soften(z21r,z21l,z22l,z22r) z23)--cycle;

  showpoints(1,2,3,4,5,6,11,13,14,21,22,23);
adjust(v_a*fitbasis.lc#-.25r_w*width#+m_a*b_mfit#,v_a*fitbasis.lc#+m_a*b_mfit#);
show_character; endchar;

% This character is based on the "f" and "l"; the width is determined 
% by the "n" width plus the width of the left part of the "f" arm.
% Placement of the curved arm on the "f" slightly altered

 
if mono=0:  % skips these characters if monopitch

iff OK "f":  "The ffi ligature";  
  beginchar(14,(2n_w+.2r_w-stem.lc#/(width#+mono#))*width#,ascender#,0);

  bot lft z4l=(round (.2r_w*width),0);  multpos(1,4,11,14,21,24)(stem.lc,0); 
  bot lft z14l=(round (x4l+n_w*width-stem.lc),0);
  bot lft z24l=(round (x14l+n_w*width-stem.lc),0);         
  top z1l=(x4l,h)//;
  top z11l=(x14l,h)//;
  top z21l=(x24l,xheight)//;
  onaline(1l,4l)(2l,3l);       y2l=max(xheight,.75xheight+(r_arch*(h-xheight)));
  onaline(1r,4r)(2r,3r);       y2r=max(xheight,.75xheight+(l_arch*(h-xheight)));
  onaline(11l,14l)(12l,13l);   y12l=y2l; y12r=y2r;
  onaline(11r,14r)(12r,13r);   y3l=y3r=y13l=y13r=y23l=y23r=x_bracket_h;
  onaline(21l,24l)(23l); 
  onaline(21r,24r)(23r);
  rt z16=(x24l,.99h)//;         
  rt z6=(x14l,y5r-y15r+y16)//;       
  top y15r=bot y15l+minor_curve.lc=round(.5[h+ov_t.lc,maxheight]); 
  top y5r=inlimit(.9[xheight,h+ov_t.lc])(xheight+2minor_curve.lc,h+ov_t.lc);
  bot y5l+minor_curve.lc=top y5r;
  good_x_for(5r)(z3l,z6,.5)a;  
  good_x_for(5l)(z3r,z6-(bulb_thickness,0),.5)b;
  good_x_for(15r)(z13l,z16,.5)c;
  good_x_for(15l)(z13r,z16-(bulb_thickness,0),.5)d;
  bot z31l=(0,top y21l-max(1,.8thin_stem.lc))//;
  z32r=z21l; 
  multpos(31,32)(max(1,.8thin_stem.lc),90);

  min_limit(join_radius)(.5*min(.8thin_stem.lc,serif_thickness));
  p1=fullserif(z4,z1,z3l,z3r,.5hs,.5hs)--z2r{upward} i_t
     bulb.tr(z6,z5l,z5r,.75cs,bulb_thickness,90) o_t z2l{downward}--cycle;
  p2=fullserif(z14,z11,z13l,z13r,.5hs,.5hs)--z12r{upward} i_t
     bulb.tr(z16,z15l,z15r,.75cs,bulb_thickness,90) o_t z12l{downward}--cycle;
  p3=(fullserif(z24,z21,z23l,z23r,.5hs,.75hs) soften(z21r,z31r,z31l,z32l) 
     z23l)--cycle;

  showpoints(1,2,3,4,5,6,11,12,13,14,15,16,21,23,24,31,32);
adjust(v_a*fitbasis.lc#-.25r_w*width#,v_a*fitbasis.lc#);
show_character; endchar;

% This character is based on 2 "f" and an "i"; the width is 
% determined by 2 "n" widths plus the width of the single "f" minus two stems. 
% It's a combination of the "ff" and "fi" ligatures
% Placement of the curved arm on first and second "f" slightly altered
% No setting for fixed pitch


iff OK "f":  "The ffl ligature";  
  beginchar(15,(2n_w+.2r_w-stem.lc#/(width#+mono#))*width#,ascender#,0);

  bot lft z4l=(round (.2r_w*width),0);  multpos(1,4,11,14,21,24)(stem.lc,0);
  bot lft z14l=(round (x4l+n_w*width-stem.lc),0); 
  bot lft z24l=(round (x14l+n_w*width-stem.lc),0);
  top z1l=(x4l,h)//;
  top z11l=(x14l,h)//;
  top z21l=(x24l,.98h)//;
  onaline(1l,4l)(2l,3l);       y2l=max(xheight,.75xheight+(r_arch*(h-xheight)));
  onaline(1r,4r)(2r,3r);       y2r=max(xheight,.75xheight+(l_arch*(h-xheight)));
  onaline(11l,14l)(12l,13l);   y12l=y2l; y12r=y2r;
  onaline(11r,14r)(12r,13r);   y3l=y3r=y13l=y13r=y23l=y23r=x_bracket_h;
  onaline(21l,24l)(23l); 
  onaline(21r,24r)(23r);
  rt z16=(x24,.99h)//;   
  rt z6=(x14l,y5r-y15r+y16)//;                  
  top y15r=bot y15l+minor_curve.lc=round(.5[h+ov_t.lc,maxheight]); 
  top y5r=inlimit(.9[xheight,h+ov_t.lc])(xheight+2minor_curve.lc,h+ov_t.lc);
  bot y5l+minor_curve.lc=top y5r;
  good_x_for(5r)(z3l,z6,.5)a;  
  good_x_for(5l)(z3r,z6-(bulb_thickness,0),.5)b;
  good_x_for(15r)(z13l,z16,.5)c;
  good_x_for(15l)(z13r,z16-(bulb_thickness,0),.5)d;

  top rt z31r=(x24,xheight)//;  multpos(31,32)(max(1,.8thin_stem.lc),90);
  lft z32r=(0,y31r)//; 
  z33=.5[z31r,z32r];

  min_limit(join_radius)(.5*min(.8thin_stem.lc,serif_thickness));
  p1=fullserif(z4,z1,z3l,z3r,.5hs,.5hs)--z2r{upward} i_t
     bulb.tr(z6,z5l,z5r,.75cs,bulb_thickness,90) o_t z2l{downward}--cycle;
  p2=fullserif(z14,z11,z13l,z13r,.5hs,.5hs)--z12r{upward} i_t
     bulb.tr(z21r,z15l,z15r,.75cs,bulb_thickness,90)soft o_t z12l{downward}--
     cycle;
  p3=fullserif(z24,z21,z23l,z23r,.5hs,.75hs)--z21r--z21l--cycle;
  p4=(z33 soften(z31r,z31l,z32l,z32r) z33)--cycle;

  showpoints(1,2,3,4,5,6,11,12,13,14,15,16,21,22,23,24,31,32,33);
adjust(v_a*fitbasis.lc#-.25r_w*width#,v_a*fitbasis.lc#);
show_character; endchar;

% This character is based on 2 "f" and an "l"; the width is 
% determined by 2 "n" widths plus the width of the single "f" minus two stems. 
% It's a combination of the "ff" and "fl" ligatures
% Placement of the curved arm on first and second "f" slightly altered
% No setting for fixed pitch

fi %*****closing for case if monopitch
