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

cmchar "The ligature ae";
newchar(ae,13u#,x_height#,0);
italcorr .5[bar_height#,x_height#]*slant+.5min(curve#-1.5u#,0);
adjust_fit(0,0);
numeric left_curve,right_curve;
if monospace: right_curve=left_curve=fudged.stem;
else: left_curve=max(tiny.breadth,hround(curve-2stem_corr));
right_curve=max(tiny.breadth,hround(curve-if serifs:6 
else:8 fi\\stem_corr));fi
pickup tiny.nib; pos11(right_curve,0);
pos12(vair,90); pos13(mfudged.stem,180);
y11=good.y bar_height; top y12r=h+vround 1.5oo; y10l=bot y11;
rt x11r=hround min(w-.5u,w-u+.5right_curve);
lft x13r=hround (.5w-.5mfudged.stem); x12=.55[x13,x11];
{{interim superness:=more_super;
 filldraw stroke super_arc.e(11,12)}};  % right bowl of e
y13=.5[y12,y14]; bot y14r=-oo; x14=x12+.25u;
if serifs: pos14(vair',270); pos15(mfudged.hair,360);
 y15=max(good.y(.5bar_height-.9),y14l+vair); x15r=x11r;
 (x,y14l)=whatever[z14r,z15]; x14l:=min(x,x14l+.5u);
 filldraw stroke pulled_arc.e(12,13)
  & pulled_super_arc.e(13,14)(.8superpull)
  ...{x15-x14,5(y15-y14)}z15e; % left bowl, arc, and terminal of e
else: pos14(vair,270);
 filldraw stroke super_arc.e(12,13)
  & super_arc.e(13,14);  % left bowl and arc of e
 pickup fine.nib; pos14'(vair,270); z14=z14';
 pos15(.5[vair,flare],275); rt x15r=hround(w-.6u);
y15r=good.y(y15r+1/3bar_height-y15); y15l:=good.y 
 y15l; x15l:=good.x x15l;
 filldraw stroke term.e(14',15,right,1,4); fi  % right terminal
y11'r=y10r=y10l+.6[thin_join,vair]; y11'l=y10l; 
 x11'l=x11'r=x11; x10l=x10r=x13;
fill stroke z10e--z11'e;  % crossbar
pickup fine.nib; top y3r=h+vround 1.5oo;
if serifs: pos1(flare,180); pos2(mfudged.hair,180);
 pos3(vair,90);  lft x1r=hround max(u,2.1u-.5flare); x3=4u;
 y1=min(bar_height+.5flare+2vair+2,.9[bar_height,h]-.5flare);
 bulb(3,2,1);  % bulb
else: pos1(5/7[vair,flare],95); x1l=good.x 1.5u; x1r:=good.x x1r;
 pos3(1/8[vair,thin_join],90);
 x3=4.3u; top y1r=vround .82[bar_height,top y3r];
 filldraw stroke term.e(3,1,left,.9,4); fi  % left terminal
pos4(mfudged.stem,0); x4=x13; y4=1/3[bar_height,h];
pos5(mfudged.stem,0); x5=x4; y5=min(y4,y13);
filldraw stroke super_arc.e(3,4)&z4e--z5e;  % arc and stem
pos6(.6[thin_join,vair],90); x6=x4; bot y6=y10l;
pos7(left_curve,180);
lft x7r=hround max(.5u,1.5u-.5left_curve); 
y7=1/3[top y8l,top y6r];
pos8(vair,270); x8l=3.75u; bot y8r=-oo;
pos9(.5[vair,fudged.stem],360); x9=x5; y9=.55bar_height;
(x',y8r)=whatever[z8l,z9l]; x8r:=max(x',x8-u);
{{interim superness:=more_super;
 filldraw stroke z9e{down}...z8e{left}...{up}z7e&super_arc.e(7,6)}}; % bowl
if y9<y5: 
filldraw stroke z5e{down}..{down}z9e; 
fi  % link (usually hidden)
pairassign(tca,x4,y3);  %top center accentpoint
pairassign(lca,x4,y8);  %low center accentpoint
pairequate(tra,z12); %top right accentpoint
pairequate(tla,z3); %top left accentpoint
pairequate(lla,z8); %low left accentpoint
pairequate(lra,z14); %low right accentpoint
penlabels(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); 
endchar;

cmchar "The ligature oe";
newchar(oe,14u#,x_height#,0);
italcorr .5[bar_height#,x_height#]*slant+.5min(curve#-1.5u#,0);
adjust_fit(0,0);
numeric left_curve,right_curve;
if monospace: right_curve=left_curve=fudged.stem;
else: left_curve=max(fine.breadth,hround(curve-2stem_corr));
 right_curve=max(tiny.breadth,hround(curve-if serifs:6 else:8 fi\\stem_corr));fi
pickup tiny.nib; pos11(right_curve,0);
pos12(vair,90); pos13(mfudged.stem,180);
y11=good.y bar_height; top y12r=h+vround 1.5oo; y10l=bot y11;
rt x11r=hround min(w-.5u,w-u+.5right_curve);
lft x13r=hround (.5(w+u)-.5mfudged.stem); x12=.55[x13,x11];
{{interim superness:=more_super;
 filldraw stroke super_arc.e(11,12)}};  % right bowl of e
y13=.5[y12,y14]; bot y14r=-oo; x14=x12+.25u;
if serifs: pos14(vair',270); pos15(mfudged.hair,360);
 y15=max(good.y(.5bar_height-.9),y14l+vair); x15r=x11r;
 (x,y14l)=whatever[z14r,z15]; x14l:=min(x,x14l+.5u);
 filldraw stroke pulled_arc.e(12,13)
  & pulled_super_arc.e(13,14)(.8superpull)
  ...{x15-x14,5(y15-y14)}z15e; % left bowl, arc, and terminal of e
else: pos14(vair,270);
 filldraw stroke super_arc.e(12,13)
  & super_arc.e(13,14);  % left bowl and arc of e
 pickup fine.nib; pos14'(vair,270); z14=z14';
 pos15(.5[vair,flare],275); rt x15r=hround(w-.6u);
 y15r=good.y(y15r+1/3bar_height-y15); y15l:=good.y y15l; x15l:=good.x x15l;
 filldraw stroke term.e(14',15,right,1,4); fi  % terminal
y11'r=y10r=y10l+.6[thin_join,vair]; y11'l=y10l; x11'l=x11'r=x11; x10l=x10r=x13;
fill stroke z10e--z11'e;  % crossbar
pickup fine.nib; pos1(vair,90); pos3(vair,-90);
pos2(left_curve,180); pos4(mfudged.stem,0);
lft x2r=hround max(.5u,1.25u-.5curve);
z4=z13; x1=x3=.5[x2,x4]; top y1r=h+vround 1.5oo; bot y3r=-oo;
y2=y4; y2l:=y4l:=.52h;
filldraw stroke pulled_arc.e(1,2) & pulled_arc.e(2,3); % left half of left bowl
filldraw stroke pulled_arc.e(3,4) & pulled_arc.e(4,1); % right half of left bowl
pairassign(tca,x4,y1);  %top center accentpoint
pairassign(lca,x4,y3);  %low center accentpoint
pairequate(tra,z12); %top right accentpoint
pairequate(tla,z1); %top left accentpoint
pairequate(lla,z3); %low left accentpoint
pairequate(lra,z14); %low right accentpoint
penlabels(1,2,3,4,10,11,12,13,14,15); 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 ligature.mf


