% blackboard typefaces by Anthony Phan.
% file: mbbsymbl.mf (various blackboard symbols)
% last modification: 25.10.2001.

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

% usual symbols

iff known equal_sign:
compute_spread(.35x_height#,.45x_height#);
beginchar(equal_sign,12u#+2appr#,v_center(spread#+rule_thickness#));
  "Equality sign";
  italcorr charht*slant-.5u#;
  penpos1(rule_thickness,90); penpos2(rule_thickness,90);
  penpos3(rule_thickness,90); penpos4(rule_thickness,90);
  x1=x3=Apprl; x2=x4=w-Apprr;
  y1=y2; y3=y4; y1-y3=spread; .5[y1,y3]=math_axis;
  penstroke z1e..z2e;  % upper bar
  penstroke z3e..z4e;  % lower bar
  penlabels(1,2,3,4);
endchar;

iff known plus_sign:
beginchar(plus_sign,12u#+2appr#,6u#+math_axis#,6u#-math_axis#);
  "Plus sign";
  italcorr charht*slant-.5u#;
  penpos1(rule_thickness*(1++slant),0);
  penpos2(rule_thickness*(1++slant),0);
  penpos3(rule_thickness,90); penpos4(rule_thickness,90);
  x1l=x2l=hround(0.5[Apprl,w-Apprr]-0.5rule_thickness*(1++slant));
  x3=Apprl; y3=y4=math_axis; x1l-x3=x4-x1r=y1-y3r=y3l-y2;
  penstroke z1e..z2e; % stem
  penstroke z3e..z4e; % crossbar
  penlabels(1,2,3,4);
endchar;

iff known minus_sign:
beginchar(minus_sign,12u#+2appr#,6u#+math_axis#,6u#-math_axis#);
  "Minus sign";
  italcorr charht*slant-.5u#;
  penpos1(rule_thickness,90); penpos2(rule_thickness,90);
  y1=y2=math_axis; x1=Apprl; x2=w-Apprr;
  penstroke z1e..z2e;
  penlabels(1,2,3,4);
endchar;

iff known hash_sign:
compute_spread(.35x_height#,.45x_height#);
beginchar(hash_sign,12u#+2appr#,6u#+math_axis#,6u#-math_axis#);
  "Hash sign";
  italcorr charht*slant-.5u#;
  penpos1(rule_thickness,90); penpos2(rule_thickness,90);
  penpos3(rule_thickness,90); penpos4(rule_thickness,90);
  penpos5(rule_thickness*(1++slant),0);
  penpos6(rule_thickness*(1++slant),0);
  penpos7(rule_thickness*(1++slant),0);
  penpos8(rule_thickness*(1++slant),0);
  x5l=x6l=hround(0.5[Apprl,w-Apprr]
    -0.5(rule_thickness+spread)*(1++slant));
  x7l=x8l=hround(x5l+spread*(1++slant));
  x1=x3=Apprl; x2=x4=x7r+(x5l-x1);
  y1r=y2r=vround(math_axis+0.5(rule_thickness+spread));
  y3r=y4r=y1r-spread;
  %x5l-x1=y5-y1r=y3l-y6; y5=y7; y6=y8;
  y5=y7=h; y5-y1r=y3l-y6; y6=y8;
  penstroke z1e..z2e; penstroke z3e..z4e;
  penstroke z5e..z6e; penstroke z7e..z8e;
  penlabels(1,2,3,4,5,6,7,8);
endchar;

iff known inferior_sign:
compute_spread(5/4x_height#,3/2x_height#);
beginchar(inferior_sign,11u#+2appr#,
    v_center(spread#+rule_thickness#));
  "Inferior sign";
  italcorr charht*slant-.5u#;
  y2r=0.5[y1,y3]=vround math_axis+0.5; y1-y3=spread;
  x1=w-apprr; x2r=apprl-0.5; x1=x1r=x3=x3r;
  adjust_slanted_bar(2r,1,2a,1')(0.5rule_thickness,-1);
  adjust_slanted_bar(2r,3,2b,3')(0.5rule_thickness,1);
  z1r=whatever[z2r,z1']; z3r=whatever[z2r,z3'];
  z1r-z1=z1-z1l; z3r-z3=z3-z3l;
  z2l-z1l=whatever*(z2r-z1r); z2l-z3l=whatever*(z2r-z3r);
  penstroke z1e--z2e--z3e;
  penlabels(1,2,3); labels(1',3',2a,2b);  
endchar;

iff known superior_sign:
compute_spread(5/4x_height#,3/2x_height#);
beginchar(superior_sign,11u#+2appr#,
    v_center(spread#+rule_thickness#));
  "Superior sign";
  italcorr charht*slant-.5u#;
  y2r=0.5[y1,y3]=vround math_axis+0.5; y1-y3=spread;
  x1=apprl; x2r=w-apprr+0.5; x1=x1r=x3=x3r;
  adjust_slanted_bar(2r,1,2a,1')(0.5rule_thickness,1);
  adjust_slanted_bar(2r,3,2b,3')(0.5rule_thickness,-1);
  z1r=whatever[z2r,z1']; z3r=whatever[z2r,z3'];
  z1r-z1=z1-z1l; z3r-z3=z3-z3l;
  z2l-z1l=whatever*(z2r-z1r); z2l-z3l=whatever*(z2r-z3r);
  penstroke z1e--z2e--z3e;
  penlabels(1,2,3); labels(1',3',2a,2b);  
endchar;

% blackboard symbols

iff known bbhash_mark:
use_rule2;
compute_spread(0.45x_height#,0.55x_height#);
beginchar(bbhash_mark,13u#+2appr#,asc_height#,asc_depth#);
  "Hash mark";
  italcorr (math_axis#+0.5(spread#+thin#))*slant-0.5u#;
  pickup circle.nib;
  lft x9=lft x15=apprl; rt x14=rt x20=w-apprr;
  x10-x9=x14-x13=hround((x14-x9-2hthick-thin)/3); x11-x10=x13-x12=hthick;
  x1=x2=x10=x16; x3=x4=x11=x17; x5=x6=x12=x18; x7=x8=x13=x19;
  bot y1=-d; y1=y4=y5=y8; top y2=h; y2=y3=y6=y7;
  y9=good.y(math_axis-0.5spread); y9=y10=y11=y12=y13=y14;
  y15=good.y(math_axis+0.5spread); y15=y16=y17=y18=y19=y20;
  pickup square.nib;
  draw z1--z2--z3--z4--cycle; draw z5--z6--z7--z8--cycle;
  draw z9..z10; draw z11..z12; draw z13..z14;
  draw z15..z16; draw z17..z18; draw z19..z20;
  labels(range 1 thru 20);
endchar;

% The small zero for `per cent sign' and al. is defined here.
if (known bbpercent)or(known bbperthousand)or(known bbsmall_zero)
  or(known bbpertenthousand):
  begingroup
    use_rule1;
    clearit; clearxy;
    h:=vround(hppp*(0.5asc_height#));
    d:=vround(hppp*(body_height#-asc_height#));
    w:=hround(hppp*(7.5u#+2appr#));
    save hThick; hThick:=hthick;
    pickup circle.nib;
    bbcircle1(apprl,w-apprr,h,0); draw last_path;
    bbbowl(z1b,z1a,z1d,hThick) last_path;
    bbbowl(z1b,z1c,z1d,hThick) last_path;
    picture tmp_picture; tmp_picture=currentpicture;
    numeric tmp_w,tmp_h; tmp_w=w; tmp_h=h;
  endgroup;
fi

iff known bbpercent:
use_rule1;
beginchar(bbpercent,16u#+2appr#,body_height#,
    body_height#-asc_height#);
  "Per cent sign";
  italcorr body_height#*slant-2.5u#;
  y1l=-d; y2r=h; x1l-apprl=w-apprr-x2r=hround 2u;
  adjust_slanted_bar(1l,2r,1r,2l)(thin,-1); penstroke z1e..z2e;
  currentpicture:=currentpicture
  +(tmp_picture shifted((tmp_h+d)*slant,asc_height-tmp_h))
  +(tmp_picture shifted(w-tmp_w,0));
  penlabels(1,2);
endchar;

% The widths of the small zero and of the next character
% are adjusted so that the distance between the two lowest
% small zeroes is exactly 0.5u# (independent of letter_fit#).
% This should be remembered when defining kerning rules.

iff known bbperthousand:
use_rule1;
beginchar(bbperthousand,24u#+2appr#,body_height#,
    body_height#-asc_height#);
  "Per thousand sign";
  italcorr body_height#*slant-u#;
  a:=hround(hppp*(16u#+2appr#));
  currentpicture:=currentpicture
  +(tmp_picture shifted((tmp_h+d)*slant,asc_height-tmp_h))
  +(tmp_picture shifted(w-tmp_w,0))
  +(tmp_picture shifted(a-tmp_w,0));
  y1l=-d; y2r=h;  x1l-apprl=a-apprr-x2r=hround 2u;
  adjust_slanted_bar(1l,2r,1r,2l)(thin,-1);
  penstroke z1e..z2e; penlabels(1,2);
endchar;

iff known bbpertenthousand:
use_rule1;
beginchar(bbpertenthousand,31.5u#+2appr#,body_height#,
    body_height#-asc_height#);
  "Per ten thousand sign";
  italcorr body_height#*slant-10u#;
  a:=hround(hppp*(16u#+2appr#));
  currentpicture:=currentpicture
  +(tmp_picture shifted((tmp_h+d)*slant,asc_height-tmp_h))
  +(tmp_picture shifted(w-tmp_w,0))
  +(tmp_picture shifted(a-tmp_w,0))
  +(tmp_picture shifted(0.5(a+w)-tmp_w,0));
  y1l=-d; y2r=h;  x1l-apprl=a-apprr-x2r=hround 2u;
  adjust_slanted_bar(1l,2r,1r,2l)(thin,-1);
  penstroke z1e..z2e; penlabels(1,2);
endchar;

iff known bbsmall_zero:
use_rule1;
beginchar(bbsmall_zero,7.5u#+2appr#,0.5asc_height#,
    body_height#-asc_height#);
  "Small zero";
  currentpicture:=tmp_picture;
endchar;

iff known bbampersand:
use_rule1;
beginchar(bbampersand,11u#+2appr#,asc_height#,0);
  "The ampersand";
  italcorr x_height#*slant-.5u#;
  numeric second_slope,t;
  pickup circle.nib;
  y2=0.558h; x4-x10=hround 0.9u; rt x6-lft x4=hround 5.6u;
  x17-x4=hround 0.5[thin,thick]; lft x10=apprl-ho;
  x5=x11=max(0.5[x4,x6],x17+eps);
  x2-x10=hThick; x15=w-apprr; y15=0;
  adjust_slanted_bar(2,15,2a,1)(thick,1);
  slope:=(y2-y1)/(x2-x1); second_slope=-0.56slope;
  a:=diag_width(thin,(1,slope));
  penpos1(a,0); penpos15(a,0);
  top y5=h+oo; bot y11=-oo;
  ellipse_set(5,4,3,1); ellipse_set(5,17,16,15);
  slope:=second_slope;
  ellipse_set(11,10,9,2); ellipse_set(5,6,7,2);
  x14r=w-apprr; y14r=x_height; z13r=whatever[z15,z16];
  z13r=whatever[z14r,(0.5[x11,x1],0)];
  penpos14(diag_width(thin,z14r-z13r),0);
  z13l=whatever[z15,z16]; z14l-z13l=whatever*(z14r-z13r);
  z13=whatever[z15,z16]; z14-z13=whatever*(z14r-z13r);
  z12=whatever[z1,z2]; z12=whatever[z13,z14];
  tmp_path:=z3{z3-z1}...z4 up_to_right z5 right_to_down z6
  ...z7---z2---z9...z10 down_to_right z11...z12{z14-z13};
  t=xpart(tmp_path intersectiontimes(z15..z16));
  z8=point t of tmp_path;
  ortho_penpos3(thin,z3-z1); ortho_penpos16(thin,z16-z15);
  y1a-y1=thin; z1a-z1=z15a-z15=whatever*(z2-z1);
  penstroke z1e..z3e; penstroke z15e..z16e; penstroke z13e..z14e;
  fill z1--z1a--z15a--z15--cycle;
  draw subpath (0,t) of tmp_path;
  draw subpath (7,12) of tmp_path;
  hbbowl(z11,z10,(x10,y2),x2-x10) tmp_path;
  draw z16{z16-z15}...z17 up_to_right z5;
  labels(1a,2,2a,4,5,6,7,8,9,10,11,12,15a,17);
  penlabels(1,3,13,14,15,16);
endchar;

iff known bbat_sign:
use_rule1;
beginchar(bbat_sign,12u#+2appr#,asc_height#,0);
  "At sign";
  italcorr 0.7asc_height#*slant-.5u#;
  numeric t; pickup circle.nib;
  if hround((w+apprl-apprr-hThick-thin)/2)
    <>(w+apprl-apprr-hThick-thin)/2: change_width fi;
  lft x7=(w+apprl-apprr-hThick-thin)/2;
  lft x3=apprl; rt x1=rt x5=w-apprr;
  x6=x8=0.5[x7,x5]; y1=0.707[y3,y2];
  top y4=h+oo; bot y2=-oo; x4=0.5[x2,0.5[x3,x5]];
  bot y6=vround 0.2h-oo; top y8=vround 0.8h+oo;
  y3=0.5[y2,y4]; y7=0.5[y6,y8];
  tmp_path:=reverse elliptic_arc(3,2,1);
  y5=0.5[y7,((x5-x4)/(x4-x3))[y4,y3]];% key formula
  tmp_path:=tmp_path & z3 up_to_right z4 right_to_down z5
  down_to_left z6 left_to_up z7 up_to_right z8 right_to_down z5;
  bbbowl(z4,z5,z6,hThick) tmp_path;
  t=12+xpart(subpath (12,infinity) of tmp_path
    intersectiontimes bowl_path);
  draw subpath (0,t) of tmp_path;
  bbbowl(z4,z3,z2,hThick) tmp_path;
  bbbowl(z8,z7,z6,hThick) tmp_path;
  square_end1(z1-z1');
  labels(1,1',2,3,4,5,6,7,8);
endchar;

iff known bbpartial:
use_rule1;
beginchar(bbpartial,8u#+2appr#,asc_height#,0);
  "The partial derivative symbol";
  italcorr .7asc_height#*slant-.5u#;
  numeric t; pickup circle.nib;
  top y2=h+oo; bot y4=-oo; y1=0.92[y4,y2];
  top y6=x_height+oo; y3=0.43[y4,y2]; y5=0.5[y4,y6];
  lft x1=apprl+hround 0.4u; rt x3=w-apprr+ho; lft x5=apprl-ho;
  x4=x6=0.5[x5,x3]; x3=x7; y5=y7;
  tmp_path:=reverse elliptic_arc(3,2,1) & z3 down_to_left
  z4 left_to_up z5 up_to_right z6 right_to_down z7;
  bbbowl(z6,z5,z4,hThick) tmp_path;
  bbbowl(z2,z3,z4,hThick) tmp_path;
  t=8+xpart(subpath (8,infinity) of tmp_path
    intersectiontimes bowl_path);
  draw subpath (0,t) of tmp_path;
  square_end1(z1-z1');
  labels(1,1',2,3,4,5,6,7);
endchar;

iff known bbWeierstrass_p:
use_rule1;
beginchar(bbWeierstrass_p,10u#+2appr#,x_height#,desc_depth#);
  "The Weierstrass' p";
  italcorr 0.6x_height#*slant+ho#-.5u#;
  path tmp_path[]; numeric t[]; pickup circle.nib;
  top y1=h+o; top y8=vround 0.9h+o; bot y10=-oo; bot y6=-d-o;
  y0=0.5[y1,y6]; y9=0.5[y8,y10];
  lft x2l=apprl-ho; rt x9=w-apprr+ho; x5r-x2l=hround 5u+2eps;
  x2r-x2l=x5r-x5l=hround 0.375[thin,ess]; x0=x6=0.5[x2l,x5r];
  x1=good.x x0; x9-x12=hThick; x8=x10=0.7[x2l,x9];
  slope:=-(h+d)/9u; ortho_penpos0(ess,-(1,slope));
  ellipse_set(1,2l,3l,0l); ellipse_set(1,2r,3r,0r);
  ellipse_set(6,5l,4l,0l); ellipse_set(6,5r,4r,0r);
  tmp_path1=z1 left_to_down z2r...z3r---z4r...z5r down_to_left z6;
  tmp_path2=z1 left_to_down z2l...z3l---z4l...z5l down_to_left z6;
  y7=0.5[y5r,y5l]; x7=good.x(2x0-0.5[x5r,x5l]);
  y11''=y9; 0.5[x11'',x9]=x10; lft x11=max(rt x5r+0.25u,lft x11'');
  y11'=y10;
  tmp_path3=z7 up_to_right z8 right_to_down z9 down_to_left z10
  left_to_up z11'';
  t1=xpart(tmp_path3 intersectiontimes tmp_path2);
  t2=xpart(tmp_path3 intersectiontimes tmp_path1);
  t3=xpart(tmp_path3 intersectiontimes ((x11,y10)..(x11,y9)));
  bbbowl(z8,z9,z10,hThick) tmp_path3;
  z11=point t3 of tmp_path3; z11'-z11=whatever*(direction t3 of tmp_path3);
  draw tmp_path1&z6 left_to_up z7&subpath (0,t1) of tmp_path3;
  draw tmp_path2; draw subpath (t2,t3) of tmp_path3;
  square_end1(right); square_end11(z11-z11');
  penlabels(0,2,3,4,5); labels(1,6,7,8,9,10,11);
endchar;

% Currency signs

iff known bbdollar:
use_rule2;
beginchar(bbdollar,8u#+2appr#,body_height#,body_height#-asc_height#);
  "The dollar sign";
  italcorr fig_height#*slant-.5u#;% I don't know why (see computer modern).
  center_stem(10,13);
  slope:=-asc_height/40u; y5=0.52asc_height;
  top y2=asc_height+oo; bot y8=-oo;
  y1=good.y 0.918[y8,y2]; y9=good.y 0.126[y8,y2];
  lft x3l=lft x9-0.15u=apprl;
  rt x7r=w-apprr; rt x1=w-apprr-0.825u;
  x2=x5=x8=0.5[apprl,w-apprr];
  x3r-x3l=x7r-x7l=hround 0.475[thin,cap_ess];
  ortho_penpos5(cap_ess,(-1,-slope));
  forsuffixes $=r,l:
    ellipse_set(2,3.$,4.$,5.$); ellipse_set(8,7.$,6.$,5.$);
  endfor
  z1'-z1=(z2-z1)xscaled 0.36; z9-z9'=(z9-z8)xscaled 0.3;
  tmp_path:=z1{z1'-z1}...z2 left_to_down z3l...z4l
  ---z6l...z7l down_to_left z8;
  tmpp_path:= z2 left_to_down z3r...z4r
  ---z6r...z7r down_to_left z8...{z9-z9'}z9;
  bot y10=-d; top y13=h;
  z11=tmp_path intersectionpoint((x10,y3l)..(x10,y7l));
  z12=tmpp_path intersectionpoint((x10,y3r)..(x10,y7r));
  draw tmp_path; draw tmpp_path; draw z10..z11; draw z12..z13;
  square_end10(down); square_end13(up);
  square_end1(z1-z1'); square_end9(z9-z9');
  labels(1,1',2,8,9,9',10,11,12,13); penlabels(3,4,5,6,7);
endchar;

iff known bbeuro:
use_rule2;
beginchar(bbeuro,12u#+2appr#,asc_height#,0);
  "The euro sign";
  italcorr asc_height#*slant-.5u#;
  pickup circle.nib;
  ortho_penpos2(thin,left); ortho_penpos4(thin,right);
  x1l=x5l=x5r=w-apprr; lft x3=apprl+ceiling u-eps;
  x0=x2=x4=(1/(1+cosd40))[rt x3,x1l];
  top y2=h+o; bot y4=-o; y3=y0=0.5[y2,y4];
  y1l-y0=y0-y5l=(y2l-y0)*sind 40;
  y5l-y5r=thin/sind 40;
  z1r-z1l=thin/cosd(angle(z1l-z4r)-40)*unitvector(z1l-z4r);
  tmp_path:=z2 left_to_down z3 down_to_right z4;
  draw tmp_path;
  bbbowl(z2,z3,z4,hThick) tmp_path;
  y8=good.y 0.6[y4,y2]; y12=good.y 0.4[y4,y2];
  y8r=top y8; y8l=bot y8; y12r=top y12; y12l=bot y12;
  y8r=y11r; y8l=y11l; y12r=y15r; y12l=y15l;
  x8r=x12r=apprl; z8r-z8l=z12r-z12l=whatever*(z1l-z4r);
  z11r=whatever[z1l,z4r]; z11l=whatever[z1l,z4r];
  z15r=whatever[z1l,z4r]; z15l=whatever[z1l,z4r];
  z9r=tmp_path intersectionpoint ((0,y8r)...(w,y8r));
  z9l=tmp_path intersectionpoint ((0,y8l)...(w,y8l));
  z10r=bowl_path intersectionpoint ((0,y8r)...(w,y8r));
  z10l=bowl_path intersectionpoint ((0,y8l)...(w,y8l));
  z13r=tmp_path intersectionpoint ((0,y12r)...(w,y12r));
  z13l=tmp_path intersectionpoint ((0,y12l)...(w,y12l));
  z14r=bowl_path intersectionpoint ((0,y12r)...(w,y12r));
  z14l=bowl_path intersectionpoint ((0,y12l)...(w,y12l));
  penstroke z1e...z2e{left}; penstroke z4e{right}...z5e;
  penstroke z8e..z9e; penstroke z10e..z11e;
  penstroke z12e..z13e; penstroke z14e..z15e;
  penlabels(1,2,4,5,8,9,10,11,12,13,14,15);
  labels(0,3,3,5);
endchar;

iff known bbpound:
use_rule2;
beginchar(bbpound,8.5u#+2appr#,asc_height#,0);
  "The pound sign";
  italcorr asc_height#*slant-.5u#;% to be corrected
  pickup circle.nib;
  lft x1=lft x3=apprl; rt x2=w-apprr;
  hround((w-apprl-apprr-hthick-thin)/3)=x8-x1=x2-x6;  
  hthick=x11-x8; x4=lft x8; x5=rt x11;
  x12=0.25[x1,x8]; bot y1=0; y1=y2=y12;
  y3=y4=y5=y6=good.y 0.5h; y8=0.75h; y11=0.25h;
  x9=x6+hround 0.05u; x9=0.25[x10,x11];
  top y9=top y10=h;
  tmp_path:=z8 up_to_right z9...z10;
  tmpp_path:=z11 down_to_left z12---z1;
  draw tmp_path; draw tmpp_path;
  hbbowl(z9,z8,(x8,y11),x11-x8) tmp_path;
  hbbowl(z12,z11,(x11,y8),x11-x8) tmpp_path;
  square_end10(right); pickup square.nib;
  draw z1..z2; draw z3..z4; draw z5..z6;
  labels(1,2,3,4,5,6,7,8,9,10,11,12);
endchar;

iff known bbcent:
use_rule1;
beginchar(bbcent,7u#+2appr#,x_height#+0.5desc_depth#,0.5desc_depth#);
  "The cent sign";
  italcorr x_height#*slant-.5u#;
  pickup circle.nib;
  x1=x5=w-apprr; lft x3=apprl-ho;
  top y2=x_height+uo; bot y4=-oo; y3=0.5[y4,y2];
  y1=0.707[y3,y2]; y5=0.707[y3,y4];
  tmp_path:=reverse elliptic_arc(3,2,1)&elliptic_arc(3,4,5);
  x6=x7=good.x(x2+eps); bot y6=-d; top y7=h;
  draw tmp_path; bbbowl(z2,z3,z4,hThick) tmp_path;
  square_end1(z1-z1');
  square_end5(z5-z5');
  pickup square.nib; draw z6..z7;
  labels(1,1',2,3,4,5,5',6,7);
endchar;

iff known bbyen:
use_rule2;
beginchar(bbyen,12u#+2appr#,cap_height#,0); "The Yen sign";
  italcorr cap_height#*slant-0.5u#;
%  copy of roman Y
  center_bar(3,4); bot y3=bot y4=-d;
  x3l=apprl+hround(0.5(w-apprr-apprl-hthick-thin*(1++slant)));
  x4l-x3l=hround(hthick+thin*(1++slant));
  x3r-x3l=x4l-x4r=thin*(1++slant);
  y4l=y3l=-d; y3r-y3l=y4r-y4l=thin;
  y1=y6=y7r=h; x1=apprl; x7r=w-apprr;
  x2=x3; y2=y5a=0.4h; x6-x1=x5a-x2=diag_width(thick,z1-z2);
  a:=diag_width(thin,z1-z2);
  penpos1(a,0); penpos6(a,180); z8=z5;
  forsuffixes $=,r,l: x5$=x4$; z5$-z6$=whatever*(z2-z1); endfor
  forsuffixes $=r,l: x2$=x3$; z2$-z1$=whatever*(z2-z1); endfor
  y1-y1a=y6-y6a=thin; z1a=whatever[z1,z2]; z6a=whatever[z6,z5a];
  adjust_slanted_bar(7r,8,7,8a)(0.5thin,-1); z7-z7l=z7r-z7;
  ortho_penpos8(thin,z7-z8);
  penstroke z1e--z2e--z3e--z4e--z5e--z6e;
  fill z1--z6--z6a--z1a--cycle; penstroke z7e..z8e;
  penlabels(1,2,3,4,5,6,7,8,9,10); labels(1a,5a,6a,8a);
%  bars
  lft x11=lft x15=apprl+hround 0.8u;
  rt x14=rt x18=w-apprr-hround 0.8u;
  y11=h-y15=good.y 0.6h; y11=y12=y13=y14; y15=y16=y17=y18;
  x16=x3; if y5>y17: x17=x4 else: z17=whatever[z5,z6] fi;
  z12=whatever[z1,z2];  z13=whatever[z5,z6];
  draw z11..z12; draw z13..z14; draw z15..z16; draw z17..z18;
  square_end14(right); square_end18(right);
  square_end11(left);square_end15(left);
  labels(11,12,13,14,15,16,17,18);
endchar;

% The next symbol is supposed to be associated
% to the israelian currency: the shereq
iff known bbshereq:
use_rule2;
beginchar(bbshereq,16u#+2appr#,cap_height#,0);
  "The shereq sign";
  italcorr cap_height#*slant-.5u#;
  pickup circle.nib;
  top y1=h; bot y2=0; y1=y4=y5=y15; y2=y3=y9=y12=y13;
  top y10=top y11=vround 0.8h; y7=y1-y10;
  y6=0.3[y1,y2]; y14-y13=y5-y6;
  lft x3=lft x4=apprl; rt x14=rt x15=w-apprr;
  x1=x2=x3+hthick; x6=x7; x9=x10; x11=x12=x9-hthick;
  x11-x3=x15-x7=hround((x15-x3-4hthick)/3)+hthick;
  x5=0.5[x1,x7]; x13=0.5[x9,x15];
  tmp_path:=z4..z5 right_to_down z6..z7;
  tmpp_path:=z12..z13 right_to_up z14..z15;
  draw tmp_path; draw tmpp_path;
  hbbowl(z5,z6,z7,hthick) tmp_path; z8=z.bowl.bot;
  hbbowl(z13,z14,z15,hthick) tmpp_path;
  pickup square.nib;
  draw z1--z2--z3--z4; draw z9--z10--z11--z12;
  draw z7..z8; draw z15..z.bowl.bot;
  labels(range 1 thru 18);
endchar;

% funny things

iff known bbestimated:
use_rule2;
beginchar(bbestimated,13u#+2appr#,cap_height#,0);
  "The Estimated sign (large e)";
  italcorr 0.6cap_height#*slant-.5u#;
  numeric t; pickup circle.nib;
  rt x1=w-apprr; lft x3=apprl; x2=x4=0.5[x1,x3];
  top y2=h+o; bot y4=-o; y1=y3=good.y(0.5[y2,y4]);
  tmp_path:=superellipse(z1,z2,z3,z4,superness);
  t=xpart(tmp_path intersectiontimes
    (bot(w/2,0.25[y4,y2])..bot(w,0.25[y4,y2])));
  draw subpath (0,t) of tmp_path;
  z5=point t of tmp_path;
  bbbowl(z2,z3,z4,hThick) tmp_path;
  z6=(x.bowl.mid,y1);
  hbbowl(z2,z1,z1,hThick) tmp_path;
  x6r=x6l=x6; x1r=x1; x1m=x1l=rt x1;
  y6r=y1r=top y1; y1m=y1; y1l=y6l=bot y1;
  fill z1l--z1m--z1r--z6r--z6l--cycle;
  square_end5(direction t of tmp_path);
  labels(1,1r,1l,1m,2,3,4,5,6,6l,6r);
  math_fit(0,0);
endchar;

iff known bbbar_h:
use_rule1;
beginchar(bbbar_h,8u#+2appr#,asc_height#,0);
  "The letter bar h";
  italcorr 0.75x_height#*slant-.5u#;
  complete_n;
  y13=y14=y15=y16=good.y 0.5[bot h,bot x_height];
  lft x13=apprl-hround u; x14=lft x1; x15=rt x2;
  rt x16-lft x13=hround(3.8u+thin+hthick);
  draw z13..z14; draw z15..z16; labels(13,14,15,16);
endchar;

iff known bbcross_h:
use_rule1;
beginchar(bbcross_h,8u#+2appr#,asc_height#,0);
  "The letter crossed h";
  italcorr 0.75x_height#*slant-.5u#;
  complete_n;
  y13r=x_height; y16r=h; x13r=apprl-hround u;
  x16r-x13r=hround(3.8u+thin+hthick);
  ortho_penpos13(thin,z13r-z16r); ortho_penpos16(thin,z13r-z16r);
  x14r=x14l=x1; x15r=x15l=x2;
  z14r=whatever[z13r,z16r]; z14l=whatever[z13l,z16l];
  z15r=whatever[z13r,z16r]; z15l=whatever[z13l,z16l];
  penstroke z13e..z14e; penstroke z15e..z16e;
  penlabels(13,14,15,16);
endchar;

