% mathematical symbols by Anthony Phan.
% file: matharrw.mf (arrow kit)
% last modification: May 16, 2005.
% Only known charcodes will be generated.

use_rule1;

%turningcheck:=0;

arrow_head_fitting:=false;
arrow_width   := 2ceiling 0.84spread1+rth;
arrow_height# := 4.2u#;
arrow_height  := round 4.2u;
arrow_breadth := rth;
arrow_stress  := 0.52;%0.65;
arrow_tense1  := 0.75;
arrow_tense2  := 0.875;

% Funny thing: using def for the next definition would
% lead to strange things with transforms. The path must
% be a whole thing (grouping). One could also use
% parentheses.

vardef straight_path(expr dir,overshot)=
  save x_; x_=hround(0.5w+0.5rth)-0.5rth;
  if dir=up:(x_,-d)..(x_,h+overshot-pen_top)
  elseif dir=down:(x_,h)..(x_,-d-overshot-pen_bot)
  elseif dir=left:(w-appr,math_axis)..(appr-overshot-pen_lft,math_axis)
  else:(appr,math_axis)..(w-appr+overshot-pen_rt,math_axis) fi
enddef;

% ARROWS

beginchar(arrow_left,
    16u#+2appr#,v_center(spread1#+rth#));
  "Left arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),both);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(arrow_right,
    16u#+2appr#,v_center(spread1#+rth#));
  "Right arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0),both);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(arrow_left_right,
    16u#+2appr#,v_center(spread1#+rth#));
  "Left-right arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),both);
  arrow_head2(straight_path(right,0),both);
  filldraw z1l--z2r--z2l--z1r--cycle;
  penlabels(1,2);
endchar;

beginchar(arrow_left_not,
    16u#+2appr#,v_center(spread1#+rth#));
  "Negated left arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),both);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  v_adjust(3r,4l,y1,arrow_width);% to be checked
  lft x4l=w-rt x3r=appr+hround 6u;
  adjust_slanted_bar(4l,3r,4r,3l)(rth-tiny,-1);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_right_not,
    16u#+2appr#,v_center(spread1#+rth#));
  "Negated right arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0),both);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  v_adjust(3r,4l,y1,arrow_width);% to be checked
  lft x4l=w-rt x3r=appr+hround 6u;
  adjust_slanted_bar(4l,3r,4r,3l)(rth-tiny,-1);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_left_right_not,
    16u#+2appr#,v_center(spread1#+rth#));
  "Negated left-right arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),both);
  arrow_head2(straight_path(right,0),both);
  filldraw z1l--z2r--z2l--z1r--cycle;
  v_adjust(3r,4l,y1,arrow_width);% to be checked
  lft x4l=w-rt x3r=appr+hround 6u;
  adjust_slanted_bar(4l,3r,4r,3l)(rth-tiny,-1);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_up,
    7u#+2appr#,asc_height#,asc_depth#);
  "Upward arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0),both);% corrected 2002/07/29
  bot y2=-d; x2=x1; pos2(rth,0);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(arrow_down,
    7u#+2appr#,asc_height#,asc_depth#);
  "Downward arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(down,0),both);% corrected 2002/07/29
  top y2=h; x2=x1; pos2(rth,180);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(arrow_up_down,
    7u#+2appr#,asc_height#,asc_depth#);
  "Upward-Downward arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0),both);% corrected 2002/07/29
  arrow_head2(straight_path(down,0),both);% corrected 2002/07/29
  filldraw z1l--z2r--z2l--z1r--cycle;;
  penlabels(1,2);
endchar;

beginchar(arrow_northwest,
    16u#+2appr#,asc_height#,asc_depth#);
  "Northwest arrow";
  pickup rule.nib; bot y2=-d; rt x2=w-appr;
  pickup tiny.nib; top y3=h; lft x3=appr;
  arrow_head1(z2..z3,both);
  pickup rule.nib; draw z1..z2;
  penlabels(1); labels(2,3);
endchar;

beginchar(arrow_northeast,
    16u#+2appr#,asc_height#,asc_depth#);
  "Northeast arrow";
  pickup rule.nib; bot y2=-d; lft x2=appr;
  pickup tiny.nib; top y3=h; rt x3=w-appr;
  arrow_head1(z2..z3,both);
  pickup rule.nib; draw z1..z2;
  penlabels(1); labels(2,3);
endchar;

beginchar(arrow_southwest,
    16u#+2appr#,asc_height#,asc_depth#);
  "Southwest arrow";
  pickup rule.nib; top y2=h; rt x2=w-appr;
  pickup tiny.nib; bot y3=-d; lft x3=appr;
  arrow_head1(z2..z3,both);
  pickup rule.nib; draw z1..z2;
  penlabels(1); labels(2,3);
endchar;

beginchar(arrow_southeast,
    16u#+2appr#,asc_height#,asc_depth#);
  "Southeast arrow";
  pickup rule.nib; top y2=h; lft x2=appr;
  pickup tiny.nib; bot y3=-d; rt x3=w-appr;
  arrow_head1(z2..z3,both);
  pickup rule.nib; draw z1..z2;
  penlabels(1); labels(2,3);
endchar;

beginchar(arrows_left_left,
    16u#+2appr#,v_center(spread2#+spread1#+rth#));
  "Left-left arrows";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0) shifted (0,0.5spread2),both);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(left,0) shifted (0,-0.5spread2),both);
  rt x4=w-appr; y4=y3; pos4(rth,90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrows_right_right,
    16u#+2appr#,v_center(spread2#+spread1#+rth#));
  "Right_right arrows";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0) shifted (0,0.5spread2),both);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(right,0) shifted (0,-0.5spread2),both);
  lft x4=appr; y4=y3; pos4(rth,-90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrows_left_right,
    16u#+2appr#,v_center(spread2#+spread1#+rth#));
  "Left-right arrows";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0) shifted (0,0.5spread2),both);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(right,0) shifted (0,-0.5spread2),both);
  lft x4=appr; y4=y3; pos4(rth,-90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrows_right_left,
    16u#+2appr#,v_center(spread2#+spread1#+rth#));
  "Right-left arrows";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0) shifted (0,0.5spread2),both);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(left,0) shifted (0,-0.5spread2),both);
  rt x4=w-appr; y4=y3; pos4(rth,90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrows_up_up,
    7u#+spread2#+2appr#,asc_height#,asc_depth#);
  "Upward arrows";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0)% corrected 2002/07/29
    shifted (-0.5spread2,0),both);
  bot y2=-d; x2=x1; pos2(rth,0);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(up,0)% corrected 2002/07/29
    shifted (0.5spread2,0),both);
  bot y4=-d; x4=x3; pos4(rth,0);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrows_down_down,
    7u#+spread2#+2appr#,asc_height#,asc_depth#);
  "Downward arrows";
  pickup tiny.nib;
  arrow_head1(straight_path(down,0)% corrected 2002/07/29
    shifted (-0.5spread2,0),both);
  top y2=h; x2=x1; pos2(rth,180);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(down,0)% corrected 2002/07/29
    shifted (0.5spread2,0),both);
  top y4=h; x4=x3; pos4(rth,180);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrows_up_down,
    7u#+spread2#+2appr#,asc_height#,asc_depth#);
  "Upward_downward arrows";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0)% corrected 2002/07/29
    shifted (-0.5spread2,0),both);
  bot y2=-d; x2=x1; pos2(rth,0);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(down,0)% corrected 2002/07/29
    shifted (0.5spread2,0),both);
  top y4=h; x4=x3; pos4(rth,180);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrows_down_up,
    7u#+spread2#+2appr#,asc_height#,asc_depth#);
  "Downward-upward arrows";
  pickup tiny.nib;
  arrow_head1(straight_path(down,0)% corrected 2002/07/29
    shifted (-0.5spread2,0),both);
  top y2=h; x2=x1; pos2(rth,180);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(up,0)% corrected 2002/07/29
    shifted (0.5spread2,0),both);
  bot y4=-d; x4=x3; pos4(rth,0);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

% STRANGE ARROWS

beginchar(arrow_shift_up_left,
    arithmetic_bounds);
  "Up_left shift arrow";
  pickup tiny.nib;
  pos3(rth,0); rt x3r=w-Appr; bot y3=-d-o;
  arrow_head1(straight_path(left,0) shifted (0,vround 3u),both);
  forsuffixes $=,r,l: y2$=y1$; x2$=x3$; endfor
  filldraw stroke z1e--z2e--z3e;
  penlabels(1,2,3);
endchar;

beginchar(arrow_shift_up_right,
    arithmetic_bounds);
  "Up_right shift arrow";
  pickup tiny.nib;
  pos3(rth,0); lft x3l=Appr; bot y3=-d-o;
  arrow_head1(straight_path(right,0) shifted (0,vround 3u),both);
  forsuffixes $=,r,l: y2$=y1$; x2$=x3$; endfor
  filldraw stroke z1e--z2e--z3e;
  penlabels(1,2,3);
endchar;

beginchar(arrow_shift_down_left,
    arithmetic_bounds);
  "Down-left shift arrow";
  pickup tiny.nib;
  pos3(rth,180); rt x3l=w-Appr; top y3=h+o;
  arrow_head1(straight_path(left,0) shifted (0,-vround 3u),both);
  forsuffixes $=,r,l: y2$=y1$; x2$=x3$; endfor
  filldraw stroke z1e--z2e--z3e;
  penlabels(1,2,3);
endchar;

beginchar(arrow_shift_down_right,
    arithmetic_bounds);
  "Down-right shift arrow";
  pickup tiny.nib;
  pos3(rth,180); lft x3r=Appr; top y3=h+o;
  arrow_head1(straight_path(right,0) shifted (0,-vround 3u),both);
  forsuffixes $=,r,l: y2$=y1$; x2$=x3$; endfor
  filldraw stroke z1e--z2e--z3e;
  penlabels(1,2,3);
endchar;

beginchar(arrow_squig_left,
    6*3.5u#+arrow_height#+2appr#,v_center(spread1#+rth#));
  "Left squig-arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),both);
  pickup rule.nib;
  y2=y1;
  y3=y5=y7=math_axis+0.5spread1;
  y4=y6=y8=math_axis-0.5spread1;
  x8=w-appr; x8-x2=6*3.5u;
  x2-x3=x3-x4=x4-x5=x5-x6=x6-x7=x7-x8;
  autorounded;
  draw z1---z2...0.5[z3,z2]{(z3-z2) yscaled 2}...
  z3{right}...0.5[z4,z3]{(z4-z3) yscaled 3}...
  z4{right}...0.5[z5,z4]{(z5-z4) yscaled 3}...
  z5{right}...0.5[z6,z5]{(z6-z5) yscaled 3}...
  z6{right}...0.5[z7,z6]{(z7-z6) yscaled 3}...
  z7{right}...0.5[z8,z7]{(z8-z7) yscaled 3}...
  z8{right};
  cullit; unfill (x8+1,top y8+1)--(x8+1,bot y8-1)
  --(rt x8+1,bot y8-1)--(rt x8+1,top y8+1)--cycle;
  labels(2,3,4,5,6,7,8); penlabels(1);
endchar;

beginchar(arrow_squig_right,
    6*3.5u#+arrow_height#+2appr#,v_center(spread1#+rth#));
  "Right squig-arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0),both);
  pickup rule.nib;
  y2=y1;
  y3=y5=y7=math_axis-0.5spread1;
  y4=y6=y8=math_axis+0.5spread1;
  x8=appr; x2-x8=6*3.5u;
  x2-x3=x3-x4=x4-x5=x5-x6=x6-x7=x7-x8;
  autorounded;
  draw z1---z2...0.5[z3,z2]{(z3-z2) yscaled 2}...
  z3{left}...0.5[z4,z3]{(z4-z3) yscaled 3}...
  z4{left}...0.5[z5,z4]{(z5-z4) yscaled 3}...
  z5{left}...0.5[z6,z5]{(z6-z5) yscaled 3}...
  z6{left}...0.5[z7,z6]{(z7-z6) yscaled 3}...
  z7{left}...0.5[z8,z7]{(z8-z7) yscaled 3}...
  z8{left};
  cullit; unfill (x8-1,top y8+1)--(x8-1,bot y8-1)
  --(lft x8-1,bot y8-1)--(lft x8-1,top y8+1)--cycle;
  labels(2,3,4,5,6,7,8); penlabels(1);
endchar;

beginchar(arrow_squig_left_right,
    7*3.5u#+2*arrow_height#+2appr#,v_center(spread1#+rth#));
  "Left right squig-arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),both);
  arrow_head10(straight_path(right,0),both);
  pickup rule.nib;
  y2=y1; y9=y10;
  y3=y5=y7=math_axis+0.5spread1;
  y4=y6=y8=math_axis-0.5spread1;
  x9-x2=7*3.5u; 0.5[x2,x9]=0.5w;
  x2-x3=x3-x4=x4-x5=x5-x6=x6-x7=x7-x8=x8-x9;
  autorounded;
  draw z1---z2...0.5[z3,z2]{(z3-z2) yscaled 3}...
  z3{right}...0.5[z4,z3]{(z4-z3) yscaled 3}...
  z4{right}...0.5[z5,z4]{(z5-z4) yscaled 3}...
  z5{right}...0.5[z6,z5]{(z6-z5) yscaled 3}...
  z6{right}...0.5[z7,z6]{(z7-z6) yscaled 3}...
  z7{right}...0.5[z8,z7]{(z8-z7) yscaled 3}...
  z8{right}...0.5[z9,z8]{(z9-z8) yscaled 3}...
  z9---z10;
  labels(2,3,4,5,6); penlabels(1,7);
endchar;

beginchar(arrow_curve_top_left,
    16u#+2appr#,v_center(spread1#+rth#));
  "Top-left curved arrow";
  pickup tiny.nib;
  bot y1=bot y3=-d-eps; y2+0.5rth=h+o;
  rt x1=w-appr; x2=0.5w; lft x3=appr;
  z0=(z2-z1) yscaled 3;
  tmp_path:=z1{z0}...z2{left}...z3{(z3-z2) yscaled 3};
  arrow_head4(tmp_path,both);
  pos1(rth,angle z0-90); pos2(rth,90);
  filldraw stroke z1e{z0}...z2e{left}
  ...z4e{direction arrow_time of tmp_path};
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_curve_top_right,
    16u#+2appr#,v_center(spread1#+rth#));
  "Top-right curved arrow";
  pickup tiny.nib;
  bot y1=bot y3=-d-eps; y2+0.5rth=h+o;
  lft x1=appr; x2=0.5w; rt x3=w-appr;
  z0=(z2-z1) yscaled 3;
  tmp_path:=z1{z0}...z2{right}...z3{(z3-z2) yscaled 3};
  arrow_head4(tmp_path,both);
  pos1(rth,angle z0-90); pos2(rth,-90);
  filldraw stroke z1e{z0}...z2e{right}
  ...z4e{direction arrow_time of tmp_path};
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_curve_top_left_right,
    16u#+2appr#,v_center(spread1#+rth#));
  "Top-left-right curved arrow";
  pickup tiny.nib;
  bot y1=bot y3=-d-eps; y2+0.5rth=h+o;
  rt x1=w-appr; x2=0.5w; lft x3=appr;
  tmp_path:=z1{(z2-z1) yscaled 3}...z2{left}...z3{(z3-z2) yscaled 3};
  arrow_head0(reverse tmp_path,both); t:=2-arrow_time;
  arrow_head4(tmp_path,both);
  pickup rule.nib;
  draw subpath (t,arrow_time) of tmp_path;
  labels(1,2,3); penlabels(0,4);
endchar;

beginchar(arrow_curve_bot_left,
    16u#+2appr#,v_center(spread1#+rth#));
  "Bot-left curved arrow";
  pickup tiny.nib;
  top y1=top y3=h+eps; y2-0.5rth=-d-o;
  rt x1=w-appr; x2=0.5w; lft x3=appr;
  z0=(z2-z1) yscaled 3;
  tmp_path:=z1{z0}...z2{left}...z3{(z3-z2) yscaled 3};
  arrow_head4(tmp_path,both);
  pos1(rth,angle z0-90); pos2(rth,90);
  filldraw stroke z1e{z0}...z2e{left}
  ...z4e{direction arrow_time of tmp_path};
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_curve_bot_right,
    16u#+2appr#,v_center(spread1#+rth#));
  "Bot-right curved arrow";
  pickup tiny.nib;
  top y1=top y3=h+eps; y2-0.5rth=-d-o;
  lft x1=appr; x2=0.5w; rt x3=w-appr;
  z0=(z2-z1) yscaled 3;
  tmp_path:=z1{z0}...z2{right}...z3{(z3-z2) yscaled 3};
  arrow_head4(tmp_path,both);
  pos1(rth,angle z0-90); pos2(rth,-90);
  filldraw stroke z1e{z0}...z2e{right}
  ...z4e{direction arrow_time of tmp_path};
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_curve_bot_left_right,
    16u#+2appr#,v_center(spread1#+rth#));
  "Bot-left-right curved arrow";
  pickup tiny.nib;
  top y1=top y3=h+eps; y2-0.5rth=-d-o;
  rt x1=w-appr; x2=0.5w; lft x3=appr;
  tmp_path:=z1{(z2-z1) yscaled 3}...z2{left}...z3{(z3-z2) yscaled 3};
  arrow_head0(reverse tmp_path,both); t:=2-arrow_time;
  arrow_head4(tmp_path,both);
  pickup rule.nib;
  draw subpath (t,arrow_time) of tmp_path;
  labels(1,2,3); penlabels(0,4);
endchar;

beginchar(arrow_loop_up_left,
    16u#+2appr#,v_center(12u#));
  "Up-left loop-arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),both);
  lft x8l=w-appr-hround 6u; bot y8=-d;
  pos7(rth,180); pos8(rth,180);
  y1=y2=y3=y7; x2=x6=x7=x8;
  filldraw stroke z8e..z7e;
  pickup rule.nib; autorounded;
  top y5=h; rt x4=w-appr;
  y4=y6=0.5[y3,y5]; x3=x5=0.5[x4,x6];
  draw z1..z2..z3 right_to_up z4
  up_to_left z5 left_to_down z6..z7;
  labels(1,2,3,4,5,6); penlabels(7,8);
endchar;

beginchar(arrow_loop_up_right,
    16u#+2appr#,v_center(12u#));
  "Up-right loop-arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0),both);
  rt x8r=appr+hround 6u; bot y8=-d;
  pos7(rth,180); pos8(rth,180);
  y1=y2=y3=y7; x2=x6=x7=x8;
  filldraw stroke z8e..z7e;
  pickup rule.nib; autorounded;
  top y5=h; lft x4=appr;
  y4=y6=0.5[y3,y5]; x3=x5=0.5[x4,x6];
  draw z1..z2..z3 left_to_up z4
  up_to_right z5 right_to_down z6..z7;
  labels(1,2,3,4,5,6); penlabels(7,8);
endchar;

beginchar(arrow_loop_down_left,
    16u#+2appr#,v_center(12u#));
  "Down-left loop-arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),both);
  lft x8r=w-appr-hround 6u; top y8=h;
  pos7(rth,0); pos8(rth,0);
  y1=y2=y3=y7; x2=x6=x7=x8;
  filldraw stroke z8e..z7e;
  pickup rule.nib; autorounded;
  bot y5=-d; rt x4=w-appr;
  y4=y6=0.5[y3,y5]; x3=x5=0.5[x4,x6];
  draw z1..z2..z3 right_to_down z4
  down_to_left z5 left_to_up z6..z7;
  labels(1,2,3,4,5,6); penlabels(7,8);
endchar;

beginchar(arrow_loop_down_right,
    16u#+2appr#,v_center(12u#));
  "Down-right loop-arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0),both);
  rt x8l=appr+hround 6u; top y8=h;
  pos7(rth,0); pos8(rth,0);
  y1=y2=y3=y7; x2=x6=x7=x8;
  filldraw stroke z8e..z7e;
  pickup rule.nib; autorounded;
  bot y5=-d; lft x4=appr;
  y4=y6=0.5[y3,y5]; x3=x5=0.5[x4,x6];
  draw z1..z2..z3 left_to_down z4
  down_to_right z5 right_to_up z6..z7;
  labels(1,2,3,4,5,6); penlabels(7,8);
endchar;

beginchar(arrow_circle_left,
    arithmetic_bounds);
  "Left circle-arrow";
  arrow_head_fitting:=true;
  a:=6.75u; t:=0.25;
  pickup rule.nib;
  x0=x1=x3=good.x 0.5w;
  y0=y2=y4=math_axis;
  y1-y0=y0-y3=x4-x0=x0-x2=round(a-0.5rth);
  tmp_path:=subpath (t,8-t) of
  (z1 left_to_down z2 down_to_right
    z3 right_to_up z4 up_to_left z1);
  pickup tiny.nib;
  arrow_head5(tmp_path,both);
  pickup rule.nib;
  cutdraw subpath(0,arrow_time) of tmp_path;
  labels(1,2,3,4); penlabels(1);
endchar;

beginchar(arrow_circle_right,
    arithmetic_bounds);
  "Right circle-arrow";
  arrow_head_fitting:=true;
  a:=6.75u; t:=0.25;
  pickup rule.nib;
  x0=x1=x3=good.x 0.5w;
  y0=y2=y4=math_axis;
  y1-y0=y0-y3=x2-x0=x0-x4=round(a-0.5rth);
  tmp_path:=subpath (t,8-t) of
  (z1 right_to_down z2 down_to_left
    z3 left_to_up z4 up_to_right z1);
  pickup tiny.nib;
  arrow_head5(tmp_path,both);
  pickup rule.nib;
  cutdraw subpath(0,arrow_time) of tmp_path;
  labels(1,2,3,4); penlabels(1);
endchar;

beginchar(arrow_left_to_right,
    16u#+2appr#,v_center(12u#));
  "Left to right arrow";
  arrow_head_fitting:=true;
  pickup rule.nib;
  x1=x5=w-appr; lft x3=appr; top y2=h-vround 0.5u; y1-y5=spread1;
  0.5[y1,y5]=0.5[y2,y4]=y3=math_axis;
  x2=x4=3/8[appr,w-appr];
  tmp_path:=z1{(z2-z1) yscaled 2}...z2 left_to_down
  z3 down_to_right z4...z5{(z5-z4) yscaled 2};
  pickup tiny.nib;
  arrow_head6(tmp_path,both);
  pickup rule.nib;
  cutdraw subpath (0,arrow_time) of tmp_path;
  labels(1,2,3,4,5); penlabels(6);
endchar;

beginchar(arrow_right_to_left,
    16u#+2appr#,v_center(12u#));
  "Right to left arrow";
  arrow_head_fitting:=true;
  pickup rule.nib;
  x1=x5=appr; rt x3=w-appr; top y4=h-vround 0.5u; y5-y1=spread1;
  0.5[y1,y5]=0.5[y2,y4]=y3=math_axis;
  x2=x4=5/8[appr,w-appr];
  tmp_path:=z1{(z2-z1) yscaled 2}...z2 right_to_up
  z3 up_to_left z4...z5{(z5-z4) yscaled 2};
  pickup tiny.nib;
  arrow_head6(tmp_path,both);
  pickup rule.nib;
  cutdraw subpath (0,arrow_time) of tmp_path;
  labels(1,2,3,4,5); penlabels(6);
endchar;

beginchar(arrow_up_to_down,
    12u#+2appr#,asc_height#,asc_depth#);
  "Up to down arrow";
  arrow_head_fitting:=true;
  pickup rule.nib;
  y1=y5=-d; top y3=h; lft x4=appr+hround 0.5u; x1-x5=spread1;
  0.5[x1,x5]=0.5[x2,x4]=x3=0.5w;
  y2=y4=5/8[-d,h];
  tmp_path:=z1{(z2-z1) xscaled 2}...z2 up_to_left
  z3 left_to_down z4...z5{(z5-z4) xscaled 2};
  pickup tiny.nib;
  arrow_head6(tmp_path,both);
  pickup rule.nib;
  cutdraw subpath (0,arrow_time) of tmp_path;
  labels(1,2,3,4,5); penlabels(6);
endchar;

beginchar(arrow_down_to_up,
    12u#+2appr#,asc_height#,asc_depth#);
  "Down to up arrow";
  arrow_head_fitting:=true;
  pickup rule.nib;
  y1=y5=h; bot y3=-d; lft x2=appr+hround 0.5u; x5-x1=spread1;
  0.5[x1,x5]=0.5[x2,x4]=x3=0.5w;
  y2=y4=3/8[-d,h];
  tmp_path:=z1{(z2-z1) xscaled 2}...z2 down_to_right
  z3 right_to_up z4...z5{(z5-z4) xscaled 2};
  pickup tiny.nib;
  arrow_head6(tmp_path,both);
  pickup rule.nib;
  cutdraw subpath (0,arrow_time) of tmp_path;
  labels(1,2,3,4,5); penlabels(6);
endchar;

% HARPOONS

beginchar(harpoon_left_up,
    16u#+2appr#,v_center(spread1#+rth#));
  "Left up-harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),right);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(harpoon_right_up,
    16u#+2appr#,v_center(spread1#+rth#));
  "Right up-harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0),left);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(harpoon_left_down,
    16u#+2appr#,v_center(spread1#+rth#));
  "Left down-harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),left);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(harpoon_right_down,
    16u#+2appr#,v_center(spread1#+rth#));
  "Right down-harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0),right);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(harpoon_up_left,
    7u#+2appr#,asc_height#,asc_depth#);
  "Upward left-harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0),left);
  bot y2=-d; x2=x1; pos2(rth,0);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(harpoon_down_left,
    7u#+2appr#,asc_height#,asc_depth#);
  "Upward left-harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(down,0),right);
  top y2=h; x2=x1; pos2(rth,180);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(harpoon_up_right,
    7u#+2appr#,asc_height#,asc_depth#);
  "Downward right-harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0),right);
  bot y2=-d; x2=x1; pos2(rth,0);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(harpoon_down_right,
    7u#+2appr#,asc_height#,asc_depth#);
  "Downward right-harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(down,0),left);
  top y2=h; x2=x1; pos2(rth,180);
  filldraw stroke z1e..z2e;
  penlabels(1,2);
endchar;

beginchar(harpoons_left_left,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Left-left harpoons";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0) shifted (0,0.5spread1),right);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(left,0) shifted (0,-0.5spread1),left);
  rt x4=w-appr; y4=y3; pos4(rth,90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoons_right_right,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Right-right harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0) shifted (0,0.5spread1),left);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(right,0) shifted (0,-0.5spread1),right);
  lft x4=appr; y4=y3; pos4(rth,-90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoons_left_right,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Left-right harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0) shifted (0,0.5spread1),right);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(right,0) shifted (0,-0.5spread1),right);
  lft x4=appr; y4=y3; pos4(rth,-90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoons_right_left,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Right-left harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0) shifted (0,0.5spread1),left);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(left,0) shifted (0,-0.5spread1),left);
  rt x4=w-appr; y4=y3; pos4(rth,90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoons_up_up,
    7u#+spread1#+2appr#,asc_height#,asc_depth#);
  "Upward-upward hapoons";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0) shifted (-0.5spread1,0),left);
  bot y2=-d; x2=x1; pos2(rth,0);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(up,0) shifted (0.5spread1,0),right);
  bot y4=-d; x4=x3; pos4(rth,0);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoons_down_down,
    7u#+spread1#+2appr#,asc_height#,asc_depth#);
  "Downward-downward hapoons";
  pickup tiny.nib;
  arrow_head1(straight_path(down,0) shifted (-0.5spread1,0),right);
  top y2=h; x2=x1; pos2(rth,180);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(down,0) shifted (0.5spread1,0),left);
  top y4=h; x4=x3; pos4(rth,180);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoons_up_down,
    7u#+spread1#+2appr#,asc_height#,asc_depth#);
  "Upward-downward hapoons";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0) shifted (-0.5spread1,0),left);
  bot y2=-d; x2=x1; pos2(rth,0);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(down,0) shifted (0.5spread1,0),left);
  top y4=h; x4=x3; pos4(rth,180);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoons_down_up,
    7u#+spread1#+2appr#,asc_height#,asc_depth#);
  "Downward-upward hapoons";
  pickup tiny.nib;
  arrow_head1(straight_path(down,0) shifted (-0.5spread1,0),right);
  top y2=h; x2=x1; pos2(rth,180);
  filldraw stroke z1e..z2e;
  arrow_head3(straight_path(up,0) shifted (0.5spread1,0),right);
  bot y4=-d; x4=x3; pos4(rth,0);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

%
% T. Chaundy uniquely
%

beginchar(harpoon_left_bar,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Left-bar harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0) shifted (0,0.5spread1),right);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  lft x3=appr; rt x4=w-appr;
  y4=y3=math_axis-0.5spread1;
  pos3(rth,90); pos4(rth,90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoon_right_bar,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Right-bar harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0) shifted (0,0.5spread1),left);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  lft x3=appr; rt x4=w-appr;
  y4=y3=math_axis-0.5spread1;
  pos3(rth,90); pos4(rth,90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoon_bar_left,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Bar-left harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0) shifted (0,-0.5spread1),left);
  rt x2=w-appr; y2=y1; pos2(rth,90);
  filldraw stroke z1e..z2e;
  lft x3=appr; rt x4=w-appr;
  y4=y3=math_axis+0.5spread1;
  pos3(rth,90); pos4(rth,90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoon_bar_right,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Bar-right harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0) shifted (0,-0.5spread1),right);
  lft x2=appr; y2=y1; pos2(rth,-90);
  filldraw stroke z1e..z2e;
  lft x3=appr; rt x4=w-appr;
  y4=y3=math_axis+0.5spread1;
  pos3(rth,90); pos4(rth,90);
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(harpoon_left_right,
    16u#+2appr#,v_center(spread1#+rth#));
  "Left-right harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(left,0),right);
  arrow_head2(straight_path(right,0),right);
  filldraw z1l--z2r--z2l--z1r--cycle;
endchar;

beginchar(harpoon_right_left,
    16u#+2appr#,v_center(spread1#+rth#));
  "Right-left harpoon";
  pickup tiny.nib;
  arrow_head1(straight_path(right,0),left);
  arrow_head2(straight_path(left,0),left);
  filldraw z1l--z2r--z2l--z1r--cycle;
endchar;

% ARROW KIT

beginchar(maps_to_char,0,v_center(spread1#+rth#));
  "Maps to char";
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0); pos3(rth,90); pos4(rth,90);
  lft x1l=lft x2l=appr; x3=x1r; x4=x3+ceiling 0.5u;
  y3=y4=math_axis; 0.5[y1,y2]=y3;
  top y1-bot y2=arrow_width;%2vround 0.60arrow_width;
  filldraw stroke z1e..z2e; filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(maps_from_char,0,v_center(spread1#+rth#));
  "Maps from char";
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0); pos3(rth,-90); pos4(rth,-90);
  rt x1r=rt x2r=-appr; x3=x1l; x4=x3-ceiling 0.5u;
  y3=y4=math_axis; 0.5[y1,y2]=y3;
  top y1-bot y2=arrow_width; %2vround 0.60arrow_width;
  filldraw stroke z1e..z2e; filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(relbar_char,12u#+2appr#,v_center(spread1#+rth#));
  "Relation bar char";
  pickup tiny.nib; pos1(rth,90); pos2(rth,90);
  y1=y2=math_axis; lft x1=appr; rt x2=w-appr;
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

%
% trop \'ecras\'es \`a mon go\^ut.
%

beginchar(hook_left,3u#+2appr#,v_center(spread1#+rth#));
  "Left hook";
  pickup tiny.nib; pos1(rth,90); pos2(rth,0); pos3(rth,-90);
  y3=math_axis; y1-y3=vround min(1.4spread1,3u);
  y2=0.5[y1,y3]; lft x1=lft x3=appr; rt x2r=w-appr;
  filldraw stroke z1e right_to_down z2e down_to_left z3e;
  penlabels(1,2,3);
endchar;

beginchar(hook_right,3u#+2appr#,v_center(spread1#+rth#));
  "Right hook";
  pickup tiny.nib; pos1(rth,-90); pos2(rth,0); pos3(rth,90);
  y3=math_axis; y1-y3=vround min(1.4spread1,3u);
  y2=0.5[y1,y3]; rt x1=rt x3=w-appr; lft x2l=appr;
  filldraw stroke z1e left_to_down z2e down_to_right z3e;
  penlabels(1,2,3);
endchar;

beginchar(diag_up,16u#+2appr#,asc_height#,asc_depth#);
  "Diagonal up";
  pickup rule.nib;
  lft x1=appr; rt x2=w-appr; bot y1=-d; top y2=h;
  draw z1..z2; labels(1,2);
endchar;

beginchar(diag_down,16u#+2appr#,asc_height#,asc_depth#);
  "Diagonal down";
  pickup rule.nib;
  lft x1=appr; rt x2=w-appr; top y1=h; bot y2=-d;
  draw z1..z2; labels(1,2);
endchar;

% DOUBLE ARROWS

% for horizontal arrows...

double_arrow_width   := 2ceiling 0.70spread1+spread1+rth1;
double_arrow_height  := round 6.5u;
double_arrow_tense   := 0.65;
double_arrow_flatness:= 0.25;

beginchar(double_arrow_left,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Left double arrow";
  pickup tiny.nib;
  double_arrow_head1((appr,math_axis),left);
  pos2r(rth,90); pos2l(rth,90);
  rt x2r=rt x2l=w-appr; y2r=y1r; y2l=y1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  penlabels(2r,2l);
endchar;

beginchar(double_arrow_right,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Right double arrow";
  pickup tiny.nib;
  double_arrow_head1((w-appr,math_axis),right);
  pos2r(rth,-90); pos2l(rth,-90);
  lft x2r=lft x2l=appr; y2r=y1r; y2l=y1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  penlabels(2r,2l);
endchar;

beginchar(double_arrow_left_right,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Left-right double arrow";
  pickup tiny.nib;
  double_arrow_head1((appr-o,math_axis),left);
  double_arrow_head2((w-appr+o,math_axis),right);
  filldraw z1r.r--z1r.l--z2l.r--z2l.l--cycle;
  filldraw z1l.r--z1l.l--z2r.r--z2r.l--cycle;
endchar;

beginchar(double_arrow_left_not,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Left double arrow";
  pickup tiny.nib;
  double_arrow_head1((appr,math_axis),left);
  pos2r(rth,90); pos2l(rth,90);
  rt x2r=rt x2l=w-appr; y2r=y1r; y2l=y1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  v_adjust(3r,4l,y1,double_arrow_width);% to be checked
  lft x4l-appr=hround 7u; w-appr-rt x3r=hround 5u;
  adjust_slanted_bar(4l,3r,4r,3l)(rth-tiny,-1);
  filldraw stroke z3e..z4e;
  penlabels(2r,2l,3,4);
endchar;

beginchar(double_arrow_right_not,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Right double arrow";
  pickup tiny.nib;
  double_arrow_head1((w-appr,math_axis),right);
  pos2r(rth,-90); pos2l(rth,-90);
  lft x2r=lft x2l=appr; y2r=y1r; y2l=y1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  v_adjust(3r,4l,y1,double_arrow_width);% to be checked
  lft x4l=appr+hround 5u; w-rt x3r=appr+hround 7u;
  adjust_slanted_bar(4l,3r,4r,3l)(rth-tiny,-1);
  filldraw stroke z3e..z4e;
  penlabels(2r,2l,3,4);
endchar;

beginchar(double_arrow_left_right_not,
    16u#+2appr#,v_center(2spread1#+rth#));
  "Left-right double arrow";
  pickup tiny.nib;
  double_arrow_head1((appr-o,math_axis),left);
  double_arrow_head2((w-appr+o,math_axis),right);
  filldraw z1r.r--z1r.l--z2l.r--z2l.l--cycle;
  filldraw z1l.r--z1l.l--z2r.r--z2r.l--cycle;
  v_adjust(3r,4l,y1,double_arrow_width);% to be checked
  lft x4l=w-rt x3r=appr+hround 6.5u;
  adjust_slanted_bar(4l,3r,4r,3l)(rth-tiny,-1);
  filldraw stroke z3e..z4e;
  penlabels(3,4);
endchar;

% for horizontal arrows...

double_arrow_width   := 2ceiling 0.70spread1+spread1+rth1;
double_arrow_height  := round 6.5u;
double_arrow_tense   := 0.65;
double_arrow_flatness:= 0.25;

beginchar(double_arrow_up,
    9u#+2appr#,asc_height#,asc_depth#);
  "Up double arrow";
  pickup tiny.nib;
  double_arrow_head1((hround 0.5(w-rth)+0.5rth,
      h+o),up);
  pos2r(rth,0); pos2l(rth,0);
  bot y2r=bot y2l=-d; x2r=x1r; x2l=x1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  penlabels(2r,2l);
endchar;

beginchar(double_arrow_down,
    9u#+2appr#,asc_height#,asc_depth#);
  "Down double arrow";
  pickup tiny.nib;
  double_arrow_head1((hround 0.5(w-rth)+0.5rth,
      -d-o),down);
  pos2r(rth,180); pos2l(rth,180);
  top y2r=top y2l=h; x2r=x1r; x2l=x1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  penlabels(2r,2l);
endchar;

beginchar(double_arrow_up_down,
    9u#+2appr#,body_height#,paren_depth#);
  "Up-down double arrow";
  pickup tiny.nib;
  double_arrow_head1((hround 0.5(w-rth)+0.5rth,
      h+o),up);
  double_arrow_head2((hround 0.5(w-rth)+0.5rth,
      -d-o),down);
  filldraw z1r.r--z1r.l--z2l.r--z2l.l--cycle;
  filldraw z1l.r--z1l.l--z2r.r--z2r.l--cycle;
endchar;

beginchar(Relbar_char,12u#+2appr#,v_center(2spread1#+rth#));
  "Double relation bar char";
  pickup tiny.nib;
  pos1(rth,90); pos2(rth,90); pos3(rth,90); pos4(rth,90);
  lft x1=lft x3=appr; rt x2=rt x4=w-appr;
  y1=y2; y3=y4; y1-y3=spread1; .5[y1,y3]=math_axis;
  filldraw stroke z1e..z2e; % upper bar
  filldraw stroke z3e..z4e; % lower bar
  penlabels(1,2,3,4);
endchar;

beginchar(Maps_to_char,0,v_center(2spread1#+rth#));
  "Double maps to char";
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0); pos3(rth,90); pos4(rth,90);
  pos5(rth,90); pos6(rth,90);
  lft x1l=lft x2l=appr; x3=x5r=x1r; x4=x6=x3+ceiling 0.5u;
  y3=y4=math_axis+0.5spread1; y5=y6=math_axis-0.5spread1;
  0.5[y1,y2]=math_axis;
  top y1-bot y2=arrow_width % 2vround 0.60arrow_width
  +spread1;
  filldraw stroke z1e..z2e; filldraw stroke z3e..z4e;
  filldraw stroke z5e..z6e; penlabels(1,2,3,4,5,6);
endchar;

beginchar(Maps_from_char,0,v_center(2spread1#+rth#));
  "Double maps from char";
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0); pos3(rth,-90); pos4(rth,-90);
  pos5(rth,-90); pos6(rth,-90);
  rt x1r=rt x2r=-appr; x3=x5r=x1l; x4=x6=x3-ceiling 0.5u;
  y3=y4=math_axis+0.5spread1; y5=y6=math_axis-0.5spread1;
  0.5[y1,y2]=math_axis;
  top y1-bot y2=arrow_width % 2vround 0.60arrow_width
  +spread1;
  filldraw stroke z1e..z2e; filldraw stroke z3e..z4e;
  filldraw stroke z5e..z6e; penlabels(1,2,3,4,5,6);
endchar;

% EXTENSIBLE ARROWS (revoir les parametres)

use_rule1;

arrow_width   := 2ceiling 0.70spread1+rth;
arrow_height# := 4u#;
arrow_height  := round 4u;
arrow_breadth := rth;
arrow_stress  := 0.65;
arrow_tense1  := 0.75;
arrow_tense2  := 0.875;

beginchar(arrow_top,10u#+2appr#,0,dh#);
  pickup tiny.nib;
  a:=hround rth1+0.2dw; save rth; rth:=a;
  lft x2l=hround 0.5(w-rth);
  y2=-d-eps; pos2(rth,0); top y3=h; x3=x2;
  arrow_head1(z2..z3,both);
  filldraw stroke z1e--z2e; penlabels(1,2);
endchar;

beginchar(arrow_bot,10u#+2appr#,0,dh#);
  pickup tiny.nib;
  a:=hround rth1+0.2dw; save rth; rth:=a;
  lft x2r=hround 0.5(w-rth);
  y2=h+eps; pos2(rth,180); bot y3=-d; x3=x2;
  arrow_head1(z2..z3,both);
  filldraw stroke z1e--z2e; penlabels(1,2);
endchar;

beginchar(arrow_mod,10u#+2appr#,0,dh#);
  pickup tiny.nib;
  a:=hround rth1+0.2dw; save rth; rth:=a;
  lft x1l=lft x2l=hround 0.5(w-rth);
  y1=h+eps; y2=-d-eps; pos1(rth,0); pos2(rth,0);
  filldraw stroke z1e--z2e; penlabels(1,2);
endchar;

% for horizontal arrows...

double_arrow_width   := 2ceiling 0.70spread1+spread1+rth;
double_arrow_height  := round 6.5u;
double_arrow_tense   := 0.65;
double_arrow_flatness:= 0.25;

beginchar(double_arrow_top,
    12u#+2appr#,0,dh#);
  "double arrow top";
  pickup tiny.nib;
  double_arrow_head1((hround 0.5(w-rth)+0.5rth,
      h+o),up);
  pos2r(rth,0); pos2l(rth,0);
  y2r=y2l=-d-1-eps; x2r=x1r; x2l=x1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  penlabels(2r,2l);
endchar;

beginchar(double_arrow_bot,
    12u#+2appr#,0,dh#);
  "double arrow bot";
  pickup tiny.nib;
  double_arrow_head1((hround 0.5(w-rth)+0.5rth,
      -d-o),down);
  pos2r(rth,180); pos2l(rth,180);
  y2r=y2l=h+1+eps; x2r=x1r; x2l=x1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  penlabels(2r,2l);
endchar;

beginchar(double_arrow_mod,
    12u#+2appr#,0,dh#);
  "double arrow extension's module";
  pickup tiny.nib;
  x3-x1=x4-x2=spread1;
  0.5[x1,x3]=0.5[x2,x4]=hround 0.5(w-rth)+0.5rth;
  pos1(rth,0); pos2(rth,0); pos3(rth,0); pos4(rth,0);
  y1=y3=h+1+eps; y2=y4=-d-1-eps;
  filldraw stroke z1e..z2e;
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

endinput;

beginchar(arrow_up_not,
    7u#+2appr#,asc_height#,asc_depth#);
  "Negated upward arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(up,0),both);% corrected 2002/07/29
  bot y2=-d; x2=x1; pos2(rth,0);
  filldraw stroke z1e..z2e;
%
  x3r=x3l=x1c.l; x4r=x4l=x1c.r; 0.5[y3l,y4r]=0.5[-d,h];
  y1c.r-y4r=vround 1/3(y1c.r-0.5[-d,h]);
  a:=rth-tiny; b:=abs(z4r-z3l);
  y3r-y3l=y4r-y4l=a/(((x4r-x3l)/b)*((b+-+a)/b)+((y4r-y3l)/b)*(a/b));
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_down_not,
    7u#+2appr#,asc_height#,asc_depth#);
  "Negated downward arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(down,o),both);% corrected 2002/07/29
  top y2=h; x2=x1; pos2(rth,180);
  filldraw stroke z1e..z2e;
%
  x3r=x3l=x1c.r; x4r=x4l=x1c.l; 0.5[y3l,y4r]=0.5[-d,h];
  y3l-y1c.r=vround 1/3(0.5[-d,h]-y1c.r);
  a:=rth-tiny; b:=abs(z4r-z3l);
  y3r-y3l=y4r-y4l=a/(((x4r-x3l)/b)*((b+-+a)/b)+((y4r-y3l)/b)*(a/b));
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(arrow_up_down_not,
    7u#+2appr#,asc_height#,asc_depth#);
  "Negated Upward-Downward arrow";
  pickup tiny.nib;
  arrow_head1(straight_path(up,o),both);% corrected 2002/07/29
  arrow_head2(straight_path(down,o),both);% corrected 2002/07/29
  filldraw z1l--z2r--z2l--z1r--cycle;;
%
  x3r=x3l=x1c.l; x4r=x4l=x1c.r; 0.5[y3l,y4r]=0.5[-d,h];
  y1c.r-y4r=vround 1/3(y1c.r-0.5[-d,h]);
  a:=rth-tiny; b:=abs(z4r-z3l);
  y3r-y3l=y4r-y4l=a/(((x4r-x3l)/b)*((b+-+a)/b)+((y4r-y3l)/b)*(a/b));
  filldraw stroke z3e..z4e;
  penlabels(1,2,3,4);
endchar;

beginchar(double_arrow_up_not,
    9u#+2appr#,asc_height#,asc_depth#);
  "Negated Up double arrow";
  pickup tiny.nib;
  double_arrow_head1((hround 0.5(w-rth)+0.5rth,
      h+o),up);
  pos2r(rth,0); pos2l(rth,0);
  bot y2r=bot y2l=-d; x2r=x1r; x2l=x1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  penlabels(2r,2l);
%
  rt x4r=rt x4l=x1a.l; x3l=x3r=2x1-x4r;
  0.5[y3l,y4r]=0.5[-d,h];
  y1a.l-top y4r=vround 1/5(y1a.l-0.5[-d,h]);
  a:=rth-tiny; b:=abs(z4r-z3l);
  y3r-y3l=y4r-y4l=a/(((x4r-x3l)/b)*((b+-+a)/b)+((y4r-y3l)/b)*(a/b));
  filldraw stroke z3e..z4e;
  penlabels(3,4);
endchar;

beginchar(double_arrow_down_not,
    9u#+2appr#,asc_height#,asc_depth#);
  "Negated down double arrow";
  pickup tiny.nib;
  double_arrow_head1((hround 0.5(w-rth)+0.5rth,
      -d-o),down);
  pos2r(rth,180); pos2l(rth,180);
  top y2r=top y2l=h; x2r=x1r; x2l=x1l;
  filldraw stroke z1r.e..z2r.e;
  filldraw stroke z1l.e..z2l.e;
  penlabels(2r,2l);
%
  lft x3r=lft x3l=x1a.l; x4l=x4r=2x1-x3r;
  0.5[y3l,y4r]=0.5[-d,h];
  bot y3l-y1a.l=vround 1/5(0.5[-d,h]-y1a.l);
  a:=rth-tiny; b:=abs(z4r-z3l);
  y3r-y3l=y4r-y4l=a/(((x4r-x3l)/b)*((b+-+a)/b)+((y4r-y3l)/b)*(a/b));
  filldraw stroke z3e..z4e;
  penlabels(3,4);
endchar;

beginchar(double_arrow_up_down_not,
    9u#+2appr#,body_height#,paren_depth#);
  "Negated up-down double arrow";
  pickup tiny.nib;
  double_arrow_head1((hround 0.5(w-rth)+0.5rth,
      h+o),up);
  double_arrow_head2((hround 0.5(w-rth)+0.5rth,
      -d-o),down);
  filldraw z1r.r--z1r.l--z2l.r--z2l.l--cycle;
  filldraw z1l.r--z1l.l--z2r.r--z2r.l--cycle;
%
  rt x4r=rt x4l=x1a.l; x3l=x3r=2x1-x4r;
  0.5[y3l,y4r]=0.5[-d,h];
  y1a.l-top y4r=vround 1/5(y1a.l-0.5[-d,h]);
  a:=rth-tiny; b:=abs(z4r-z3l);
  y3r-y3l=y4r-y4l=a/(((x4r-x3l)/b)*((b+-+a)/b)+((y4r-y3l)/b)*(a/b));
  filldraw stroke z3e..z4e;
  penlabels(3,4);
endchar;
