%
% Washington Romanized Indic accent driver
%
% Macros to draw italic ligature characters
%

cmchar "The italic ligature ae";
newchar(ae,13u#,x_height#,0);
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#);
adjust_fit(if monospace:-u#,-u# else: 0,0 fi); pickup fine.nib;
forsuffixes $=hair,stem: shaved$:=mfudged$; save $; $=shaved$; endfor
numeric heavy_hair; heavy_hair=hround .2[hair,stem];
numeric light_stem; light_stem=hround .75[hair,stem];
pos0(vair,-90); pos1(heavy_hair,0); pos2(vair,90);
pos3(light_stem,180); pos4(vair,270); pos5(hair,320);
x0=rt x3l; rt x1r=hround(w-1.5u+.5heavy_hair); x2=x4=.5(w+6u);
lft x3r=hround(.5w-.5light_stem); x5r=good.x(w-.5u); x6=x5;
y0=y3=y6=bar_height; y1=.5[y0,y2]; top y2r=h+oo; bot y4r=-oo;
top y5l=vround(.5bar_height+.5); path p; p=z4{right}..z5..z6;
filldraw stroke z0e{right}...z1e{up}...pulled_arc.e(2,3)
 & pulled_arc.e(3,4)...{direction 1 of p}z5e;  % arc of e
pos7(light_stem,0); pos8(light_stem,0);
x7=x8=x3; y7+.5light_stem=h+oo; y8-.5light_stem=-oo;
pos7'(vair,-225); pos11(curve,-180); z7'=z7;
pos12(vair,-90); pos3'(hair,0); z3'=z3;
lft x11r=hround(1.5u-.5curve); x12=.5[x11,x3];
y11=.3[y12,y7]; bot y12r=-oo;
filldraw stroke z7'e{3(x11-x7),y11-y7}...pulled_arc.e(11,12)
 & pulled_arc.e(12,3');  %  bowl of a
filldraw z7l---z8l..z8r---z7r..cycle;  % stem
pairequate(tca,z7);  %top center accentpoint
pairequate(lca,z8);  %low center accentpoint
pairequate(tra,z2); %top right accentpoint
pairassign(tla,x12,y7); %top left accentpoint
pairequate(lla,z12); %low left accentpoint
pairequate(lra,z4); %low right accentpoint
penlabels(0,1,2,3,4,5,6,7,8,11,12); endchar;

cmchar "The italic ligature oe";
newchar(oe,13u#,x_height#,0);
italcorr max(1/3x_height#*slant,x_height#*slant+.5(.2[hair#,stem#])-u#);
adjust_fit(if monospace:-u#,-u# else: 0,0 fi); pickup fine.nib;
forsuffixes $=hair,stem: shaved$:=mfudged$; save $; $=shaved$; endfor
numeric heavy_hair; heavy_hair=hround .2[hair,stem];
pos0(vair,-90); pos1(heavy_hair,0); pos2(vair,90);
pos3(stem,180); pos4(vair,270); pos5(hair,320);
x0=rt x3l; rt x1r=hround(w-1.5u+.5heavy_hair); x2=x4=.5(w+6u);
lft x3r=hround(.5w-.5stem); x5r=good.x(w-.5u); x6=x5;
y0=y3=y6=bar_height; y1=.5[y0,y2]; top y2r=h+oo; bot y4r=-oo;
top y5l=vround(.5bar_height+.5); path p; p=z4{right}..z5..z6;
filldraw stroke z0e{right}...z1e{up}...pulled_arc.e(2,3)
 & pulled_arc.e(3,4)...{direction 1 of p}z5e;  % arc of e
pos11(vair,90); pos12(curve,180); pos13(vair,270); pos14(stem,360);
x11=x13=.5[x12,x14]; lft x12r=hround(1.5u-.5curve); x14=x3;
top y11=h+oo; y12=y14=.5[y11,y13]; bot y13=-oo;
filldraw stroke pulled_arc.e(11,12) & pulled_arc.e(12,13)
 & pulled_arc.e(13,14) & pulled_arc.e(14,11); % bowl
pairassign(tca,x3,y2);  %top center accentpoint
pairassign(lca,x3,y4);  %low center accentpoint
pairequate(tra,z2); %top right accentpoint
pairequate(tla,z11); %top left accentpoint
pairequate(lla,z13); %low left accentpoint
pairequate(lra,z14); %low right accentpoint
penlabels(1,2,3,4,5,6,11,12,13,14); endchar;

cmchar "The ligature AE";
newchar(AE,16u#,cap_height#,0);
italcorr cap_height#*slant-beak_jut#-.5u#;
adjust_fit(cap_serif_fit#,0);
numeric left_stem,mid_stem,outer_jut,alpha;
mid_stem=max(tiny.breadth,hround .9[mfudged.hair,mfudged.cap_stem]);
pickup tiny.nib; pos1(mid_stem,0); pos2(mid_stem,0);
lft x1l=lft x2l=hround(if monospace or hefty:.55 else:.5 fi\\w-.75u);
top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pickup crisp.nib; pos3(slab,90); pos4(mfudged.hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-u); y4=good.y(y3l-beak)-eps;
arm(3,4,e,beak_darkness,beak_jut);  % upper arm and beak
pos5(cap_bar,-90); pos6(mfudged.hair,0); x5=x1;
top y5l=vround(if hefty:.52 else:.48 fi\\[y2,y1]+.5cap_bar);
pos0(cap_bar,90); pos7(mfudged.hair,0);
z0=z5; x6=x7; y6-y5l=y0l-y7;
if serifs and not(monospace and hefty): rt x6r=hround(w-3.65u+.5mfudged.hair);
 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
pos8(slab if not serifs:+2stem_corr fi,-90);
pos9(mfudged.hair,0); bot y8r=0; x8=x2; y9=good.y(y8l+7/6beak)+eps;
arm(8,9,h,beak_darkness,1.5beak_jut);  % lower arm and beak
left_stem=if monospace:fudged.hair else: cap_hair fi if hefty: -3stem_corr fi;
outer_jut=.8cap_jut; x11l=l+letter_fit+outer_jut+.5u; y11=0;
x12=x1l-apex_corr-if monospace:2 fi\\u; y12=h;
alpha=diag_ratio(1,.5left_stem,y12-y11,x12-x11l);
penpos11(alpha*left_stem,0); penpos12(alpha*left_stem,0);
fill diag_end(12l,11l,1,1,11r,12r)
 --diag_end(11r,12r,1,1,12l,11l)--cycle; % diagonal
y10=h-slab; z10=whatever[z11,z12];
fill z10--(x1,y10)--(x1,h)--z12--cycle;  % link
penpos13(whatever,angle(z2-z1)); z13=whatever[z11,z12];
penpos14(cap_band,90); x14=x0; y13l=y14l; y13r=y14r;
if hefty: y14r=.4h; else: y14=y0; fi
penstroke z13e--z14e; % bar line
if serifs: numeric inner_jut; pickup tiny.nib;
 prime_points_inside(11,12);
 if rt x11'r+cap_jut+.5u+1<=lft x2l-.75cap_jut: inner_jut=cap_jut;
 else: rt x11'r+inner_jut+.5u+1=lft x2l-.75inner_jut; fi
 dish_serif(11',12,i,1/2,outer_jut,j,.6,inner_jut)(dark);  % lower left serif
 nodish_serif(1,2,a,1/3,cap_jut+x1l-x12,b,1/3,.5cap_jut);  % upper serif
 nodish_serif(2,1,c,1/3,.75inner_jut,d,1/3,.5cap_jut); fi  % lower middle serif
pairequate(tca,z3);  %top center accentpoint
pairequate(lca,z8);  %low center accentpoint
pairassign(tra,x.e2,y3); %top right accentpoint
pairequate(tla,z12); %top left accentpoint
pairequate(lla,z11); %low left accentpoint
pairassign(lra,x.h2,y2); %low right accentpoint
penlabels(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14); endchar;

cmchar "The ligature OE";
newchar(OE,18u#,cap_height#,0);
italcorr cap_height#*slant-beak_jut#-.5u#;
adjust_fit(cap_serif_fit#,0);
numeric light_stem;
light_stem=max(tiny.breadth,hround .8[mfudged.hair,mfudged.cap_stem]);
pickup tiny.nib; pos1(light_stem,0); pos2(light_stem,0);
lft x1l=lft x2l=hround .5w; top y1=h; bot y2=0;
filldraw stroke z1e--z2e; % stem
pickup crisp.nib; pos3(slab,90); pos4(mfudged.hair,0);
top y3r=h; x3=x1; rt x4r=hround(w-u); y4=good.y(y3l-beak)-eps;
arm(3,4,e,beak_darkness,beak_jut);  % upper arm and beak
pos5(cap_bar,-90); pos6(mfudged.hair,0);
top y5l=vround(.52[y2,y1]+.5cap_bar); x5=x1;
pos0(cap_bar,90); pos7(mfudged.hair,0);
z0=z5; x6=x7; y6-y5l=y0l-y7;
if serifs and not(monospace and hefty): rt x6r=hround(w-3.4u+.5mfudged.hair);
 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
pos8(slab if not serifs:+2stem_corr fi,-90);
pos9(mfudged.hair,0); bot y8r=0; x8=x2; y9=good.y(y8l+7/6beak)+eps;
arm(8,9,h,beak_darkness,1.5beak_jut);  % lower arm and beak
penpos11(vair,90); penpos13(vair,-90);
if monospace: penpos12(fudged.cap_stem,180);
 interim superness:=sqrt superness;  % make |"O"|, not |"0"|
else: penpos12(hround(cap_curve-stem_corr),180); fi
x11=x13=.5w-2u; y11r=h+o; y13r=-o; y12=.5h-vair_corr; x12r=hround u;
x14=x15=.5w; y14=2/3h; y15=1/3h; y12l:=.52h;
penstroke super_arc.e(11,12) & super_arc.e(12,13);  % left half of bowl
fill z13r{right}..{right}(x2,0)--(x1,h){left}..{left}z11r
 --z11l{right}...{z14-z11l}(.82[x11l,x14],.82[y14,y11l])
 ...z14---z15...{z13l-z15}(.82[x13l,x15],.82[y15,y13l])
 ...{left}z13l--cycle;  % right half of bowl
if serifs: serif(1,2,a,1/3,.5cap_jut);  % upper serif
 serif(2,1,b,1/3,.5cap_jut); fi  % lower serif
pairequate(tca,z3);  %top center accentpoint
pairequate(lca,z8);  %low center accentpoint
pairassign(tra,x.e2,y3); %top right accentpoint
pairequate(tla,z1); %top left accentpoint
pairequate(lla,z13); %low left accentpoint
pairassign(lra,x.h2,y2); %low right accentpoint
penlabels(0,1,2,3,4,5,6,7,8,9,11,12,13,14,15); endchar;

% end of file ligaturi.mf

