% blackboard typefaces by Anthony Phan.
% file: mbbhebma.mf (Hebrew masoteric accents)
% last modification: 25.10.2001.

diacritics_proofing;% changes extra_endchar for proof mode.

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

use_rule1;

beginchar(bbhebmas[1],8u#+2appr#,0,bot_skip#+
    if square_dots: heb_size1# else: heb_size2# fi);
  "Hebrew accent etnahta";
  if square_dots:
    if not(odd(w-apprl-apprr)): change_width; fi
    x2r=0.5[apprl,w-apprr]; x3r-x1r=hround 6u; 0.5[x3r,x1r]=x2r; 
    y2r=-bot_skip+0.5; y1r=y3r=-d;
    z1l-z1r=(diag_width(thin,z2r-z1r),0);
    z3l-z3r=(-diag_width(thin,z2r-z3r),0);
    z2l-z1l=whatever*(z2r-z1r); z2l-z3l=whatever*(z2r-z3r);
    penstroke z1e--z2e--z3e; penlabels(1,2,3);
  else: center_stem(2,4); top y4=-bot_skip; bot y1=bot y3=-d;
    y2=good.y 0.5[y4,y1]; x2-x1=x3-x2=hround 3u;
    draw z1 up_to_right z2 right_to_down z3; draw z2..z4;
    square_end1(down); square_end3(down);
    square_end4(up); labels(1,2,3,4);
  fi
endchar;

beginchar(bbhebmas[2],8u#+2appr#,x_height#+top_skip#+heb_size2#,0);
  "Hebrew accent segol";
  center_bar(3,3');
  lft x1-apprl=w-apprr-rt x2'=hround 0.5u; x1'-x1=x2'-x2=hthick;
  bot y1=top y3'-heb_size2=x_height+top_skip; y2=y1;
  top y1'-bot y1=top y2'-bot y2=top y3'-bot y3=dot_size;
  dot(1,1'); dot(2,2'); dot(3,3');
endchar;

beginchar(bbhebmas[3],8u#+2appr#,x_height#+top_skip#+heb_size2#,0);
  "Hebrew accent shalshelet";
  numeric a,b; a=vround 0.2(heb_size2-2thin);
  b=hround max(3thin,4u);
  x1l=x1r=x3l=x5l=hround(0.5[apprl,w-apprr]-0.5b);
  x2r=x4r=x6r=x6l=x1l+b; x7l=x7r=x6r+hround 0.5u;
  y2r-y1l=y3l-y2r=y4r-y3l=y5l-y4r=y6r-y5l=a;
  y1l=x_height+top_skip+thin+0.5;
  adjust_slanted_bar(1l,2r,1a,2b)(thin,-1);
  adjust_slanted_bar(2r,3l,2a,3b)(thin,1);
  adjust_slanted_bar(3l,4r,3a,4b)(thin,-1);
  adjust_slanted_bar(4r,5l,4a,5b)(thin,1);
  adjust_slanted_bar(5l,6r,5a,6b)(thin,-1);
  z1r=whatever[z1a,z2r];
  z2l=whatever[z1l,z2b]; z2l=whatever[z3l,z2a];
  z3r=whatever[z2r,z3b]; z3r=whatever[z4r,z3a];
  z4l=whatever[z3l,z4b]; z4l=whatever[z5l,z4a];
  z5r=whatever[z4r,z5b]; z5r=whatever[z6r,z5a];
  z6l=whatever[z5l,z6b];
  z7r=whatever[z5r,z6r]; z7l=whatever[z5l,z6l];
  penstroke z1e--z2e--z3e--z4e--z5e--z7e;
  penlabels(1,2,3,4,5,6,7);
  labels(1a,2a,2b,3a,3b,4a,4b,5a,5b,6b);
endchar;

beginchar(bbhebmas[4],8u#+2appr#,x_height#+top_skip#+heb_size2#,0);
  "Hebrew accent zaqef qatan";
  center_bar(1,1'); x2=x1; x2'=x1';
  bot y1=top y2'-heb_size2=x_height+top_skip;
  top y1'-bot y1=top y2'-bot y2=dot_size;
  dot(1,1'); dot(2,2');
endchar;

beginchar(bbhebmas[5],8u#+2appr#,x_height#+top_skip#+heb_size2#,0);
  "Hebrew accent zaqef gadol";
  pickup circle.nib; a:=max(u,1.5thin,0.5(hthick+thin));
  lft x1=lft x2=vround(0.5[apprl,w-apprr]+a-0.5(hthick+thin));
  x3=x4=good.x(0.5[apprl,w-apprr]-a); x1'-x1=x2'-x2=hthick;
  bot y1=top y4-heb_size2=x_height+top_skip; y1=y3; y2'=y4;
  top y1'-bot y1=top y2'-bot y2=dot_size; dot(1,1'); dot(2,2');
  pickup square.nib; draw z3..z4; labels(3,4);
endchar;

beginchar(bbhebmas[6],8u#+2appr#,0,top_skip#+heb_size1#);
  "Hebrew accent tipeha";
  complete_hebrew_club(0.5[apprl,w-apprr],-bot_skip,-d,1);
endchar;

% okay sauf la hauteur.
beginchar(bbhebmas[7],8u#+2appr#,x_height#+top_skip#+dot_size#,0);
  "Hebrew accent revia";
  if not(odd(w-apprl-apprr)): change_width; fi
  x0=0.5[apprl,w-apprr];
  y0=x_height+top_skip+vround 0.5dot_size+0.5;
  x3r-x1r=sqrt 2*(thick+thin)*(1++slant);
  y2r-y4r=sqrt2*dot_size;
  x0=x2r=x4r=0.5[x3r,x1r]; y0=y1r=y3r=0.5[y2r,y4r];
  z1a-z1r=(diag_width(thin,z2r-z1r),0);
  z1b-z1r=(diag_width(thin,z4r-z1r),0);
  z3a-z3r=(-diag_width(thin,z2r-z3r),0);
  z3b-z3r=(-diag_width(thin,z4r-z3r),0);
  z2l-z1a=whatever*(z2r-z1r); z2l-z3a=whatever*(z2r-z3r);
  z4l-z1b=whatever*(z4r-z1r); z4l-z3b=whatever*(z4r-z3r);
  z2l-z1l=whatever*(z2r-z1r); z4l-z1l=whatever*(z4r-z1r);
  z2l-z3l=whatever*(z2r-z3r); z4l-z3l=whatever*(z4r-z3r);
  penstroke z1e--z2e--z3e--z4e--cycle;
  penlabels(1,2,3,4,1',2',3',4'); labels(1a,1b,2a,2b);
endchar;

beginchar(bbhebmas[8],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent zarqa";
  pickup circle.nib;
  a:=max(6u,5thin);
  bot y1=x_height+top_skip; y1=y6; top y8=h; y8=y3;
  y0=y2=y7=0.5[y1,y8]; rt x7=hround(0.5[apprl,w-apprr]-0.5a);
  rt x7-lft x2=hround a; x0=0.5[x2,x7]; slope:=-heb_size1/2u;
  hellipse_set(2,3,4,0); hellipse_set(7,6,5,0);
  x1=good.x x3; x8=good.x x6;
  draw z1 left_to_up z2 up_to_right z3...z4---z5
  ...z6 right_to_up z7 up_to_left z8;
  square_end1(right); square_end8(left);
  labels(0,1,2,3,4,5,6,7,8);
endchar;

beginchar(bbhebmas[9],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent pashta";
  complete_hebrew_club(apprl,x_height+top_skip,h,-1);
endchar;

% almost okay
beginchar(bbhebmas[10],8u#+2appr#,0,bot_skip#+heb_size1#);
  "Hebrew accent yetiv";
  y2r=0.5[y1,y3]=-vround(0.5[bot_skip,d])-0.5; y1-y3=heb_size1;
  x1=w-apprr+hround u; x1-x2r=hround 6u; x1=x1r=x3=x3r;
  adjust_slanted_bar(2r,1,2a,1a)(0.5(thin),-1);
  adjust_slanted_bar(2r,3,2b,3b)(0.5(thin),1);
  z1r=whatever[z2r,z1a]; z3r=whatever[z2r,z3b];
  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(1a,2a,2b,3b);
endchar;

beginchar(bbhebmas[11],8u#+2appr#,0,bot_skip#+heb_size1#);
  "Hebrew accent tevir";
  pickup circle.nib;
  complete_hebrew_club(0.5[apprl,w-apprr],
    -bot_skip,-bot_skip-heb_size1,-1);
  top y4'=-bot_skip; top y4'-bot y4=dot_size;
  lft x4=x1l; x4'-x4=hthick; dot(4,4');
endchar;

beginchar(bbhebmas[12],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent geresh";
  complete_hebrew_club(0.5[apprl,w-apprr],x_height+top_skip,h,1);
endchar;

beginchar(bbhebmas[13],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent geresh muqdam";
  complete_hebrew_club(w-apprr,x_height+top_skip,h,1);
endchar;

beginchar(bbhebmas[14],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent gershayim";
  a:=0.5max(5u,1.5hthick+thin,3thin)+1.5u;
  complete_hebrew_club(0.5[apprl,w-apprr]-0.5a,x_height+top_skip,h,1);
  complete_hebrew_club'(0.5[apprl,w-apprr]+0.5a,x_height+top_skip,h,1);
endchar;

beginchar(bbhebmas[15],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent qarney para";
  pickup circle.nib;
  a:=hround max(5u,hthick*sqrt 2+thin+dot_skip);
  x2=hround(0.5[apprl,w-apprr]+0.5a); x2-x8=a;
  0.5[x1,x3]=x2=x4; 0.5[x7,x9]=x8=x10;
  x1-x3=x7-x9=2hround(hthick/sqrt 2)+2eps;
  top y2=h+o; 0.5[y2,y4]=y1=y3=y7=y9; y8=y2; y10=y4;
  top y2-bot y4=2vround(dot_size/sqrt 2)+2eps;
  tmp_path:=superellipse(z1,z2,z3,z4,superness);
  tmpp_path:=superellipse(z7,z8,z9,z10,superness);
  y6=x_height+top_skip; x6=0.5[x2,x8];
  z5=tmp_path intersectionpoint ((x2,y1)..z6);
  z11=tmpp_path intersectionpoint ((x8,y7)..z6);
  ortho_penpos5(thin,z6-z5); ortho_penpos11(thin,z11-z6);
  z6r-z5r=whatever*(z6-z5); z6r-z11r=whatever*(z6-z11);
  z6l-z5l=whatever*(z6-z5); z6l-z11l=whatever*(z6-z11);
  draw tmp_path; draw tmpp_path; penstroke z5e--z6e--z11e;
  labels(1,2,3,4,7,8,9,10); penlabels(5,6,11);
endchar;

beginchar(bbhebmas[16],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent telisha gedola";
  pickup circle.nib;
  0.5[x1,x3]=x2=x4=w-apprr; x1-x3=2hround(hthick/sqrt 2)+2eps;
  top y2=h+o; 0.5[y2,y4]=y1=y3;
  top y2-bot y4=2vround(dot_size/sqrt 2)+2eps;
  tmp_path:=superellipse(z1,z2,z3,z4,superness);
  y6=x_height+top_skip; rt x1-x6=5u;
  z5=tmp_path intersectionpoint ((x2,y1)..z6);
  ortho_penpos5(thin,z6-z5);
  z6r-z6=z6-z6l=whatever*((z6-z5)rotated 90);
  z6r-z5r=whatever*(z6-z5);
  draw tmp_path; penstroke z5e..z6e;
  labels(1,2,3,4); penlabels(5,6);
endchar;

beginchar(bbhebmas[17],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent pazer";
  a:=hround max(3thin,4u);
  lft x2=hround(0.5[apprl,w-apprr]-0.5a); x2=x3=x4; rt x1-lft x2=a;
  bot y3=x_height+top_skip; y4-y1=y1-y3;
  y1=y2=good.y(x_height+top_skip+0.5heb_size1);
  pickup square.nib; draw z1..z2; draw z3..z4; labels(1,2,3,4);
endchar;

beginchar(bbhebmas[19],8u#+2appr#,0,bot_skip#+heb_size1#);
  "Hebrew accent munah";
  pickup circle.nib;
  a:=hround max(3thin,4u);
  rt x2=rt x3=hround(0.5[apprl,w-apprr]+0.5a); rt x2-lft x1=a;
  top y3=-bot_skip; bot y1=bot y2=-d;
  pickup square.nib; draw z1--z2--z3; labels(1,2,3);
endchar;

beginchar(bbhebmas[20],8u#+2appr#,0,bot_skip#+heb_size1#);
  "Hebrew accent mahapakh";
  y2r=0.5[y1,y3]=-vround(0.5[bot_skip,d])-0.5; y1-y3=heb_size1;
  x1=hround(0.5[apprl,w-apprr]+3u); x1-x2r=hround 6u; x1=x1r=x3=x3r;
  adjust_slanted_bar(2r,1,2a,1a)(0.5(thin),-1);
  adjust_slanted_bar(2r,3,2b,3b)(0.5(thin),1);
  z1r=whatever[z2r,z1a]; z3r=whatever[z2r,z3b];
  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(1a,2a,2b,3b);
endchar;

beginchar(bbhebmas[21],8u#+2appr#,0,bot_skip#+heb_size1#);
  "Hebrew accent merkha";
  complete_hebrew_club(0.5[apprl,w-apprr],-bot_skip,-d,-1);
endchar;

beginchar(bbhebmas[22],8u#+2appr#,0,bot_skip#+heb_size1#);
  "Hebrew accent kefula";
  a:=0.5max(5u,1.5hthick+thin,3thin)+1.5u;
  complete_hebrew_club(0.5[apprl,w-apprr]-0.5a,-bot_skip,-d,-1);
  complete_hebrew_club'(0.5[apprl,w-apprr]+0.5a,-bot_skip,-d,-1);
endchar;

beginchar(bbhebmas[23],8u#+2appr#,0,bot_skip#+heb_size2#);
  "Hebrew accent darga";
  a:=hround max(6u,1.5hthick+1.5thin);
  x2l=x4r=hround(0.5[apprl,w-apprr]-0.5a); x1l=x3r=x2l+a;
  y1l=y2l=-d; y3r=y4r=-bot_skip;
  penpos1(thin,90); penpos2(thin,90);
  penpos3(thin,90); penpos4(thin,90);
  z5l=z1r; z8r=z4l;
  adjust_slanted_bar(5l,8r,6r,7l)(thick+thin,+1);
  a:=-diag_width(thin,z8r-z6r);
  penpos5(a,0); penpos6(a,0); penpos7(a,0); penpos8(a,0);
  penstroke z1e..z2e; penstroke z3e..z4e;
  penstroke z5e..z7e; penstroke z6e..z8e; 
  penlabels(1,2,3,4,5,6,7,8);
endchar;

beginchar(bbhebmas[24],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent qadma";
  complete_hebrew_club(0.5[apprl,w-apprr],x_height+top_skip,h,-1);
endchar;

beginchar(bbhebmas[25],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent telisha qetana";
  complete_hebrew_club(apprl,h,x_height+top_skip,1);
endchar;

beginchar(bbhebmas[26],8u#+2appr#,0,bot_skip#+
    if square_dots: heb_size1# else: heb_size2# fi);
  "Hebrew accent yera ben yomo";
  if square_dots:
    if not(odd(w-apprl-apprr)): change_width; fi
    x2r=0.5[apprl,w-apprr]; x3r-x1r=hround 6u; 0.5[x3r,x1r]=x2r; 
    y2r=-d-0.5; y1r=y3r=-bot_skip;
    z1l-z1r=(diag_width(thin,z2r-z1r),0);
    z3l-z3r=(-diag_width(thin,z2r-z3r),0);
    z2l-z1l=whatever*(z2r-z1r); z2l-z3l=whatever*(z2r-z3r);
    penstroke z1e--z2e--z3e; penlabels(1,2,3);
  else: center_stem(2,4); top y1=top y3=-bot_skip; bot y4=-d;
    y2=good.y 0.5[y4,y1]; x2-x1=x3-x2=hround 3u;
    draw z1 down_to_right z2 right_to_up z3; draw z2..z4;
    square_end1(up); square_end3(up);
    square_end4(down); labels(1,2,3,4);
  fi
endchar;

beginchar(bbhebmas[27],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent ole";
  y2r=0.5[y1,y3]=vround(0.5[x_height+top_skip,h])+0.5; y1-y3=heb_size1;
  x1=hround(0.5[apprl,w-apprr]+3u); x1-x2r=hround 6u; x1=x1r=x3=x3r;
  adjust_slanted_bar(2r,1,2a,1a)(0.5(thin),-1);
  adjust_slanted_bar(2r,3,2b,3b)(0.5(thin),1);
  z1r=whatever[z2r,z1a]; z3r=whatever[z2r,z3b];
  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(1a,2a,2b,3b);
endchar;

beginchar(bbhebmas[28],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent iluy";
  pickup circle.nib;
  a:=hround max(3thin,4u);
  rt x2=rt x3=hround(0.5[apprl,w-apprr]+0.5a); rt x2-lft x1=a;
  top y3=h; bot y1=bot y2=x_height+top_skip;
  pickup square.nib; draw z1--z2--z3; labels(1,2,3);
endchar;

beginchar(bbhebmas[29],8u#+2appr#,0,bot_skip#+heb_size1#);
  "Hebrew accent dehi";
  complete_hebrew_club(w-apprr,-bot_skip,-d,1);
endchar;

beginchar(bbhebmas[30],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew accent zinor";
  pickup circle.nib;
  a:=max(6u,5thin);
  bot y1=x_height+top_skip; y1=y6; top y8=h; y8=y3;
  y0=y2=y7=0.5[y1,y8]; lft x2=hround(0.5[apprl,w-apprr]-0.5a);
  rt x7-lft x2=hround a; x0=0.5[x2,x7]; slope:=-heb_size1/2u;
  hellipse_set(2,3,4,0); hellipse_set(7,6,5,0);
  x1=good.x x3; x8=good.x x6;
  draw z1 left_to_up z2 up_to_right z3...z4---z5
  ...z6 right_to_up z7 up_to_left z8;
  square_end1(right); square_end8(left);
  labels(0,1,2,3,4,5,6,7,8);
endchar;

beginchar(bbhebmas[31],8u#+2appr#,x_height#+top_skip#+heb_size1#,0);
  "Hebrew mark masora circle";
  pickup circle.nib;
  if odd(w-apprl-apprr): change_width; fi
  0.5[x1,x3]=x2=x4=0.5[apprl,w-apprr];
  x1-x3=2hround(hthick/sqrt 2)+2eps;
  0.5[y2,y4]=y1=y3=x_height+top_skip+vround 0.5dot_size;
  top y2-bot y4=2vround(dot_size/sqrt 2)+2eps;
  draw superellipse(z1,z2,z3,z4,superness); labels(1,2,3,4);
endchar;

standard_proofing;% restore extra_endchar.