%% @metafontfile{
%%     filename="xbcaps.mf",
%%     version="2.2",
%%     date="04-JAN-1995",
%%     filetype="Metafont: driver",
%%     copyright="Copyright (C) American Mathematical Society,
%%            all rights reserved.  Copying of this file is
%%            authorized only if either:
%%            (1) you make absolutely no changes to your copy
%%                including name; OR
%%            (2) if you do make changes, you first rename it to some
%%                other name.",
%%     author="American Mathematical Society",
%%     address="American Mathematical Society,
%%            Technical Support Department,
%%            P. O. Box 6248,
%%            Providence, RI 02940,
%%            USA",
%%     telephone="401-455-4080 or (in the USA) 800-321-4AMS",
%%     email="Internet: Tech-Support@Math.AMS.org",
%%     codetable="ISO/ASCII",
%%     checksum = "54815 833 1446 27412"
%%     keywords="amsfonts, tex, metafont , AMSSymbols ",
%%     abstract="This is the driver file for use with 
%%            the Blackboard Bold characters in AMSFonts 2.2."
%%     docstring       = "The checksum field above contains a CRC-16
%%                        checksum as the first value, followed by the
%%                        equivalent of the standard UNIX wc (word
%%                        count) utility output of lines, words, and
%%                        characters.  This is produced by Robert
%%                        Solovay's checksum utility.",
%%     }
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Changes made by Stefan Lindner for version 2.1 to fix some 
% rounding problems at low resolutions 03-Mar-1991
% ru defined and substituted for u in drawings of characters.

def ru(expr A)=
  begingroup
  save rounded_u; rounded_u#:=A*u#;
  define_whole_vertical_pixels(rounded_u);
  rounded_u
  endgroup
enddef;

iff OK "A":  "The letter A";  beginchar("A",13unit#,cap#,0);

  top z20=(.48w,h+Aapex); pos20(Atip,0);
  bot y3=0; z3l=whatever[z20l,(1.5unit,0)];
  bot y6=0; z6r=whatever[z20r,(w-round(unit+u),0)];
  z20l=z1l; z20r=z4r;
  mpos(1,3)(Athin,constant_angle(z20l,(1.5unit,0),0));
  mpos(4,6)(stem,constant_angle(z20r,(w-round(unit+u),0),0));
  onaline(1l,3l)(2l);  y2l=c_round_bracket;
  onaline(1r,3r)(2r);  y2r=c_inner_bracket;
  onaline(4l,6l)(5l);  y5l=c_inner_bracket;
  onaline(4r,6r)(5r);  y5r=c_thick_stem_bracket;
  z40=whatever[.8[z1l,z1r],z2r]; z40=whatever[.8[z4r,z4l],z5l];
  y41=round(.4[serif_thickness,y40]-Abar);        % bar bottom
  y42=y41+Abar;
   ref1=rightserif(z3,z1,z2l,z40,ru(7),bracket0)--z40;
   ref2=z40--leftserif(z6,z4,z40,z5r,ru(7),bracket32);
   ref3=(0,y41)--(w,y41);
   ref4=(0,y42)--(w,y42);
  x11=xpart (ref1 intersectionpoint ref3);
  x12=xpart (ref2 intersectionpoint ref3);
  x13=xpart (ref2 intersectionpoint ref4);
  x14=xpart (ref1 intersectionpoint ref4);
  y11=y12=y41; y13=y14=y42;

  p1=z20l--leftserif(z3,z1,z2l,z1r,ru(3),bracket0)--ref1--ref2--
     rightserif(z6,z4,z5l,z5r,ru(2.5),bracket0)--z20r--cycle;
  p2=z11--z12--z13--z14--cycle;

  showpoints(1,2,3,4,5,6,11,12,13,14,20,40,41,42);
  draw_outlines;
  endchar;


iff OK "B":  "The letter B";  beginchar("B",12unit#,cap#,0); 
  
  top lft z1l=(round(ru(5)+2smallu),h); 
  z2l=(x1l,h-c_thick_stem_bracket); 
  z2r=(x1r,h-c_round_bracket); 
  z3l=(x1l,c_thick_stem_bracket); 
  z3r=(x1r,c_round_bracket);  
  bot z4l=(x1l,0); 
  mpos(1,4)(Bstem,0); 
  z5l=(rt x1r+ru(4),y1); 
  z5r=(rt x1r+ru(3),y1-Btopthin); 
  onaline(1r,4r)(8l);  
  bot y8l=.5h-smallu; pos8(Bmidthin,90); 
  rt z6l=(w-round(1.5unit),.5[y5l,y8l]); pos6(Btopcurve,180); 
  rt z9l=(w-round(ru(2.5)),.5[y10l,y8r]); pos9(Bbotcurve,180); 
  z10l=(rt x1r+ru(4),y4); 
  z10r=(rt x1r+ru(3),y4+Bbotthin);   
  z7l=(rt x1r+ru(3),y8l); 
  rt z7=(lft x9r-ru(3),.5[top y8l,y8r]); 
  
  p1=leftserif(z1,z4,z2l,z2r,ru(5.2),bracket4)-- 
     leftserif(z4,z1,z3l,z3r,ru(5.2),bracket4)-- 
     curve.br(z10l,.5,z9l,.7)--curve.tr(z9l,.7,z7,.5)-- 
     curve.br(z7,.5,z6l,.5)--curve.tr(z6l,.8,z5l,.6)--cycle; 
  p1'=z8l--z8r; 
  p1''=curve.br(z8r,.6,z6r,.85)--curve.tr(z6r,.7,z5r,.5)... 
       {left}z5r...{down}z2r--cycle; 
  p2''=z8l--z3r{down}...{right}z10r-- 
       curve.br(z10r,.6,z9r,.7)--curve.tr(z9r,.8,z7l,.6)--cycle; 
  
  showpoints(1,2,3,4,5,6,7,8,9,10); 
  draw_outlines; 
  endchar; 


iff OK "C":  "The letter C";  beginchar("C",(1+12)*unit#,cap#,0);

  bot z2l=(max(7unit,.5w),-Cover);
  y2r=y2l+Cbotthin;
  x2r=x2l+(min(Cbotthin,abs(y2r-y2l)));
  bot rt z1l=(w-ru(2),2unit);
  ref1=z2l{right}...z1l; 
  pos1(Ctip,angle(z1l-precontrol 1 of ref1)+ 90);
  lft z3l=(round ru(2),.5h); pos3(Ccurve,0);
  top z4l=(x2l,h+Cover);
  y4r=y4l-Ctopthin;
  x4r=x4l+(min(ru(.5),abs(y4r-y4l)));
  bot rt z5=(w-round(unit+ru(.5)),h-3unit-ru(2.5));
  z6=(x5,y4l);
  z7=z6-(ru(2.5),ru(2.5));
  p1=curve.tl(z4l,.5,z3l,.7)--curve.bl(z3l,.7,z2l,.5)...z1l--
     z1r...reversecurve.bl(z3r,.7,z2r,.6)--reversecurve.tl(z4r,.6,z3r,.6)--
     beak(z4r,z5,z6,z7,z4l,1.2)--cycle;

  showpoints(1,2,3,4,5,6,7);
  draw_outlines;
  endchar;


iff OK "D":  "The letter D";  beginchar("D",13unit#,cap#,0); 
    
  top lft z1l=(round(ru(5)+smallu),h); 
  z2l=(x1l,h-c_thick_stem_bracket); 
  z2r=(x1r,h-c_round_bracket); 
  z3l=(x1l,c_thick_stem_bracket); 
  z3r=(x1r,c_round_bracket); 
  bot z4l=(x1l,0); 
  mpos(1,4)(stem,0); 
  z5l=(rt x1r+ru(4),y4); 
  z5r=(rt x1r+ru(3),y5l+Dbotthin); 
  rt z6l=(w-u-2smallu,.52h); pos6(Dcurve,180); 
  z7l=(rt x1r+ru(4),y1);    
  z7r=(rt x1r+ru(3.5),y7l-Dtopthin); 
  
  p1=leftserif(z1,z4,z2l,z2r,ru(4.5),bracket4)-- 
     leftserif(z4,z1,z3l,z3r,ru(4.5),bracket4)-- 
     curve.br(z5l,.5,z6l,.7)--curve.tr(z6l,.7,z7l,.5)--cycle; 
  p1''=curve.br(z5r,.5,z6r,.8)--curve.tr(z6r,.7,z7r,.5)... 
      {down}z2r...z3r{down}...{right}z5r--cycle; 
  
  showpoints(1,2,3,4,5,6,7); 
  draw_outlines; 
  endchar; 
  

iff OK "E":  "The letter E";  beginchar("E",(1+11)*unit#,cap#,0);

  top lft z1l=(round(ru(5.5)),h);                                    
  z2l=(x1l,h-c_thick_stem_bracket);
  z2r=(x1r,h-c_inner_bracket);
  z3l=(x1l,c_thick_stem_bracket);
  z3r=(x1r,c_inner_bracket);
  bot z4l=(x1l,0);
  mpos(1,4)(Estem,0);
  bot rt z11=(w-unit,0);
  top rt z12=(w-.5unit,3unit+ru(2));
  z13=(.5w+.5unit,y4+Ebotarm);
  z14=(min(x13,rt x4r+.5unit),y13);  
  rt z21=(w-ru(4),y1);
  bot z22=(x21,top y1-3.5unit);
  z23=(ru(19),y1-Etoparm);
  z24=(rt x1r+.5unit,y23);
  onaline(1r,4r)(31,35);
  bot y31=.5h-smallu;
  y35=y31+Emidarm;
  rt z33=(w-(3.8unit),.5[y31,y35]);
  x32=x34=x33;
  bot y32=bot y31-2.5unit;
  top y34=bot y32+6unit;

  p1=leftserif(z4,z1,z3l,z3r,ru(4.75),.4)--
     straightarm.br(z13,z12,z11,Ebot_tip,pullout)--z14{left}...{up}z3r--
     z2r{up}...{right}z24--straightarm.tr(z23,z22,z21,Emid_tip,pulleven)--
     leftserif(z1,z4,z2l,z2r,ru(4.75),.4)--cycle;
  p1'=straightarm.br(z31,z32,z33,Emid_tip,pullin)--
     straightarm.tr(z35,z34,z33,Emid_tip,pullin);

  showpoints(1,2,3,4,11,12,13,14,21,22,23,24,31,32,33,34,35);
  draw_outlines;
  endchar;


iff OK "F":  "The letter F";  beginchar("F",(1+10)*unit#,cap#,0); 
  
  top lft z1l=(round(ru(5.5)),h); 
  z2l=(x1l,h-c_thick_stem_bracket); 
  z2r=(x1r,h-c_inner_bracket);    
  z3l=(x1l,c_thick_stem_bracket); 
  z3r=(x1r,c_inner_bracket);    
  bot z4l=(x1l,0); 
  mpos(1,4)(Fstem,0);
  rt z21=(w-.5unit,y1); 
  bot z22=(x21,top y1-3.5unit); 
  z23=(ru(19),y1-Etoparm); 
  z24=(rt x1r+.5unit,y23);
  onaline(1r,4r)(31,35); 
  bot y31=.5h-smallu; 
  y35=y31+Emidarm; 
  rt z33=(w-3unit,.5[y31,y35]); 
  x32=x34=x33;   
  bot y32=bot y31-2.5unit; 
  top y34=bot y32+6unit;
  
  p1=fullserif(z4,z1,z3l,z3r,ru(4.75),ru(6),bracket4)--z2r{up}...{right}z24--
     straightarm.tr(z23,z22,z21,Emid_tip,pulleven)--
     leftserif(z1,z4,z2l,z2r,ru(4.75),bracket4)--cycle; 
  p1'=straightarm.br(z31,z32,z33,Emid_tip,pullin)-- 
     straightarm.tr(z35,z34,z33,Emid_tip,pullin); 
  
  showpoints(1,2,3,4,21,22,23,24,31,32,33,34,35); 
  draw_outlines; 
  endchar; 


iff OK "G":  "The letter G";  beginchar("G",(1+13)*unit#,cap#,0);

  bot z2l=(max(7unit,.5w),-Gover);
  y2r=y2l+Gbotthin;
  x2r=x2l+(min(Gbotthin,abs(y2r-y2l)));
  lft z3l=(round ru(2),.5h); pos3(Gcurve,0);
  top z4l=(x2l,h+Gover);
  y4r=y4l-Gtopthin;
  x4r=x4l+(min(.5u,abs(y4r-y4l)));
  bot rt z5=(w-round(2unit+.5u),h-3unit-ru(2.5));
  z6=(x5,y4l);
  z7=z6-(ru(2.5),ru(2.5));
  top rt z11r=(rt x5+.5u,5unit+.5u);
  bot z13r=(x11r,unit-2smallu);
  mpos(11,13)(Gstem,0);
  onaline(11r,13r)(12r); y12r=max(y11r-c_thick_stem_bracket,y13r);
  onaline(11l,13l)(12l); y12l=max(y11l-c_thick_stem_bracket,y13r+unit);

  p1=curve.tl(z4l,.5,z3l,.7)--curve.bl(z3l,.7,z2l,.5)--z2l{right}...z13r--
     fullserif(z11,z13,z12l,z12r,ru(5.5),ru(4.5),bracket0)...{down}z13l...{left}z2r--
     reversecurve.bl(z3r,.7,z2r,.6)--reversecurve.tl(z4r,.6,z3r,.6)--
     beak(z4r,z5,z6,z7,z4l,1.2)--cycle;

  showpoints(2,3,4,5,6,7,11,12,13);
  draw_outlines;
  endchar;


iff OK "H":  "The letter H";  beginchar("H",(1+13)*unit#,cap#,0);

  numeric H_inner_serif_amt;
  top lft z1l=(round(3.75unit/2),h);
  z2l=(x1l,h-c_thick_stem_bracket);
  z3l=(x1l,c_thick_stem_bracket);
  bot z4l=(x1l,0);
  top rt z11r=(w-round(3.75unit/2),h);
  z12r=(x11r,h-c_thick_stem_bracket);
  z13r=(x11r,c_thick_stem_bracket);
  bot z14r=(x11r,0);
  mpos(1,2,3,4,11,12,13,14)(stem,0);
  onaline(1r,4r)(5l,5r); bot y5l=bot y15l=.5cap-u;
  onaline(11l,14l)(15l,15r); y5r=y15r=y5l+Hbar;
  H_inner_serif_amt=ru(4.75);
   if (x1r+H_inner_serif_amt+.5linethickness)>.5w:    % keeps inner serifs
      H_inner_serif_amt:=.5w-x1r-.5linethickness-1;   % from merging
   fi 

  p1=fullserif(z1,z4,z2l,z2r,ru(4.75),H_inner_serif_amt,bracket4)--
     fullserif(z4,z1,z3l,z3r,ru(4.75),H_inner_serif_amt,bracket4)--cycle;
  p2=fullserif(z11,z14,z12l,z12r,H_inner_serif_amt,ru(4.75),bracket4)--
     fullserif(z14,z11,z13l,z13r,H_inner_serif_amt,ru(4.75),bracket4)--cycle;
  p1'=z5r--z15r--z15l--z5l;

  showpoints(1,2,3,4,5,11,12,13,14,15);
  draw_outlines;
  endchar;


iff OK "I":  "The letter I";  beginchar("I",(1+6)*unit#,cap#,0);

  top lft z1l=(round((w-stem-linethickness)/2),h);
  z2l=(x1l,h-c_thick_stem_bracket);
  z3l=(x1l,c_thick_stem_bracket);
  bot z4l=(x1l,0);
  mpos(1,2,3,4)(stem,0);

  p1=fullserif(z1,z4,z2l,z2r,ru(5),ru(5),bracket4)--
     fullserif(z4,z1,z3l,z3r,ru(5),ru(5),bracket4)--cycle;

  showpoints(1,2,3,4);
  draw_outlines;
  endchar;


iff OK "J":  "The letter J";  beginchar("J",(2+7)*unit#,cap#,descender#);

  top rt z1r=(round(w-2unit),h);
  z2r=(x1r,h-c_thick_stem_bracket);
  z3r=(x1r,2unit);
  z3l=(x1l,u);
   mpos(1,2)(stem,0);
  bot z10r=(w/3,-.45d);
  z10l=z10r+(-smallu,Jbotthin);
  lft z12l=(smallu,ru(2)); pos12(Jbulb,0);
  top z13=(x12,2unit-smallu); 
   ref1=z12r...z12l...cycle;
  z14= point 1.75 of ref1; z15=direction 1.75 of ref1;
  z11=(x12r-.5unit,.5[y10l,y14]);

  p1=fullserif(z1,z2,z2l,z2r,ru(5.5),ru(4.75),bracket4)--z3l{down}...z10l{left}...
     z11{up}...z14{z15}...z12r{up}...z13{left}...z12l{down}...  % bulb
     curve.br(z10r,.65,z3r,.65)--cycle;

  showpoints(1,2,3,10,11,12,13,14,15);
  draw_outlines;
  endchar;


iff OK "K":  "The letter K";  beginchar("K",(1+13)*unit#,cap#,0);

  numeric K_inner_serif_amt;
  top lft z11l=(2unit,h);
  z12l=(x11l,h-c_thick_stem_bracket);
  z13l=(x11l,c_thick_stem_bracket); 
  bot z14l=(x11l,0);
  mpos(11,12,13,14)(stem,0);
  onaline(11r,14r)(3r,4);  
  bot y3r=.4cap; 
  top rt z1r=(w-2unit,cap);
  mpos(1,3)(Kthin,angle(z1r-z3r)-90);
  y2l=y2r=cap-Kthin_diag_bracket;   
  onaline(1l,3l)(2l,4);
  onaline(1r,3r)(2r,21l);
  onaline(1,3)(0); top y0=cap;   
  bot y21l=y3r+.5unit;
  bot rt z23r=(w-ru(2),0);  
  mpos(21,23)(Kdiag,angle(z1r-z3r));
  y22l=y22r=c_thick_stem_bracket; 
  onaline(21l,23l)(22l);
  onaline(21r,23r)(22r);
  onaline(21,23)(20); bot y20=0; 

  K_inner_serif_amt=ru(4.75); 
   if (x11r+K_inner_serif_amt+.5linethickness)>.5w:
      K_inner_serif_amt:=.5w-x11r-.5linethickness-1;
   fi

  p1=fullserif(z11,z14,z12l,z12r,ru(4.75),K_inner_serif_amt,bracket4)-- 
     fullserif(z14,z11,z13l,z13r,ru(4.75),K_inner_serif_amt,bracket4)--cycle; 
  p2=z3r--fullserif(z0,z3,z2l,z2r,ru(9),ru(3.5),bracket01)--z4--cycle; 
  p3=z21l--fullserif(z20,z21,z22l,z22r,ru(4),.5unit,bracket32)--z21r--cycle;

  showpoints(0,1,2,3,4,11,12,13,14,20,21,22,23);
  draw_outlines;    
  endchar;  


iff OK "L":  "The letter L";  beginchar("L",(1+11)*unit#,cap#,0); 

  top lft z1l=(round(ru(5.5)),h); 
  z2l=(x1l,h-c_thick_stem_bracket); 
  z3l=(x1l,c_thick_stem_bracket); 
  z3r=(x1r,c_inner_bracket); 
  bot z4l=(x1l,0); 
  mpos(1,2,4)(Lstem,0); 
  bot rt z11=(w-unit,0); 
  top rt z12=(w-.5unit,4unit); 
  z13=(.5w+.5unit,y4+Lthin);
  z14=(min(x13,rt x4r+.5unit),y13); 

  p1=fullserif(z1,z4,z2l,z2r,ru(4.75),ru(4.5),bracket4)-- 
     leftserif(z4,z1,z3l,z3r,ru(4.75),bracket4)-- 
     straightarm.br(z13,z12,z11,Ltip,pullout)--z14{left}...{up}z3r--cycle; 

  showpoints(1,2,3,4,11,12,13,14); 
  draw_outlines; 
  endchar; 


iff OK "M":  "The letter M";  beginchar("M",(1+16)*unit#,cap#,0);

  lft x4l=ru(5.6); bot y4=0;
  rt x14r=w-2unit; bot y14=0;
  top z1l=(x4l,h);
  top z11r=(x14r,h);
  mpos(1,3,4)(Mthin_vert,0);
  mpos(11,12,13,14)(Mstem,0);
  onaline(1,4)(3); y12l=h-c_thick_stem_bracket;
  onaline(11,14)(12,13); y3l=y13l=c_thick_stem_bracket;
  bot z22=(x1r+.5(x11l-x1r-Mapex),0); pos22(Mapex,0);
  top z24=(x11l-u,h);
  top z26=(rt x1r+Mdiag,h);
  top z25=(.5[x24,x26],3unit+ru(2)); pos25(u,0);
  bot y23=h-ru(4);
  (z23-z22r)=whatever*(z24-z25r);
  bot y21=h-ru(5);
  (z21-z22l)=whatever*(z26-z25l);
  onaline(26,25l)(30r,31r); onaline(21,22l)(30l,31l);
  y30=y30l=y30r=h-.5linethickness; x30=.5[x30l,x30r];
  y31=y31l=y31r=0; x31=.5[x31l,x31r];
  ref1=leftserif(z30,z31,z21,z25r,ru(5.5),bracket0)--z22l;
  z2l=ref1 intersectionpoint ((x3l,0)--(x3l,h));
  z2r=ref1 intersectionpoint ((x3r,0)--(x3r,h));

  p1=fullserif(z4,z3,z3l,z3r,ru(4.7),ru(5),bracket0)--z2r--z2l--cycle;
  p2=z22r--z23--(x11l,y24)--z24--z25r--z25l--z26--ref1--cycle;
  p3=fullserif(z14,z13,z13l,z13r,ru(4.7),ru(5),bracket0)--
     rightserif(z11,z12,z12l,z12r,ru(4.7),bracket0)--(x11l,y24)--cycle;
   
  showpoints(1,2,3,4,11,12,13,14,21,22,23,24,25,26,30,31);
  draw_outlines;
  endchar;


iff OK "N":  "The letter N";  beginchar("N",13unit#,cap#,0);

  bot lft z1l=(round 2unit,0); mpos(1,2,11,12)(Nthin,0);
  z2=(x1,c_thin_stem_bracket);
  z3=(x1l,h-ru(4));
  top rt z11r=(round (w-ru(5.3)),h);
  z12=(x11,h-c_thin_stem_bracket);
  bot z22=(x11r,-Napex);
  z23l=z22-(Ntip,0); mpos(4,23)(Ndiag,angle(z3-z23l)-90);
%  onaline(1r,2r)(4l); bot z4l=whatever[z3,z23l];
  onaline(1r,2r)(4l);  z4l=whatever[z3,z23l];
  onaline(11l,12l)(14); onaline(4r,23r)(13,14);
  top y21=h; z21=whatever[z14,1.05[z4l,z4r]];
  onaline(4,23)(20); y20=y21;
  onaline(11r,12r)(13);

  p1=leftserif(z20,z4,z4l,z4r,ru(2.5),bracket0)--z23l--z22--z13--z21--cycle;
  p1'=z3--fullserif(z1,z2,z2l,z2r,ru(4.7),ru(5),bracket3)--z4l;
  p2'=z13--fullserif(z11,z12,z12l,z12r,ru(5),ru(4.2),bracket3)--z14;

 showpoints(1,2,3,4,11,12,13,14,20,21,22,23);
 draw_outlines;
 endchar;


iff OK "O":  "The letter O";  beginchar("O",(1+13)*unit#,cap#,descender#);

  top z1l=(.5w,h+Oover); pos1(Othin,-90);
  lft z2l=(round(ru(1.8)),.5h); pos2(Ocurve,0);
  bot z3l=(.5w,-Oover); pos3(Othin,90);
  rt z4l=(round(w-ru(1.8)),.5h); pos4(Ocurve,180);

  p1=curve.tl(z1l,.5,z2l,.7)--curve.bl(z2l,.7,z3l,.5)--
     curve.br(z3l,.5,z4l,.7)--curve.tr(z4l,.7,z1l,.5)--cycle;
  p1''=curve.tl(z1r,.6,z2r,.7)--curve.bl(z2r,.7,z3r,.6)--
     curve.br(z3r,.6,z4r,.7)--curve.tr(z4r,.7,z1r,.6)--cycle;

  showpoints(1,2,3,4);
  draw_outlines;
  endchar;


iff OK "P":  "The letter P";  beginchar("P",(1+10)*unit#,cap#,0);

  top lft z1l=(round(ru(5)+smallu),h);
  z2l=(x1l,h-c_thick_stem_bracket);
  z2r=(x1r,h-c_round_bracket);
  z3l=(x1l,c_thick_stem_bracket);
  z3r=(x1r,c_inner_bracket);
  bot z4l=(x1l,0);
  mpos(1,4)(stem,0);
  z5l=(rt x1r+ru(4),y1);
  z5r=(rt x1r+ru(3),y1-Pthin);
  rt z6l=(w-2smallu,.5[y5l,y7l]); pos6(Pcurve,180);
  onaline(1r,4r)(8l,8r); bot y8l=5.5unit; y8r=y8l+Pmidarm;
  z7l=(rt x1r+ru(4),y8l-round(.2smallu));
  z7r=(rt x1r+ru(3),y8l+Pthin);

  p1=leftserif(z1,z4,z2l,z2r,ru(4.5),bracket4)--
     fullserif(z4,z1,z3l,z3r,ru(4.5),ru(4.8),bracket4)--z8l{right}...
     curve.br(z7l,.5,z6l,.7)--curve.tr(z6l,.7,z5l,.6)--cycle;
  p1'=z8l--z8r;
  p1''=z8r--curve.br(z7r,.6,z6r,.8)--curve.tr(z6r,.8,z5r,.7)...
      {down}z2r--cycle;

  showpoints(1,2,3,4,5,6,7,8);
  draw_outlines;
  endchar;

 
iff OK "Q":  "The letter Q";  beginchar("Q",(1+13)*unit#,cap#,descender#);

  top z1l=(.5w,h+Oover); pos1(Othin,-90);
  lft z2l=(round(ru(1.8)),.5h); pos2(Ocurve,0);
  bot z3l=(.5w,-Oover); pos3(Othin,90);
  rt z4l=(round(w-ru(1.8)),.5h); pos4(Ocurve,180);
  ref1=curve.bl(z2l,.7,z3l,.5)--curve.br(z3l,.5,z4l,.7);
  ref2=(.35w,-d)--(.35w,h);
  ref3=(.35w+stem+2linethickness,-d)--(.35w+stem+2linethickness,h);
  lft z11=ref1 intersectionpoint ref2;
  bot rt z13r=(round(w-ru(2.5)),-d+4smallu);
  bot z12=(.6[x11,x13r],-d-round(2smallu));
  ref4=z12{right}...z13r;
  pos13(serif_thickness,angle(z13r-precontrol 1 of ref4)-90);
  z14=z13l-(ru(3.5),.5u);
  rt z15=ref1 intersectionpoint ref3;

  p1=curve.tl(z1l,.5,z2l,.7)--ref1--curve.tr(z4l,.7,z1l,.5)--cycle;
  p1'=z11...z12{right}...z13r--z13l...z14{left}...z15;
  p1''=curve.tl(z1r,.6,z2r,.7)--curve.bl(z2r,.7,z3r,.6)--
     curve.br(z3r,.6,z4r,.7)--curve.tr(z4r,.7,z1r,.6)--cycle;

  showpoints(1,2,3,4,11,12,13,14,15);
  draw_outlines;
  endchar;


iff OK "R":  "The letter R";  beginchar("R",(1+12)*unit#,cap#,0);

  top lft z1l=(round(ru(5)+2smallu),h);
  z2l=(x1l,h-c_thick_stem_bracket);
  z2r=(x1r,h-c_round_bracket);
  z3l=(x1l,c_thick_stem_bracket);
  z3r=(x1r,c_inner_bracket);
  bot z4l=(x1l,0);
  mpos(1,4)(stem,0);
  z5l=(rt x1r+ru(5),y1);
  z5r=(rt x1r+ru(3),y1-Rthin);
  rt z6r=(w-(ru(5.0)),.5[y5l,y8l]); pos6(Rcurve,0);
  onaline(1r,4r)(8l,8r); bot y8l=5.6unit; y8r=y8l+Rthin;
  ref1=curve.br(z8l,.5,z6r,.9);
  ref2=(rt x4r+.5unit,0)--(rt x4r+.5unit,h);
  ref3=(x4r+stem+2linethickness,0)--(x4r+stem+2linethickness,h);
  lft z11l=ref1 intersectionpoint ref2;
  rt z13l=(w-u,y4); pos13(serif_thickness,90);
  lft z12l=(w-4unit,y13l);
  z14=z13r-(ru(3),0);
  top rt z15=ref1 intersectionpoint ref3;

  p1=leftserif(z1,z4,z2l,z2r,ru(4.8),bracket4)--
     fullserif(z4,z1,z3l,z3r,ru(4.8),ru(4.8),bracket4)--
     curve.br(z8l,.6,z6r,.9)--curve.tr(z6r,.7,z5l,.5)--cycle;
  p1'=z8l--z8r;
  p2'=z11l--z12l--z13l--z13r{left}
      if lowres:..tension 10.. else:... fi{z15-z14}z15;
  p1''=z8r--curve.br(z8r,.8,z6l,.9)--curve.tr(z6l,.9,z5r,.5)...
      {down}z2r--cycle;

  showpoints(1,2,3,4,5,6,8,11,12,13,14,15);
  draw_outlines;
  endchar;


iff OK "S":  "The letter S";  beginchar("S",10unit#,cap#,0);

  top z1r=(.5w-u,h+Sover_top); pos1(Stopthin,90);
  rt z3=(w-ru(4),y1r);
  x4=.3[x3,x1r]; y4=y3-ru(1.5); 
  bot z2=top z3-(0,4unit-smallu);
  bot z11l=(.5w-u,-Sover_bot); pos11(Sbotthin,90);
  lft z13=(ru(2),y11l); 
  x14=.3[x13,x11l]; y14=y13+ru(1.5);  
  top z12=bot z13+(0,4.5unit); 
  z21l=(ru(2.5),.73h);
  y21r=.35[y21l,y1r]; rt x21r=.48[x21l,x1r]; 
  z22=(.5w,.52h); pos22(stem,37);
  z23r=(w-ru(2)-smallu,.28h);    
  y23l=.7[y11l,y23r]; lft x23l=.53[x11l,x23r]; 

  p1=beak(z1l,z2,z3,z4,z1r,1.2)--curve.tl(z1r,.65,z21l,.65)...
     z22l...
     reversecurve.br(z11r,.7,z23l,.7)--
     beak(z11r,z12,z13,z14,z11l,1.2)--
     curve.br(z11l,.6,z23r,.6)...1.1[z22l,z22r]...
     reversecurve.tl(z1l,.6,z21r,.6)--cycle;

  showpoints(1,2,3,4,11,12,13,14,21,22,23); 
  draw_outlines;
  endchar;


iff OK "T":  "The letter T";  beginchar("T",(1+11)*unit#,cap#,0);

  mpos(1,2,3)(stem,0);
  bot lft z1l=(round((w-stem-linethickness)/2),0);
  z2l=(x1l,c_thick_stem_bracket);
  top z4=(x1,h); 
  bot y5l=top y4-(3unit+ru(2)); onaline(1,4)(5);
  mpos(4,5)(round(w-ru(3.5)-linethickness),0);
  z3l=(x1l,y4-Tthin);

  p1=straightarm.br(z3r,z5r,z4r,Ttip,pulleven)--
     straightarm.bl(z3l,z5l,z4l,Ttip,pulleven)--cycle;
  p1'=z3l--fullserif(z1,z4,z2l,z2r,ru(5.25),ru(5.25),bracket4)--z3r;

  showpoints(1,2,3,4,5);
  draw_outlines;
  endchar;


iff OK "U":  "The letter U";  beginchar("U",13unit#,cap#,0);

  top lft z1l=(round(ru(5)+smallu),h);
  z2l=(x1l,h-c_thick_stem_bracket);
  z3l=(x1l,4unit);
  top rt z11r=(w-round(ru(5.5)),h);
  z12r=(x11r,h-Uthin_bracket);
  z13r=(x11r,4.5unit);
  mpos(1,2,3)(Ustem,0);
  mpos(11,12,13)(Uthin,0);
  bot z10r=(.5w,-Uover); 
  z10l=z10r+(.5unit,Uthin);

  p1=fullserif(z1,z2,z2l,z2r,ru(4.5),ru(5),bracket4)--
     curve.bl(z3l,.65,z10r,.65)--curve.br(z10r,.65,z13r,.65)--
     fullserif(z11,z12,z12l,z12r,ru(4.75),ru(4.75),bracket01)--z13l{down}--
     reversecurve.br(z10l,.65,z13l,.65)--
     reversecurve.bl(z3r,.7,z10l,.7)--cycle; 

  showpoints(1,2,3,10,11,12,13); 
  draw_outlines; 
  endchar;
         

iff OK "V":  "The letter V";  beginchar("V",13unit#,cap#,0);

  bot z20=(.51w,-Vapex); pos20(Vtip,0);
  top y3=h; z3r=whatever[z20r,(w-round(unit+2smallu),h)];
  top y6=h; z6l=whatever[z20l,(unit,h)];
  z20r=z1r; z20l=z4l;
  mpos(1,3)(Vthin,constant_angle((w-round(unit+2smallu),h),z20r,0));
  mpos(4,6)(stem,constant_angle((unit,h),z20l,0));
  onaline(1r,3r)(2r);  y2r=h-c_round_bracket;
  onaline(1l,3l)(2l);  y2l=h-c_inner_bracket;
  onaline(4r,6r)(5r);  y5r=h-c_inner_bracket;
  onaline(4l,6l)(5l);  y5l=h-c_thick_stem_bracket;
  z40=whatever[.8[z1r,z1l],z2l]; z40=whatever[.8[z4l,z4r],z5r];

  p1=z20l--z20r--rightserif(z3,z1,z2l,z2r,ru(3),bracket0)--        
     leftserif(z3,z1,z40,z2r,ru(7),bracket0)--z40--
     rightserif(z6,z4,z5l,z40,ru(7),bracket32)--
     leftserif(z6,z4,z5l,z5r,ru(2.5),bracket0)--z20l--cycle;

  showpoints(1,2,3,4,5,6,20,40);
  draw_outlines;
  endchar;


iff OK "W":  "The letter W";  beginchar("W",(1+17)*unit#,cap#,0);

  bot z20=(.3w,-Wapex); pos20(Wtip,0);
  top y3=h; z3r=whatever[z20r,(.6w,h)];
  top y6=h; z6l=whatever[z20l,(unit,h)];
  z20r=z1r; z20l=z4l;
  mpos(1,3)(Wleftthin,constant_angle((.6w,h),z20r,0));
  mpos(4,6)(stem,constant_angle((unit,h),z20l,0));
  onaline(1r,3r)(2r);  y2r=h-c_round_bracket;
  onaline(1l,3l)(2l);  y2l=h-c_inner_bracket;
  onaline(4r,6r)(5r);  y5r=h-c_inner_bracket;
  onaline(4l,6l)(5l);  y5l=h-c_thick_stem_bracket;
  z40=whatever[.8[z1r,z1l],z2l]; z40=whatever[.8[z4l,z4r],z5r];

  bot z21=(.7w,-Wapex); pos21(Wtip,0);
  top y13=h; z13r=whatever[z21r,(w-unit,h)];
  top y16=h; z16l=whatever[z21l,(.44w,h)];
  z21r=z11r; z21l=z14l;
  mpos(11,13)(Wrightthin,constant_angle((w-unit,h),z21r,0));
  mpos(14,16)(stem,constant_angle((.44w,h),z21l,0));
  onaline(11r,13r)(12r);  y12r=h-c_round_bracket;
  onaline(11l,13l)(12l);  y12l=h-c_inner_bracket;
  onaline(14r,16r)(15r);  y15r=h-c_inner_bracket;
  onaline(14l,16l)(15l);  y15l=h-c_thick_stem_bracket;
  z41=whatever[.8[z11r,z11l],z12l]; z41=whatever[.8[z14l,z14r],z15r];
   
  ref1=leftserif(z16,z14,z15l,z15r,ru(2.5),bracket0)--z21l; 
  z30=ref1 intersectionpoint (z20r--z3r);
  z31=ref1 intersectionpoint (z40--z3l);

  p1=z21l--z21r--rightserif(z13,z11,z12l,z12r,ru(2),bracket0)--
     leftserif(z13,z11,z41,z12r,ru(7),bracket0)--z41--
     rightserif(z16,z14,z15l,z41,ru(6),bracket32)--
     ref1--cycle;
  p2=z20l--z20r--z30--z31--z40-- 
     rightserif(z6,z4,z5l,z40,ru(5),bracket32)-- 
     leftserif(z6,z4,z5l,z5r,ru(2),bracket0)--z20l--cycle; 

  showpoints(1,2,3,4,5,6,11,12,13,14,15,16,20,21,30,31,40,41);
  draw_outlines; 
  endchar;


iff OK "X":  "The letter X";  beginchar("X",13unit#,cap#,0);

  numeric botjoin,topjoin,joinwidths;
  botjoin=.42h; topjoin=.62h;

  top z1=(.2w,h);
  bot z3=(.8w,0);
  z2r=.5[z1r,z3r];
  mpos(1,3)(Xdiag,constant_angle(z1,z3,0));
  pos2(.9Xdiag,constant_angle(z1,z3,0));
  ref1=leftserif(z1,z3,z2l,z2r,ru(2.5),bracket4)...
       leftserif(z3,z1,z2l,z2r,ru(7),bracket42);
  ref2=rightserif(z3,z1,z2l,z2r,ru(2),bracket42)--
       rightserif(z1,z3,z2l,z2r,ru(6),bracket4);
  bot z4=ref1 intersectionpoint ((0,botjoin)--(w,botjoin));
  top z9=ref2 intersectionpoint ((0,topjoin)--(w,topjoin));
  bot z6=(.12w,0); top z7=(.8w,h);
  mpos(4,6)(Xthin,constant_angle(z4,z6,0));
  mpos(7,9)(Xthin,constant_angle(z7,z9,0));
  onaline(4l,6l)(5l);  y5l=y5r=Xthin_diag_bracket;
  onaline(4r,6r)(5r); 
  onaline(7r,9r)(8r);  y8r=y8l=h-Xthin_diag_bracket;
  onaline(7l,9l)(8l);            
  ref3=fullserif(z6,z4,z5l,z5r,ru(2.5),ru(8),bracket01);
  ref4=z5l--2[z5l,z4l];
  ref5=fullserif(z7,z9,z8l,z8r,ru(7),ru(5),bracket01);
  ref6=z8r--2[z8r,z9r];
  z21=ref1 intersectionpoint (ref3--z4r);
  z22=ref1 intersectionpoint ref4;
  z23=ref2 intersectionpoint (ref5--z9l);
  z24=ref2 intersectionpoint ref6;

  p1=ref1--ref2--cycle;  
  p2=z22--ref3--z21--cycle;
  p3=z24--ref5--z23--cycle;

  showpoints(1,2,3,4,5,6,7,8,9,21,22,23,24); 
   draw_outlines;
  endchar;


iff OK "Y":  "The letter Y";  beginchar("Y",13unit#,cap#,0); 
  
  bot lft z3l=(5unit,0); 
  z2l=z3l+(0,c_thick_stem_bracket); 
  mpos(2,3)(stem,0); 
  onaline(2l,3l)(1l); y1l=.39h; 
  onaline(2r,3r)(1r); y1r=.45h; 
  top lft z4l=(unit,h); 
  z6l=z1l; 
  mpos(4,6)(Ythick_diag, constant_angle(z4l,z6l,0));
  onaline(4l,6l)(5l); y5l=y5r=h-c_thick_stem_bracket;
  onaline(4r,6r)(5r);
  onaline(4,6)(20); top y20=h;
  top rt z7r=(w-unit,h); 
  z9r=z1r;  

  mpos(7,9)(Ydiag, constant_angle(z7r,z9r,0)); 
  onaline(7l,9l)(8l); y8l=y8r=h-Ythin_diag_bracket;
  onaline(7r,9r)(8r);
  onaline(7,9)(21); top y21=h; 

  ref1=z5r--1.5[z5r,z6r]; 
  ref2=z8l--1.5[z8l,z9l];
  z22=ref1 intersectionpoint ref2; 

  p1=fullserif(z20,z6,z5l,z5r,ru(2),ru(4),bracket4)--z1l--
     fullserif(z3,z2,z2l,z2r,ru(5),ru(5),bracket4)--z1r--
     fullserif(z21,z9,z8l,z8r,ru(8),ru(2),bracket01)--z22--cycle;
  
  showpoints(1,2,3,4,5,6,7,8,9,20,21,22);   
   draw_outlines;  
  endchar;  


iff OK "Z":  "The letter Z";  beginchar("Z",(1+11)*unit#,cap#,0);

  top lft z1=(ru(4)+smallu,h);
  bot lft z2=(ru(3)+smallu,top y1-3.5unit);
  z3=(.5w,y1-Zthin);
  bot lft z5l=(.5unit,0);
  rt z15r=(w-ru(3)-smallu,y1);
  mpos(5,15)(Zdiag,constant_angle(z15r,z5l,Zdiag));
  rt z11=(w-ru(3.2),y5l);
  top rt z12=(w-ru(1.7),4unit+u);
  z13=(.55w,y11+Zthin);
  onaline(5l,15l)(4); y4=y3;
  onaline(5r,15r)(14); y14=y13;

  p1=straightarm.tl(z3,z2,z1,Ztip,pulleven)--z4--z5l--
     straightarm.br(z13,z12,z11,Ztip,pulleven)--z14--z15r--cycle;

  showpoints(1,2,3,4,5,11,12,13,14,15);                               
  draw_outlines;
  endchar;



% ----- Phase 3 -----


iff OK "k":  "The letter k";  beginchar(oct"174",(1+9)*unit#,ascender#,0);

  top lft z11l=(unit+.5u,h);
  bot z14l=(x11l,0);
  mpos(11,14)(kstem,0);
  onaline(11r,14r)(3r,4,12r,13r); 
    bot y3r=.4xheight; y12l=h-lc_thick_stem_bracket; top y12r=h;
  onaline(11l,14l)(12l,13l); 
    y13l=y13r=lc_thick_stem_bracket;
  top rt z1r=(w-1.5unit,xheight); 
  mpos(1,3)(kthin,angle(z1r-z3r)-90); 
  y2l=y2r=xheight-k_thin_diag;
  onaline(1l,3l)(2l,4);
  onaline(1r,3r)(2r,21l);
  onaline(1,3)(0); top y0=xheight; 
  y21l=y3r+.5unit; 
  bot rt z23r=(w-ru(2),0); 
  mpos(21,23)(kdiag,angle(z1r-z3r));  
  y22l=y22r=lc_thick_stem_bracket; 
  onaline(21l,23l)(22l);
  onaline(21r,23r)(22r);
  onaline(21,23)(20); bot y20=0; 

  p1=fullserif(z14,z11,z13l,z13r,ru(2.5),ru(2.5),bracket0)--z12r--
     leftserif(z11,z14,z12l,z12r,ru(2.5),bracket0)--cycle;
  p2=z3r--fullserif(z0,z3,z2l,z2r,ru(7),ru(2.5),bracket01)--z4--cycle;
  p3=z21l--fullserif(z20,z21,z22l,z22r,ru(4),u,bracket32)--z21r--cycle;
     
  showpoints(0,1,2,3,4,11,12,13,14,20,21,22,23);
  draw_outlines;
  endchar;
