%% This file is public domain.
%% Originally written 1998, Ivan A Derzhanski.
%% Notice added by Clea F. Rees 2009/01/06.
%% 
% eiru.mf: Irish upper case (majuscules)

def cap_h_stroke(suffix $,@,@@,$$) =
 penpos$$(x@@r-x@@l,0); x$$=x@@; bot y$$=0;
 y@@=1/3[x_height,cap_height];
 penpos$''(x$r-x$l,0); x$''=x$; y$''=x_height;
 filldraw stroke z$''e--z$e;  % thicken the lower left stem
 penpos@0(min(rt x$r-lft x$l,thin_join)-fine,180); pickup fine.nib;
 rt x@0l=tiny.rt x$r; y@0=y$'';
 pos@1(vair,90); pos@@'(x@@r-x@@l+tiny,0); z@@'=z@@;
 x@1=.5[rt x@0l,rt x@@'r]; top y@1r=cap_height+oo;
 (x@,y@1l)=whatever[z@1r,z@0l]; x@1l:=x@;
 filldraw stroke z@0e{x@1-x@0,1.5(y@1-y@0)}...{right}z@1e
  &{{interim superness:=hein_super; super_arc.e(@1,@@')}};  % arch
 pickup tiny.nib; filldraw stroke z@@e--z$$e;  % right stem
 labels(@0); penlabels(@1); enddef;

def saillipse_set(suffix $,@,@@,$$) =
 alpha_:=slope*(x@-x$); beta_:=y$$-y$-slope*(x$$-x$);
 gamma_:=alpha_/beta_;
 x@@-x$=-2gamma_*(x@-x$)/(1+gamma_*gamma_);
 y@@-y$$=slope*(x@@-x$$) enddef;

def gen_letter =
adjust_fit(cap_serif_fit#-2stem_shift# if monospace:-.5u# fi,
  cap_serif_fit#-2stem_shift# if monospace:-.5u# fi);
numeric left_stem,right_stem,outer_jut,alpha,beta;
right_stem=cap_curve-stem_corr;
left_stem=min(cap_hair if hefty: -3stem_corr fi,right_stem);
outer_jut=.8cap_jut; x1l=w-x4r=l+letter_fit+.5u; y4=0;
y1=.1x_height;
x2-x1=x4-x3+2.5u; x3r=x2r+apex_corr; y2=y3=cap_height+apex_o+apex_oo;
alpha=diag_ratio(2,left_stem,y2-y1,x4r-x1l-apex_corr);
penpos1(alpha*left_stem,0); penpos2(alpha*left_stem,0);
penpos3(alpha*right_stem,0); penpos4(alpha*left_stem,0);
z0=whatever[z1r,z2r]=whatever[z3l,z4l];
if y0<cap_height-cap_notch_cut: y0:=cap_height-cap_notch_cut;
 fill z0+.5right{z4l-z3l}...{z4-z3}diag_end(3l,4l,1,1,4r,3r)
  --diag_end(4r,3r,1,1,2l,1l)--diag_end(2l,1l,1,1,1r,2r){z2-z1}
  ...{up}z0+.5left--cycle; % left and right diagonals
else: fill z0{z4r-z3r}..diag_end(0,4l,1,1,4r,3r)--diag_end(4r,3r,1,1,2l,1l)
  --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
beta=angle(z1-z2);
penpos5(cap_stem,beta); z5=whatever[z1,z2];
penpos6(cap_band,angle(z4-z3)); z6=whatever[z3,z4];
y5=.4[y1,y0]; y6=.4[y4,y0];
penpos7(cap_stem,beta); x7r=.5(w-u); bot y7r=-oo;
filldraw stroke z5e{z7r-z5l} ... z7e .. {z6l-z7r}z6e;
penlabels(0,1,2,3,4,5,6,7); enddef;

guta_mowr ("Ailm", 14u#, 2);

def gen_letter =
italcorr .7cap_height#*slant+.5curve#-u#;
adjust_fit(cap_serif_fit#,0); pickup tiny.nib;
pos1(cap_stem,0); pos2(cap_stem,0); x1=x2;
lft x1l=hround 2.5u-.5cap_stem;
top y1=h; y2=bar_height; y4=.5cap_height;
filldraw stroke z1e--z2e;  % stem
if serifs: trasnawn(1,a,cap_jut); fi  % serif
pickup fine.nib; pos2'(cap_stem,-180); pos3(vair,-90);
pos4(cap_curve,0); pos5(vair,90); pos0(hair,180);
z0=z2=z2'; x3=x5-.5u=.5[x2,x4]; rt x4r=hround min(w-1.35u+.5curve,w-.6u);
bot y3r=-oo; top y5r=cap_height+oo;
filldraw stroke pulled_arc.e(2',3) & pulled_arc.e(3,4)
 & pulled_arc.e(4,5) & super_arc.e(5,0);  % bowl
penlabels(0,1,2,3,4,5); enddef;

cmchar "Beith";
beginchar("B",12.5u#,cap_asc_height#,0); gen_letter; endchar;

cmchar "Beith-h";
beginchar(Beith_h,12.5u#,cap_asc_height#,0);
gen_letter; aspirate(5); endchar;

def gen_letter =
italcorr cap_height#*slant-.5u#;
adjust_fit(0,0); pickup fine.nib;
pos3(cap_curve,180); y3=.5cap_height;
if serifs:
 pos1(1.2flare,40); pos2(vair',90);
 pos4(vair',270); pos5(hair,-40);
 x2=x4=.5(w+u); top y2r=vround(cap_height+1.5oo); bot y4r=-oo;
 rt x1r=hround(w-.6u); top y1r=vround .7[bar_height,top y2r];
 filldraw stroke term.e(2,1,right,.8,4);  % upper terminal
 lft x3r=hround u;
 rt x5r=hround(w-.5u);
 y5=max(good.y .95(cap_height-y1),y4l+eps);
 (x,y4l)=whatever[z4r,z5l];
 filldraw stroke pulled_super_arc.e(2,3)(.7superpull)
  & pulled_super_arc.e(3,4)(.5superpull) & term.e(4,5,right,.8,4);
else:
 pos1(1.2flare,80); pos2(slab,90);
 pos4(slab,270); pos5(flare,275);
 rt x1r=hround(w-1.1u); x2=x4=.5w+1.25u;
 lft x3r=hround max(u,2u-.5cap_curve); rt x5r=hround(w-.9u);
 top y1r=vround .95cap_height+o; top y2r=cap_height+o; bot y4r=-o;
 bot y5r=vround .08cap_height-o; y5l:=good.y y5l; x5l:=good.x x5l;
 filldraw stroke rterm.e(2,1,right,.9,4) & super_arc.e(2,3)
  & super_arc.e(3,4) & term.e(4,5,right,.8,4); fi % arc and terminals
penlabels(1,2,3,4,5); enddef;

consan_mowr ("Coll", 11.5u#, 0, 4);

def gen_letter =
italcorr cap_height#*slant+.5cap_stem#-u#;
adjust_fit(0,0); pickup fine.nib;
pos1(vair,90); pos2(cap_curve,0); pos3(vair,-90); pos4(cap_curve,-180);
x1=x3=.5[x2,x4]; w-rt x2r=hround if monospace: 1.5u else: u fi;
lft x4r=hround 2.5u;
y1r=cap_height+o; y2=y4=.5[y1,y3]; y3r=-o;
filldraw circ_stroke pulled_arc.e(1,4) & pulled_arc.e(4,3)
 & pulled_arc.e(3,2) & pulled_arc.e(2,1);  % bowl
if serifs: pos8(hair,210); lft x8r=hround u; y8=cap_height+apex_o;
 path arc; arc=z1l{left}..{z8-z2}z8r;
 pos9(slab,-60); lft x9l=.5u; y9r=.8cap_height;
 filldraw z8r{down}..z9l--z9r{z1-z9}..subpath(.4,0) of arc
   --z1r{left}..{z8-z2}z8l--cycle;  % lower barb
else: pos6(cap_vstem,80); x6=.5u; top y6r=top y1r+oo;
 filldraw stroke z6e{z2l-z6r} .. {right}z1e; fi  % ear
penlabels(1,2,3,4,6,8,9); enddef;

consan_mowr ("Dair", 14u#, 0, 1);

def gen_letter =
italcorr .5[x_height#,cap_height#]*slant+.5min(cap_curve#-1.5u#,0);
adjust_fit(0,0);
numeric left_curve,right_curve;
left_curve=right_curve+6stem_corr=cap_curve if not serifs: -3stem_corr fi;
if right_curve<tiny.breadth: right_curve:=tiny.breadth; fi
if left_curve<tiny.breadth: left_curve:=tiny.breadth; fi
pickup fine.nib; pos1(right_curve,0);
pos2(vair,90); pos3(left_curve,180);
y1=vround .52cap_height;
top y2r=cap_height+vround 1.5oo; y0l=bot y1l;
lft x3r=hround hround u;
rt x1r=hround min(w-1.5u,w-2u+.5right_curve); x2=.5[x3l,x1l];
{{interim superness:=more_super;
 filldraw stroke super_arc.e(1,2)}};  % right bowl
y3=.5[y2,y4]; bot y4r=-oo;
if serifs: pos4(vair',270); pos5(hair,360); x4=x2;
 y5=max(good.y(.26cap_height-.9),y4l+vair); x5r=x1r;
 (x,y4l)=whatever[z4r,z5]; x4l:=min(x,x4l+.5u);
 filldraw stroke pulled_arc.e(2,3) & pulled_arc.e(3,4)
  ...{x5-x4,5(y5-y4)}z5e; % left bowl, arc, and terminal
else: pos4(slab,270); x4=.5w+.5u;
 filldraw stroke super_arc.e(2,3) & super_arc.e(3,4);  % left bowl and arc
 pos5(flare,275); rt x5r=hround(w-1.6u);
 bot y5r=vround .08cap_height-o;
 filldraw stroke term.e(4,5,right,1,4); fi  % terminal
path testpath; testpath=super_arc.r(2,3) & super_arc.r(3,4);
y1'r=y0r=y0l+cap_bar; y1'l=y0l; x1'l=x1'r=w-.5u;
forsuffixes $=l,r:
 x0$=xpart(((0,y0$)--(x1,y0$)) intersectionpoint testpath); endfor
fill stroke z0e--z1'e;  % crossbar
penlabels(0,1,1',2,3,4,5); enddef;

guta_mowr ("Eabhadh", 12u#, 2);

def gen_letter =
italcorr cap_height#*slant if not serifs:+.25u# fi;
adjust_fit(cap_serif_fit#,0);
numeric arm_thickness; arm_thickness=hround .9[vair,.85cap_stem];
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
numeric shaved_stem; shaved_stem=hround(cap_stem-2stem_corr);
pos1'(shaved_stem,0); pos2'(shaved_stem,0); pos3(1.2flare,40);
lft x1l=hround(2.5u-.5cap_stem); x1l=x1'l=x2l=x2'l; rt x3r=hround(w-1.1u);
top y1=cap_height+min(oo,serif_drop); bot y2=-d; y1=y1'; y2=y2';
filldraw stroke z1'e--z2'e;  % left stem
top y3r=vround .3[x_height,cap_height];
penpos2''(x2r-x2l,0); x2''=x2; y2''=x_height;
filldraw stroke z2''e--z2e;  % thicken the lower left stem
penpos.a0(min(rt x2r-lft x2l,thin_join)-fine,180); pickup fine.nib;
rt x.a0l=tiny.rt x2r; y.a0=y2'';
pos.a1(vair,90); pos3'(1.2flare+tiny,40); z3'=z3;
x.a1=.5[rt x.a0l,rt x3'r]; top y.a1r=cap_height+oo;
(x.a,y.a1l)=whatever[z.a1r,z.a0l]; x.a1l:=x.a;
filldraw stroke z.a0e{x.a1-x.a0,1.5(y.a1-y.a0)}...{right}z.a1e
  &{{interim superness:=hein_super; super_arc.e(a1,3')}};  % arch
if serifs: trasnawn(1',b,cap_jut); fi %  upper left serif
pickup crisp.nib; pos13(arm_thickness,90); pos14(arm_thickness,90);
bot y13l=bot y14l=.25x_height; lft x13=x1;
rt x14=x3l; filldraw stroke z13e--z14e;  % bar
labels(a0); penlabels(a1,1,2,3,4,13,14); enddef;

consan_mowr ("Fearn", 13u#+.5width_adj#, desc_depth#, a1);

def gen_letter =
italcorr cap_height#*slant+.25u#;
adjust_fit(0,0);
numeric arm_thickness; arm_thickness=hround .9[vair,.85cap_stem];
numeric s_slab; s_slab=if serifs:slab else:vround .2[slab,cap_stem] fi;
numeric ess'; ess'=max(fine.breadth,cap_ess);
pickup crisp.nib; pos17(arm_thickness,90); pos18(arm_thickness,90);
top y17r=top y18r=cap_height; rt x17=hround(w-.8u); lft x18r=hround .9u;
filldraw stroke z17e--z18e;
numeric theta; theta=90-angle(50u,cap_height);
slope:=-cap_height/50u;  % angle at middle
pickup fine.nib;
pos0(ess',theta); pos7(s_slab,-90);
2x0=w; x7-.5w=if serifs: u else: 0 fi; bot y7r=-d-o;
pos2(max(fine.breadth,s_slab-vround vair_corr),-90); z2=(x17-u,y17);
y0=.5[y7l,y12r];
lft x3l=hround 2.5u; rt x6r=hround(w-1.4u);
x3r-x3l=x6r-x6l=hround .5[s_slab,ess']-fine;
pos12(s_slab,-90); z12=.5[z17l,z18l];
ellipse_set(12l,3l,4l,0l); ellipse_set(12r,3r,4r,0r); y3=y3r;
ellipse_set(7l,6l,5l,0l); ellipse_set(7r,6r,5r,0r); y6=y6r;
filldraw stroke super_arc.e(2,3) & z3e{down}
 ..z4e---z5e..z6e{down} & super_arc.e(6,7);  % main stroke
if serifs:
 pos9(slab,-70); lft x9l=hround 1.25u; bot y9r=good.y-5/6d;
 pos8(hair,180); x8=x9+1.5u; y8=apex_o;
 path arc; arc=z7r{left}....{up}z8r;
 filldraw z8r{down}..z9l--z9r...subpath(.3,0) of arc
   --z7l{left}....{up}z8l--cycle;  % barb
else: pos8(1.2flare,-100);
 lft x8r=hround 1.25u; bot y8r=good.y-5/6d;
 filldraw stroke term.e(7,8,left,1,4); fi  % arc and terminal
penlabels(0,2,3,4,5,6,7,8,9,10,12,17,18); enddef;

consan_mowr ("Gort", 13u#, desc_depth#, 12);

cmchar "Uath";
beginchar("H",13u#+.5width_adj#,cap_asc_height#,0);
italcorr .5[x_height#,cap_height#]*slant-cap_serif_fit#+.5cap_stem#-2u#;
adjust_fit(cap_serif_fit#,
  cap_serif_fit#-2stem_shift# if monospace:-.5u# fi);
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
numeric shaved_stem; shaved_stem=hround(cap_stem-2stem_corr);
pos1'(shaved_stem,0); pos2'(shaved_stem,0); pos3(cap_stem,0);
lft x1l=hround(2.5u-.5cap_stem); x1l=x1'l=x2l=x2'l; x3=w-x1;
top y1=h+min(oo,serif_drop); bot y2=0; y1=y1'; y2=y2';
filldraw stroke z1'e--z2'e;  % left stem
cap_h_stroke(2,a,3,4);  % arch and right stem
if serifs: trasnawn(1',b,cap_jut); fi %  upper left serif
penlabels(1,2,3,4); endchar;

def gen_letter =
italcorr cap_height#*slant-.25u#;
adjust_fit(cap_serif_fit#,
  cap_serif_fit#-2stem_shift# if monospace:-.5u# fi);
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
lft x1l=lft x2l=hround(.5w-.5cap_stem); top y1=cap_height; bot y2=0;
filldraw stroke z1e--z2e; % stem
if serifs: trasnawn(1,a,cap_jut); fi  % upper serif
penlabels(1,2); enddef;

guta_mowr ("Iodha", max(6u#,4u#+cap_stem#), 1);

cmchar "Luis";
beginchar("L",10u#,cap_asc_height#,0);
italcorr x_height#*slant if serifs: -.9u# else: -.4u# fi;
adjust_fit(cap_serif_fit#,if serifs: 0 else: -.5u# fi);
pickup tiny.nib; pos1(cap_stem,180); pos2(cap_stem,180);
lft x1r=lft x2r=hround max(2u,3u-.5cap_stem);
top y1=h; y2=max(.5bar_height,2vair);
filldraw stroke z1e--z2e;
pickup fine.nib; interim superness:=more_super;
pos3(cap_stem,180); z3=z2;
pos4(vair',-90); bot y4r=-o; rt x5r=hround(w-u);
if serifs: pos5(hair,0); y5=y3; x4l=.5[x3l,x5l];
 (x,y4r)=whatever[z4l,z5l]; x4r:=max(x,.5[x3r,x4]);
 filldraw stroke super_arc.e(3,4)...{up}z5e;  % stem and hook
else: pos5(vair,-75); top y5l=vround .2[top y4l,bar_height];
 x5l:=good.x x5l; x4l=1/3[x3l,x5l]; x4r:=1/3[x3r,x5r]; y3l:=y3l+.2vair;
 filldraw stroke z3e..super_arc.e(3,4);  % stem and hook
 path p; p=stroke z4e{right}..tension .9 and atleast 1..z5e;  % terminal
 if (xpart(z5l-precontrol 1 of p)<0) or (xpart(z5r-postcontrol 2 of p)<0):
  filldraw stroke z4e{right}...{up}z5e;
 else: filldraw p; fi fi;
if serifs:
 z1l=z1'r; z1r=z1'l; trasnawn(1',a,jut); fi  % upper serif
penlabels(1,2,3,4,5); endchar;

def gen_letter =
italcorr .5[x_height#,cap_height]*slant-cap_serif_fit#+.5cap_stem#-2u#;
adjust_fit(cap_serif_fit#,
  cap_serif_fit#-2stem_shift# if monospace:-.5u# fi);
numeric mfudged_stem; mfudged_stem=hround(cap_stem-stem_corr);
numeric shaved_stem; shaved_stem=hround(cap_stem-stem_corr);
pickup tiny.nib; pos1(mfudged_stem,0); pos2(mfudged_stem,0);
pos1'(shaved_stem,0); pos2'(shaved_stem,0);
pos3(mfudged_stem,0); pos5(mfudged_stem,0);
lft x1l=hround(2.5u-.5cap_stem); x1l=x1'l=x2l=x2'l;
lft x3l=hround(.5w-.5cap_stem); x5-x3=x3-x1;
%if not monospace: r:=hround(x5+x1)+l; fi  % change width for better fit
top y1=cap_height+min(oo,serif_drop); bot y2=0; y1=y1'; y2=y2';
filldraw stroke z1'e--z2'e;  % left stem
cap_h_stroke(2,a,3,4);  % left arch and middle stem
cap_h_stroke(4,b,5,6);  % right arch and right stem
if serifs: trasnawn(1',c,cap_jut); fi  % upper left serif
penlabels(1,2,3,4,5,6); enddef;

consan_mowr ("Muin", 17u#, 0, 3);

cmchar "Nuin";
beginchar("N",13u#+.5width_adj#,cap_height#,0);
italcorr .5[x_height#,cap_height#]*slant-cap_serif_fit#+.5cap_stem#-2u#;
adjust_fit(cap_serif_fit#,
  cap_serif_fit#-2stem_shift# if monospace:-.5u# fi);
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
numeric shaved_stem; shaved_stem=hround(cap_stem-2stem_corr);
pos1'(shaved_stem,0); pos2'(shaved_stem,0); pos3(cap_stem,0);
lft x1l=hround(2.5u-.5cap_stem); x1l=x1'l=x2l=x2'l; x3=w-x1;
top y1=h+min(oo,serif_drop); bot y2=0; y1=y1'; y2=y2';
filldraw stroke z1'e--z2'e;  % left stem
cap_h_stroke(2,a,3,4);  % arch and right stem
if serifs: trasnawn(1',b,cap_jut); fi %  upper left serif
penlabels(1,2,3,4); endchar;

def gen_letter =
italcorr .7cap_height#*slant-.5u#;
adjust_fit(0,0);
penpos1(vair',90); penpos3(vround(vair+1.5vair_corr),-90);
penpos2(cap_curve,180); penpos4(cap_curve,0);
if monospace: x2r=hround 1.5u;
 interim superness:=sqrt superness;  % make |"O"|, not |"0"|
else: x2r=hround u; fi
x4r=w-x2r; x1=x3=.5w; y1r=cap_height+o; y3r=-o;
y2=y4=.5cap_height-vair_corr; y2l:=y4l:=.52cap_height;
penstroke pulled_super_arc.e(1,2)(.5superpull)
 & pulled_super_arc.e(2,3)(.5superpull)
 & pulled_super_arc.e(3,4)(.5superpull)
 & pulled_super_arc.e(4,1)(.5superpull) & cycle;  % bowl
penlabels(1,2,3,4); enddef;

guta_mowr ("Oir", 13u#-width_adj#, 1);

def gen_letter =
italcorr .5cap_height#*slant+min(.5curve#-.85u#,-.1u#);
adjust_fit(cap_serif_fit#,0);
pickup tiny.nib; pos1(cap_stem',0); pos2(cap_stem,0);
pos0'(cap_stem',0); pos0(cap_stem,0); z0l=z0'l; x0'=x1;
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem'); top y1=cap_height; bot y2=-d;
numeric edge; edge=rt x2r;
pickup fine.nib; pos3(if hefty:thin_join else: hair fi,180);
pos4(vair',90); pos5(cap_curve,0); pos6(vair,-90);
rt x3l=hround max(2u,3u-.5cap_stem')+cap_stem';
y0=y3=.58cap_height;
x4l=w-.5(w-serif_fit)+.5u; top y4r=cap_height+oo;
rt x5r=hround min(w-1.35u+.5curve,w-.6u); y5=.5[y4l,y6l];
x6l=x4l+u; bot y6=-oo;
(x,y4r)=whatever[z3l,z4l]; x4r:=min(x,.5[x5r,x4]);
filldraw stroke z3e{up}...{right}z4e&super_arc.e(4,5)
 &super_arc.e(5,6)&z6e{left};  % bowl
if serifs:
 pos9(slab,-70); lft x9l=rt x3l+.8u; y9r=.05cap_height;
 pos8(hair,180); x8=x9+1.5u; top y8=vround .3cap_height-1;
 path arc; arc=z6r{left}....{up}z8r;
 filldraw z8r{down}..z9l--z9r...subpath(.3,0) of arc
   --z6l{left}....{up}z8l--cycle;  % barb
else: pos8(1.2flare,-100);
 lft x8r=rt x3l+hround .8u; bot y8r=vround .1cap_height-o;
 filldraw stroke term.e(6,8,left,1,4); fi  % arc and terminal
pickup tiny.nib;
filldraw stroke z1e--z0e--z0'e--z2e;  % stem
if serifs: trasnawn(1,a,cap_jut); fi  % upper serif
penlabels(0,1,2,3,4,5,6,8,9); enddef;

consan_mowr ("Peith_Bhog", 12.5u#+.5max(2u#,cap_curve#), desc_depth#, 4);

cmchar "Ruis";
beginchar("R",if serifs: 12u#+.5max(2u#,cap_curve#)
 else:12.5u#-.5width_adj# fi,cap_height#,0);
italcorr .75cap_height#*slant- if serifs: 1.75 else: .5 fi\\ u#;
adjust_fit(cap_serif_fit#,0);
pickup tiny.nib; pos1(cap_stem',0); pos2(cap_stem',0);
lft x1l=lft x2l=hround max(2u,3u-.5cap_stem'); top y1=h; bot y2=0;
numeric edge; edge=rt x2r;
pickup fine.nib; pos3(if hefty:thin_join else: hair fi,180);
rt x3l=max(rt x3l-(lft x3r-tiny.lft x2l), 1/3[rt x2,edge]);
y3=.7cap_height;
pos4(vair',90); pos5(cap_curve if hefty:-3stem_corr fi,0);
pos6(vair,-90);
top y4r=cap_height+oo;
if serifs: x4=.5w-.5u; x5r=hround(w-2.25u);
else: x4=.5w+.5u; x5r=hround(w-u); fi
y5=.4[y4l,y6l];
x6=x3+2.5u; y6=vround(.5h-.5vair);
(x,y4r)=whatever[z3l,z4l]; x4r:=min(x,.5[x5r,x4]);
filldraw stroke z3e{up}...{right}z4e&super_arc.e(4,5)&pulled_arc.e(5,6);
pickup tiny.nib; filldraw stroke z1e--z2e;  % stem
if serifs: pos6'(vair,-90); pos0(cap_stem,180);
 pos8(cap_curve,180); pos9(vair,-90); pos10(hair,0);
 z6'=z6; lft x0r=lft x8r-.1u=hround(x5-.5cap_curve);
 y8=1/3[y2,y6]; y0=3/5[y2,y6]; x9=.5[x8l,x10r];
 bot y9r=-o; rt x10r=hround(w+.2u); y10=1/10[y2,y6];
 filldraw stroke z6'e{right}..z0e---z8e....z9e{right}..z10e{up};  % tail
 trasnawn(1,a,cap_jut);  % upper serif
else: penpos8(cap_stem-2stem_corr,0); penpos9(cap_stem,0);
 x8l=x6+.5u; y8=y6; x9r=hround(w-.5u); y9=0;
 fill z8l--diag_end(8l,9l,.5,1,9r,8r)--z8r--cycle; fi  % tail
penlabels(0,1,2,3,4,5,6,8,9,10); endchar;

def gen_letter =
italcorr cap_height#*slant-u#;
adjust_fit(0,0);
numeric theta; theta=90-angle(50u,cap_height);
slope:=-cap_height/50u;  % angle at middle
numeric s_slab; s_slab=if serifs:slab else:vround .2[slab,cap_stem] fi;
numeric ess'; ess'=max(fine.breadth,cap_ess);
pickup fine.nib; pos2(max(fine.breadth,s_slab-vround vair_corr),-90);
pos0(s_slab,theta); pos7(s_slab,-90);
x2+x7=2x0=w; x7-x2=if serifs: u else: 0 fi; top y2l=cap_height+o; bot y7r=-o;
y0=.52cap_height; lft x3l=hround u; rt x6r=hround(w-u);
pos3(cap_curve,slope); pos6(cap_curve,slope);
ellipse_set(2l,3l,4l,0l); saillipse_set(2r,3r,4r,0r);
ellipse_set(7l,6l,5l,0l); saillipse_set(7r,6r,5r,0r);
filldraw stroke super_arc.e(2,3) & z3e{down}..z4e---z5e..z6e{down}; 
filldraw stroke super_arc.e(7,6);  % main stroke
if serifs: pos1(hair,180); pos8(hair,180);
 rt x1l=hround(w-2u); lft x8r=hround 2u;
 bot y1=vround .7cap_height+1; top y8=vround .3cap_height-1;
 path upper_arc, lower_arc;
 upper_arc=z1l{x2l-x1l,10(y2l-y1l)}....{left}z2l;
 lower_arc=z7r{left}....{up}z8r;
 pos10(slab,-70); pos9(slab,-70);
 x10r=x6r; y10l=.95cap_height; x9l=x3l; y9r=.05cap_height;
 filldraw z1l{up}..z10r--z10l..subpath(.6,1) of upper_arc
   --z2r{right}....{x1-x2,10(y1-y2)}z1r--cycle;  % upper barb
 filldraw z8r{down}..z9l--z9r..subpath(.4,0) of lower_arc
   --z7l{left}....{up}z8l--cycle;  % lower barb
else: pos1(1.2flare,-100); pos8(1.2flare,-100);
 x1l=good.x(x1l+w-1.75u-rt x1); lft x8r=hround .8u;
 top y1l=vround .93cap_height+o; bot y8r=vround .1cap_height-o;
 filldraw stroke term.e(2,1,right,.9,4);  % upper arc and terminal
 filldraw stroke term.e(7,8,left,1,4); fi  % lower arc and terminal
penlabels(0,1,2,3,4,5,6,7,8,9,10); enddef;

consan_mowr ("Sail", 11u#, 0, 2);

def gen_letter =
italcorr .8cap_height#*slant-.4u#;
adjust_fit(0,0);
numeric arm_thickness, hair_vair; arm_thickness=hround .9[vair,.85cap_stem];
hair_vair=min(.25[vair,hair],arm_thickness);
pickup crisp.nib; pos7(arm_thickness,90); pos8(arm_thickness,90);
top y7r=top y8r=cap_height; rt x7=hround(w-.8u); lft x8r=hround .9u;
filldraw stroke z7e--z8e;
pickup fine.nib; pos2(min(vair',arm_thickness),90);
x2=x4=.5(w+u); bot y2l=crisp.bot y7l; bot y4r=-oo;
pos3(cap_curve,180);
if serifs: pos4(vair',270); pos5(hair,-40);
y5=max(good.y(.3x_height-.9),y4l+vair');
else: pos4(slab,270); pos5(flare,275);
bot y5r=vround .08cap_height-o; fi
lft x3r=w-rt x5r=hround 1.9u; y3=.5[y2l,y4l];
(x,y4l)=whatever[z4r,z5l];
filldraw stroke pulled_super_arc.e(2,3)(.7superpull)
 & pulled_super_arc.e(3,4)(.5superpull) & term.e(4,5,right,.8,4);
penlabels(2,3,4,5,7,8); enddef;

consan_mowr ("Teine", 13.5u#, 0, 4);

def gen_letter =
italcorr cap_height#*slant-cap_serif_fit#+cap_jut#-2.5u#+min(.5cap_stem#,u#);
adjust_fit(cap_serif_fit#,
  cap_serif_fit#-2stem_shift# if monospace:-.5u# fi);
numeric light_vair; light_vair=vair if hefty: -vround 2vair_corr fi;
if light_vair<fine.breadth: light_vair:=fine.breadth; fi
pickup tiny.nib; pos1(cap_stem,0); pos2(cap_stem,0);
pos3(cap_stem,0); pos4(cap_stem',0);
lft x1l=hround(2.5u-.5cap_stem); x1=x2; x3=w-x1; x3r=x4r;
if serifs: top y1=cap_height+min(oo,serif_drop); bot y4=-min(oo,serif_drop);
else: top y1=cap_height; bot y4=0; fi
pos0(cap_stem,0); pos0'(cap_stem',0); x0=x3; x0'=x4; y0=y0';
penpos2'(cap_stem-fine,-180); z2'=z2; y3=y1; y2=.5x_height;
penpos5(max(eps,light_vair-fine),-90); penpos6(thin_join-fine,0);
y6=y0=bar_height;
filldraw stroke z1e--z2e;  % left stem
filldraw stroke z3e..z0e--z0'e..z4e;  % right stem
pickup fine.nib; bot y5r=-oo; x5l=.5w-.25u; lft x6l=tiny.lft x0l;
(x,y5r)=whatever[z5l,z6l]; x5r:=max(x,.5[x5,x2'r]);
filldraw stroke {{interim superness:=hein_super;
  pulled_arc.e(2',5)}} & z5e{right}...{up}z6e;  % arc
if serifs: trasnawn(1,a,cap_jut); % upper left serif
 pickup tiny.nib; trasnawn(3,b,cap_jut); fi % upper right serif
penlabels(1,2,3,4,5); labels(6); enddef;

guta_mowr ("Uwr", 13u#+.5width_adj#, 5);
