% mathematical symbols by Anthony Phan.
% file: mathcall.mf (calligraphic font)
% last modification: May 16, 2005.

%
% LOWERCASE
%
% design, metrics and italic corrections checked (nov. 28, 2002).
%

cmchar "Calligraphic a";
beginchar("a", 9u#, x_height#, 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    x_height#*slant+0.5lower_cal_width#-2u#) if math_fitting: -0.5u# fi;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = vround 0.98h; x1 = x2 = good.x(w-2.5u); x4 = w;
  draw z1..hook_out(2, 3, 4);
  top y6 = x_height+oo; bot y8 = -oo; y5 = y7 = 0.5[y6, y8];
  x5 = x1; x7 = good.x(1.25u); x6 = x8 = 0.5[x5, x7];
  draw z5 up_to_left z6 left_to_down z7
  down_to_right z8 right_to_up z5;
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic b";
beginchar("b", 8u#, asc_height#, 0);
  italcorr .75x_height#*slant+0.5curve#-u# if math_fitting: -0.5u# fi;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = h; y2 = 0.5x_height; bot y3 = -oo;
  y4 = 0.5x_height; top y5 = x_height+oo;
  x1 = x2 = good.x 1.5u; x3 = 0.5[x2, x4];
  x4 = good.x(w-1.25u); x5 = 0.5[x2, x4];
  draw z1-cal.extension--z1..z2{down}
  ...z3{right}...z4{up}...z5{left}...z2{down};
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5);
endchar;

cmchar "Calligraphic c";
beginchar("c", 8u#, x_height#, 0);
  italcorr max(0.25x_height#*slant+0.5lower_cal_width#, 
    0.85x_height#*slant+0.5lower_cal_width#-1.1u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x2-x1 = hround u; rt x2 = hround(w-1.1u);
  if x2 > w-1.25u: x2 := good.x w-1.25u; fi
  x3 = 0.6[x4, x2]; x4 = good.x 1.25u;
  x5 = 0.5[x4, x6]; x6 = good.x w;
  top y3 = h+oo; y4 = .5h; bot y5 = -oo;
  y1 = good.y 0.65[y5, y3]; y2 = .8[y5, y3];
  y6 = good.y 1/4x_height;
  draw z1 ... z2 up_to_left z3 left_to_down
  z4 down_to_right z5...z6;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5, 6);
endchar;

cmchar "Calligraphic d";
beginchar("d", 9u#, asc_height#, 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    h#*slant+0.5lower_cal_width#-2u#) if math_fitting: -0.5u# fi;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = h; x1 = x2 = good.x(w-2.5u); x4 = w;
  draw z1-cal.extension--z1---hook_out(2, 3, 4);
  top y6 = x_height+oo; bot y8 = -oo; y5 = y7 = 0.5[y6, y8];
  x5 = x1; x7 = good.x(1.25u); x6 = x8 = 0.5[x5, x7];
  draw z5 up_to_left z6 left_to_down z7
  down_to_right z8 right_to_up z5;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic e";
beginchar("e", 8u#, x_height#, 0);
  italcorr max(0.25x_height#*slant+0.5lower_cal_width#, 
    0.85x_height#*slant+0.5lower_cal_width#-1.1u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  rt x1 = hround(w-1.1u); x2 = 0.6[x3, x1];
  if x1 > w-1.25u: x1 := good.x w-1.25u; fi
  x3 = good.x 1.25u; x4 = 0.5[x3, x5]; x5 = good.x w;
  y1 = 0.8[y4, y2]; top y2 = h+oo; y3 = .5h; bot y4 = -oo;
  y5 = good.y 1/4x_height;
  draw z3 right_to_up z1 up_to_left z2
  left_to_down z3 down_to_right z4...z5;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5);
endchar;

cmchar "Calligraphic f";
beginchar("f", 5.5u#, asc_height#, desc_depth#);
  italcorr asc_height#*slant+.75u#;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  z88 = (0.5w-0.5u, h); z89 = (0.5w+0.5u, -d);
  top y2 = h+oo; bot y5 = -d-oo; top y8 = top y9 = x_height;
  y2-y0 = y6-y5 = vround 0.35min(d, h-x_height);
  y1 = 0.5[y0, y2]; y6 = 0.5[y5, y7];
  y3 = 0.25[x_height, y2]; y4 = 0.5[y5, y3];
  rt x1-w = -lft x6 = hround 0.25u; x7-x6 = hround 0.5u;
  x0 = x1; x2 = 0.4[x1, x3]; x5 = 0.4[x6, x4];
  z3 = whatever[z88, z89]; z4 = whatever[z88, z89];
  lft x8 = hround(lft x3-0.5stem-1.25u);
  rt x9 = hround(rt x3+0.5stem+1.7u);
  draw (z0--z1) softjoin (z1 up_to_left z2....z3
    ---z4....z5{left}...z6);%...z7);
  draw z8..z9;
  %
  math_fit(desc_depth#*slant+u#, x_height#*slant);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic g";
beginchar("g", 8u#, x_height#, desc_depth#);
  italcorr x_height#*slant+0.5lower_cal_width#-u#;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = vround 0.98h;
  top y6 = x_height+oo; bot y8 = -oo; y5 = y7 = 0.5[y6, y8];
  x1 = x2 = x5 = good.x(w-1.5u); x4 = 1.5u;
  x7 = good.x(1.25u); x6 = x8 = 0.5[x5, x7];
  draw z1..desc_curve(2, 3, 4);
  draw z5 up_to_left z6 left_to_down z7
  down_to_right z8 right_to_up z5;
  %
  math_fit(-min(.3x_height#*slant+0.5curve#-u#, 
      1.5u#-desc_depth#*slant), ic#-1/3x_height#*slant);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic h";
beginchar("h", 9u#, asc_height#, 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    0.75x_height#*slant+0.5lower_cal_width#-2u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = h; bot y2 = -oo;
  x1 = x2 = good.x 1.5u;
  x4 = w-2.45u; x5 = w-2.80u; x7 = w;
  draw z1-cal.extension--z1--z2
  --ital_arch(2, 3, 4)...hook_out(5, 6, 7);
  %
  math_fit(0, ic#);
  labels(1, 2, 3, 4, 5, 6, 7);
endchar;

cmchar "Calligraphic i";
beginchar("i", 5u#, min(10/7x_height#+0.5flare#, asc_height#), 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    (h#-0.5flare#)*slant
    -2.5u#-0.4(h#-x_height#)*slant+0.5flare#+0.5u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = good.x(0.5w+0.30u);
  x4 = good.x(0.5w-0.30u); x6 = w;
  draw hook_in(1, 2, 3)...hook_out(4, 5, 6);
  %
  pickup fine_cal.nib;
  cal_dot7(0.5w-0.4(h-x_height)*slant, h+1-0.5flare, flare);
  %
  math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, ic#);
  labels(1, 2, 3, 4, 5, 6); penlabels(7, 7');
endchar;

cmchar "Calligraphic j";
beginchar("j", 5u#, min(10/7x_height#+0.5flare#, asc_height#), desc_depth#);
  italcorr max(0.8x_height#*slant+0.5lower_cal_width#-u#, 
    (h#-0.5flare#)*slant
    -1.5u#+0.5lower_cal_width#-0.6(h#-x_height#)*slant+0.5u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = x4 = good.x(w-1.5u);
  x6 = good.x 0; x0 = rt x3;
  draw hook_in(1, 2, 3)..desc_curve(4, 5, 6);
  %
  pickup fine_cal.nib;
  cal_dot7(x0-0.5flare-0.6(h-x_height)*slant, h+1-0.5flare, flare);
  %
  math_fit(desc_depth#*slant, x_height#*slant+0.5stem#-u#);
  labels(1, 2, 3, 4, 5, 6); penlabels(7, 7');
endchar;

cmchar "Calligraphic k";
beginchar("k", 8.5u#, asc_height#, 0);
  italcorr max(0.2x_height#*slant+0.1w#, 
    0.95x_height#*slant-0.1w#+0.5u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = h; bot y2 = -oo; x1 = x2 = good.x 1.5u;
  draw z1-cal.extension--z1--z2;
  %
  rt x4 = .9w; x5 = x4-.1w; x7 = .8w; rt x8 = 1.1w;
  y4 = .9x_height; top y5 = x_height+oo; bot y7 = -oo; y8 = .2x_height-oo;
  (lft z6)t_ = (x2, 0.4x_height).t_+penoffset up of pen_[lower_cal.nib];
  draw z4{up}...{left}z5..tension atleast 2..{down}z6
  ..tension atleast 3 and atleast 2..z7{right}...{up}z8; % diagonals
  %
  math_fit(0, 1/3x_height#*slant+0.5hair#+0.5u#);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic l";
beginchar("l", 4.5u#, asc_height#, 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    asc_height#*slant+0.5lower_cal_width#-2.1u#) if math_fitting: +0.5u# fi;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = h; x1 = x2 = good.x 1.9u; x4 = w;
  draw z1-cal.extension--z1---hook_out(2, 3, 4);
  %
  math_fit(-0.5u#, 1/3x_height#*slant+0.5hair#+u#);
  labels(1, 2, 3, 4, 5, 6, 7);
endchar;

cmchar "Calligraphic m";
beginchar("m", 15u#, x_height#, 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    0.75x_height#*slant+0.5lower_cal_width#-2u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = x4 = good.x 2.5u; x6 = x7 = good.x 0.5w;
  x9 = good.x(w-2.45u); x10 = good.x(w-2.80u); x12 = w;
  bot y4 = bot y7 = -oo;
  draw hook_in(1, 2, 3)---z4;
  draw ital_arch(4, 5, 6)---z7;
  draw ital_arch(7, 8, 9)...hook_out(10, 11, 12);
  %
  math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
endchar;

cmchar "Calligraphic n";
beginchar("n", 10u#, x_height#, 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    0.75x_height#*slant+0.5lower_cal_width#-2u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = x4 = good.x 2.5u; bot y4 = -oo;
  x6 = good.x(w-2.45u); x7 = good.x(w-2.80u);
  x9 = w;
  draw hook_in(1, 2, 3)---z4;
  draw ital_arch(4, 5, 6)...hook_out(7, 8, 9);
  %
  math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
endchar;

cmchar "Calligraphic o";
beginchar("o", 9u#, x_height#, 0);
  italcorr .7x_height#*slant+0.5lower_cal_width#-u#
  if math_fitting: -0.5u# fi;
  adjust_fit(0, 0);%(-0.25u#, -0.25u#);
  %
  pickup lower_cal.nib;
  top y1 = h+oo; bot y3 = -oo; y2 = y4 = 0.5[y1, y3];
  x2 = good.x 1.25u; x4 = good.x(w-1.25u); x1 = x3 = 0.5[x2, x4];
  draw z1 left_to_down z2 down_to_right
  z3 right_to_up z4 up_to_left z1;
  % not good
%  x5 = good.x 0.75[x2, x1]; x6 = 0.5[x5, x7]; x7 = good.x w;
%  y5 = 0.75[y6, y1]; y6 = good.y 0.6[y3, y1]; y7 = good.y 3/4x_height;
%  draw z1{left}...z5 down_to_right z6...z7;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7);
endchar;

cmchar "Calligraphic p";
beginchar("p", 9u#, x_height#, desc_depth#);
  italcorr .7x_height#*slant+0.5lower_cal_width#-u#
  if math_fitting: -0.5u# fi;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = x4 = good.x 2.5u; bot y4 = -d-eps;
  draw hook_in(1, 2, 3)..z4;
  top y6 = x_height+oo; bot y8 = -oo; y5 = y7 = 0.5[y6, y8];
  x5 = good.x(w-1.25u); x7 = x3; x6 = x8 = 0.5[x5, x7];
  draw z5 up_to_left z6 left_to_down z7
  down_to_right z8 right_to_up z5;
  %
  math_fit(-min(2/3x_height#*slant-0.5hair#-0.5u#, 
      2u#-0.5stem#-desc_depth#*slant), ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic q";
beginchar("q", 8u#, x_height#, desc_depth#);
  italcorr x_height#*slant+0.5lower_cal_width#-u#;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = vround 0.98h; bot y2 = -d-eps;
  x1 = x2 = good.x(w-1.5u);
  draw z1--z2--z2+cal.extension;
  top y6 = x_height+oo; bot y8 = -oo; y5 = y7 = 0.5[y6, y8];
  x5 = x1; x7 = good.x(1.25u); x6 = x8 = 0.5[x5, x7];
  draw z5 up_to_left z6 left_to_down z7
  down_to_right z8 right_to_up z5;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#-1/3x_height#*slant);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic r";
beginchar("r", 7.25u#, x_height#, 0);
  italcorr 0.8x_height#*slant+0.5lower_cal_width#-0.15u#;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = x4 = good.x 2.5u; bot y4 = -oo;
  draw hook_in(1, 2, 3)---z4;
  y5 = y2; y7 = good.y 0.65[y4, y5]; y6 = .8[y4, y5];
  x6 = good.x(w-0.65u); x6-x7 = hround 0.75u; x5 = 0.75[x4, x6];
  draw z4{up}...z5 right_to_down z6...z7;
  %
  math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, ic#-0.5u#);
  labels(1, 2, 3, 4, 5, 6, 7);
endchar;

cmchar "Calligraphic s";
beginchar("s", 5.25u#+1.75u#, x_height#, 0);
  italcorr 0.9x_height#*slant-0.05w#+0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  rt x0 = rt x1 = .95w; x2 = .5[x3, x1]; lft x3 = .15w; x4 = .5[x6, x2];
  rt x5 = w; x6 = .5w; lft x7 = 0; lft x8 = .075w;
  y0 = .8h; y1 = .9h; top y2 = h+o; y3 = .55[y4, y2]; y4 = .55[y6, y2];
  y5 = .45[y6, y4]; bot y6 = -o; y7 = .2h; y8 = .35h;
  draw\\(z0--z1) softjoin (z1...z2{left}...z3{down}...z4...z5{down}
    ...z6{left}...z7) softjoin (z7{up}...{right}z8); % stroke
  math_fit(0, ic#);
  labels(0, 1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic t";
beginchar("t", 5.5u#, min(asc_height#, 10/7x_height#), 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    x_height#*slant-.25u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = h; x1 = x2 = good.x 2u; x4 = w;
  draw z1---hook_out(2, 3, 4);
  lft x5 = hround -0.75u; rt x6 = hround(w-0.65u);
  top y5 = top y6 = x_height;
  draw z5..z6;
  %
  math_fit(1.25u#-x_height#*slant, ic#);
  labels(1, 2, 3, 4, 5, 6);
endchar;

cmchar "Calligraphic u";
beginchar("u", 9.5u#, x_height#, 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    x_height#*slant+0.5lower_cal_width#-2u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = good.x(2.80u); x4 = good.x(2.3u);
  x5 = 0.5[x4, x6]; x6 = x7 = x8 = good.x(w-2.5u); x10 = w;
  y4 = 0.7[y5, y6]; bot y5 = -oo; y6 = 0.57h; top y7 = h;
  draw hook_in(1, 2, 3)...z4 down_to_right z5...z6{up};
  draw z7..hook_out(8, 9, 10);
  %
  math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, ic#);
  labels(1, 2, 3, 4, 6, 7, 8, 9, 10);
endchar;

%cmchar "Calligraphic v";
% beginchar("v", 8u#, x_height#, 0);
%   italcorr 0.8x_height#*slant;
%   adjust_fit(0, 0.5u#);
%   %
%   pickup lower_cal.nib;
%   x1 = 0; top y1 = h; z3 = (.48w, 0);
%   z0.t_ = z2.t_+penoffset down of currentpen
%   = z3.t_+penoffset down of pen_[tilted.nib];
%   draw z1{right}..tension atleast 1 and infinity..z2; % left diagonal
%   pickup tilted.nib;
%   rt x4 = w; x5 = x4-.2w; top y4 = .8h; top y5 = h;
%   path p; p = z3..tension atleast 3 and 1..{up}z4;
%   erase fill z0--(x0, y0-0.5h)--(x4, y0-0.5h)--(x4+eps, y4)--reverse p--cycle;
%   draw p...{left}z5; % right diagonal
%   %
%   math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, 2/3ic#);
%   labels(0, 1, 2, 3, 4, 5);
% endchar;

cmchar "Calligraphic v";
beginchar("v", 8.75u#, x_height#, 0);
  italcorr .7x_height#*slant+0.5lower_cal_width#-u#
  if math_fitting: -0.5u# fi; % same as "o"
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = good.x(2.80u); x4 = good.x(2.3u);
  x5 = 0.5[x4, x6]; x6 = good.x(w-1.25u); x7 = good.x(w-2.25u);
  y4 = 0.7[y5, y6]; bot y5 = -oo; y6 = 0.57h; top y7 = h+oo;
  draw hook_in(1, 2, 3)...z4 down_to_right z5...z6{up}...z7;
  %
  math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7);
endchar;

cmchar "Calligraphic w";
% beginchar("w", 12.3u#, x_height#, 0);
%   italcorr 0.8x_height#*slant;
%   adjust_fit(0.2u#, 0.5u#);
%   %
%   pickup lower_cal.nib;
%   x1 = 0; x3 = .5[x1, x6]; x6 = .52w;
%   x9 = .58[x6, x10]; y3 = y9 = 0; top y1 = top y6 = h;
%   z7 = .5[z8, z6]+bend; z4 = .5[z3, z5]+bend;
%   (z0)t_ = (z2)t_+penoffset down of currentpen
%   = (z3)t_+penoffset down of pen_[tilted.nib];
%   (z20)t_ = (z8)t_+penoffset down of currentpen
%   = (z9)t_+penoffset down of pen_[tilted.nib];
%   draw z1{right}..tension atleast 1 and infinity..z2; % first diagonal
%   pickup tilted.nib;
%   x5 = x6; rt x10 = w;
%   x11 = x10-.1w; top y5 = h; top y10 = .8h; top y11 = h;
%   erase fill z0--(x0, y0-0.5h)--(x5, y0-0.5h)--z5..z4..z3--cycle;
%   draw z3..z4..z5; % second diagonal
%   pickup lower_cal.nib;
%   erase fill\\(.3w, bot y6)--(w, bot y6)--(w, top y6)--(.3w, top y6)--cycle;
%   draw z6..z7..z8; % third diagonal
%   pickup tilted.nib;
%   path p; p = z9..tension atleast 3 and 1..{up}z10;
%   erase fill z20--(x20, y20-0.5h)--(x10, y20-0.5h)--(x10+eps, y10)
%   --reverse p--cycle;
%   draw p..{left}z11; % fourth diagonal
%   %
%   math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, 3/4ic#);
%   labels(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20);
% endchar;

cmchar "Calligraphic w";
beginchar("w", 12.5u#, x_height#, 0);
  italcorr .7x_height#*slant+0.5lower_cal_width#-u#
  if math_fitting: -0.5u# fi; % same as "o"
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = good.x(2.80u); x4 = good.x(2.3u);
  x5 = 0.5[x4, x6]; x6 = x7 = good.x 0.5[2.5u,w-1.5u]; x8 = 0.5[x6,x9];
  x9 = good.x(w-1.25u); x10 = good.x(w-2.25u);
  y4 = 0.7[y5, y6]; bot y5 = bot y8 = -oo; y6 = y9 = 0.57h;
  top y7 = top y10 = h+oo;
  draw hook_in(1, 2, 3)...z4 down_to_right z5...z6---z7;
  draw z6 down_to_right z8...z9{up}...z10;
  %
  math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7);
endchar;

cmchar "Calligraphic x";
beginchar("x", 8.25u#, x_height#, 0);
  italcorr max(1/9x_height#*slant, 0.9x_height#*slant+.5u#);
  adjust_fit(0, 0.25u#);
  %
  pickup lower_cal.nib;
  lft x1 = .08w; lft x2 = .2w; x4-x3 = x2-x1; rt x4 = w;
  h-y1 = y4 = 1/9h; top y2 = h; bot y3 = 0;
  draw z1{up}....z2{right}
  ... .2[z2+(.1w, 0), z3-(.1w, 0)]---.8[z2+(.1w, 0), z3-(.1w, 0)]
  ...{right}z3....{up}z4; % left diagonal
  x5 = x6-u; rt x6 = w; lft x7 = 0; x8 = x7+u;
  top y5 = h; y6 = .85h; y7 = h-y6; bot y8 = 0;
  draw z5{right}...z6{down}
  ..tension atleast 3..{down}z7...{right}z8; % right diagonal
  %
  math_fit(0, ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

cmchar "Calligraphic y";
beginchar("y", 8.5u#, x_height#, desc_depth#);
  italcorr x_height#*slant+0.5lower_cal_width#-0.5u#;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = good.x(2.80u); x4 = x10 = good.x(2.3u);
  x5 = 0.5[x4, x6]; x6 = x7 = x8 = good.x(w-1.5u);
  y4 = 0.7[y5, y6]; bot y5 = -oo; y6 = 0.57h; top y7 = h;
  draw hook_in(1, 2, 3)...z4 down_to_right z5...z6{up};
  draw z7..desc_curve(8, 9, 10);
  %
  math_fit(-2/3x_height#*slant+0.5hair#+0.5u#, ic#-1/3x_height#*slant);
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
endchar;

cmchar "Calligraphic z";
beginchar("z", 5.5u#+max(1.5u#, stem#), x_height#, 0);%desc_depth#);
  italcorr x_height#*slant+0.5lower_cal_width#;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  y1 = good.y 3/4x_height;
  top y2 = h+oo; top y3 = vround 0.98h+eps;
  bot y4 = -oo; bot y5 = -oo;
  y6 = good.y 1/4x_height;
  x1 = x4 = good.x u; x6 = good.x w; x6-x3 = hround 0.5u;
  x2 = 0.25[x1, x3]; x5 = 0.25[x6, x4];    
  draw z1 ... z2{right}..{z3-z4}z3
  --z4{z3-z4}..z5{right}... z6;
  %
  math_fit(0, 1/3x_height#*slant+0.5hair#+0.5u#);
  labels(1, 2, 3, 5, 6);
endchar;

%
% LATIN EXTENSION
%
% the three first have been checked: design, metrics
% and italic corrections (nov. 28, 2002).
%

cmchar "Calligraphic dotless i";
beginchar(hex"10", 5u#, x_height#, 0);% height
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    0.8x_height#*slant+0.5lower_cal_width#-1.7u#);
  italcorr 1/3x_height#*slant+0.5hair#+0.5u#;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = good.x(0.5w+0.30u);
  x4 = good.x(0.5w-0.30u); x6 = w;
  draw hook_in(1, 2, 3)...hook_out(4, 5, 6);
  %
  math_fit(0, 0);
  labels(1, 2, 3, 4, 5, 6, 7);
endchar;

cmchar "Calligraphic dotless j";
beginchar(hex"11", 5u#, x_height#, desc_depth#);
  italcorr max(0.8x_height#*slant+0.5lower_cal_width#-u#, 
    0.8x_height#*slant+0.5lower_cal_width#-0.5u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = 0; x3 = x4 = good.x(w-1.5u);
  x6 = good.x 0;
  draw hook_in(1, 2, 3)..desc_curve(4, 5, 6);
  %
  math_fit(0, 0);
  labels(1, 2, 3, 4, 5, 6);
endchar;

cmchar "Calligraphic es-zet";
beginchar(oct"31", 8u#, asc_height#, desc_depth#);
  italcorr max(.8h#*slant-.1w#, .5x_height#*slant)+.5u#;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  x1 = x3 = good.x 1.5u; x4 = .6[x2, x5]; rt x5 = .9w; x6 = .4w;
  rt x7 = w;
  x8 = .4[x9, x7]; lft x9 = rt x3;
  top y1 = x_height+oo; bot y3 = -d-eps; z2 = .3[z3, z1]+bend;
  top y4 = h+oo; y5 = .6[y6, y4]; y6 = .55h; y7 = .45[y8, y6];
  bot y8 = -oo; y9 = .1h;
  draw z1-cal.extension--flex(z1, z2, z3);  % stem
  draw z2{up}...z4...z5{down}...{dir 200}z6{dir 10}
  ...z7{down}...z8{left}...z9;  % lobes
  %
  math_fit(.5u#, .3h#*slant+.5u#);
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9);
endchar;

cmchar "Calligraphic ae";
beginchar(oct"32", 13u#, x_height#, 0);
  italcorr max(0.25x_height#*slant+0.5lower_cal_width#, 
    0.85x_height#*slant+0.5lower_cal_width#-1.1u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = h+oo; bot y3 = -oo; y2 = y4 = 0.5[y1, y3];
  x2 = good.x 1.25u; x4 = good.x 0.5w;
  x1 = 0.5[x2, x4]; x3 = 0.5[x2, x4];
  draw z1 left_to_down z2 down_to_right
  z3 right_to_up z4 up_to_left z1;
  %
  rt x5 = hround(w-1.1u); x6 = 0.6[x7, x5];
  if x5 > w-1.25u: x5 := good.x w-1.25u; fi
  x7 = x4; x8 = 0.5[x7, x9]; x9 = good.x w;
  y5 = 0.8[y8, y6]; top y6 = h+oo; y7 = .5h; bot y8 = -oo;
  y9 = good.y 1/4x_height;
  draw z7 right_to_up z5 up_to_left z6
  left_to_down z7 down_to_right z8...z9;
  %
  top y10=vround 0.98h; bot y11=0;
  x10=x11=x4; draw z10..z11;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
endchar;

cmchar "Calligraphic oe";
beginchar(oct"33", 13u#, x_height#, 0);
  italcorr max(0.25x_height#*slant+0.5lower_cal_width#, 
    0.85x_height#*slant+0.5lower_cal_width#-1.1u#);
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = h+oo; bot y3 = -oo; y2 = y4 = 0.5[y1, y3];
  x2 = good.x 1.25u; x4 = good.x 0.5w; x1 = x3 = 0.5[x2, x4];
  draw z1 left_to_down z2 down_to_right
  z3 right_to_up z4 up_to_left z1;
  %
  rt x5 = hround(w-1.1u); x6 = 0.6[x7, x5];
  if x5 > w-1.25u: x5 := good.x w-1.25u; fi
  x7 = x4; x8 = 0.5[x7, x9]; x9 = good.x w;
  y5 = 0.8[y8, y6]; top y6 = h+oo; y7 = .5h; bot y8 = -oo;
  y9 = good.y 1/4x_height;
  draw z7 right_to_up z5 up_to_left z6
  left_to_down z7 down_to_right z8...z9;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9);
endchar;

cmchar "Calligraphic o/slash";
beginchar(oct"34", 9u#, x_height#+0.5desc_depth#, 0.5desc_depth#);
  italcorr .7x_height#*slant+0.5lower_cal_width#-u#
  if math_fitting: -0.5u# fi;
  adjust_fit(0, 0);%(-0.25u#, -0.25u#);
  %
  pickup lower_cal.nib;
  top y1 = x_height+oo; bot y3 = -oo; y2 = y4 = 0.5[y1, y3];
  x2 = good.x 1.25u; x4 = good.x(w-1.25u); x1 = x3 = 0.5[x2, x4];
  draw z1 left_to_down z2 down_to_right
  z3 right_to_up z4 up_to_left z1;
  %
  pickup fine_cal.nib;
  x5=good.x x4; x6=good.x x2; top y5=h+eps; bot y6=-d-eps; draw z5..z6;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5, 6);
endchar;

cmchar "Calligraphic AE";
beginchar(oct"35",18u#,cap_height#,0);
  italcorr max(h#*slant-.1w#,.2h#*slant)+.5u#;
  adjust_fit(0,0); pickup cal.nib;
  w':=hround 8.5u;
  x1=.9[x3,x2]; rt x2=.9w'+w-w'; x3=.6[x4,x2]; lft x4=.05w'+w-w';
  x5=.7[x6,x2]; lft x6=w-w'; x7=.5[x6,x8]; rt x8=w;
  y1=y2-.1h; y2=.9h+o; top y3=h+o; y4=.5[y5,y3];
  y5=.55h; y6=.6[y5,y7]; bot y7=-o; y8=.2h;
  %
  pickup tilted.nib;
  lft x4'=.05w'+w-w';
  w':=hround 14.4u;
  lft x1'=.05w'; x2'=.2w';
  y1'=y2'+.1h; bot y2'=bot_flourish_line;
  y3'=y6; z3'=whatever[z2',z4]+2bend; y4'=y4;
  draw\\(z1'..tension 1.2..{right}z2') softjoin (z2'...z3'...z4'{up});
% left diagonal
  pickup cal.nib;
  draw\\(z1{2(x2-x1),y2-y1}...z2)
  softjoin (z2...z3{left}...z4{down}...{right}z5);  % upper arc
  draw z5{left}...z6{down}...z7{right}...z8;  % lower arc
  draw rt z3'--z6;  % bar
  math_fit(.5u#-.2h#*slant,.2h#*slant+.5u#);
  labels(1',2',3',4',1,2,3,4,5,6,7,8);
endchar;

cmchar "Calligraphic OE";
beginchar(oct"36",16u#,cap_height#,0);
  italcorr max(h#*slant-.1w#,.2h#*slant)+.5u#;
  adjust_fit(0,0); pickup cal.nib;
  w':=hround 8.5u;
  x1=.9[x3,x2]; rt x2=.9w'+w-w'; x3=.6[x4,x2]; lft x4=.05w'+w-w';
  x5=.7[x6,x2]; lft x6=w-w'; x7=.5[x6,x8]; rt x8=w;
  y1=y2-.1h; y2=.9h+o; top y3=h+o; y4=.5[y5,y3];
  y5=.55h; y6=.6[y5,y7]; bot y7=-o; y8=.2h;
  draw\\(z1{2(x2-x1),y2-y1}...z2)
  softjoin (z2...z3{left}...z4{down}...{right}z5);  % upper arc
  draw z5{left}...z6{down}...z7{right}...z8;  % lower arc
  %
  w':=hround 12.6u;
  x1'=.3w'; lft x2'=0; x3'=0.6[x2',x6]; x5'=0.75[x2',x4];
  lft x6'=.27w';
  top y1'=top y5'=h+o; y2'=.55h; bot y3'=-o; y6'=y2';
  draw z1'...z2'{down}...z3'{right}...z6{up};
  save p; path p; p = z4{up}...z5'{left}...{down}z6';
  draw subpath (0,1.8) of p;
  math_fit(.5u#-.2h#*slant,.2h#*slant+.5u#);
  labels(1',2',3',5',6',1,2,3,4,5,6,7,8);
endchar;

cmchar "Calligraphic O/slash";
beginchar(oct"37",12.6u#,cap_height#+0.25desc_depth#, 0.25desc_depth#);
  italcorr .7h#*slant+.5u#;
  adjust_fit(0,0); pickup cal.nib;
  x1=.3w; lft x2=0; x3=.5w; rt x4=w; x5=.6w; lft x6=.27w;
  top y1=top y5=cap_height+o; y2=.55cap_height;
  bot y3=-o; y4=.5cap_height; y6=y2;
  path p; p=z1...z2{down}...z3{right}...z4{up}...z5{left}...{down}z6;
  draw subpath(0,4.8) of p;  % bowl
%  pickup .nib;
  top y7= vround(h+0.25desc_depth)+eps; bot y8=-hround(0.25desc_depth)-eps;
  x7 = good.x x4; x8 = good.x 0.1[x2, x6]; draw z7..z8;
  math_fit(.5u#-.3h#*slant,ic#-.5u#);
  labels(1,2,3,4,5,6);
endchar;

%
% DIGITS
%

beginchar("0", 9u#, fig_height#, 0);
  "The digit 0";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  numeric a; a = min(0.25h, 0.5(x_height-o));
  top y1 = h+o; bot y3 = -o; y2 = y4 = 0.5[y1, y3];
  lft x2 = hround max(0.7u, lft 1.45u); x4 = w-x2;
  x1 = x3 = 0.5[x2, x4];
  draw z1 left_to_down z2 down_to_right z3
  right_to_up z4 up_to_left z1;
  labels(1, 2, 3, 4);
  math_fit(0, 0.5ic#);
endchar;

beginchar("1", 9u#, fig_height#, 0);
  "The digit 1";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  top y2 = h+o; bot y3 = -max(hround(0.05h)+eps, oo); y1 = good.y 0.35[y2, y3];
  rt x2-lft x1 = hround 4.875u; rt x2 = w-hround 2.125u;
  rt x3 = w-hround 3.75u;
  draw z1{x2-x1, 0.5(y2-y1)}...z2 & z2{x3-x2, 0.4(y3-y2)}...{down}z3;
  labels(1, 2, 3);
  math_fit(0, 0.5ic#);
endchar;

beginchar("2", 9u#, fig_height#, 0);
  "The digit 2";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  top y2 = h+o; bot y5 = bot y6 = 0; y1 = y3 = good.y 0.75h;
  lft x1 = lft x5+eps = hround u; rt x3 = rt x6-eps = w-hround u;
  x2 = x4 = 0.5[x1, x3]; y4 = 0.4[y5, y3];
  draw z1 up_to_right z2 right_to_down z3...z4---z5--z6;
  labels(1, 2, 3, 4, 5, 6);
  math_fit(0, 0.5ic#);
endchar;

% beginchar("3", 9u#, fig_height#, 0);
%   "The digit 3";
%   italcorr fig_height#*slant-0.5u#;
%   adjust_fit(0, 0);
%   pickup lower_cal.nib;
%   bot y2 = -o; top y5 = top y6 = x_height;
%   y1 = good.y 1/4x_height;
%   y3 = a; y5-y4 = y3-y2; top y7 = top y8 = h;
%   rt x3 = w-hround u; x3 = x4 = x7+hround 0.5u-eps;
%   lft x1 = hround u; x1+hround 0.5u-eps = x8;
%   lft x6 = hround 3u-eps;
%   x2 = x5 = 0.5[x1, x3];
%   draw z1 ... z2 right_to_up z3..z4 up_to_left z5--z6--z7--z8;
%   labels(1, 2, 3, 4, 5, 6, 7, 8);
%   math_fit(0, 0.5ic#);
% endchar;

beginchar("3", 9u#,fig_height#,0);
  "The digit 3";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0,0); pickup lower_cal.nib;
  lft x2 = hround 1.25u; x3=.46[x2,x4]; x4=good.x(w-2u);
  x5=.7[x6,x2]; x6= good.x(w-1.25u); x7=.5[x6,x8]; lft x8 = hround u;
  x1=good.x 0.6[x5, x2];
  %y1=y2-.1h;
  y2=.85h+oo; top y3=h+oo; y4=.5[y5,y3];
  y5=good.y .55h; y6=.5[y5,y7]; bot y7=-oo; y8=good.y 1/4x_height;
  y1 = good.y 0.55[y5, y3];
  draw\\(z1{2(x2-x1),y2-y1}...z2)
  softjoin (z2...z3 right_to_down z4...{left}z5);  % upper arc
  draw z5 right_to_down z6...z7{left}...z8;  % lower arc
  math_fit(.5u#-.2h#*slant,.2h#*slant+.5u#);
  labels(1,2,3,4,5,6,7,8);
endchar;

beginchar("4", 9u#, fig_height#, 0);
  "The digit 4";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  top y1 = h+o; bot y5 = -max(hround(0.05h)+eps, oo); top y4 = x_height+eps;
  y2 = y3 = good.y(0.5x_height);
  rt x3 = w-hround 0.1u+eps;
  lft x2 = hround 0.5u-eps;
  x1 = good.x 0.33[x2, x3];
  x4 = good.x 0.725[x2, x3];
  x5 = good.x 0.475[x2, x3];
  draw z1{down}...z2--z3; draw z4{x5-x4, 0.45(y5-y4)}..z5{down};
  labels(1, 2, 3, 4, 5);
  math_fit(0, 0.5ic#);
endchar;

beginchar("5", 9u#, fig_height#, 0);
  "The digit 5";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  bot y2 = -o; top y4 = x_height+eps; y1 = good.y 1/4x_height;
  y3 = 0.5[y2, y4]; y5 = good.y 0.2[y4, y2]; top y6 = top y7 = h;
  rt x3 = w-hround u; x3 = x7+hround 0.5u-eps;
  lft x1 = hround u; x1+hround 0.5u = x5 = x6;
  x2 = x4 = 0.5[x1, x3];
  draw z1 ... z2 right_to_up z3
  up_to_left z4 ... z5&z5..{0.5(x6-x4), y6-y4}z6&z6..{x7-x5, 0.5(y7-y5)}z7;
  labels(1, 2, 3, 4, 5, 6, 7);
  math_fit(0, 0.5ic#);
endchar;

beginchar("6", 9u#, fig_height#, 0);
  "The digit 6";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  top y2 = h+o; bot y4 = -o; y1 = good.y(h-0.2x_height);
  top y6 = x_height+eps; y3 = 0.45[y4, y2]; y5 = 0.5[y4, y6];
  lft x3 = hround max(0.7u, lft 1.45u); x5 = w-x3;
  rt x1 = w-hround u; x2 = 0.6[x3, x1]; x4 = x6 = 0.5[x3, x5];
  draw z1 ... z2{left} ... z3 down_to_right z4
  right_to_up z5 up_to_left z6 ...z3;
  labels(1, 2, 3, 4, 5, 6);
  math_fit(0, 0.5ic#);
endchar;

beginchar("7", 9u#, fig_height#, 0);
  "The digit 7";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  top y2 = top y3 = h+o; bot y4 = -max(hround(0.05h)+eps, oo);
  y1 = good.y 0.3[y2, y4];
  lft x1 = lft x2 = hround 0.75u; rt x3 = w-hround 0.25u;
  x4 = good.x 0.4[x2, x3];
  draw z1{0.2(x3-x1), y3-y1}..z2 & z2{x4-x2, 0.2(y4-y2)}..z3
  &z3{x4-x3, 0.4(y4-y3)}..z4;
  labels(1, 2, 3, 4);
  math_fit(0, 0.5ic#);
endchar;

beginchar("8", 9u#, fig_height#, 0);
  "The digit 8";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  bot y1 = vround 0.5h; bot y4 = -o;
  y1-y2 = y1-y6 = y3-y4; y3 = y5 = a;
  lft x2 = lft x3 = hround u;
  rt x5 = rt x6 = w-hround u;
  x1 = x4 = x7 = 0.5[x2, x6];
  top y7 = h+o; y8 = y9 = 0.5[y7, y1];
  lft x8 = w-rt x9 = hround 1.4u-eps;
  draw z1 left_to_down z2..z3 down_to_right z4 right_to_up z5..z6
  up_to_left z1; draw superellipse(z9, z7, z8, z1, superness);
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9);
  math_fit(0, 0.5ic#);
endchar;

beginchar("9", 9u#, fig_height#, 0);
  "The digit 9";
  italcorr fig_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  bot y2 = -o; top y4 = h+o; y1 = good.y 0.2x_height;
  bot y6 = h-x_height-eps; y3 = 0.45[y4, y2]; y5 = 0.5[y4, y6];
  lft x5 = hround max(0.7u, lft 1.45u); x3 = w-x5;
  lft x1 = hround u; x2 = 0.6[x3, x1]; x4 = x6 = 0.5[x3, x5];
  draw z1 ... z2{right}... z3 up_to_left z4
  left_to_down z5 down_to_right z6 ...z3;
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9);
  math_fit(0, 0.5ic#);
endchar;

%
% PUNCTUATION
%

call_spanish_query:=0;
call_spanish_shriek:=1;
call_laquo:=2;
call_raquo:=3;

vardef complete_quote@#(expr $,$$)=
  pickup lower_cal.nib;
  bot y@#.c=hround 0.06h; y@#.b=good.y 0.5h; y@#.a-y@#.b=y@#.b-y@#.c;
  if $$<0: lft x@#.a=lft x@#.c=rt x@#.b-(hround 4u+2eps)=$;
  else: rt x@#.a=rt x@#.c=lft x@#.b+(hround 4u+2eps)=$; fi
  draw z@#.a{(z@#.b-z@#.a) yscaled 3}..z@#.b
  &z@#.b..{(z@#.c-z@#.b) yscaled 3}z@#.c;
  labels(@#.a,@#.b,@#.c);
enddef;

beginchar("<",8u#,x_height#,0);
  "French single opening quote";
  complete_quote1(w-hround 2u+eps,1);
endchar;

beginchar(">",8u#,x_height#,0);
  "French single closing quote";
  complete_quote1(hround 2u-eps,-1);
endchar;

beginchar(call_laquo,10u#,x_height#,0);
  "French double opening quote";
  complete_quote1(w-hround u+eps,1);
  complete_quote2(w-hround 4u+eps,1);
endchar;

beginchar(call_raquo,10u#,x_height#,0);
  "French double closing quote";
  complete_quote1(hround u-eps,-1);
  complete_quote2(hround 4u-eps,-1);
endchar;

cmchar "Hash mark (number sign)";
spread#:=math_spread[0.45x_height#,0.55x_height#];
spread:=2ceiling(spread#*hppp/2)+eps;
beginchar("#",15u#,asc_height#,asc_depth#);
  italcorr (math_axis#+.5(spread#+rth1#))*slant-.5u#;
  adjust_fit(0,0);
  pickup lower_cal.nib; lft x1=hround u-eps; x3=x1; x2=x4=w-x1;
  y1=y2; y3=y4; y1-y3=spread; .5[y1,y3]=math_axis;
  draw z1--z2;  % upper bar
  draw z3--z4;  % lower bar
  lft x6=hround 3u; rt x7=hround(w-3u); x5-x6=x7-x8;
  x8=good.x .5\\w;
  top y5=top y7=h+eps; bot y6=bot y8=-d-eps;
  y15=y1; z15=whatever[z5,z6]; y36=y3; z36=whatever[z5,z6];
  y27=y2; z27=whatever[z7,z8]; y48=y4; z48=whatever[z7,z8];
  draw z5--if x5>x6+1:(good.x(x15+.5),y1)--(good.x(x15-.5),y1)
    --(good.x(x36+.5),y3)--(good.x(x36-.5),y3)--fi\\z6;  % left diagonal
  draw z7--if x7>x8+1:(good.x(x27+.5),y2)--(good.x(x27-.5),y2)
    --(good.x(x48+.5),y4)--(good.x(x48-.5),y4)--fi\\z8;  % right diagonal
  labels(1,2,3,4,5,6,7,8,15,27,36,48);
endchar;

cmchar "Plus sign";
beginchar("+",arithmetic_bounds);
  pickup lower_cal.nib;
  x1=x2=good.x .5w; top y1=h+eps; .5[y1,y2]=math_axis;
  lft x3=hround u-eps; x4=w-x3; y3=y4=math_axis;
  draw z1--z2;  % stem
  draw z3--z4;  % crossbar
  labels(1,2,3,4);
endchar;

beginchar("*",9u#,body_height#,0);
  "Asterisk";
  italcorr body_height#*slant-u#;
  pickup lower_cal.nib;
  top y1=h+eps; bot y2=h-x_height-eps;
  x1=x2=good.x 0.5w;
  x3=good.x (x1-3u*cosd 30);
  x1-x3=x1-x6=x5-x1=x4-x1;
  y3=good.y (0.5[y1,y2]+3u*sind 30);
  y1-y3=y1-y5=y4-y2=y6-y2;
  draw z1..z2; draw z3..z4; draw z5..z6;
  labels(1,2,3,4,5,6);
endchar;

cmchar "Virgule (slash)";
beginchar("/",9u#,body_height#,paren_depth#);
  italcorr body_height#*slant-.5u#;
  pickup fine_cal.nib;
  rt x1=hround(w-u)+eps; top y1=h+eps;
  lft x2=hround u-eps; bot y2=-d-eps;
  draw z1--z2;  % diagonal
  labels(1,2);
endchar;

beginchar("=",14u#,v_center(spread#+rth1#));
  italcorr h#*slant-.5u#;
  adjust_fit(0,0); pickup lower_cal.nib;
  lft x1=hround u-eps; x3=x1; x2=x4=w-x1;
  y1=y2; y3=y4; y1-y3=spread; .5[y1,y3]=math_axis;
  draw z1--z2;  % upper bar
  draw z3--z4;  % lower bar
  labels(1,2,3,4);
endchar;

cmchar "Calligraphic dot";
beginchar(".", 5u#, dtsz#, 0);
  italcorr 0.5u#;
  adjust_fit(0, 0);
  pickup fine_cal.nib;
  cal_dot1(0.5w, 0.5dtsz, dtsz);
  math_fit(0, 0);
  penlabels(1, 1');
endchar;

cmchar "Calligraphic comma";
beginchar(", ", 5u#, dtsz#, comma_depth#);
  italcorr 0.5u#;
  adjust_fit(0, 0);
  cal_comma1(0.5w, 0.5dtsz, 1, -comma_depth);
  math_fit(0, 0);
endchar;

cal_apostrophe=hex"27"; cal_reverse_apostrophe=hex"60";
cal_opening_quotes=hex"5C"; cal_closing_quotes=hex"22";

cmchar "Calligraphic apostrophe";
beginchar(cal_apostrophe, 5u#, asc_height#, 0);
  italcorr 0.5u#;
  adjust_fit(0, 0);
  cal_comma1(0.5w, h-0.5dtsz, 1, h-comma_depth-dtsz);
  math_fit(0, 0);
endchar;

cmchar "Calligraphic reverse apostrophe";
beginchar(cal_reverse_apostrophe, 5u#, asc_height#, 0);
  italcorr 0.5u#;
  adjust_fit(0, 0);
  cal_comma1(0.5w, h-0.5dtsz-comma_depth, 
    -1, h);
  math_fit(0, 0);
endchar;

cmchar "Calligraphic opening quotes";
beginchar(cal_opening_quotes, 7u#+max(2u#, dtsz#), 
    asc_height#, 0);
  italcorr 0.5u#;
  adjust_fit(0, 0);
  cal_comma1(w-0.6u-0.5dtsz, 
    h-0.5dtsz-comma_depth, -1, h);
  cal_comma2(w-0.6u-0.5dtsz-1.5u-max(2u, dtsz), 
    h-0.5dtsz-comma_depth, -1, h);
  math_fit(0, 0);
endchar;

cmchar "Calligraphic closing quotes";
beginchar(cal_closing_quotes, 7u#+max(2u#, dtsz#), 
    asc_height#, 0);
  italcorr 0.5u#;
  adjust_fit(0, 0);
  cal_comma1(0.6u+0.5dtsz, 
    h-0.5dtsz, 1, h-dtsz-comma_depth);
  cal_comma2(0.6u+0.5dtsz+1.5u+max(2u, dtsz), 
    h-0.5dtsz, 1, h-dtsz-comma_depth);
  math_fit(0, 0);
endchar;

cmchar "Calligraphic semicolon";
beginchar(";", 5u#, x_height#, comma_depth#);
  italcorr 0.5u#;
  adjust_fit(0, 0);
  pickup fine_cal.nib;
  cal_dot1(0.5w, h-0.5dtsz, dtsz);
  cal_comma2(0.5w, 0.5dtsz, 1, -comma_depth);
  math_fit(0, 0);
endchar;

cmchar "Calligraphic colon";
beginchar(":", 5u#, x_height#, 0);
  italcorr 0.5u#;
  adjust_fit(0, 0);
  pickup fine_cal.nib;
  cal_dot1(0.5w, 0.5dtsz, dtsz);
  cal_dot2(0.5w, h-0.5dtsz, dtsz);
  math_fit(0, 0);
  penlabels(1, 1', 2, 2');
endchar;

cmchar "Calligraphic hyphen";
beginchar("-", 6u#, x_height#, 0);
  italcorr 0.5x_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  y1 = y3 = good.y 0.5h;
  lft x1 = hround 0.2u-eps; rt x3 = hround(w-u)+eps;
  z2 = 0.5[z1, z3];
  draw z1{w, h}...z2{w, -0.5h}...z3{w, h};
  math_fit(0, 0);
  labels(1, 2, 3);
endchar;

cmchar "Calligraphic en-dash";
beginchar(oct"173", 9u#, x_height#, 0);
  italcorr 0.61803x_height#*slant+0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  y1 = y2 = good.y 0.61803h; lft x1 = -eps; rt x2 = w+eps;
  draw z1..z2; math_fit(0, 0); labels(1, 2);
endchar;

cmchar "Calligraphic em-dash";
beginchar(oct"174", 18u#, x_height#, 0);
  italcorr 0.61803x_height#*slant+0.5u#;
  adjust_fit(letter_fit#, letter_fit#);
  pickup lower_cal.nib;
  y1 = y2 = good.y 0.61803h; lft x1 = -eps; rt x2 = w+eps;
  draw z1..z2; math_fit(0, 0); labels(1, 2, 3);
endchar;

beginchar("(", 6u#, asc_height#, desc_depth#);
    italcorr asc_height#*slant;
    adjust_fit(0, 0);
    pickup med_cal.nib;
    top y1 = h; bot y3 = -d; y2 = 0.5(y1+y3);
    rt x1 = rt x3 = hround(w-0.5u); lft x2 = hround u;
    draw z1{x2-x1, 0.5(y2-y1)}...z2{down}...{x3-x2, 0.5(y3-y2)}z3;
    labels(1, 2, 3);
  endchar;

  beginchar(")", 6u#, asc_height#, desc_depth#);
  italcorr asc_height#*slant;
  adjust_fit(0, 0);
  pickup med_cal.nib;
  top y1 = h; bot y3 = -d; y2 = 0.5(y1+y3);
  lft x1 = lft x3 = hround(0.5u); rt x2 = hround(w-u);
  draw z1{x2-x1, 0.5(y2-y1)}...z2{down}...{x3-x2, 0.5(y3-y2)}z3;
  labels(1, 2, 3);
endchar;

beginchar("[", 6u#, asc_height#, desc_depth#);
  italcorr asc_height#*slant;
  adjust_fit(0, 0);
  pickup med_cal.nib;
  top y1 = top y2 = h; bot y4 = bot y5 = -d; y3 = 0.5[y1, y5]; 
  rt x1 = rt x5 = hround(w-0.25u); lft x2 = lft x4 = hround 1.25u;
  lft x3 = hround 1.5u;
  draw z1--z2...z3{down}...z4--z5;
  labels(1, 2, 3, 4, 5);
endchar;

beginchar("]", 6u#, asc_height#, desc_depth#);
  italcorr asc_height#*slant;
  adjust_fit(0, 0);
  pickup med_cal.nib;
  top y1 = top y2 = h; bot y4 = bot y5 = -d; y3 = 0.5[y1, y5]; 
  lft x1 = lft x5 = hround(0.25u); rt x2 = rt x4 = hround(w-1.25u);
  rt x3 = hround(w-1.5u);
  draw z1--z2...z3{down}...z4--z5;
  labels(1, 2, 3, 4, 5);
endchar;

beginchar("!", 5u#, asc_height#, 0);
  "Exclamation point";
  italcorr asc_height#*slant-2u#+0.5curve#;
  adjust_fit(0, 0);
  pickup med_cal.nib;
  x1=x2=good.x 0.5w;
  top y2= h+eps;
  cal_dot3(0.5w, 0.5dtsz, dtsz);
  bot y1=ceiling 0.25[top y3.b, x_height]-eps;
  draw z1..z2; labels(1, 2);
endchar;

beginchar(call_spanish_shriek, 5u#, asc_height#-desc_depth#, desc_depth#);
  "Spanish shriek";
  italcorr (charht-0.5dtsz#)*slant-2u#+0.5dtsz#;
  adjust_fit(0, 0);
  pickup med_cal.nib;
  x1=x2=good.x 0.5w;
  bot y2=-d-eps;
  cal_dot3(0.5w, h-0.5dtsz, dtsz);
  top y1=floor 0.25[bot y3.d, h-x_height]+eps;
  draw z1..z2; labels(1, 2);
endchar;

cmchar "Question mark";
beginchar("?", 9u#, asc_height#, 0);
  italcorr 0.8asc_height#*slant-0.5u#;
  pickup med_cal.nib;
  cal_dot9(0.5w, 0.5dtsz, dtsz);
  top y4 = h+oo; bot y7=ceiling 0.25[top y9.b, x_height]-eps;
  y2=good.y 0.5[y7, y4]; y3=y5=0.5[y2,y4]; y1= good.y 0.4[y2,y3];
  y6=1/9[y7,y4]; y8 = good.y 0.8[y7, y6];
  x3=good.x 1.5u; x5=good.x(w-1.25u); x4=0.55[x3,x5]; x7=0.5w;
  x1=good.x 0.5[x3,x5]; x2=0.25[x3,x5]; x6=good.x 2/3[x3,x4];
  x8=good.x 0.5[x7,x5];
  draw z1...z2 left_to_up z3 ...z4 right_to_down z5...z6 down_to_right z7...z8;
  labels(1, 2, 3, 4, 5, 6,7,8);
endchar;

beginchar(call_spanish_query, 9u#, asc_height#-desc_depth#, desc_depth#);
  "Spanish query";
  pickup med_cal.nib;
  cal_dot9(0.5w, h-0.5dtsz, dtsz);
  bot y4 = -d-oo; top y7=ceiling 0.25[bot y9.d, h-x_height]+eps;
  y2=good.y 0.5[y7, y4]; y3=y5=0.5[y2,y4]; y1=good.y 0.4[y2,y3];
  y6=1/9[y7,y4]; y8 = good.y 0.8[y7,y6];
  x3=good.x(w-1.5u); x5=good.x 1.25u; x4=0.55[x3,x5]; x7=0.5w;
  x1=good.x 0.5[x3,x5]; x2=0.25[x3,x5]; x6=good.x 2/3[x3,x4];
  x8=good.x 0.5[x7,x5];
  draw z1...z2 right_to_down z3 ...z4 left_to_up z5...z6 up_to_left z7...z8;
  labels(1, 2, 3, 4, 5, 6,7,8);
endchar;

% just look at italic corection and math fitting
cmchar "Calligraphic ampersand";
beginchar(oct"46", 14u#, asc_height#, 0);
  italcorr max(0.15x_height#*slant+0.5lower_cal_width#, 
    x_height#*slant+0.5lower_cal_width#-2u#) if math_fitting: -0.5u# fi;
  adjust_fit(0, 0);
  %
  pickup lower_cal.nib;
  top y1 = vround 0.98x_height;
  bot y2 = bot y7 = -oo;
  top y5 = h+oo;
  y3 = 0.5[y2, x_height]; y4 = y6 = 0.6[x_height, y5];
  y8 = good.y 7/8[x_height, y7];
  x1 = x7 = good.x(w-2.5u);
  x3 = good.x 1.25u; x6 = good.x 3u;
  x8 = good.x w; x2 = 5u; x4-x6=hround 3u; x5=0.6[x6,x4];
  draw z1{down}...z2 left_to_up z3...z4 up_to_left z5 left_to_down z6
  ...z7{right}...z8;
  %
  math_fit(-.3x_height#*slant+0.5curve#-u#, ic#);
  labels(1, 2, 3, 4, 5, 6, 7, 8);
endchar;

%
% ACCENTS
%

cmchar "Calligraphic grave accent";
beginchar(oct"22", 9u#, min(asc_height#, 2x_height#), 0);
  italcorr asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup pencircle xscaled stem yscaled hair;
  top y1 = h+eps; bot y2 = vround 1/3[x_height, h]-eps;
  lft x1 = hround 1.75u; rt x2 = hround 2/3[x1, w-x1];
  draw z1{x2-x1, 2(y2-y1)}..z2;
  labels(1, 2);
endchar;

cmchar "Calligraphic acute accent";
beginchar(oct"23", 9u#, min(asc_height#, 2x_height#), 0);
  italcorr asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup pencircle xscaled stem yscaled hair;
  top y1 = h+eps; bot y2 = vround 1/3[x_height, h]-eps;
  rt x1 = w-hround 1.75u; lft x2 = hround 2/3[x1, w-x1]; 
  draw z1{x2-x1, 2(y2-y1)}..z2;
  labels(1, 2);
endchar;

% HUM
cmchar "Calligraphic tilde accent";
beginchar(oct"176", 9u#, 
    min(asc_height#, 10/7x_height#+0.5flare#), 0);
  italcorr asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  bot y4 = vround 1/3[x_height, h]-eps;
  top y2 = h+eps; y1 = y3 = y5 = good.y 0.5[y2, y4];
  lft x1 = w-rt x5 = hround 1.25u;
  x2 = 0.25[x1, x5]; x3 = 0.5[x1, x5]; x4 = 0.75[x1, x5];
  draw z1{(z2-z1) yscaled 2}...z2{right}...
  z3{(z4-z3)yscaled 2}...z4{right} ...{(z5-z4) yscaled 2}z5;
  labels(1, 2, 3, 4, 5);
endchar;

cmchar "Calligraphic circumflex accent";
beginchar(oct"136", 9u#, min(asc_height#, 2x_height#), 0);
  italcorr asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup pencircle xscaled stem yscaled hair;
  top y2 = h+eps; bot y1 = bot y3 = vround 1/3[x_height, h]-eps;
  lft x1 = w-rt x3 = hround 1.75u; x2 = good.x 0.5[x1, x3];
  draw z1..{x2-x1, 2(y2-y1)}z2
  &z2{x3-x2, 2(y3-y2)}..z3;
  labels(1, 2, 3);
endchar;

cmchar "Calligraphic hacheck accent";
beginchar(oct"24", 9u#, min(asc_height#, 2x_height#), 0);
  italcorr asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup pencircle xscaled stem yscaled hair;
  top y1 = top y3 = h+eps; bot y2 = vround 1/3[x_height, h]-eps;
  lft x1 = w-rt x3 = hround 1.75u; x2 = good.x 0.5[x1, x3];
  draw z1..{x2-x1, 2(y2-y1)}z2
  &z2{x3-x2, 2(y3-y2)}..z3;
  labels(1, 2, 3);
endchar;

cmchar "Calligraphic breve accent";
beginchar(oct"25", 9u#, min(asc_height#, 2x_height#), 0);
  "Breve accent";
  italcorr asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
%  pickup pencircle xscaled stem yscaled hair;
  pickup lower_cal.nib;
  top y1 = top y3=h+eps; bot y2=vround 1/3[x_height, h]-eps;
  lft x1 = w-rt x3=hround 1.5u; x2=0.5[x1, x3];
  draw z1 down_to_right z2 right_to_up z3; labels(1, 2, 3);
endchar;

cmchar "Calligraphic macron accent";
beginchar(oct"26", 9u#, 0.4[x_height#, asc_height#]+0.5hair#, 0);
  italcorr charht*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib; top y1 = top y2 = h;
  lft x1 = w-rt x2 = hround 1.25u;
  draw z1..z2; labels(1, 2);
endchar;

cmchar "Calligraphic circ accent";
beginchar(oct"27", 14.4u#
    +4/3(asc_height#-x_height#)*slant+1.5u#, 
    asc_height#, 0);
  italcorr asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup fine_cal.nib;
  numeric a, b; b = vround(1/3[x_height, h]);
  a = round max(3.6u, h+o-b);
  top y2 = b+a+eps; bot y4 = b-eps;
  y0 = y1 = y3 = 0.5[y4, y2]; x0 = x2 = x4 = 0.5w;
  lft x3 = hround(x0-0.5a)-eps; x1-x0 = x0-x3;
  draw superellipse(z1, z2, z3, z4, superness);
  labels(1, 2, 3, 4, 0);
endchar;

cmchar "Calligraphic cedilla accent";
beginchar(oct"30", 9u#, 0, desc_depth#);
  italcorr asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  bot y1 = -oo; top y2 = -vround max(o, -d/6);
  bot y4 = -d; y3 = 0.5[y2, y4]; y5 = good.y 0.4[y4, y3];
  x1 = x2 = x4 = good.x 0.5w;
  lft x5 = w-rt x3 = hround 1.5u-eps;
  draw z1--z2 right_to_down z3 down_to_left
  z4 ... z5;
  labels(1, 2, 3, 4, 5);
endchar;

cmchar "Calligraphic dot accent";
beginchar(oct"137", 9u#, 
    min(asc_height#, 10/7x_height#+0.5flare#), 0);
  adjust_fit(0, 0);
  pickup fine_cal.nib; 
  cal_dot1(0.5w, h-0.5flare, flare);
  math_fit(0, 0);
  penlabels(1, 1');
endchar;

cmchar "Calligraphic umlaut accent";
beginchar(oct"177", 9u#, 
    min(asc_height#, 10/7x_height#+0.5flare#), 0);
  adjust_fit(0, 0);
  pickup fine_cal.nib;  
  cal_dot1(2.75u, h-0.5flare, flare);
  cal_dot2(w-2.75u, h-0.5flare, flare);
  math_fit(0, 0);
  penlabels(1, 1', 2, 2');
endchar;

cmchar "Calligraphic long umlaut accent";
beginchar(oct"175", 9u#, min(asc_height#, 2x_height#), 0);
  adjust_fit(0, 0);
  pickup pencircle xscaled stem yscaled hair;
  top y1 = top y3 = h+eps;
  bot y2 = bot y4 = vround 1/3[x_height, h]-eps;
  lft x4 = hround 2.25u; rt x1 = w-hround 1.5u;
  x1-x3 = x2-x4 = hround 3u;
  draw z1{x2-x1, 2(y2-y1)}..z2;
  draw z3{x4-x3, 2(y4-y3)}..z4;
  labels(1, 2, 3, 4);
endchar;

beginchar("@", 15u#, asc_height#, 0);
  "The at sign";
  italcorr 0.7asc_height#*slant-0.5u#;
  adjust_fit(0, 0);
  pickup lower_cal.nib;
  top y1 = 0.75h+eps; bot y3 = vround 0.25h-eps; y4 = 0.333[y3, y5];
  top y5 = h+o; y6 = 0.5[y5, y7]; bot y7 = -o; y8 = good.y 0.15h;
  y2 = 0.2[y3, y1];
  rt x4 = rt x8 = w-hround u+eps; lft x6 = hround u-eps;
  x5 = x7 = 0.5[x4, x6];
  x1 = x2 = good.x(0.7[x6, x4]); x3 = 0.333[x2, x4];
  draw z1..z2 down_to_right z3 right_to_up z4 up_to_left z5
  left_to_down z6 down_to_right z7...z8;
  %
  y9b = good.y(0.73[y7, y5]); y9d = good.y(0.27[y7, y5]);
  0.5[y9b, y9d] = y9a = y9c;
  y9a-y9e = 0.4*(y9b-y9e);
  x9a = x1; x9c = good.x 0.71[x4, x6];
  x9b = x9d = 0.5[x9a, x9c];
  draw z9a up_to_left z9b...z9c down_to_right
  z9d right_to_up z9a;
  labels(1, 2, 3, 4, 5, 6, 7, 8, 9a, 9b, 9c, 9d);
  math_fit(0, 0);
endchar;

skewchar=oct"060"; skew#=.5u#;

ligtable cal_reverse_apostrophe: cal_reverse_apostrophe=: cal_opening_quotes;
ligtable cal_apostrophe: cal_apostrophe=: cal_closing_quotes;
ligtable "!": cal_reverse_apostrophe =: call_spanish_shriek;
ligtable "?": cal_reverse_apostrophe =: call_spanish_query;
ligtable "<": "<" =: call_laquo;
ligtable ">": ">" =: call_raquo;

ligtable "-" : "-"  =: oct"173";
ligtable oct"173" : "-"  =: oct"174";

ligtable "I": "T": "V": skewchar kern skew#;
ligtable "D": "R": "U": "W": "Y": skewchar kern 3skew#;
ligtable "E": "G": "O": "Q": skewchar kern 4skew#;
ligtable "B": "C": "L": "S": "X": "Z": skewchar kern 5skew#;
ligtable "J": skewchar kern 6skew#;
ligtable "A": skewchar kern 7skew#;

ligtable "F": skewchar kern 4skew#, 
"a" kern -2u#, "e" kern -2u#, "o" kern -2u#, "r" kern -u#;

ligtable "H": skewchar kern 4skew#, 
"a" kern -u#, "e" kern -u#, "o" kern -u#;

ligtable "K": skewchar kern 2skew#,
"a" kern -u#, "e" kern -u#, "o" kern -u#;

ligtable "M": skewchar kern 5skew#, 
"a" kern -u#, "e" kern -u#, "o" kern -u#, "r" kern -u#;

ligtable "N": skewchar kern 3skew#, 
"a" kern -u#, "e" kern -u#, "o" kern -u#;

ligtable "P": skewchar kern 3skew#,
"a" kern -u#, "e" kern -u#, "o" kern -u#;

ligtable "f": "a" kern -0.5u#, "e" kern -0.5u#, "o" kern -0.5u#;
ligtable "h": "m": "n": "t": "x":
"a" kern -0.25u#, "e" kern -0.25u#, "o" kern -0.25u#, 
"d" kern -0.25u#, "g" kern -0.25u#, "q" kern -0.25u#;
ligtable "o": "x" kern -0.25u#;

endinput.
