% This file describes five roman ligatures that begin with `f'
% and puts them in code positions \0013--\0017.

numeric itc#; % modified italic correction on `f' and `ff'
itc#=if serifs: max(0,flare#-.25u#) else: 1.25u# fi;

ligtable "f": "i"=:oct"014", "f"=:oct"013", "l"=:oct"015",
 "'" kern itc#, "?" kern itc#, "!" kern itc#, ")" kern itc#, "]" kern itc#;
ligtable oct"013": "i"=:oct"016", "l"=:oct"017",
 "'" kern itc#, "?" kern itc#, "!" kern itc#, ")" kern itc#, "]" kern itc#;

cmchar "The ligature ff";
beginchar(oct"013",10.5u#+2letter←fit#,asc←height#,0);
italcorr asc←height#*slant+if serifs:flare#-.25u# else: 1.25u# fi;
adjust←fit(0,0);
pickup tiny.nib; pos1(stem',0); lft x1l=hround(2.5u-.5stem');
pos11(stem',0); rt x11r=hround(w-3u+.5stem');
pickup fine.nib; numeric bulb←diam, inner←jut;
if serifs: bulb←diam=hround .8[stem,flare];
 pos2(bulb←diam,0); pos12(bulb←diam,0);
 rt x2r=hround(rt x11r-stem←corr); lft x12l=hround(w-.75u+.5);
 y2+.5bulb←diam=.85[x←height,h+oo]; y12+.5bulb←diam=.9[x←height,h+oo];
 if rt x1r+jut+.5u+2<=lft x11l-jut: inner←jut=jut;
 else: rt x1r+inner←jut+.5u+2=lft x11l-inner←jut; fi
else: pos2(5/7[vair,flare],90); top y2r=h; rt x2=hround 6.25u;
 pos12(5/7[vair,flare],90); y12=y2; rt x12=hround(w+.75u); fi
f←stroke(1,2,a,b,c,jut,inner←jut); % left stem, arc, terminal, serif
f←stroke(11,12,d,e,f,inner←jut,1.25jut); % right stem, arc, terminal, serif
pickup crisp.nib; top y3r=top y4r=x←height; lft x3=hround .5u-1;
pos3(bar,90); pos4(bar,90);
rt x4=hround(w-1/3u);
if hefty: pos3'(bar,90); x3'-x1=x4-x11; y3'=y3;
 pos4'(bar,90); x4'=x11; y4'=y4;
 filldraw stroke z3e--z3'e; filldraw stroke z4'e--z4e;  % bars
else: filldraw stroke z3e--z4e; fi  % bar
penlabels(1,2,3,4,11,12); endchar;

cmchar "The ligature fi";
beginchar(oct"014",10u#+2letter←fit#,asc←height#,0);
italcorr asc←height#*slant-serif←fit#+.5if serifs:stem# else:dot←size# fi-2u#;
adjust←fit(0,serif←fit#);
pickup tiny.nib; pos1(stem',0); lft x1l=hround(2.5u-.5stem');
pos11(stem',0); rt x11r=hround(w-2.5u+.5stem');
pos12(stem',0); x11=x12; bot y12=0;
pickup fine.nib; numeric bulb←diam, inner←jut;
if serifs: bulb←diam=hround 1/4[.8[stem,flare],dot←size];
 pos2(bulb←diam,0); x2r=x12r;
 y2+.5bulb←diam=.8[x←height,h+oo]; top y11=x←height+min(oo,serif←drop);
 if rt x1r+jut+.5u+2<=lft x11l-jut: inner←jut=jut;
 else: rt x1r+inner←jut+.5u+2=lft x11l-inner←jut; fi
else: bulb←diam=max(stem,dot←size);
 pos2(6/7[vair,flare],90); top y2r=h; rt x2=hround 5.3u;
 pickup tiny.nib; pos13(bulb←diam,0); pos14(bulb←diam,90);
 x13=x11-.5; top y14r=min(2x←height,h+1); top y11=x←height;
 if bot y14l-x←height<tiny: y14l:=min(y14r-eps,y11+2tiny); fi
 x13=x14; y13=.5[y14l,y14r]; dot(13,14);  % dot
fi;  % this is the ligature we're drawing
f←stroke(1,2,a,b,c,jut,inner←jut); % left stem, arc, terminal, serif
pickup tiny.nib; filldraw stroke z11e--z12e;  % right stem
pickup crisp.nib; top y3r=top y4r=x←height; lft x3=hround .5u-1;
pos3(bar,90); pos4(bar,90);
if serifs: x4=x11;  % bar will overlap upper right serif
 sloped←serif.l(11,12,d,1/3,jut,min(oo,serif←drop));  % upper right serif
 dish←serif(12,11,e,1/3,inner←jut,f,1/3,jut);  % lower right serif
else: rt x4= hround 5.3u; fi
pickup crisp.nib; filldraw stroke z3e--z4e;  % bar
penlabels(1,2,3,4,11,12,13,14); endchar;

cmchar "The ligature fl";
beginchar(oct"015",10u#+2letter←fit#,asc←height#,0);
italcorr asc←height#*slant-serif←fit#+.5stem#-2u#;
adjust←fit(0,serif←fit#);
pickup tiny.nib; pos1(stem',0); lft x1l=hround(2.5u-.5stem');
pos11(stem',0); rt x11r=hround(w-2.5u+.5stem');
pos12(stem',0); x11=x12; bot y12=0; top y11=h;
filldraw stroke z11e--z12e;  % right stem
pickup fine.nib; numeric bulb←diam, inner←jut;
if serifs: bulb←diam=hround .8[stem,flare];
 pos2(bulb←diam,0); x2r=x11r-stem←corr;
 y2+.5bulb←diam=.9[x←height,h+oo];
 sloped←serif.l(11,12,d,1/3,eps,max(serif←drop,oo)); % erase excess at top
 if rt x1r+jut+.5u+2<=lft x11l-jut: inner←jut=jut;
 else: rt x1r+inner←jut+.5u+2=lft x11l-inner←jut; fi
else: pos2(5/7[vair,flare],90); top y2r=h; rt x2=hround 5.3u; fi
f←stroke(1,2,a,b,c,jut,inner←jut); % left stem, arc, terminal, serif
pickup crisp.nib; top y3r=top y4r=x←height; lft x3=hround .5u-1;
pos3(bar,90); pos4(bar,90);
if serifs: x4=x11;
 dish←serif(12,11,e,1/3,inner←jut,f,1/3,jut);  % lower right serif
else: rt x4= hround 5.3u; fi
pickup crisp.nib; filldraw stroke z3e--z4e;  % bar
penlabels(1,2,3,4,11,12); endchar;

cmchar "The ligature ffi";
beginchar(oct"016",15u#+4letter←fit#,asc←height#,0);
italcorr asc←height#*slant-serif←fit#+.5if serifs:stem# else:dot←size# fi-2u#;
adjust←fit(0,serif←fit#);
pickup tiny.nib; pos1(stem',0); lft x1l=hround(2.5u-.5stem');
pos11(stem',0); lft x11l=hround(.5w-.5stem');
pos21(stem',0); rt x21r=hround(w-2.5u+.5stem');
pos22(stem',0); x21=x22; bot y22=0;
pickup fine.nib; numeric bulb←diam, inner←jut;
if serifs: bulb←diam=hround 1/4[.8[stem,flare],dot←size];
 pos2(bulb←diam,0); x2r=x11r-stem←corr;
 pos12(bulb←diam,0); x12r=x21r;
 top y21=x←height+min(oo,serif←drop);
 y2+.5bulb←diam=.8[x←height,h+oo]; y12=y2;
 if rt x1r+jut+.5u+2<=lft x11l-jut: inner←jut=jut;
 else: rt x1r+inner←jut+.5u+2=lft x11l-inner←jut; fi
else: bulb←diam=max(stem,dot←size);
 pos2(5/7[vair,flare],90); top y2r=h; rt x2=hround 5.75u;
 pos12(6/7[vair,flare],90); y12=y2; rt x12=hround(.5w+2.8u);
 pickup tiny.nib; pos23(bulb←diam,0); pos24(bulb←diam,90);
 x23=x21-.5; top y24r=min(2x←height,h+1); top y21=x←height;
 if bot y24l-x←height<tiny: y24l:=min(y24r-eps,y21+2tiny); fi
 x23=x24; y23=.5[y24l,y24r]; dot(23,24); fi  % dot
f←stroke(1,2,a,b,c,jut,inner←jut); % left stem, arc, terminal, serif
f←stroke(11,12,d,e,f,inner←jut,inner←jut); % middle ditto
pickup tiny.nib; filldraw stroke z21e--z22e;  % right stem
pickup crisp.nib; top y3r=top y4r=x←height; lft x3=hround.5u-1;
pos3(bar,90); pos4(bar,90);
if serifs: x4=x21;  % bar will overlap upper right serif
 sloped←serif.l(21,22,g,1/3,jut,min(oo,serif←drop));  % upper right serif
 dish←serif(22,21,h,1/3,inner←jut,i,1/3,jut);  % lower right serif
else: rt x4=hround(.5w+2.8u); fi
pickup crisp.nib;
if hefty: pos3'(bar,90); x3'-x1=x4-x11; y3'=y3;
 pos4'(bar,90); x4'=x11; y4'=y4;
 filldraw stroke z3e--z3'e; filldraw stroke z4'e--z4e;  % bars
else: filldraw stroke z3e--z4e; fi  % bar
penlabels(1,2,3,4,11,12,21,22,23,24); endchar;

cmchar "The ligature ffl";
beginchar(oct"017",15u#+4letter←fit#,asc←height#,0);
italcorr asc←height#*slant-serif←fit#+.5stem#-2u#;
adjust←fit(0,serif←fit#);
pickup tiny.nib; pos1(stem',0); lft x1l=hround(2.5u-.5stem');
pos11(stem',0); lft x11l=hround(.5w-.5stem');
pos21(stem',0); rt x21r=hround(w-2.5u+.5stem');
pos22(stem',0); x21=x22; bot y22=0; top y21=h;
filldraw stroke z21e--z22e;  % right stem
pickup fine.nib; numeric bulb←diam, inner←jut;
if serifs: bulb←diam=hround .8[stem,flare];
 pos2(bulb←diam,0); x2r=x11r-stem←corr;
 pos12(bulb←diam,0); x12r=x21r-stem←corr;
 y2+.5bulb←diam=.85[x←height,h+oo]; y12+.5bulb←diam=.9[x←height,h+oo];
 sloped←serif.l(21,22,g,1/3,eps,max(serif←drop,oo)); % erase excess at top
 if rt x1r+jut+.5u+2<=lft x11l-jut: inner←jut=jut;
 else: rt x1r+inner←jut+.5u+2=lft x11l-inner←jut; fi
else: pos2(5/7[vair,flare],90); top y2r=h; rt x2=hround 5.75u;
 pos12(5/7[vair,flare],90); y12=y2; rt x12=hround(.5w+2.8u); fi
f←stroke(1,2,a,b,c,jut,inner←jut); % left stem, arc, terminal, serif
f←stroke(11,12,d,e,f,inner←jut,inner←jut); % middle ditto
pickup crisp.nib; top y3r=top y4r=x←height; lft x3=hround.5u-1;
pos3(bar,90); pos4(bar,90);
if serifs: dish←serif(22,21,h,1/3,inner←jut,i,1/3,jut);  % lower right serif
 pickup crisp.nib; x4=x21;
else: rt x4=hround(.5w+2.8u); fi
if hefty: pos3'(bar,90); x3'-x1=x4-x11; y3'=y3;
 pos4'(bar,90); x4'=x11; y4'=y4;
 filldraw stroke z3e--z3'e; filldraw stroke z4'e--z4e;  % bars
else: filldraw stroke z3e--z4e; fi  % bar
penlabels(1,2,3,4,11,12,21,22); endchar;