% This is  LOWERXYZ.MF
% Version 1.0b 
% Date 6-APR-2004
% 
% (c) 1991--2004 by J"org Knappen. See fc.rme for copying conditions
% This file is part of the fc-package 
% See fc.rme for more information

% Contents:
%
% The following characters are generated without condition:
%
% x, y, z
%
% And the following on demand, i. e. if their code is known:
%
% hooktop_y, zhe (ezh)
%
% Higher versions of this file might include more characters.

cmchar "The letter x";
beginchar("x",if serifs:9.5u# else:9u# fi,x_height#,0);
italcorr x_height#*slant-.05u#;
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ serif_fit#);
numeric stem[],outer_jut,xjut,alpha[];
stem1=fudged.stem-4stem_corr; stem2=min(fudged.hair,stem1);
outer_jut=.75jut; xjut= if serifs: (stem1-stem2)/4 else: 0 fi;
x1l=l+letter_fit+.1u+outer_jut; x2r=r-letter_fit-.3u-outer_jut-xjut;
x3l=l+letter_fit+outer_jut+xjut; x4r=r-letter_fit-outer_jut;
y1=y2=h; y3=y4=0;
alpha1=diag_ratio(1,stem1,h,x4r-x1l);
alpha2=diag_ratio(1,stem2,h,x2r-x3l);
penpos1(alpha1*stem1,0); penpos2(alpha2*stem2,0);
penpos3(alpha2*stem2,0); penpos4(alpha1*stem1,0);
if hefty: z0=whatever[z1,z4]=whatever[z2,z3];
 x12=x34=x0; y13=y24=y0;
 z12=whatever[z2l,z3l]; z13=whatever[z2l,z3l];
 z24=whatever[z2r,z3r]; z34=whatever[z2r,z3r];
 forsuffixes $=13,24,34: z$'=.2[z$,z0]; endfor
 fill diag_end(12,1r,.5,1,1l,13')--z13'--diag_end(13',3l,1,.5,3r,34')--z34'
  --diag_end(34',4l,.5,1,4r,24')--z24'
  --diag_end(24',2r,1,.5,2l,12)--z12--cycle; % diagonals
else: fill diag_end(4r,1r,.5,1,1l,4l)
  --diag_end(1l,4l,.5,1,4r,1r)--cycle; % left diagonal
 fill diag_end(2l,3l,.5,1,3r,2r)
  --diag_end(3r,2r,.5,1,2l,3l)--cycle; fi  % right diagonal
if serifs: numeric inner_jut[]; pickup tiny.nib;
 prime_points_inside(1,4); prime_points_inside(2,3);
 prime_points_inside(3,2); prime_points_inside(4,1);
 if rt x1'r+jut+.5u+1<=lft x2'l-jut-xjut: inner_jut1=jut;
 else: rt x1'r+inner_jut1+.5u+1=lft x2'l-inner_jut1-xjut; fi
 if rt x3'r+jut+.5u+1<=lft x4'l-jut-xjut: inner_jut2=jut;
 else: rt x3'r+inner_jut2+.5u+1=lft x4'l-inner_jut2-xjut; fi
 dish_serif(1',4,a,1/3,outer_jut,b,2/3,inner_jut1);  % upper left serif
 dish_serif(4',1,c,2/3,inner_jut2,d,1/3,outer_jut);  % lower right serif
 dish_serif(2',3,e,2/3,inner_jut1+xjut,
  f,1/2,outer_jut+xjut)(dark);  % upper right serif
 dish_serif(3',2,g,1/2,outer_jut+xjut,
  h,2/3,inner_jut2+xjut)(dark); fi  % lower left serif
penlabels(0,1,2,3,4,12,13,24,34); endchar;


cmchar "The letter y";
beginchar("y",if serifs:9.5u# else:9u# fi,x_height#,desc_depth#);
italcorr x_height#*slant+.25u#;
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ serif_fit#);
numeric left_stem,right_stem,bot_stem,bot_vair,outer_jut;
left_stem=fudged.stem-stem_corr;
right_stem=fudged.hair if hefty:-2stem_corr fi;
bot_stem=fudged.hair if hefty:-8stem_corr fi;
bot_vair=Vround(if serifs: vair else:.5[vair,bot_stem] fi);
outer_jut=.75jut;
x1l=w-x4r=l+letter_fit+outer_jut+.25u; y1=y4r=h; y2=y3=0; x2l=x3l;
numeric alpha,alpha[]; x9=3u; y9=bot_vair-d-oo;
alpha1=diag_ratio(2,bot_stem,y1-y3,x4r-x1l-apex_corr);
alpha2=diag_ratio(1,bot_stem,y1-y9,x4r-x9);
if alpha1<alpha2: x2l-x1l=x4r-x3r+apex_corr; alpha=alpha1;
else: alpha=alpha2; z3l=whatever[z9,z4r-(alpha*bot_stem,0)]; fi
penpos3(alpha*bot_stem,0); penpos4(alpha*right_stem,0);
alpha3=(y1++(x2l-x1l))/y1;
penpos1(alpha3*left_stem,0); penpos2(alpha3*left_stem,0);
z0=whatever[z1r,z2r]=z4l+whatever*(z3r-z4r);
if y0>notch_cut: y0:=notch_cut;
  fill z0+.5right{up}...{z4r-z3r}diag_end(0,4l,1,1,4r,3r)
    --z3r--z2l--diag_end(2l,1l,1,1,1r,2r){z2-z1}
    ...{down}z0+.5left--cycle; % left and right diagonals
else: fill z0--diag_end(0,4l,1,1,4r,3r)--z3r--z2l
    --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
penpos5(alpha*bot_stem,0); z5r=whatever[z3r,z4r]; y5-.5vair=-.5d;
if serifs: numeric light_bulb; light_bulb=hround 7/8[hair,flare]; clearpen;
 penpos6(vair,-90); penpos7(hair,-180); penpos8(light_bulb,-180);
 x6=2u; y6r=-d-oo; y8-.5light_bulb=-.85d; x8r=hround .35u;
 fill stroke z3e---z5e...{left}z6e; bulb(6,7,8);  % arc and bulb
 numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(4,3);
 if rt x1'r+jut+.5u+1<=lft x4'l-jut: inner_jut=jut;
 else: rt x1'r+inner_jut+.5u+1=lft x4'l-inner_jut; fi
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut);  % left serif
 dish_serif(4',3,c,.6,inner_jut,d,1/2,outer_jut)(dark);  % right serif
else: penpos6(bot_vair,-90); x6=2.5u; y6r=-d-oo;
 fill stroke z3e---z5e...{left}z6e;  % arc
 pickup fine.nib; pos6'(bot_vair,-90); z6'=z6;
 pos7(2/3[bot_vair,flare],-85);
 lft x7l=hround u; bot y7r=vround-.96d-oo; y7l:=good.y y7l;
 filldraw stroke term.e(6',7,left,1,4); fi % arc and terminal
penlabels(0,1,2,3,4,5,6,7,8,9); endchar;

iff known hooktop_y:
cmchar "The letter hooktop y";  
beginchar(hooktop_y,11.5u#,x_height#,desc_depth#);
italcorr x_height#*slant+.25u#;
adjust_fit(serif_fit# if monospace:+\\.5u#,.5u#+ else:,fi\\ serif_fit#);
numeric left_stem,right_stem,bot_stem,bot_vair,outer_jut;
left_stem=fudged.stem-stem_corr;
right_stem=fudged.hair if hefty:-2stem_corr fi;
bot_stem=fudged.hair if hefty:-8stem_corr fi;
bot_vair=Vround(if serifs: vair else:.5[vair,bot_stem] fi);
outer_jut=.75jut;
x1l=w-3u-x4r=l+letter_fit+outer_jut+.25u; y1=y4r=h; y2=y3=0; x2l=x3l;
numeric alpha,alpha[]; x9=3u; y9=bot_vair-d-oo;
alpha1=diag_ratio(2,bot_stem,y1-y3,x4r-x1l-apex_corr);
alpha2=diag_ratio(1,bot_stem,y1-y9,x4r-x9);
if alpha1<alpha2: x2l-x1l=x4r-x3r+apex_corr; alpha=alpha1;
else: alpha=alpha2; z3l=whatever[z9,z4r-(alpha*bot_stem,0)]; fi
penpos3(alpha*bot_stem,0); penpos4(alpha*right_stem,0);
alpha3=(y1++(x2l-x1l))/y1;
penpos1(alpha3*left_stem,0); penpos2(alpha3*left_stem,0);
z0=whatever[z1r,z2r]=z4l+whatever*(z3r-z4r);
  z11=whatever[z3,z4]; y11=.8h; penpos11(alpha*right_stem,0);
if y0>notch_cut: y0:=notch_cut;
  fill z0+.5right{up}...{z4r-z3r}diag_end(0,11l,1,1,11r,3r)
    --z3r--z2l--diag_end(2l,1l,1,1,1r,2r){z2-z1}
    ...{down}z0+.5left--cycle; % left and right diagonals
else: fill z0--diag_end(0,11l,1,1,11r,3r)--z3r--z2l
    --diag_end(2l,1l,1,1,1r,0)--cycle; fi % left and right diagonals
penpos5(alpha*bot_stem,0); z5r=whatever[z3r,z4r]; y5-.5vair=-.5d;
if serifs: numeric light_bulb; light_bulb=hround 7/8[hair,flare]; clearpen;
 penpos6(vair,-90); penpos7(hair,-180); penpos8(light_bulb,-180);
 x6=2u; y6r=-d-oo; y8-.5light_bulb=-.85d; x8r=hround .35u; 
 z11'=z11; penpos11'(alpha*right_stem,180);
 penpos12(vair,90);penpos13(hair,0);penpos14(light_bulb,0);
 x12=w-2u; top y12=h+oo; y14=.85h-.5light_bulb; rt x14=hround w-.35u;
  fill stroke z3e---z5e...{left}z6e; bulb(6,7,8);  % lower arc and bulb
  fill stroke z11'e{z4-z3}...{right}z12e; bulb(12,13,14); % upper arc & bulb
 numeric inner_jut; pickup tiny.nib;
 prime_points_inside(1,2); prime_points_inside(3,4);
 inner_jut=jut; 
 dish_serif(1',2,a,1/3,outer_jut,b,1/2,inner_jut);  % left serif
else: penpos6(bot_vair,-90); x6=2.5u; y6r=-d-oo;
 fill stroke z3e---z5e...{left}z6e;  % lower arc
 pickup fine.nib; pos6'(bot_vair,-90); z6'=z6;
 pos7(2/3[bot_vair,flare],-85);
 lft x7l=hround u; bot y7r=vround-.96d-oo; y7l:=good.y y7l;
 filldraw stroke term.e(6',7,left,1,4); % arc and terminal
 clearpen; penpos13(bot_vair,-90); x13=w-2.5u; y13l=h+oo;
 fill stroke z11e{z4-z3}...{right}z13e; % upper arc
 pickup fine.nib; pos 13'(bot_vair,-90); z13'=z13;
 pos14(2/3[bot_vair,flare],-85);
 rt x14l=hround w-u; top y14l=vround .96h+oo;
 filldraw stroke term.e(13',14,right,1,4); % upper terminal
fi
penlabels(0,1,2,3,4,5,6,7,8,9); endchar;


cmchar "The letter z";
beginchar("z",8u#,x_height#,0);
italcorr x_height#*slant-.5serif_fit#-.3u#;
adjust_fit(0,.5serif_fit#);
numeric arm_thickness[],z_stem;
if hefty: arm_thickness1=Vround(vair-vair_corr); arm_thickness2=vair;
 z_stem=.6[vair,stem];
else: arm_thickness1=vair; arm_thickness2=vair'; z_stem=.9[vair,stem]; fi
pickup tiny.nib; rt x1r=rt x2r=hround(w-.8u); lft x3l=lft x4l=hround .5u;
top y1=h; y2=min(y1,h-2/3arm_thickness1);
bot y4=0; y3=max(y4,2/3arm_thickness2);
numeric alpha; alpha=diag_ratio(1,z_stem-tiny,y2-y3,x2r-x3l-slant*(y2-y3));
penpos1(alpha*(z_stem-tiny),0); penpos2(alpha*(z_stem-tiny),0);
penpos3(alpha*(z_stem-tiny),0); penpos4(alpha*(z_stem-tiny),0);
pair delta; delta=penoffset z3-z2 of currentpen;
fill top lft z1l--z2l+delta---z3l+delta..lft z3l---lft z4l..bot z4l
 ---bot rt z4r--z3r-delta---z2r-delta..rt z2r---rt z1r..top z1r
 ---cycle;  % diagonal
pickup crisp.nib; pos5(arm_thickness1,90); pos6(hair,180);
top y5r=h; x5=x1; lft x6r=hround .75u; y6=good.y(y5l-beak/1.4)-eps;
arm(5,6,a,beak_darkness,-.4beak_jut);  % upper arm and beak
pos7(arm_thickness2,-90); pos8(hair,0);
bot y7r=0; x7=x4; rt x8r=hround(w-.75u); y8=good.y(y7l+beak/1.2)+eps;
arm(7,8,b,beak_darkness,.6beak_jut);  % lower arm and beak
penlabels(1,2,3,4,5,6,7,8); endchar;

iff known zhe:
cmchar "The letter ezh";    % adapted from Julian Bradfield's cmoe yogh
beginchar(zhe,8u#,x_height#,desc_depth#);
italcorr x_height#*slant-.5serif_fit#-.3u#;
adjust_fit(0,0);
numeric arm_thickness,arm_thickness#,z_stem ;
arm_thickness# = .9[vair#,.85stem#];  % changed
define_whole_vertical_blacker_pixels(arm_thickness);
if arm_thickness<crisp.breadth: arm_thickness:=crisp.breadth; fi
z_stem = .1[vair,stem] ;
pickup tiny.nib; rt x1r=rt x2r=hround(w-1.2u);
top y1=h; y2=min(y1,h-2/3arm_thickness);
lft x3l = hround .33w ; y3 = .7bar_height ;
numeric alpha; alpha=diag_ratio(1,z_stem-tiny,y2-y3,x2r-x3l-slant*(y2-y3));
penpos1(alpha*(z_stem-tiny),0); penpos2(alpha*(z_stem-tiny),0);
penpos3(alpha*(z_stem-tiny),0);
pair delta; delta=penoffset z3-z1 of currentpen;
fill top lft z1l--z1l+delta---z3l+delta..lft z3l
 ..bot z3r--z3r-delta---rt z1r..top z1r
 ---cycle;  % diagonal
z99 = rt z1r ; z98 = z99 + (u,0) ;   % for cutting away
z97 = z99 + 10*(z3-z1) ; z96 = z97 + (u,0) ;
pickup crisp.nib; pos5(arm_thickness,90); pos6(hair,180);
top y5r=h; x5=x1; lft x6r=hround .75u; y6=good.y(y5l-beak/1.6)-eps;
arm(5,6,a,beak_darkness,-.4beak_jut);  % upper arm and beak
% now cut away the excess arm
erase fill z99 --- z98 --- z96 --- z97 --- cycle ;
pickup fine.nib ;
pos10'(vair,90) ; pos11(curve,0) ;
pos12(.1[vair,curve],-90) ;
z10' - z3 = whatever*dir 30 ;
x10' = x3 + u ; x10 = x10' ; y10r = good.y y10'r ; pos10(vair,90) ;
bot y12r = -d-oo ; x12 = .5w ;
y11 = .5[y10,y12] ; rt x11r = hround(w-.9u) ;
z3' = z3 ; z3'l = z3r ; z3'r = z3l ;
filldraw stroke z3'e .. z10e{right} ;
filldraw stroke pulled_arc.e(10,11) & pulled_arc.e(11,12) ;
if serifs: pos13(hair,-180) ; y13=-.1d ; lft x13r = hround .8u ;
   pos14(flare,-180) ; bulb(12,13,14) ;
else: pos13(5/7[vair,flare],angle(-3u,-h)) ;
lft x13r = hround .9u ; y13 = -.1d ;
x13l := good.x x13l ; y13l := good.y y13l ;
filldraw stroke term.e(12,13,left,1,4) ; fi
penlabels(1,2,3,4,5,6,7,8,10,11,12,13,14); endchar;

endinput;
