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

% Inclusion signs and related things (relations).
% Some pictures overlap the bottom. It is necessary
% for correct centering of the whole box.
% Spreads for cross bars have been checked.

def horizontal_rules_list=math_axis,
  -body_depth,-desc_depth,x_height,cap_height,asc_height,body_height
enddef;

%turningcheck:=0;

use_rule1;

beginpicture(tmp,12u#+2appr#,v_center(spread2#+rth#));
pickup tiny.nib;
if main_name_string="subset":
  pos1(rth,90); pos2(rth,90);
  pos4(rth,270); pos5(rth,270);
  y1-y5=spread2; 0.5[y1,y5]=y3=math_axis; y2=y1; y4=y5;
  rt x1=rt x5=w-Appr; x3-0.5rth=appr; x2=x4=1/3[x3,x1];
  filldraw stroke z5e..z4e; filldraw stroke z2e..z1e;
  pickup rule.nib; autorounded;
  draw z2 left_to_down z3 down_to_right z4;
elseif main_name_string="supset":
  pos1(rth,90); pos2(rth,90);
  pos3(rth,0); pos4(rth,-90); pos 5(rth,-90);
  y1-y5=spread2; 0.5[y1,y5]=y3=math_axis; y2=y1; y4=y5;
  lft x1=lft x5=Appr; x3+0.5rth=w-appr; x2=x4=1/3[x3,x1];
  filldraw stroke z1e..z2e; filldraw stroke z4e..z5e;
  pickup rule.nib; autorounded;
  draw z2 right_to_down z3 down_to_left z4;
elseif main_name_string="sqsubset":
  pos1(rth,90); pos4(rth,-90);
  x2l-x2r=x3l-x3r=rth-tiny;
  y1-y4=spread2; 0.5[y1,y4]=math_axis;
  rt x1=rt x4=w-Appr; lft x2r=lft x3r=Appr;
  forsuffixes $=r,l: y1$=y2$; y3$=y4$; endfor
  filldraw stroke z4e--z3e--z2e--z1e;
else:
  pos1(rth,90); pos4(rth,-90);
  x2r-x2l=x3r-x3l=rth-tiny;
  y1-y4=spread2; 0.5[y1,y4]=math_axis;
  lft x1=lft x4=Appr; rt x2r=rt x3r=w-Appr;
  forsuffixes $=r,l: y1$=y2$; y3$=y4$; endfor
  filldraw stroke z1e--z2e--z3e--z4e;
fi
endpicture;

beginchar(main_name_with(),
    12u#+2appr#,v_center(spread2#+rth#));
  main_name_string&" sign";
  currentpicture:=tmp_picture;
endchar;

beginchar(main_name_with(_not),
    12u#+2appr#,asc_height#,asc_depth#);
  "not "&main_name_string&" sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0);
  v_adjust(1l,2l,math_axis,max(h+d,spread2+spread1));
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_eq),
    12u#+2appr#,v_center(spread2#+rth#+spread1#));
  main_name_string&" or equal sign";
  currentpicture:=tmp_picture
  shifted(0,0.5spread1);
  pickup tiny.nib;
  pos1(rth,90); pos2(rth,90);
  y1=y2=math_axis-0.5(spread2+spread1);
  lft x1=Appr; rt x2=w-Appr;
  filldraw stroke z1e..z2e; penlabels(1,2);
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_not_eq),
    12u#+2appr#,asc_height#,asc_depth#);
  "not "&main_name_string&" nor equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0);
  v_adjust(1l,2l,math_axis,max(h+d,spread2+2spread1));
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_eq_not),
    12u#+2appr#,v_center(spread2#+rth#+spread1#));
  main_name_string&" but not equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread2+spread1);
  x0=0.5w;
  v_adjust(1r,2l,y0,1.5spread1-0.5rth);
  lft x2l-Appr=w-Appr-rt x1r=hround 3.5u;
  adjust_slanted_bar(2l,1r,2r,1l)(rth-tiny,-1);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_eq_varnot),
    12u#+2appr#,v_center(spread2#+rth#+spread1#));
  "variant "&main_name_string&" but not equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5spread2; x0=0.5w;
  v_adjust(1r,2l,y0,2.5spread1-0.5rth);
  lft x2l-Appr=w-Appr-rt x1r=hround 2.75u;
  adjust_slanted_bar(2l,1r,2r,1l)(rth-tiny,-1);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_eqq),
    12u#+2appr#,v_center(spread2#+rth#+2spread1#));
  main_name_string&" or equal-equal sign";
  currentpicture:=tmp_picture shifted(0,0.5spread1);
  pickup tiny.nib;
  pos1(rth,90); pos2(rth,90);
  y1=y2=math_axis+spread1-0.5spread2-2spread1;
  lft x1=Appr; rt x2=w-Appr;
  filldraw stroke z1e..z2e; penlabels(1,2);
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_not_eqq),
    12u#+2appr#,asc_height#,asc_depth#);
  "not "&main_name_string&" nor equal-equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  pos1(rth,0); pos2(rth,0);
  v_adjust(1l,2l,math_axis,max(h+d,spread2+3spread1));
  lft x1l=lft x2l=hround 0.5(w-rth);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_eqq_not),
    12u#+2appr#,v_center(spread2#+rth#+2spread1#));
  main_name_string&" but not equal-equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread2+spread1);
  x0=0.5w;
  v_adjust(1r,2l,y0,2.5spread1-0.5rth);
  lft x2l-Appr=w-Appr-rt x1r=hround 2.75u;
  adjust_slanted_bar(2l,1r,2r,1l)(rth-tiny,-1);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_eqq_varnot),
    12u#+2appr#,v_center(spread2#+rth#+2spread1#));
  "variant "&main_name_string&" but not equal-equal sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  y0=math_axis-0.5(spread2); x0=0.5w;
  v_adjust(1r,2l,y0,3.5spread1-0.5rth);
  lft x2l-Appr=w-Appr-rt x1r=hround 2.25u;
  adjust_slanted_bar(2l,1r,2r,1l)(rth-tiny,-1);
  filldraw stroke z1e..z2e; penlabels(0,1,2);
endchar;

beginchar(main_name_with(_double),
    arithmetic_bounds);
  main_name_string&" double sign";
  pickup tiny.nib;
  numeric a; a=0.5min(spread2,0.5(h+d-rth));
  if main_name_string="subset":
    rt x1=rt x5=w-appr; rt x6=rt x10=w-Appr;
    y1-y5=4vround a; y6-y10=2vround a;
    y3=y8=0.5[y1,y5]=0.5[y6,y10]=math_axis;
    y2=y1; y4=y5; y7=y6; y9=y10;
    pos1(rth,90); pos2(rth,90);
    pos3(rth,180); pos4(rth,270); pos5(rth,270);
    pos6(rth,90); pos7(rth,90);
    pos8(rth,180); pos9(rth,270); pos10(rth,270);
    lft x3r=appr; x8-x3=hround a;
    x2=x4=x7=x9=1/3[x8,x6];
    filldraw stroke z5e..z4e left_to_up
    z3e up_to_right z2e..z1e;
    filldraw stroke z10e..z9e left_to_up
    z8e up_to_right z7e..z6e;
    penlabels(1,2,3,4,5,6,7,8,9,10);
  elseif main_name_string="supset":
    lft x1=lft x5=appr; lft x6=lft x10=Appr;
    y1-y5=4vround a; y6-y10=2vround a;
    y3=y8=0.5[y1,y5]=0.5[y6,y10]=math_axis;
    y2=y1; y4=y5; y7=y6; y9=y10;
    pos1(rth,90); pos2(rth,90);
    pos3(rth,0); pos4(rth,270); pos5(rth,270);
    pos6(rth,90); pos7(rth,90);
    pos8(rth,0); pos9(rth,270); pos10(rth,270);
    rt x3r=w-appr; x8-x3=-hround a;
    x2=x4=x7=x9=1/3[x8,x6];
    filldraw stroke z1e..z2e right_to_down
    z3e down_to_left z4e..z5e;
    filldraw stroke z6e..z7e right_to_down
    z8e down_to_left z9e..z10e;
    penlabels(1,2,3,4,5,6,7,8,9,10);
  elseif main_name_string="sqsubset":
    rt x1=rt x5=w-appr; rt x6=rt x10=w-Appr;
    y1-y5=4vround a; y6-y10=2vround a;
    y3=y8=0.5[y1,y5]=0.5[y6,y10]=math_axis;
    lft x3r=Appr; x8-x3=hround a;
    pos1(rth,90); pos3(rth,180); pos5(rth,270);
    pos6(rth,90); pos8(rth,180); pos10(rth,270);
    forsuffixes $=,r,l: x2$=x3$=x4$; y1$=y2$; y4$=y5$;
      x7$=x8$=x9$; y6$=y7$; y9$=y10$; endfor
    filldraw stroke z5e--z4e--z2e--z1e;
    filldraw stroke z10e--z9e--z7e--z6e;
    penlabels(1,2,3,4,5,6,7,8,9,10);
  else:
    lft x1=lft x5=appr; lft x6=lft x10=Appr;
    y1-y5=4vround a; y6-y10=2vround a;
    y3=y8=0.5[y1,y5]=0.5[y6,y10]=math_axis;
    rt x3r=w-Appr; x8-x3=-hround a;
    pos1(rth,90); pos3(rth,0); pos5(rth,270);
    pos6(rth,90); pos8(rth,0); pos10(rth,270);
    forsuffixes $=,r,l: x2$=x3$=x4$; y1$=y2$; y4$=y5$;
      x7$=x8$=x9$; y6$=y7$; y9$=y10$; endfor
    filldraw stroke z1e--z2e--z4e--z5e;
    filldraw stroke z6e--z7e--z9e--z10e;
    penlabels(1,2,3,4,5,6,7,8,9,10);
  fi
  tmp_picture:=currentpicture;
endchar;

beginchar(main_name_with(_double_not),
    12u#+2appr#,asc_height#,asc_depth#);
  "not "&main_name_string&" double sign";
  currentpicture:=tmp_picture;
  pickup tiny.nib;
  numeric a; a=
  if (main_name_string="subset")
    or (main_name_string="sqsubset"): - fi
  0.5min(spread2,0.5(h+d-rth));
  pos1(rth,0); pos2(rth,0);
  v_adjust(1l,2l,math_axis,max(h+d,12u+spread1));
  lft x1l=lft x2l=hround 0.5(w-0.5rth-0.5a);
  filldraw stroke z1e..z2e; penlabels(1,2);
endchar;

beginchar(main_name_with(_dot),
    12u#+2appr#,v_center(spread2#+rth#));
  main_name_string&" with dot sign";
  currentpicture:=tmp_picture;
  adjust_dot1((math_axis,
      if (main_name_string="subset")
	or (main_name_string="sqsubset"): w-appr-0.5dtsz
      else: appr+0.5dtsz fi),dtsz,true,false);
  dot(1,1');
endchar;
