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

diacritics_proofing;% changes extra_endchar for proof mode.

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

% italic corrections to be revised

use_rule1;

numeric tmp_h; tmp_h=x_height;

beginchar(bbgrave,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Grave accent";
  italcorr asc_height#*slant-0.5u#;
  complete_grave(apprl,apprr);
endchar;

beginchar(bbacute,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Acute accent";
  italcorr asc_height#*slant-0.5u#;
  complete_acute(apprl,apprr);
endchar;

beginchar(bbcircumflex,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Circumflex accent";
  italcorr asc_height#*slant-0.5u#;
  complete_hat(apprl,apprr);
endchar;

iff known bbwide_circumflex:
beginchar(bbwide_circumflex,10u#+2appr#,min(asc_height#,2x_height#),0);
  "Wide circumflex accent";
  italcorr asc_height#*slant-0.5u#;
  complete_hat(apprl,apprr);
endchar;

beginchar(bbhacheck,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Hackeck accent";
  italcorr asc_height#*slant-0.5u#;
  complete_hacheck(apprl,apprr);
endchar;

beginchar(bbtilde,8u#+2appr#,min(asc_height#,2x_height#),0);
  "The tilde accent";
  italcorr asc_height#*slant-0.5u#;
  numeric a; if square_dots: a=0; else: a=hround 0.5u; fi
  complete_tilde(apprl+a,apprr+a); 
endchar;

iff known bbwide_tilde:
beginchar(bbwide_tilde,10u#+2appr#,min(asc_height#,2x_height#),0);
  "The wide tilde accent";
  italcorr asc_height#*slant-0.5u#;
  numeric a; if square_dots: a=0; else: a=hround 0.5u; fi
  complete_tilde(apprl+a,apprr+a); 
endchar;

iff known bbbreve:
beginchar(bbbreve,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Breve accent";
  italcorr asc_height#*slant-0.5u#;
  pickup circle.nib; top y1=top y3=h;
  lft x1=apprl+hround u; rt x3=w-apprr-hround u;
  bot y2=vround 1/3[tmp_h,h]; x2=0.5[x1,x3];
  draw z1 down_to_right z2 right_to_up z3;
  square_end1(up); square_end3(up);
  labels(1,2,3);
endchar;

iff known bbmacron:
beginchar(bbmacron,8u#+2appr#,0.4[x_height#,asc_height#]+thin#,0);
  "Macron accent";
  italcorr asc_height#*slant-0.5u#;
  pickup circle.nib; top y1=top y2=h;
  lft x1-apprl=w-apprr-rt x2=hround 0.5u;
  pickup square.nib; draw z1..z2; labels(1,2);
endchar;

beginchar(bbdotaccent,8u#+2appr#,
    min(asc_height#,10/7x_height#+0.5dot_size#),0);
  "Dot accent";
  italcorr charht*slant-0.5u#;
  pickup circle.nib; center_bar(1,2); top y2=h;
  bot y1=vround max(h-dot_size,x_height+o);
  dot(1,2); labels(1,2);
endchar;

% It's height has been corrected to fit french trema
beginchar(bbumlaut,8u#+2appr#,
    min(asc_height#,10/7x_height#
      if not low_umlaut: +0.5dot_size# fi),0);
  "Umlaut accent";
  italcorr charht*slant-.5u#;
  pickup circle.nib; x2-x1=x4-x3=hthick;
  lft x1-apprl=w-apprr-rt x4=hround 0.5u;
  top y2=top y4=h;
  bot y1=bot y3=vround max(h-dot_size,x_height+o);
  dot(1,2); dot(3,4); labels(1,2,3,4);
endchar;

iff known bblong_umlaut:
beginchar(bblong_umlaut,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Long hungarian Umlaut accent";
  italcorr charht*slant-.5u#;
  complete_long_umlaut(apprl,apprr);
endchar;

% If one compare the next program with the cm corresponding one,
% he would see that apex_o is missing from the line above. The reason is
% that our 'A' does not overshoot its upper limit.

iff known bbcirc_accent:
beginchar(bbcirc_accent,11.5u#+4/3(asc_height#-x_height#)*slant+2appr#,
    asc_height#,0);
  "The scandinavian circle accent";
  italcorr charht*slant-.5u#;
  pickup circle.nib;
  top y2=h+o; bot y4=vround(1/3[x_height,h])-eps;
  y0=y1=y3=0.5[y4,y2]; x0=x2=x4=0.5[apprl,w-apprr];
  lft x3=hround (x0-0.5max(hThick+thin,3u+thin))-eps;
  x1-x0=x0-x3; draw superellipse(z1,z2,z3,z4,superness);
  labels(1,2,3,4,0);
endchar;

iff known bbcedilla:
beginchar(bbcedilla,8u#+2appr#,0,desc_depth#);
  "The cedilla accent";
% no italic correction
  complete_cedilla(0.5[apprl,w-apprr],-0.5thin);
  square_end1(up);
endchar;

% Polish accents.

iff known bbleft_slanted_cross:
beginchar(bbleft_slanted_cross,0,asc_height#,0);
  "The left slanted cross";
% no  italic correction
  pickup circle.nib; lft x3l=apprl; x2l=x3l+hthick;
  x0=rt x2l; y0=vround x_height+.25; apprl-x4l=x1l-x0=y1l-y0=hround(u);
  y1l-y1r=thin/((1++slant)*sind angle((z1l-z0)slanted slant));
  x1r=x1l; z4l=whatever[z0,z1l]; z3l=whatever[z0,z1l];
  z2l=whatever[z0,z1l]; z2l-z2r=z3l-z3r=z4l-z4r=z1l-z1r;
  penstroke z1e..z2e; penstroke z3e..z4e;
  penlabels(0,1,2,3,4);
endchar;

iff known bbogonek:
beginchar(bbogonek,thin#+2appr#,0,desc_depth#);
  "The ogonek accent";
% no italic correction
  center_stem(0); complete_ogonek(x0,-0.5thin);
  square_end1(up);
endchar;

% Greek accents.

iff known bbstraight_accent:
beginchar(bbstraight_accent,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Greek straight accent";
  italcorr asc_height#*slant-0.5u#;
  if square_dots:
    center_bar(1,2); x3=x2; x4=x1;
    top y3=top y4=h; bot y1=bot y2=vround 1/5[x_height,h];
    pickup square.nib; draw z1--z2--z3--z4--cycle;
    labels(1,2,3,4);
  else:
    x1=x2=hround(0.5[apprl,w-apprr]-0.5dot_size)+0.5dot_size;
    y2=h+o-dot_size/2; y1=vround 1/5[x_height,h]+dot_size/4;
    long_dot(1,2);
  fi
endchar;

iff known bbrough:
beginchar(bbrough,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Greek rough accent";
  italcorr asc_height#*slant-0.5u#;
  pickup circle.nib;
  top y4=h; bot y1=vround 1/5[x_height,h];
  lft x3-apprl=w-apprr-rt x1=hround 2u; x5-x3=hthick;
  complete_comma;
endchar;

iff known bbsmooth:
beginchar(bbsmooth,8u#+2appr#,min(asc_height#,2x_height#),0);
  "Greek smooth accent";
  italcorr asc_height#*slant-0.5u#;
  pickup circle.nib;
  top y4=h; bot y1=vround 1/5[x_height,h];
  lft x1-apprl=w-apprr-rt x3=hround 2u; x3-x5=hthick;
  complete_comma;
endchar;

iff known bbgreek_tilde:
beginchar(bbgreek_tilde,8u#+2appr#,
    min(asc_height#,10/7x_height#+0.5dot_size#),0);
  "Greek tilde accent";
  italcorr asc_height#*slant-0.5u#;
  pickup circle.nib;
  top y2=top y6=h-vround 0.25dot_size;
  bot y1=bot y5=h-dot_size;
  lft x1-apprl=w-apprr-rt x6=hround 0.75u;
  z0=0.5[z1,z6]; slope:=-dot_size/4u;
  hellipse_set(1,2,3,0); hellipse_set(6,5,4,0);
  draw z1 up_to_right z2...z3---z4...z5 right_to_up z6;
  square_end1(down); square_end6(up);
  labels(0,1,2,3,4,5,6);
endchar;

iff known bbrough_tilde:
beginchar(bbrough_tilde,8u#+2appr#,body_height#,0);
  "Greek rough and tilde accent";
  italcorr asc_height#*slant-0.5u#;
  pickup circle.nib;
  % rough
  top y4'=vround min(h-0.75dot_size,asc_height,2x_height);
  bot y1'=vround 1/5[x_height,top y4'];
  lft x3'-apprl=w-apprr-rt x1'=hround 2u; x5'-x3'=hthick;
  % tilde
  top y2=top y6=h+o; bot y1=bot y5=h+o-vround 0.75dot_size;
  lft x1-apprl=w-apprr-rt x6=hround 0.75u;
  z0=0.5[z1,z6]; slope:=-dot_size/4u;
  hellipse_set(1,2,3,0); hellipse_set(6,5,4,0);
  draw z1 up_to_right z2...z3---z4...z5 right_to_up z6;
  square_end1(down); square_end6(up);
  complete_comma'; labels(0,1,2,3,4,5,6);
endchar;

iff known bbsmooth_tilde:
beginchar(bbsmooth_tilde,8u#+2appr#,body_height#,0);
  "Greek smooth and tilde accent";
  italcorr asc_height#*slant-0.5u#;
  pickup circle.nib;
  % smooth
  top y4'=vround min(h-0.75dot_size,asc_height,2x_height);
  bot y1'=vround 1/5[x_height,top y4'];
  lft x1'-apprl=w-apprr-rt x3'=hround 2u; x3'-x5'=hthick;
  % tilde
  top y2=top y6=h+o; bot y1=bot y5=h+o-vround 0.75dot_size;
  lft x1-apprl=w-apprr-rt x6=hround 0.75u;
  z0=0.5[z1,z6]; slope:=-dot_size/4u;
  hellipse_set(1,2,3,0); hellipse_set(6,5,4,0);
  draw z1 up_to_right z2...z3---z4...z5 right_to_up z6;
  square_end1(down); square_end6(up);
  complete_comma'; labels(0,1,2,3,4,5,6);
endchar;

iff known bbsubscript_iota:
beginchar(bbsubscript_iota,8u#+2appr#,0,desc_depth#);
  "Subscript iota";
% no italic correction
  center_bar(4,5); x3=x4; x2=0.5[x1,x4];
  rt x1-lft x4=hround max(3u,hthick+thin+1.7u);
  bot y2=-(desc_depth+o+dot_skip);
  top y4=vround(h-o-dot_skip);
  y1=y3=good.y(0.3[y2,y4]);
  tmp_path:=z1 down_to_left z2 left_to_up z3..z4;
  draw tmp_path;
  hbbowl(z2,z3,z4,hthick) tmp_path;
  pickup square.nib; draw z4..z.bowl.bot;
  square_end1(up); labels(1,2,3,4);
endchar;

standard_proofing;% restore extra_endchar.

