%%
%% This is file `frubase.mf',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% allrunes.dtx  (with options: `frubase')
%% 
%% 
%% Copyright 2001-2004 Carl-Gustav Werner
%% 
%% This program is provided under the terms of the
%% LaTeX Project Public License distributed from CTAN
%% archives in directory macros/latex/base/lppl.txt.
%% 
string allrunes ;
allrunes = "2.0" ;
if proofing > 1 :
  message "Base file for font `allrunes', version " & allrunes ;
fi
font_identifier:="allrunes";

font_size 10pt#;

mode_setup;

if mag <= 1:
  magadj = 1;
  tightness_f=0.0;
elseif mag <= 4:
  magadj = 1-(mag-1)/10;
  tightness_f=0.0;
else:
  magadj = 1-(4-1)/10;
  tightness_f=0.01;
fi;

if loweredbars=true:
    topjointrounding=0.3;
    topbarred=0.85;
else:
    topjointrounding=1.0;
    topbarred=1.0;
fi;

if barshape="straight":
    curve_d=0;
elseif barshape="curved":
    curve_d=40;
elseif barshape="rounded":
    curve_d=90;
fi;

if withlines=true:
    toprounding=1.0;
else:
    toprounding=0.3;
fi;

if boldness="light":
    stem_w#=0.4pt#*magadj;
    base_width#=3.8pt#;
    margin_width#=1.1pt#;
elseif boldness="medium":
    stem_w#=0.57pt#*magadj;
    base_width#=4pt#;
    margin_width#=1.2pt#;
elseif boldness="bold":
    stem_w#=0.8pt#*magadj;
    base_width#=4.2pt#;
    margin_width#=1.2pt#;
fi;

endrounding=0.3;
jointrounding=1.0;
round_adj_f=0.2;

circle_w#=0.9*stem_w#;
stem_h#=7pt#;
full_height_f=1;
nib_w#=0.01pt#;

freedot_f=1.3;
sepdot_f=1.6;
stemdot_f=2.2;
endstemdot_f=1.7;
stemcircle_f=3.2;
endstemcircle_f=2.8;
twig_length_f=3.1;

define_pixels(nib_w);
define_pixels(stem_h);
define_whole_pixels(stem_w);
define_whole_pixels(circle_w);
define_pixels(margin_width);

def beginrunechar(expr code, width) =
    beginchar(code, width, stem_h#, 0.4*stem_h#);
    pickup pencircle scaled nib_w;
    if withlines=true:
        filldraw barpath( -stem_w/2, 0-stem_w/2, jointrounding,
                         w+stem_w/2, 0-stem_w/2, jointrounding, 0, 0, 0);
        filldraw barpath( -stem_w/2, h+stem_w/2, jointrounding,
                         w+stem_w/2, h+stem_w/2, jointrounding, 0, 0, 10);
    fi
enddef;

def dotpath (expr x, y, width_f, i) =
    fullcircle scaled (width_f*stem_w) shifted (x,y)
enddef;

def draw_circle (expr x, y, width_f, i) =
    pickup pencircle scaled circle_w;
    draw fullcircle scaled (width_f*stem_w) shifted (x,y)
enddef;

def barpath (expr x_start, y_start, start_rounding_f,
                  x_end, y_end, end_rounding_f,
                  curve_angle, tightness_f, i) =
  begingroup
    save dx, dy;
    save l;
    save xy_angle, a;
    save midshift;
    save bar_path;
    path bar_path;

    dx = x_end-x_start;
    dy = y_end-y_start;
    l = dx++dy;
    xy_angle = angle(dx,dy)-90;
    a = curve_angle/2;
    if a = 0: midshift=0;
    else: midshift = l*(1-cosd a)/(2*sind a);fi

    z[i] = .5stem_w*start_rounding_f*down rotated -a;
    z[i+1]l = .5stem_w*((1+round_adj_f*(1-start_rounding_f))*cosd -135, start_rounding_f*sind -135) rotated -a;
    z[i+1]r = .5stem_w*((1+round_adj_f*(1-start_rounding_f))*cosd -45, start_rounding_f*sind -45) rotated -a;
    .5[z[i+2]r, z[i+2]l] = origin;
    z[i+2]r - z[i+2]l = stem_w * dir -a;
    .5[z[i+3]r, z[i+3]l] = (midshift, l/2);
    z[i+3]r - z[i+3]l = (stem_w*(1-tightness_f), 0);
    .5[z[i+4]r, z[i+4]l] = (0, l);
    z[i+4]r - z[i+4]l = stem_w * dir a;
    z[i+5]l = (.5stem_w*((1+round_adj_f*(1-start_rounding_f))*cosd 135, end_rounding_f*sind 135) rotated a) + (0, l);
    z[i+5]r = (.5stem_w*((1+round_adj_f*(1-start_rounding_f))*cosd 45, end_rounding_f*sind 45) rotated a) + (0, l);
    z[i+6]  = (.5stem_w*end_rounding_f*up rotated a) + (0, l);

    bar_path = z[i]{dir(180-a)}..z[i+1]l..z[i+2]l{dir(90-a)}..
               z[i+3]l{up}..z[i+4]l{dir(90+a)}..z[i+5]l..
               z[i+6]{dir a}..z[i+5]r..z[i+4]r{dir(a-90)}..
               z[i+3]r{down}..
               z[i+2]r{dir(-90-a)}..z[i+1]r..
               cycle;
    bar_path rotated xy_angle shifted (x_start, y_start)
  endgroup
enddef;

def draw_arrowhead (expr x_centre, y_centre, arrowhead_w_f, arrowhead_l_f, dir, i) =
    save arrowhead_w_adj_f;
    save arrowhead_path;
    path arrowhead_path;

    if barshape="straight":
        arrowhead_w_adj_f=arrowhead_w_f+0.7;
        filldraw barpath(                     0, -arrowhead_l_f/2*stem_w+stem_w/2, endrounding,
                                              0,  arrowhead_l_f/2*stem_w, endrounding, 0, tightness_f, i)
                 rotated dir shifted (x_centre, y_centre);
        filldraw barpath(-arrowhead_w_adj_f/2*stem_w, -arrowhead_l_f/2*stem_w, endrounding,
                          arrowhead_w_adj_f/2*stem_w, -arrowhead_l_f/2*stem_w, endrounding,
                          0, tightness_f, i+10)
                 rotated dir shifted (x_centre, y_centre);
    elseif barshape="curved":
        arrowhead_w_adj_f=arrowhead_w_f;
        z[i]   =(0,-arrowhead_l_f/2*stem_w*0.92);
        z[i+1]l=(-arrowhead_w_adj_f/2*stem_w,-arrowhead_l_f/2*stem_w);
        z[i+1]r=( arrowhead_w_adj_f/2*stem_w,-arrowhead_l_f/2*stem_w);
        z[i+2]l=(-arrowhead_w_adj_f/4*stem_w*1.4,stem_w/6);
        z[i+2]r=( arrowhead_w_adj_f/4*stem_w*1.4,stem_w/6);
        z[i+3]l=(-0.4*stem_w,(arrowhead_l_f/2-0.5)*stem_w);
        z[i+3]r=( 0.4*stem_w,(arrowhead_l_f/2-0.5)*stem_w);
        z[i+4] =(0,arrowhead_l_f/2*stem_w);
        arrowhead_path = z[i]{left}..z[i+1]l..z[i+2]l..z[i+3]l{up}..
                        z[i+4]{right}..z[i+3]r{down}..z[i+2]r..z[i+1]r..cycle;
        filldraw arrowhead_path rotated dir shifted (x_centre, y_centre);
    elseif barshape="rounded":
        arrowhead_w_adj_f=arrowhead_w_f+0.6;
        filldraw barpath(                     0, -arrowhead_l_f/2*stem_w+stem_w/2, endrounding,
                                              0,  arrowhead_l_f/2*stem_w, endrounding, 0, tightness_f, i)
                 rotated dir shifted (x_centre, y_centre);
        filldraw dotpath(                     0, -arrowhead_l_f/2*stem_w, arrowhead_w_adj_f, i+20)
                 rotated dir shifted (x_centre, y_centre);
    fi;
enddef;


def xhalf=(w/2-stem_w/2-margin_width) enddef;

def xmid=(w/2) enddef;

def yhalf=(h/2) enddef;

def ymid=(h/2) enddef;

def yhalfred=((h*topbarred)/2) enddef;

def ymidred(expr yd)=(h*((((topbarred/2)-0.5)*yd)+0.5)) enddef;


def draw_normal_f(expr rune, xd, yd, highdot, stemdot, twigdot) =
  beginrunechar(rune, 1.08*base_width#+2*margin_width#);
    save f_ymid_f;
    save f_yup_f;
    save f_xhighdot_f;
    save f_twigdot_f;
    save f_twigdotangel_f;
    f_ymid_f=0.0;
    if highdot:
      f_yup_f=0.4;
      f_xhighdot_f=0.4;
    else:
      f_yup_f=0.5;
    fi;
    if twigdot:
      f_twigdot_f=0.52;
      f_twigdotangel_f=(if curve_d=0:0 else:(1-cosd(curve_d/2))/(2*sind(curve_d/2)) fi);
    fi;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*f_ymid_f*yhalf, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*f_yup_f*yhalf, jointrounding,
                     xmid-xd*xhalf+xd*(1-f_yup_f)*yhalf, ymid+yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 40);
    if highdot:
      filldraw dotpath(xmid-xd*xhalf+xd*(1-f_yup_f)*yhalf*f_xhighdot_f,  ymid+yd*(yhalf-stem_w/2), freedot_f, 50);
    fi;
    if stemdot:
      filldraw dotpath(xmid-xd*xhalf, ymid+yd*yhalf*f_ymid_f+yd*stem_w/3, stemdot_f, 60);
    fi;
    if twigdot:
      filldraw dotpath(xmid+xd*(-1+(1-(-1))*f_twigdot_f+(1-f_ymid_f)*(yhalf/xhalf)*(f_twigdotangel_f))*xhalf,
                       ymid+yd*(f_ymid_f+(1-f_ymid_f)*f_twigdot_f-(1-(-1))*(xhalf/yhalf)*(f_twigdotangel_f))*yhalf,
                       stemdot_f, 70);
    fi;
  endchar;
enddef;

def draw_medieval_f(expr rune, xd, yd) =
  beginrunechar(rune, 1.2*base_width#+2*margin_width#);
    save f_ylow_f;
    save f_ymid_f;
    save f_yup_f;
    f_ylow_f=-0.2;
    f_ymid_f=0.2;
    f_yup_f=0.6;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*f_ylow_f*yhalf, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*f_ymid_f*yhalf, jointrounding,
                     xmid-xd*xhalf+xd*(1-f_ymid_f)*yhalf, ymid+yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*f_yup_f*yhalf, jointrounding,
                     xmid-xd*xhalf+xd*(1-f_yup_f)*yhalf, ymid+yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 50);
  endchar;
enddef;

def draw_primitive_f(expr rune, xd, yd) =
  beginrunechar(rune, 0.65*base_width#+2*margin_width#);
    save f_yraise_f;
    save f_ysep_f;
    f_yraise_f=0.4;
    f_ysep_f=0.54;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(1-f_yraise_f), jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(1-f_yraise_f-f_ysep_f), jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*(1-f_ysep_f), toprounding, xd*yd*curve_d, tightness_f, 40);
  endchar;
enddef;

def draw_staveless_f(expr rune, xd, yd, long) =
  save end_marker_width_f;
  save end_marker_length_f;
  end_marker_width_f=1.6;
  end_marker_length_f=3.2;
  beginrunechar(rune, end_marker_width_f*stem_w#+2*margin_width#);
    save f_y_f;
    if long:
      f_y_f=0.5;
    else:
      f_y_f=-0.3;
    fi;
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf*f_y_f, toprounding, 0, tightness_f, 20);
    draw_arrowhead(xmid, ymid+yd*yhalf*f_y_f, end_marker_width_f, end_marker_length_f, -180+if yd=-1:180 else:0 fi+if loweredbars:180 else:0 fi, 30);
  endchar;
enddef;

def draw_normal_u(expr rune, xd, yd, tight, marks) =
  beginrunechar(rune, topbarred*0.98*base_width#+2*margin_width#);
    save u_x_f;
    save u_y_f;
    save u_curvehigh_f;
    save u_curvelow_f;
    save y_cross_x_f;
    save y_cross_xadj_f;
    save y_cross_y_f;
    save y_y_bary_f;
    save y_y_lbranchy_f;
    save y_y_rbranchy_f;
    if tight:
      u_x_f=0.6;
    else:
      u_x_f=0.715;
    fi;
    u_y_f=0.2;
    if curve_d > 45:
      u_curvelow_f=(1-(curve_d-45)/45)/4;
      u_curvehigh_f=1+(1-(curve_d-45)/45)/4;
    else:
      u_curvelow_f=0.25;
      u_curvehigh_f=1.25;
    fi;
    y_cross_x_f=0.4;
    y_cross_xadj_f=0.06;
    y_cross_y_f=0.9;
    y_y_bary_f=0.15;
    y_y_lbranchy_f=0.16;
    y_y_rbranchy_f=0.14;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf*u_x_f, ymidred(yd)+yd*yhalfred*u_y_f, jointrounding, 0-u_curvehigh_f*xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf*u_x_f, ymidred(yd)+yd*yhalfred*u_y_f, jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalf, toprounding, -u_curvelow_f*xd*yd*curve_d, tightness_f, 40);
    if marks=0:
    elseif marks=1: % one dot
      filldraw dotpath(xmid-xd*xhalf*0.07, ymidred(yd)-yd*yhalf*0.07, freedot_f, 50);
    elseif marks=2: % two dots
      filldraw dotpath(xmid-xd*xhalf*0.08, ymidred(yd)+yd*yhalf*0.06, freedot_f, 50);
      filldraw dotpath(xmid-xd*xhalf*0.04, ymidred(yd)-yd*yhalf*0.34, freedot_f, 60);
    elseif marks=3: % one bar
      filldraw barpath(xmid-xd*xhalf*0.08, ymidred(yd)-yd*yhalf*0.06, endrounding,
                       xmid-xd*xhalf*0.04, ymidred(yd)-yd*yhalf, endrounding, 0, tightness_f, 50);
    elseif marks=4: % one x
      filldraw barpath(xmid-xd*xhalf*(y_cross_x_f+y_cross_xadj_f), ymid-yd*yhalf*y_cross_y_f, endrounding,
                       xmid+xd*xhalf*(y_cross_x_f-y_cross_xadj_f), ymid-yd*yhalf*y_cross_y_f+2*yd*xhalf*y_cross_x_f, endrounding, 0, tightness_f, 50);
      filldraw barpath(xmid+xd*xhalf*(y_cross_x_f-y_cross_xadj_f), ymid-yd*yhalf*y_cross_y_f, endrounding,
                       xmid-xd*xhalf*(y_cross_x_f+y_cross_xadj_f), ymid-yd*yhalf*y_cross_y_f+2*yd*xhalf*y_cross_x_f, endrounding, 0, tightness_f, 60);
    elseif marks=5: % one y
      filldraw barpath(xmid-xd*xhalf*0.08, ymidred(yd)-yd*yhalf*y_y_bary_f, endrounding,
                       xmid-xd*xhalf*0.04, ymidred(yd)-yd*yhalf, endrounding, 0, tightness_f, 50);
      filldraw barpath(xmid-xd*xhalf*0.08, ymidred(yd)-yd*yhalf*y_y_bary_f, endrounding,
                       xmid-xd*xhalf, ymidred(yd)+yd*yhalf*y_y_lbranchy_f, endrounding, 0, tightness_f, 60);
      filldraw barpath(xmid-xd*xhalf*0.08, ymidred(yd)-yd*yhalf*y_y_bary_f, endrounding,
                       xmid+xd*xhalf*u_x_f, ymidred(yd)+yd*yhalf*y_y_rbranchy_f, endrounding, 0, tightness_f, 70);

    fi;
  endchar;
enddef;

def draw_medieval_w(expr rune, xd, yd) =
  beginrunechar(rune, topbarred*1.1*base_width#+2*margin_width#);
    save u_x_f;
    save u_y_f;
    save u_yinner_f;
    save u_curvehigh_f;
    save u_curvelow_f;
    u_x_f=0.715;
    u_y_f=0.2;
    u_yinner_f=0.5;
    if curve_d > 45:
      u_curvelow_f=(1-(curve_d-45)/45)/4;
      u_curvehigh_f=1+(1-(curve_d-45)/45)/3;
    else:
      u_curvelow_f=0.25;
      u_curvehigh_f=1.33;
    fi;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf*u_x_f, ymidred(yd)+yd*yhalfred*u_y_f, jointrounding, 0-u_curvehigh_f*xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf*u_x_f, ymidred(yd)+yd*yhalfred*u_y_f, jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalf, toprounding, -u_curvelow_f*xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*u_yinner_f, jointrounding,
                     xmid-xd*xhalf*(1-(1+u_x_f)/2), ymidred(yd)+yd*yhalfred*u_y_f*(1-2*(1-u_yinner_f)), jointrounding, 0-u_curvehigh_f*xd*yd*curve_d, tightness_f, 50);
    filldraw barpath(xmid-xd*xhalf*(1-(1+u_x_f)/2), ymidred(yd)+yd*yhalfred*u_y_f*(1-2*(1-u_yinner_f)), jointrounding,
                     xmid,          ymid-yd*yhalf, toprounding, -u_curvelow_f*xd*yd*curve_d, tightness_f, 60);

  endchar;
enddef;

def draw_primitive_U(expr rune, xd, yd, symmetric) =
  beginrunechar(rune, topbarred*1.02*base_width#+2*margin_width#);
    save U_x_f;
    if symmetric:
      U_x_f=0;
    else:
      U_x_f=0.99;
    fi;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf*U_x_f, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-((1-topbarred)*(1-U_x_f)+U_x_f)*xd*xhalf, ymidred(yd)+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalf, toprounding, 0, tightness_f, 30);
  endchar;
enddef;

def draw_staveless_u(expr rune, xd, yd) =
  beginrunechar(rune, 0.6*base_width#+2*margin_width#);
    save u_xmid_f;
    save u_ytop_f;
    save u_ymid_f;
    save u_curvehigh_d;
    save u_curvelow_d;
    u_xmid_f=0.6;
    u_ytop_f=0.6;
    u_ymid_f=0.15;
    u_curvelow_d=25;
    u_curvehigh_d=65;
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*u_ytop_f, endrounding,
                     xmid+xd*xhalf*u_xmid_f, ymid+yd*yhalf*u_ymid_f, jointrounding, -u_curvehigh_d*xd*yd, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf*u_xmid_f, ymid+yd*yhalf*u_ymid_f, jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalf, toprounding, -u_curvelow_d*xd*yd, tightness_f, 30);
  endchar;
enddef;

def draw_normal_th(expr rune, xd, yd, big, dot, doubble) =
  save th_width_f;
  if big:
    th_width_f=0.7;
  elseif doubble:
    th_width_f=0.85;
  else:
    th_width_f=0.65;
  fi;
  beginrunechar(rune, th_width_f*base_width#+2*margin_width#);
    save th_y_f;
    save th_innery_f;
    save dot_x;
    if big:
      th_y_f=1-(1-topbarred)*2;
    elseif doubble:
      th_y_f=0.7;
      th_innery_f=0.3;
    else:
      th_y_f=0.44;
    fi;
    dot_x=1/6*(90-xd*yd*curve_d)/90;

    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf*th_y_f, jointrounding,
                     xmid+xd*xhalf, ymid, jointrounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*th_y_f, jointrounding,
                     xmid+xd*xhalf, ymid, jointrounding, -xd*yd*curve_d, tightness_f, 40);
    if doubble:
      filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf*th_innery_f, jointrounding,
                       xmid,          ymid, jointrounding, xd*yd*curve_d, tightness_f, 50);
      filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*th_innery_f, jointrounding,
                       xmid,          ymid, jointrounding, -xd*yd*curve_d, tightness_f, 60);
    fi;
    if dot:
      filldraw dotpath(xmid-xd*xhalf*dot_x, ymid, freedot_f, 70);
    fi;
  endchar;
enddef;

def draw_staveless_th(expr rune, xd, yd) =
  beginrunechar(rune, stem_w#+2*margin_width#);
    save th_y_f;
    m_y_f=0.44;
    filldraw barpath(xmid, ymid-yd*yhalf*m_y_f, endrounding,
                     xmid, ymid+yd*yhalf*m_y_f, endrounding, 0, tightness_f, 20);
  endchar;
enddef;

def draw_normal_single_A(expr rune, xd, yd, top) =
  beginrunechar(rune, 0.6*base_width#+2*margin_width#);
    save A_ysep_f;
    save A_ydrop_f;
    save A_ymid_f;
    A_ysep_f=0.26;
    A_ydrop_f=0.4;
    if top:
      A_ymid_f=1-A_ysep_f;
    else:
      A_ymid_f=0.14;
    fi;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(A_ymid_f+A_ysep_f), jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*(A_ymid_f+A_ysep_f-A_ydrop_f), endrounding, 0, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(A_ymid_f-A_ysep_f), jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*(A_ymid_f-A_ysep_f-A_ydrop_f), endrounding, 0, tightness_f, 40);
  endchar;
enddef;

def draw_staveless_A(expr rune, xd, yd, pos, down) =
  save arrowhead_w_f;
  save arrowhead_l_f;
  save A_width_f;
  save A_dir_d;
  arrowhead_w_f=1.6;
  arrowhead_l_f=3.2;
  if down:
    A_dir_d=180;
  else:
    A_dir_d=-125;
  fi;
  A_width_f=max(abs(sind(A_dir_d))*arrowhead_l_f,
                abs(cosd(A_dir_d))*arrowhead_w_f)*stem_w#/base_width#;
  beginrunechar(rune, A_width_f*base_width#+2*margin_width#);
    save A_y_f;
    A_y_f=0.6;
    if pos=1: %high
      draw_arrowhead(xmid, ymid+yd*yhalf*A_y_f, arrowhead_w_f, arrowhead_l_f, if yd=1: xd*A_dir_d else: xd*(180-A_dir_d) fi, 20);
    elseif pos=2: %mid
      draw_arrowhead(xmid, ymid               , arrowhead_w_f, arrowhead_l_f, if yd=1: xd*A_dir_d else: xd*(180-A_dir_d) fi, 20);
    elseif pos=3: %low
      draw_arrowhead(xmid, ymid-yd*yhalf*A_y_f, arrowhead_w_f, arrowhead_l_f, if yd=1: xd*A_dir_d else: xd*(180-A_dir_d) fi, 20);
    fi;
  endchar;
enddef;

def draw_anglo_o(expr rune, xd, yd, two) =
  beginrunechar(rune, 0.87*base_width#+2*margin_width#);
    save A_ysep_f;
    save A_ydrop_f;
    save A_ymid_f;
    save o_x_f;
    A_ysep_f=0.26;
    A_ydrop_f=0.4;
    A_ymid_f=1-A_ysep_f;
    o_x_f=0.23;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*(A_ymid_f+A_ysep_f), jointrounding,
                     xmid+xd*xhalf*o_x_f, ymidred(yd)+yd*yhalfred*(A_ymid_f+A_ysep_f-A_ydrop_f), jointrounding, 0, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*(A_ymid_f-A_ysep_f), jointrounding,
                     xmid+xd*xhalf*o_x_f, ymidred(yd)+yd*yhalfred*(A_ymid_f-A_ysep_f-A_ydrop_f), if two: jointrounding else: endrounding fi, 0, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf*o_x_f, ymidred(yd)+yd*yhalfred*(A_ymid_f+A_ysep_f-A_ydrop_f), jointrounding,
                     xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*(A_ymid_f+A_ysep_f), endrounding, 0, tightness_f, 50);
    if two:
      filldraw barpath(xmid+xd*xhalf*o_x_f, ymidred(yd)+yd*yhalfred*(A_ymid_f-A_ysep_f-A_ydrop_f), jointrounding,
                       xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*(A_ymid_f-A_ysep_f), endrounding, 0, tightness_f, 60);
    fi;
  endchar;
enddef;

def draw_normal_double_A(expr rune, xd, yd, three, stlb, sblb) = % Skip Top Left Bar, Skip Bottom Left Bar
  beginrunechar(rune, 1.05*base_width#+2*margin_width#);
    save A_ysep_f;
    save A_ydrop_f;
    if three:
      A_ysep_f=0.36;
    else:
      A_ysep_f=0.24;
    fi;
    A_ydrop_f=0.3;
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    if stlb:
      filldraw barpath(xmid,          ymid+yd*yhalf*(A_ysep_f), endrounding,
                       xmid+xd*xhalf, ymid+yd*yhalf*(A_ysep_f-A_ydrop_f), endrounding, 0, tightness_f, 30);
    else:
      filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(A_ysep_f+A_ydrop_f), endrounding,
                       xmid+xd*xhalf, ymid+yd*yhalf*(A_ysep_f-A_ydrop_f), endrounding, 0, tightness_f, 30);
    fi;
    if three:
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(A_ydrop_f), endrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*(-A_ydrop_f), endrounding, 0, tightness_f, 40);
    fi;
    if sblb:
      filldraw barpath(xmid,          ymid+yd*yhalf*(-A_ysep_f), endrounding,
                       xmid+xd*xhalf, ymid+yd*yhalf*(-A_ysep_f-A_ydrop_f), endrounding, 0, tightness_f, 50);
    else:
      filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(-A_ysep_f+A_ydrop_f), endrounding,
                       xmid+xd*xhalf, ymid+yd*yhalf*(-A_ysep_f-A_ydrop_f), endrounding, 0, tightness_f, 50);
    fi;
  endchar;
enddef;

def draw_normal_r(expr rune, xd, yd, closed, topdot) =
  beginrunechar(rune, topbarred*0.92*base_width#+2*margin_width#);
    save r_xup_f;
    save r_yup_f;
    save r_xmid_f;
    save r_ymid_f;
    save r_curve_f;
    r_xup_f=0.78;
    r_yup_f=0.36;
    if closed:
      r_ymid_f=0;
      r_xmid_f=0.9;
    else:
      r_ymid_f=0.06;
      r_xmid_f=0.3;
    fi;
    r_curve_f=0.63+0.37*abs(xd*yd*curve_d-45)/45;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf+xd*1, ymidred(yd)+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf*r_xup_f, ymidred(yd)+yd*yhalfred*r_yup_f, jointrounding, -r_curve_f*xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf*r_xup_f, ymidred(yd)+yd*yhalfred*r_yup_f, jointrounding,
                     xmid-xd*xhalf*r_xmid_f, ymidred(yd)-yd*yhalfred*r_ymid_f, jointrounding, -r_curve_f*xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid-xd*xhalf*r_xmid_f, ymidred(yd)-yd*yhalfred*r_ymid_f, jointrounding,
                     xmid+xd*xhalf, ymidred(yd)-yd*yhalfred, toprounding, -r_curve_f*xd*yd*curve_d, tightness_f, 50);
    if topdot:
      filldraw dotpath(xmid-xd*xhalf/3, ymid+yd*yhalfred*(1+r_yup_f+r_ymid_f)/3, freedot_f, 60);
    fi;

  endchar;
enddef;

def draw_greenland_r(expr rune, xd, yd) =
  beginrunechar(rune, topbarred*0.92*base_width#+2*margin_width#);
    save r_ytopend_f;
    save r_ybottomstart_f;
    r_ytopend_f=0.0;
    r_ybottomstart_f=0.2;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf+xd*1, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalfred*r_ytopend_f, endrounding, -xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalfred*r_ybottomstart_f, jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalfred, endrounding, -xd*yd*curve_d, tightness_f, 40);
  endchar;
enddef;

def draw_normal_k(expr rune, xd, yd, topdot, middot, midtwig, two) =
  beginrunechar(rune, 0.9*base_width#+2*margin_width#);
    save k_ymid_f;
    k_ymid_f=0.1;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*k_ymid_f, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 30);
    if two:
      filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf*k_ymid_f, jointrounding,
                       xmid+xd*xhalf, ymid-yd*yhalf, toprounding, -xd*yd*curve_d, tightness_f, 40);
    fi;
    if topdot:
      filldraw dotpath(xmid-xd*xhalf/3+xd*stem_w/3, ymid+yd*yhalf*(2+k_ymid_f)/3+yd*stem_w/2, freedot_f, 50);
      if two:
        filldraw dotpath(xmid-xd*xhalf/3+xd*stem_w/3, ymid-yd*yhalf*(2+k_ymid_f)/3-yd*stem_w/2, freedot_f, 60);
      fi;
    fi;
    if middot:
      filldraw dotpath(xmid-xd*xhalf, ymid+yd*yhalf*k_ymid_f+yd*stem_w/3, stemdot_f, 70);
    fi;
    if midtwig:
      filldraw barpath(xmid-xd*xhalf-xd*twig_length_f*stem_w/2, ymid+yd*yhalf*k_ymid_f-yd*3*stem_w/2, endrounding,
                       xmid-xd*xhalf+xd*twig_length_f*stem_w/2, ymid+yd*yhalf*k_ymid_f-yd*3*stem_w/2, endrounding, 0, tightness_f, 80);
    fi;
  endchar;
enddef;

def draw_primitive_k(expr rune, xd, yd) =
  beginrunechar(rune, 0.72*base_width#+2*margin_width#);
    save k_y_f;
    k_y_f=0.54;
    filldraw barpath(xmid-xd*xhalf, ymid, jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalf*k_y_f, endrounding, xd*yd*curve_d, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*k_y_f, endrounding, -xd*yd*curve_d, tightness_f, 30);
  endchar;
enddef;

def draw_primitive_kup(expr rune, xd, yd, stem, big) =
  beginrunechar(rune, 1.12*base_width#+2*margin_width#);
    save k_yupsep_f;
    save k_yupmid_f;
    if big:
      k_yupsep_f=0.4;
      k_yupmid_f=0.6;
    else:
      k_yupsep_f=1/3;
      k_yupmid_f=0.0;
    fi;
    if stem:
      filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                       xmid, ymid+yd*yhalf*(k_yupmid_f-k_yupsep_f), jointrounding, 0, tightness_f, 20);
    fi;
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(k_yupmid_f+k_yupsep_f), endrounding,
                     xmid, ymid+yd*yhalf*(k_yupmid_f-k_yupsep_f), jointrounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymid+yd*yhalf*(k_yupmid_f+k_yupsep_f), endrounding,
                     xmid, ymid+yd*yhalf*(k_yupmid_f-k_yupsep_f), jointrounding, -xd*yd*curve_d, tightness_f, 40);
  endchar;
enddef;

def draw_primitive_g(expr rune, xd, yd, v_stem, h_angles, eye) =
  save g_width_f;
  if v_stem:
    g_width_f=1.3;
  else:
    g_width_f=1.1;
  fi;
  beginrunechar(rune, g_width_f*base_width#+2*margin_width#);
    save eye_x_f;
    save eye_y_f;
    save eye_curve_f;
    save h_angle_f;
    eye_x_f=0.8 - if mag <= 1: 0; elseif mag <= 2: (mag-1)/5; else: 0.2; fi;
    eye_y_f=0.45 - if mag <= 1: 0; elseif mag <= 2: (mag-1)/5; else: 0.2; fi;
    eye_curve_f=0.8;
    h_angle_f=0.3;
    if v_stem:
      filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                       xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    fi;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf, toprounding,
                     xmid+xd*xhalf, ymid-yd*yhalf, toprounding, 0, tightness_f, 40);
    if eye:
      filldraw barpath(xmid, ymid+yd*yhalf*eye_y_f, jointrounding,
                       xmid-xd*xhalf*eye_x_f, ymid, jointrounding, eye_curve_f*xd*yd*curve_d, tightness_f, 50);
      filldraw barpath(xmid-xd*xhalf*eye_x_f, ymid, jointrounding,
                       xmid, ymid-yd*yhalf*eye_y_f, jointrounding, eye_curve_f*xd*yd*curve_d, tightness_f, 60);
      filldraw barpath(xmid, ymid-yd*yhalf*eye_y_f, jointrounding,
                       xmid+xd*xhalf*eye_x_f, ymid, jointrounding, eye_curve_f*xd*yd*curve_d, tightness_f, 70);
      filldraw barpath(xmid+xd*xhalf*eye_x_f, ymid, jointrounding,
                       xmid, ymid+yd*yhalf*eye_y_f, jointrounding, eye_curve_f*xd*yd*curve_d, tightness_f, 80);
    elseif h_angles:
      filldraw barpath(xmid-xd*xhalf*h_angle_f, ymid+yd*yhalf*h_angle_f, jointrounding,
                       xmid-xd*xhalf*eye_x_f, ymid, jointrounding, eye_curve_f*xd*yd*curve_d, tightness_f, 50);
      filldraw barpath(xmid-xd*xhalf*eye_x_f, ymid, jointrounding,
                       xmid-xd*xhalf*h_angle_f, ymid-yd*yhalf*h_angle_f, jointrounding, eye_curve_f*xd*yd*curve_d, tightness_f, 60);
      filldraw barpath(xmid+xd*xhalf*h_angle_f, ymid-yd*yhalf*h_angle_f, jointrounding,
                       xmid+xd*xhalf*eye_x_f, ymid, jointrounding, eye_curve_f*xd*yd*curve_d, tightness_f, 70);
      filldraw barpath(xmid+xd*xhalf*eye_x_f, ymid, jointrounding,
                       xmid+xd*xhalf*h_angle_f, ymid+yd*yhalf*h_angle_f, jointrounding, eye_curve_f*xd*yd*curve_d, tightness_f, 80);
    fi;
  endchar;
enddef;

def draw_primitive_w(expr rune, xd, yd) =
  beginrunechar(rune, topbarred*0.7*base_width#+2*margin_width#);
    save w_y_f;
    w_y_f=0.0;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*(1+w_y_f)/2, jointrounding, -xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*(1+w_y_f)/2, jointrounding,
                     xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*w_y_f, jointrounding, -xd*yd*curve_d, tightness_f, 40);
  endchar;
enddef;

def draw_normal_h(expr rune, xd, yd, NWSE, NESW, dot) =
  beginrunechar(rune, 0.95*base_width#+2*margin_width#);
    save h_y_f;
    h_y_f=0.36;
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    if NWSE:
      filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*h_y_f, endrounding,
                       xmid+xd*xhalf, ymid-yd*yhalf*h_y_f, endrounding, 0, tightness_f, 30);
    fi;
    if NESW:
      filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf*h_y_f, endrounding,
                       xmid+xd*xhalf, ymid+yd*yhalf*h_y_f, endrounding, 0, tightness_f, 40);
    fi;
    if dot:
      filldraw dotpath(xmid, ymid, stemdot_f, 50);
    fi;
  endchar;
enddef;

def draw_medieval_h(expr rune, xd, yd, twigs, offset) =
  beginrunechar(rune, 1.2*base_width#+2*margin_width#);
    for i=0 step 1 until twigs-1:
    filldraw barpath(xmid, ymid, jointrounding,
                     xmid+xd*xhalf*cosd(i/twigs*360+offset), ymid+yd*xhalf*sind(i/twigs*360+offset), endrounding, 0, tightness_f, 20+i*10);
    endfor;
  endchar;
enddef;

def draw_medieval_bigh(expr rune, xd, yd) =
  save bigh_twigs_n;
  save bigh_offset_d;
  bigh_twigs_n=8;
  bigh_offset_d=90;
  beginrunechar(rune, 1.2*base_width#+2*margin_width#);
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    for i=1 step 1 until bigh_twigs_n/2-1:
    filldraw barpath(xmid-xd*xhalf*cosd(i/bigh_twigs_n*360+bigh_offset_d), ymid-yd*xhalf*sind(i/bigh_twigs_n*360+bigh_offset_d), jointrounding,
                     xmid+xd*xhalf*cosd(i/bigh_twigs_n*360+bigh_offset_d), ymid+yd*xhalf*sind(i/bigh_twigs_n*360+bigh_offset_d), jointrounding, 0, tightness_f, 20+i*10);
    endfor;
  endchar;
enddef;

def draw_shorttwig_n(expr rune, xd, yd, middot, sidedot) =
  save n_width_f;
  if sidedot:
    n_width_f=0.75;
  else:
    n_width_f=0.55;
  fi;
  beginrunechar(rune,n_width_f*base_width#+2*margin_width#);
    save n_ymid_f;
    save n_ydrop_f;
    save n_xdot_f;
    save n_ydot_f;
    n_ymid_f=0.0;
    n_ydrop_f=0.18;
    n_xdot_f=0.17;
    n_ydot_f=0.12;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(n_ymid_f+n_ydrop_f), endrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*(n_ymid_f-n_ydrop_f), endrounding, 0, tightness_f, 30);

    if middot:
      filldraw dotpath(xmid-xd*xhalf, ymid+yd*yhalf*(n_ymid_f+n_ydrop_f)-yd*stem_w/3, stemdot_f, 40);
    fi;
    if sidedot:
      filldraw dotpath(xmid-xd*xhalf*n_xdot_f, ymid+yd*yhalf*(n_ymid_f-n_ydrop_f-n_ydot_f), freedot_f, 50);
    fi;
  endchar;
enddef;

def draw_primitive_h(expr rune, xd, yd, top, twobars) =
  beginrunechar(rune, 1.1*base_width#+2*margin_width#);
    save h_ymid_f;
    save h_ytop_f;
    save h_ysep_f;
    h_ymid_f=0.16;
    h_ytop_f=0.96;
    h_ysep_f=0.16;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 30);
    if top:
      filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalfred*h_ytop_f, jointrounding,
                       xmid+xd*xhalf, ymid-yd*yhalfred*h_ytop_f, jointrounding, 0, tightness_f, 40);
    else:
      if twobars:
        filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(h_ymid_f-h_ysep_f), jointrounding,
                         xmid+xd*xhalf, ymid+yd*yhalf*(-h_ymid_f-h_ysep_f), jointrounding, 0, tightness_f, 40);
        filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(h_ymid_f+h_ysep_f), jointrounding,
                         xmid+xd*xhalf, ymid+yd*yhalf*(-h_ymid_f+h_ysep_f), jointrounding, 0, tightness_f, 40);
      else:
        filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*h_ymid_f, jointrounding,
                         xmid+xd*xhalf, ymid-yd*yhalf*h_ymid_f, jointrounding, 0, tightness_f, 40);
      fi;
    fi;
  endchar;
enddef;

def draw_normal_i(expr rune, xd, yd, dot, twig, high, top, twodots, circle) =
  save i_width_f;
  if twig:
    i_width_f=twig_length_f+1;
  elseif dot or twodots:
    i_width_f=stemdot_f;
  elseif circle:
    i_width_f=stemcircle_f;
  else:
    i_width_f=1.0;
  fi;
  beginrunechar(rune, i_width_f*stem_w#+2*margin_width#);
    save i_ystem_f;
    save i_ydottwig_f;
    if top:
      i_ystem_f=0.7;
      i_ydottwig_f=0.7;
    else:
      i_ystem_f=1.0;
      if high:
        i_ydottwig_f=0.6;
      elseif twodots:
        i_ydottwig_f=0.3;
      else: %mid
        i_ydottwig_f=0.0;
      fi;
    fi;
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf*i_ystem_f, toprounding, 0, tightness_f, 20);
    if dot:
      filldraw dotpath(xmid, ymid+yd*yhalf*i_ydottwig_f, stemdot_f, 30);
    elseif twodots:
      filldraw dotpath(xmid, ymid+yd*yhalf*i_ydottwig_f, stemdot_f, 30);
      filldraw dotpath(xmid, ymid-yd*yhalf*i_ydottwig_f, stemdot_f, 40);
    fi;
    if twig:
      filldraw barpath(xmid-twig_length_f*stem_w/2, ymid+yd*yhalf*i_ydottwig_f, endrounding,
                       xmid+twig_length_f*stem_w/2, ymid+yd*yhalf*i_ydottwig_f, endrounding, 0, tightness_f, 50);
    fi;
    if circle:
      draw_circle(xmid, ymid+yd*yhalf*i_ydottwig_f, stemcircle_f, 60);
    fi;
  endchar;
enddef;

def draw_roek_i(expr rune, xd, yd) =
  beginrunechar(rune, 1.3*base_width#+2*margin_width#);
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid+1,        ymidred(yd)-yd*yhalfred,   jointrounding,
                     xmid+xd*xhalf, ymidred(yd)-yd*yhalfred/2, jointrounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymidred(yd)-yd*yhalfred/2, jointrounding,
                     xmid,          ymid,                      jointrounding, xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid,          ymidred(yd)+yd*yhalfred,   jointrounding,
                     xmid-xd*xhalf, ymidred(yd)+yd*yhalfred/2, jointrounding, xd*yd*curve_d, tightness_f, 50);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred/2, jointrounding,
                     xmid-1,        ymid,                      jointrounding, xd*yd*curve_d, tightness_f, 60);
  endchar;
enddef;

def draw_primitive_j(expr rune, xd, yd) =
  beginrunechar(rune, 1.0*base_width#+2*margin_width#);
    save j_y_f;
    j_y_f=2/9;
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*j_y_f, jointrounding,
                     xmid, ymid+yd*yhalf*3*j_y_f, endrounding, -xd*yd*curve_d, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*j_y_f, jointrounding,
                     xmid, ymid-yd*yhalf*j_y_f, endrounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf*j_y_f, jointrounding,
                     xmid, ymid-yd*yhalf*3*j_y_f, endrounding, -xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf*j_y_f, jointrounding,
                     xmid, ymid+yd*yhalf*j_y_f, endrounding, xd*yd*curve_d, tightness_f, 50);
  endchar;
enddef;

def draw_primitive_jup(expr rune, xd, yd) =
  beginrunechar(rune, 1.3*base_width#+2*margin_width#);
    save j_yup_f;
    j_yup_f=0.50;
    filldraw barpath(xmid-xd*xhalf, ymid, endrounding,
                     xmid-xd*xhalf/3, ymid-yd*yhalf*j_yup_f, jointrounding, xd*yd*curve_d, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf/3, ymid-yd*yhalf*j_yup_f, jointrounding,
                     xmid+xd*xhalf/3, ymid, endrounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf/3, ymid, endrounding,
                     xmid+xd*xhalf/3, ymid+yd*yhalf*j_yup_f, jointrounding, -xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf/3, ymid+yd*yhalf*j_yup_f, jointrounding,
                     xmid+xd*xhalf, ymid, endrounding, -xd*yd*curve_d, tightness_f, 50);
  endchar;
enddef;

def draw_anglo_j(expr rune, xd, yd) =
  beginrunechar(rune, 1.6*base_width#+2*margin_width#);
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid, endrounding,
                     xmid+xd*xhalf, ymid, endrounding, 0, tightness_f, 30);
  endchar;
enddef;

def draw_primitive_I(expr rune, xd, yd) =
  beginrunechar(rune, topbarred*1.1*base_width#+2*margin_width#);
  save I_y_f;
  save I_curve_f;
  I_y_f=0.48;
  I_curve_f=0.25;
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid+xd*1, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalfred*I_y_f, endrounding, -I_curve_f*xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*1, ymid-yd*yhalfred, jointrounding,
                     xmid-xd*xhalf, ymid-yd*yhalfred*I_y_f, endrounding, -I_curve_f*xd*yd*curve_d, tightness_f, 40);
  endchar;
enddef;

def draw_roek_a(expr rune, xd, yd) =
  beginrunechar(rune, 0.65*base_width#+2*margin_width#);
    save a_y_f;
    save a_ycorner_f;
    a_y_f=0.16;
    a_ycorner_f=0.36;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf*a_y_f,       jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalf*a_ycorner_f, jointrounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf*a_ycorner_f, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*a_ycorner_f, jointrounding, xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf, ymid+yd*yhalf*a_ycorner_f, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf*a_y_f,       jointrounding, xd*yd*curve_d, tightness_f, 50);
  endchar;
enddef;

def draw_primitive_p(expr rune, xd, yd) =
  beginrunechar(rune, topbarred*1.0*base_width#+2*margin_width#);
    save p_x_f;
    save p_y_f;
    save p_curve_f;
    p_x_f=0.06;
    p_y_f=0.6;
    p_curve_f=0.25;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, topjointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalfred, jointrounding,
                     xmid+xd*xhalf*p_x_f, ymid-yd*yhalfred*p_y_f, jointrounding, -p_curve_f*xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalfred, jointrounding,
                     xmid+xd*xhalf*p_x_f, ymid-yd*yhalfred*p_y_f, jointrounding, p_curve_f*xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf*p_x_f, ymid+yd*yhalfred*p_y_f, jointrounding, p_curve_f*xd*yd*curve_d, tightness_f, 50);
    filldraw barpath(xmid+xd*xhalf, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf*p_x_f, ymid+yd*yhalfred*p_y_f, jointrounding, -p_curve_f*xd*yd*curve_d, tightness_f, 60);
  endchar;
enddef;

def draw_frisian_p(expr rune, xd, yd) =
  beginrunechar(rune, topbarred*0.63*base_width#+2*margin_width#);
    save p_y_f;
    save p_curve_f;
    p_y_f=0.55;
    p_curve_f=0.25;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, topjointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalfred*p_y_f, jointrounding, p_curve_f*xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalfred*p_y_f, jointrounding, -p_curve_f*xd*yd*curve_d, tightness_f, 40);
  endchar;
enddef;

def draw_normal_s(expr rune, xd, yd, twobars, chair, high, twigs, flat) =
  save s_width_f;
  if twigs:
    s_width_f=0.80;
  else:
    s_width_f=0.75;
  fi;
  beginrunechar(rune, s_width_f*base_width#+2*margin_width#);
    save s_xtop_f;
    save s_ymid_f;
    save s_ymidmid_f;
    save s_ysep_f;
    save s_ytwig_f;
    if chair or high or twigs:
      s_xtop_f=1.0;
    else:
      s_xtop_f=0.8;
    fi;
    if twobars:
      s_ysep_f=0.22;
    else:
      s_ysep_f=0.0;
    fi;
    if high:
      s_ymidmid_f=0.68;
      s_ymid_f=0.28;
    else:
      s_ymidmid_f=0.0;
      if flat:
        s_ymid_f=-0.08;
      else:
        s_ymid_f=0.08;
      fi;
    fi;
    s_ytwig_f=0.6;
    filldraw barpath(xmid-xd*xhalf*s_xtop_f, ymid+yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf*(s_ymidmid_f-s_ymid_f-s_ysep_f), jointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*(s_ymidmid_f-s_ymid_f-s_ysep_f), jointrounding,
                     xmid+xd*xhalf*(1+s_xtop_f)/2, ymid+yd*yhalf*(s_ymidmid_f+s_ymid_f-s_ysep_f), jointrounding, 0, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf*(1+s_xtop_f)/2, ymid+yd*yhalf*(s_ymidmid_f-s_ymid_f+s_ysep_f), jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*(s_ymidmid_f+s_ymid_f+s_ysep_f), jointrounding, 0, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf, ymid+yd*yhalf*(s_ymidmid_f+s_ymid_f+s_ysep_f), jointrounding,
                     xmid+xd*xhalf*s_xtop_f, ymid-yd*yhalf, toprounding, 0, tightness_f, 50);
    if chair:
      filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                       xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 60);
    fi;
    if twigs:
      filldraw barpath(xmid-xd*xhalf*s_xtop_f-xd*twig_length_f*stem_w/2, ymid+yd*yhalf*s_ytwig_f, endrounding,
                       xmid-xd*xhalf*s_xtop_f+xd*twig_length_f*stem_w/2, ymid+yd*yhalf*s_ytwig_f, endrounding, 0, tightness_f, 70);
      filldraw barpath(xmid+xd*xhalf*s_xtop_f-xd*twig_length_f*stem_w/2, ymid-yd*yhalf*s_ytwig_f, endrounding,
                       xmid+xd*xhalf*s_xtop_f+xd*twig_length_f*stem_w/2, ymid-yd*yhalf*s_ytwig_f, endrounding, 0, tightness_f, 80);
    fi;
  endchar;
enddef;

def draw_primitive_s(expr rune, xd, yd, strokes) =
  save s_width_f;
  s_width_f=(stem_h#/strokes+stem_w#)/base_width#;
  beginrunechar(rune, s_width_f*base_width#+2*margin_width#);
    xdir:=1;
    for i=strokes step -2 until -strokes+2:
      filldraw barpath(xmid+xdir*xd*xhalf, ymid+yd*yhalf*i/strokes, if i=strokes:toprounding else: jointrounding fi,
                       xmid-xdir*xd*xhalf, ymid+yd*yhalf*(i-2)/strokes, if i=-strokes+2:toprounding else: jointrounding fi, 0, tightness_f, (i+strokes)*10);
      xdir:=-xdir;
    endfor;
  endchar;
enddef;

def draw_shorttwig_s(expr rune, xd, yd, dot, twig, hook, arrow, circle) =
  save s_width_f;
  if twig:
    s_width_f=twig_length_f+1;
  elseif hook:
    s_width_f=0.7*twig_length_f+1;
  elseif dot:
    s_width_f=endstemdot_f;
  elseif arrow:
    s_width_f=1.4*twig_length_f+1;
  elseif circle:
    s_width_f=endstemcircle_f;
  else:
    s_width_f=1.0;
  fi;
  beginrunechar(rune, s_width_f*stem_w#+2*margin_width#);
    save s_y_f;
    save s_hooky_f;
    s_y_f=0.1;
    s_hooky_f=0.4;
    filldraw barpath(xmid if hook: -xd*xhalf fi, ymid+yd*yhalf*s_y_f, toprounding,
                     xmid if hook: -xd*xhalf fi, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    if dot:
      filldraw dotpath(xmid, ymid+yd*yhalf*s_y_f, endstemdot_f, 30);
    fi;
    if twig:
      filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*s_y_f, endrounding,
                       xmid+xd*xhalf, ymid+yd*yhalf*s_y_f, endrounding, 0, tightness_f, 40);
    fi;
    if hook:
      filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*s_y_f, jointrounding,
                       xmid+xd*xhalf, ymid+yd*yhalf*s_hooky_f, endrounding, 0, tightness_f, 50);
    elseif arrow:
      filldraw barpath(xmid, ymid+yd*yhalf*s_y_f, jointrounding,
                       xmid-xd*xhalf, ymid+yd*yhalf*s_hooky_f, endrounding, 0, tightness_f, 50);
      filldraw barpath(xmid, ymid+yd*yhalf*s_y_f, jointrounding,
                       xmid+xd*xhalf, ymid+yd*yhalf*s_hooky_f, endrounding, 0, tightness_f, 60);
    elseif circle:
      draw_circle(xmid, ymid+yd*(yhalf*s_y_f-endstemcircle_f*stem_w/2), endstemcircle_f, 50);
    fi;
  endchar;
enddef;

def draw_normal_t(expr rune, xd, yd, middot, topdots, doublearrow, arlaug, mid) =
  save t_width_f;
  if topdots:
    t_width_f=1.28;
  else:
    t_width_f=1.1;
  fi;
  beginrunechar(rune, topbarred*t_width_f*base_width#+2*margin_width#);
    save t_y_f;
    save t_curve_f;
    save t_topdotx_f;
    t_curve_f=0.25;
    t_y_f=0.42;
    t_topdotx_f=0.43;
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    if mid:
      filldraw barpath(xmid+xd*2, ymid+yd*yhalf*(1-t_y_f)/2, jointrounding,
                       xmid+xd*xhalf, ymid-yd*yhalf*(1-t_y_f)/2, endrounding, -t_curve_f*xd*yd*curve_d, tightness_f, 30);
    else:
      filldraw barpath(xmid+xd*2, ymidred(yd)+yd*yhalfred, jointrounding,
                       xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*t_y_f, endrounding, -t_curve_f*xd*yd*curve_d, tightness_f, 30);
    fi;
    if mid or arlaug:
      filldraw barpath(xmid-xd*2, ymid+yd*yhalf*(1-t_y_f)/2, jointrounding,
                       xmid-xd*xhalf, ymid-yd*yhalf*(1-t_y_f)/2, endrounding, t_curve_f*xd*yd*curve_d, tightness_f, 40);
    else:
      filldraw barpath(xmid-xd*2, ymidred(yd)+yd*yhalfred, jointrounding,
                       xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*t_y_f, endrounding, t_curve_f*xd*yd*curve_d, tightness_f, 40);
    fi;
    if middot:
      filldraw dotpath(xmid, ymidred(yd), stemdot_f, 50);
    fi;
    if topdots:
      filldraw dotpath(xmid-xd*xhalf*t_topdotx_f, ymidred(yd)+yd*yhalfred*t_y_f, freedot_f, 60);
      filldraw dotpath(xmid+xd*xhalf*t_topdotx_f, ymidred(yd)+yd*yhalfred*t_y_f, freedot_f, 70);
    fi;
    if doublearrow:
      filldraw barpath(xmid+2, ymidred(yd)-yd*yhalfred, jointrounding,
                       xmid+xd*xhalf, ymidred(yd)-yd*yhalfred*t_y_f, endrounding, xd*yd*-t_curve_f*xd*yd*curve_d, tightness_f, 80);
      filldraw barpath(xmid-2, ymidred(yd)-yd*yhalfred, jointrounding,
                       xmid-xd*xhalf, ymidred(yd)-yd*yhalfred*t_y_f, endrounding, xd*yd*t_curve_f*xd*yd*curve_d, tightness_f, 90);
    fi;
  endchar;
enddef;

def draw_normal_b(expr rune, xd, yd, topdot, bottomdot, separated) =
  save b_width_f;
  if separated:
    b_width_f=0.6;
  else:
    b_width_f=0.75;
  fi;
  beginrunechar(rune, topbarred*b_width_f*base_width#+2*margin_width#);
    save b_yup_f;
    save b_ymid_f;
    save b_curve_f;
    if separated:
      b_yup_f=0.65;
      b_ymid_f=0.3;
    else:
      b_yup_f=0.4;
      b_ymid_f=0.0;
    fi;
    b_curve_f=0.63+0.37*abs(curve_d-45)/45;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, topjointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalfred*b_yup_f, jointrounding, -b_curve_f*xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymid+yd*yhalfred*b_yup_f, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalfred*b_ymid_f, jointrounding, -b_curve_f*xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalfred*b_ymid_f, jointrounding,
                     xmid+xd*xhalf, ymid-yd*yhalfred*b_yup_f, jointrounding, -b_curve_f*xd*yd*curve_d, tightness_f, 50);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalfred*b_yup_f, jointrounding,
                     xmid-xd*xhalf, ymid-yd*yhalfred, jointrounding, -b_curve_f*xd*yd*curve_d, tightness_f, 60);
    if topdot:
      filldraw dotpath(xmid-xd*xhalf/4, ymid+yd*yhalfred*(1+b_yup_f+b_ymid_f)/3, freedot_f, 70);
    fi;
    if bottomdot:
      filldraw dotpath(xmid-xd*xhalf/4, ymid-yd*yhalfred*(1+b_yup_f+b_ymid_f)/3, freedot_f, 80);
    fi;
  endchar;
enddef;

def draw_primitive_e(expr rune, xd, yd, closed, midstem) =
  beginrunechar(rune, topbarred*1.25*base_width#+2*margin_width#);
    save e_y_f;
    save e_curve_f;
    e_y_f=0.4;
    e_curve_f=0.25;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf+1, ymid+yd*yhalfred, jointrounding,
                     xmid, ymid+yd*yhalfred*e_y_f, jointrounding, e_curve_f*xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf-1, ymid+yd*yhalfred, jointrounding,
                     xmid, ymid+yd*yhalfred*e_y_f, jointrounding, -e_curve_f*xd*yd*curve_d, tightness_f, 50);
    if closed:
      filldraw barpath(xmid-xd*xhalf+1, ymid-yd*yhalfred, jointrounding,
                       xmid, ymid-yd*yhalfred*e_y_f, jointrounding, -e_curve_f*xd*yd*curve_d, tightness_f, 60);
      filldraw barpath(xmid+xd*xhalf-1, ymid-yd*yhalfred, jointrounding,
                       xmid, ymid-yd*yhalfred*e_y_f, jointrounding, e_curve_f*xd*yd*curve_d, tightness_f, 70);
    fi;
    if midstem:
      filldraw barpath(xmid, ymid+yd*yhalfred*e_y_f, jointrounding,
                       xmid, ymid-yd*yhalfred*e_y_f, jointrounding, 0, tightness_f, 80);
    fi;
  endchar;
enddef;

def draw_primitive_E(expr rune, xd, yd, closed) =
  beginrunechar(rune, topbarred*1.15*base_width#+2*margin_width#);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalfred, jointrounding, 0, tightness_f, 40);
    if closed:
      filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalfred, jointrounding,
                       xmid+xd*xhalf, ymid-yd*yhalfred, jointrounding, 0, tightness_f, 40);
    fi;
  endchar;
enddef;

def draw_normal_m(expr rune, xd, yd, dots, double, tree) =
  beginrunechar(rune, 1.3*base_width#+2*margin_width#);
    save m_y_f;
    save m_xdot_f;
    save m_ydot_f;
    m_xdot_f=0.4 + if mag <= 1: 0; elseif mag <= 2: (mag-1)/20; else: 0.05; fi;
    m_ydot_f=0.85;
    m_y_f=0.1;
    filldraw barpath(xmid, ymid-yd*yhalf, if tree:jointrounding else:toprounding fi,
                     xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid, ymid+yd*yhalf*m_y_f, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid, ymid+yd*yhalf*m_y_f, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, -xd*yd*curve_d, tightness_f, 40);
    if double:
      filldraw barpath(xmid, ymid-yd*yhalf*m_y_f, jointrounding,
                       xmid+xd*xhalf, ymid-yd*yhalf, toprounding, -xd*yd*curve_d, tightness_f, 50);
      filldraw barpath(xmid, ymid-yd*yhalf*m_y_f, jointrounding,
                       xmid-xd*xhalf, ymid-yd*yhalf, toprounding, xd*yd*curve_d, tightness_f, 60);
    elseif tree:
      filldraw barpath(xmid, ymid-yd*yhalf, jointrounding,
                       xmid+xd*xhalf, ymid-yd*yhalf*m_y_f, toprounding, xd*yd*curve_d, tightness_f, 50);
      filldraw barpath(xmid, ymid-yd*yhalf, jointrounding,
                       xmid-xd*xhalf, ymid-yd*yhalf*m_y_f, toprounding, -xd*yd*curve_d, tightness_f, 60);
    fi;
    if dots:
      filldraw dotpath(xmid+xd*xhalf*m_xdot_f, ymid+yd*yhalf*m_ydot_f, freedot_f, 70);
      filldraw dotpath(xmid-xd*xhalf*m_xdot_f, ymid+yd*yhalf*m_ydot_f, freedot_f, 80);
      if double:
        filldraw dotpath(xmid+xd*xhalf*m_xdot_f, ymid-yd*yhalf*m_ydot_f, freedot_f, 90);
        filldraw dotpath(xmid-xd*xhalf*m_xdot_f, ymid-yd*yhalf*m_ydot_f, freedot_f, 100);
      fi;
    fi;
  endchar;
enddef;

def draw_normal_M(expr rune, xd, yd, dots) =
  beginrunechar(rune, 1.0*topbarred*base_width#+2*margin_width#);
    save M_ymid_f;
    save M_xdot_f;
    M_xdot_f=0.42;
    M_ymid_f=0.04;
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-1, ymidred(yd)+yd*yhalfred, jointrounding,
                     xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*(1+M_ymid_f)/2, jointrounding, xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*(1+M_ymid_f)/2, jointrounding,
                     xmid, ymidred(yd)+yd*yhalfred*M_ymid_f, jointrounding, xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid, ymidred(yd)+yd*yhalfred*M_ymid_f, jointrounding,
                     xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*(1+M_ymid_f)/2, jointrounding, xd*yd*curve_d, tightness_f, 50);
    filldraw barpath(xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*(1+M_ymid_f)/2, jointrounding,
                     xmid+1, ymidred(yd)+yd*yhalfred, jointrounding, xd*yd*curve_d, tightness_f, 60);
    if dots:
      filldraw dotpath(xmid+xd*xhalf*M_xdot_f, ymidred(yd)+yd*yhalfred*(1+M_ymid_f)/2, freedot_f, 50);
      filldraw dotpath(xmid-xd*xhalf*M_xdot_f, ymidred(yd)+yd*yhalfred*(1+M_ymid_f)/2, freedot_f, 60);
    fi;
  endchar;
enddef;

def draw_primitive_m(expr rune, xd, yd, big, top, double) =
  beginrunechar(rune, topbarred*1.3*base_width#+2*margin_width#);
    save m_ymid_f;
    save m_ysep_f;
    if big:
      m_ysep_f=1.0;
    else:
      m_ysep_f=0.5;
    fi;
    if top:
      m_ymid_f=0.5;
    else:
      m_ymid_f=0.0;
    fi;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, toprounding, 0, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*(m_ymid_f+m_ysep_f), jointrounding,
                     xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*(m_ymid_f-m_ysep_f), jointrounding, 0, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf, ymidred(yd)+yd*yhalfred*(m_ymid_f+m_ysep_f), jointrounding,
                     xmid-xd*xhalf, ymidred(yd)+yd*yhalfred*(m_ymid_f-m_ysep_f), jointrounding, 0, tightness_f, 50);
    if double:
      filldraw barpath(xmid-xd*xhalf, ymidred(yd)-yd*yhalfred*(m_ymid_f+m_ysep_f), jointrounding,
                       xmid+xd*xhalf, ymidred(yd)-yd*yhalfred*(m_ymid_f-m_ysep_f), jointrounding, 0, tightness_f, 60);
      filldraw barpath(xmid+xd*xhalf, ymidred(yd)-yd*yhalfred*(m_ymid_f+m_ysep_f), jointrounding,
                       xmid-xd*xhalf, ymidred(yd)-yd*yhalfred*(m_ymid_f-m_ysep_f), jointrounding, 0, tightness_f, 70);
    fi;
  endchar;
enddef;

def draw_staveless_m(expr rune, xd, yd) =
  beginrunechar(rune, freedot_f*stem_w#+2*margin_width#);
    save m_ytop_f;
    save m_ybottom_f;
    m_ytop_f=0.75;
    m_ybottom_f=0.25;
    filldraw dotpath(xmid, ymid+yd*yhalf*m_ytop_f, freedot_f, 20);
    filldraw dotpath(xmid, ymid+yd*yhalf*m_ybottom_f, freedot_f, 30);
  endchar;
enddef;

def draw_normal_l(expr rune, xd, yd, middot, topdot, midtwig, toptwig, circle) =
  beginrunechar(rune, topbarred*0.73*base_width#+2*margin_width#);
    save l_y_f;
    save l_curve_f;
    save l_topdotx_f;
    save l_twigcrossing_f;
    save l_twigtwiglength_f;
    l_curve_f=0.25;
    l_y_f=0.4;
    l_topdotx_f=0.15;
    l_twigcrossing_f=0.65;
    l_twigtwiglength_f=0.3;
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalfred*l_y_f, endrounding, -l_curve_f*xd*yd*curve_d, tightness_f, 30);
    if middot:
      filldraw dotpath(xmid-xd*xhalf, ymidred(yd), stemdot_f, 40);
    fi;
    if topdot:
      filldraw dotpath(xmid-xd*xhalf*l_topdotx_f, ymid+yd*yhalfred*l_y_f, freedot_f, 50);
    fi;
    if midtwig:
      filldraw barpath(xmid-xd*xhalf-xd*twig_length_f*stem_w/2, ymidred(yd), endrounding,
                       xmid-xd*xhalf+xd*twig_length_f*stem_w/2, ymidred(yd), endrounding, 0, tightness_f, 60);
    fi;
    if toptwig:
      filldraw barpath(xmid+xd*xhalf*(((1-(-1))*l_twigcrossing_f-1)-(l_y_f-1)*yhalfred/xhalf*l_twigtwiglength_f), ymid+yd*yhalfred*(((l_y_f-1)*l_twigcrossing_f+1)+(1-(-1))*xhalf/yhalfred*l_twigtwiglength_f), endrounding,
                       xmid+xd*xhalf*(((1-(-1))*l_twigcrossing_f-1)+(l_y_f-1)*yhalfred/xhalf*l_twigtwiglength_f), ymid+yd*yhalfred*(((l_y_f-1)*l_twigcrossing_f+1)-(1-(-1))*xhalf/yhalfred*l_twigtwiglength_f), endrounding, -l_curve_f*xd*yd*curve_d, tightness_f, 70);
    fi;
    if circle:
      draw_circle(xmid-xd*xhalf, ymidred(yd), stemcircle_f, 80);
    fi;
  endchar;
enddef;

def draw_shorttwig_l(expr rune, xd, yd) =
  beginrunechar(rune, 0.7*base_width#+2*margin_width#);
    save l_topy_f;
    save l_twigy_f;
    l_topy_f=0.76;
    l_twigy_f=0.36;
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf, toprounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*l_topy_f, endrounding, 0, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf, ymid+yd*yhalf*l_twigy_f, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, endrounding, 0, tightness_f, 30);
  endchar;
enddef;

def draw_shorttwig_L(expr rune, xd, yd) =
  beginrunechar(rune, 0.9*base_width#+2*margin_width#);
    save L_topy_f;
    save L_x_f;
    L_topy_f=0.3;
    L_x_f=0.1;
    filldraw barpath(xmid-xd*xhalf*L_x_f, ymid-yd*yhalf, toprounding,
                     xmid-xd*xhalf*L_x_f, ymid+yd*yhalf*(1+L_topy_f)/2, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf, endrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*L_topy_f, endrounding, 0, tightness_f, 30);
  endchar;
enddef;

def draw_primitive_ng(expr rune, xd, yd, top, line, empty, belgthor) =
  save ng_width_f;
  if belgthor:
    ng_width_f=1.25;
  else:
    ng_width_f=1.0;
  fi;
  beginrunechar(rune, ng_width_f*base_width#+2*margin_width#);
    save ng_curve_f;
    if belgthor:
      ng_curve_f=1.0;
    else:
      ng_curve_f=0.25;
    fi;
    if line:
      if empty:
        if top:
          filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                           xmid, ymid+yd*yhalfred-2*yd*xhalf, toprounding, 0, tightness_f, 20);
        else:
          filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                           xmid, ymid-yd*xhalf, toprounding, 0, tightness_f, 20);
          filldraw barpath(xmid, ymid+yd*yhalf, toprounding,
                           xmid, ymid+yd*xhalf, toprounding, 0, tightness_f, 30);
        fi;
      else:
        filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                         xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
      fi;
    fi;
    if top:
      filldraw barpath(xmid, ymid+yd*yhalfred, jointrounding,
                       xmid-xd*xhalf, ymid+yd*yhalfred-yd*xhalf, jointrounding, ng_curve_f*xd*yd*curve_d, tightness_f, 40);
      filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalfred-yd*xhalf, jointrounding,
                       xmid, ymid+yd*yhalfred-yd*2*xhalf, jointrounding, ng_curve_f*xd*yd*curve_d, tightness_f, 50);
      filldraw barpath(xmid, ymid+yd*yhalfred-yd*2*xhalf, jointrounding,
                       xmid+xd*xhalf, ymid+yd*yhalfred-yd*xhalf, jointrounding, ng_curve_f*xd*yd*curve_d, tightness_f, 60);
      filldraw barpath(xmid+xd*xhalf, ymid+yd*yhalfred-yd*xhalf, jointrounding,
                       xmid, ymid+yd*yhalfred, jointrounding, ng_curve_f*xd*yd*curve_d, tightness_f, 70);
    else:
      filldraw barpath(xmid, ymid+yd*xhalf, jointrounding,
                       xmid-xd*xhalf, ymid, jointrounding, ng_curve_f*xd*yd*curve_d, tightness_f, 40);
      filldraw barpath(xmid-xd*xhalf, ymid, jointrounding,
                       xmid, ymid-yd*xhalf, jointrounding, ng_curve_f*xd*yd*curve_d, tightness_f, 50);
      filldraw barpath(xmid, ymid-yd*xhalf, jointrounding,
                       xmid+xd*xhalf, ymid, jointrounding, ng_curve_f*xd*yd*curve_d, tightness_f, 60);
      filldraw barpath(xmid+xd*xhalf, ymid, jointrounding,
                       xmid, ymid+yd*xhalf, jointrounding, ng_curve_f*xd*yd*curve_d, tightness_f, 70);
    fi;
  endchar;
enddef;

def draw_primitive_NG(expr rune, xd, yd) =
  beginrunechar(rune, 0.8*base_width#+2*margin_width#);
    save NG_curve_f;
    NG_curve_f=0.25;
    filldraw barpath(xmid-xd*xhalf, ymid+yd*xhalf, jointrounding,
                     xmid+xd*xhalf, ymid+yd*xhalf, jointrounding, -NG_curve_f*xd*yd*curve_d, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf, ymid+yd*xhalf, jointrounding,
                     xmid+xd*xhalf, ymid-yd*xhalf, jointrounding, -NG_curve_f*xd*yd*curve_d, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*xhalf, jointrounding,
                     xmid-xd*xhalf, ymid-yd*xhalf, jointrounding, -NG_curve_f*xd*yd*curve_d, tightness_f, 40);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*xhalf, jointrounding,
                     xmid-xd*xhalf, ymid+yd*xhalf, jointrounding, -NG_curve_f*xd*yd*curve_d, tightness_f, 50);
  endchar;
enddef;

def draw_anglo_ng(expr rune, xd, yd) =
  beginrunechar(rune, 0.98*base_width#+2*margin_width#);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, jointrounding,
                     xmid+xd*xhalf, ymid, jointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf, ymid, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, jointrounding, 0, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf, jointrounding,
                     xmid-xd*xhalf, ymid, jointrounding, 0, tightness_f, 40);
    filldraw barpath(xmid-xd*xhalf, ymid, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, jointrounding, 0, tightness_f, 50);
  endchar;
enddef;

def draw_primitive_o(expr rune, xd, yd) =
  beginrunechar(rune, 1.4*base_width#+2*margin_width#);
    save o_x_f;
    save o_y_f;
    save oround_x_f;
    save oround_y_f;
    save oround_curve_d;
    save oroundsharp_curve_d;
    o_x_f=0.72;
    o_y_f=0.44;
    oround_x_f=0.52;
    oround_y_f=0.6;
    oround_curve_d=70;
    oroundsharp_curve_d=170;
    if curve_d < 45:
      filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                       xmid+xd*xhalf*o_x_f, ymid+yd*yhalf*o_y_f, jointrounding, 0, tightness_f, 20);
      filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf, toprounding,
                       xmid-xd*xhalf*o_x_f, ymid+yd*yhalf*o_y_f, jointrounding, 0, tightness_f, 30);
      filldraw barpath(xmid+xd*xhalf*o_x_f, ymid+yd*yhalf*o_y_f, jointrounding,
                       xmid, ymid+yd*yhalf, jointrounding, 0, tightness_f, 40);
      filldraw barpath(xmid-xd*xhalf*o_x_f, ymid+yd*yhalf*o_y_f, jointrounding,
                       xmid, ymid+yd*yhalf, jointrounding, 0, tightness_f, 50);
    else:
      filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf, toprounding,
                       xmid, ymid+yd*yhalf*(o_y_f-1)/2, jointrounding, 0, tightness_f, 20);
      filldraw barpath(xmid+xd*xhalf, ymid-yd*yhalf, toprounding,
                       xmid, ymid+yd*yhalf*(o_y_f-1)/2, jointrounding, 0, tightness_f, 30);
      filldraw barpath(xmid, ymid+yd*yhalf*(o_y_f-1)/2, jointrounding,
                       xmid-xd*xhalf*oround_x_f, ymid+yd*yhalf*oround_y_f, jointrounding, -xd*yd*oround_curve_d, tightness_f, 40);
      filldraw barpath(xmid, ymid+yd*yhalf*(o_y_f-1)/2, jointrounding,
                       xmid+xd*xhalf*oround_x_f, ymid+yd*yhalf*oround_y_f, jointrounding, xd*yd*oround_curve_d, tightness_f, 50);
      filldraw barpath(xmid-xd*xhalf*oround_x_f, ymid+yd*yhalf*oround_y_f, jointrounding,
                       xmid+xd*xhalf*oround_x_f, ymid+yd*yhalf*oround_y_f, jointrounding, -xd*yd*oroundsharp_curve_d, tightness_f, 60);
    fi;
  endchar;
enddef;

def draw_anglo_ea(expr rune, xd, yd, q) =
  beginrunechar(rune, topbarred*1.5*base_width#+2*margin_width#);
    save ea_x_f;
    save ea_y_f;
    save ea_y_mirr;
    ea_x_f=0.7;
    ea_y_f=0.53;
    ea_y_mirr=if q: -1 else: 1 fi;
    filldraw barpath(xmid, ymid-yd*yhalf, endrounding,
                     xmid, ymid+yd*yhalf, topjointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid+xd*2, ymid+yd*yhalfred, jointrounding,
                     xmid+xd*xhalf*ea_x_f, ymid+yd*yhalfred*ea_y_f, jointrounding, 0, tightness_f, 30);
    filldraw barpath(xmid+xd*xhalf*ea_x_f, ymid+yd*yhalfred*ea_y_f, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalfred, endrounding, 0, tightness_f, 40);
    filldraw barpath(xmid-xd*2, ymid+yd*yhalfred*ea_y_mirr, jointrounding,
                     xmid-xd*xhalf*ea_x_f, ymid+yd*yhalfred*ea_y_f*ea_y_mirr, jointrounding, 0, tightness_f, 50);
    filldraw barpath(xmid-xd*xhalf*ea_x_f, ymid+yd*yhalfred*ea_y_f*ea_y_mirr, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalfred*ea_y_mirr, endrounding, 0, tightness_f, 60);
  endchar;
enddef;

def draw_anglo_rex(expr rune, xd, yd) =
  beginrunechar(rune, topbarred*1.15*base_width#+2*margin_width#);
    save rex_y_f;
    rex_y_f=0.4;
    filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf*rex_y_f, jointrounding, 0, tightness_f, 20);
    filldraw barpath(xmid, ymid+yd*yhalf*rex_y_f, jointrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf, endrounding, 0, tightness_f, 30);
    filldraw barpath(xmid, ymid+yd*yhalf*rex_y_f, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, endrounding, 0, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf, ymid+yd*yhalf, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, jointrounding, 0, tightness_f, 50);
  endchar;
enddef;

def draw_medieval_x(expr rune, xd, yd, stem) =
  beginrunechar(rune, 1.25*base_width#+2*margin_width#);
    save x_y_f;
    save x_twigtwiglength_f;
    x_y_f=0.65;
    x_twigtwiglength_f=0.25;
    if stem:
      filldraw barpath(xmid, ymid-yd*yhalf, toprounding,
                     xmid, ymid+yd*yhalf, toprounding, 0, tightness_f, 20);
    fi;
    filldraw barpath(xmid-xd*xhalf, ymid+yd*yhalf*x_y_f, endrounding,
                     xmid+xd*xhalf, ymid-yd*yhalf*x_y_f, endrounding, 0, tightness_f, 30);
    filldraw barpath(xmid-xd*xhalf, ymid-yd*yhalf*x_y_f, endrounding,
                     xmid+xd*xhalf, ymid+yd*yhalf*x_y_f, endrounding, 0, tightness_f, 40);
    filldraw barpath(xmid+xd*xhalf*(1-x_twigtwiglength_f), ymid+yd*yhalf*x_y_f*(1+((xhalf/(yhalf*x_y_f))**2)*x_twigtwiglength_f), endrounding,
                     xmid+xd*xhalf*(1+x_twigtwiglength_f), ymid+yd*yhalf*x_y_f*(1-((xhalf/(yhalf*x_y_f))**2)*x_twigtwiglength_f), endrounding, 0, tightness_f, 50);
    filldraw barpath(xmid-xd*xhalf*(1-x_twigtwiglength_f), ymid-yd*yhalf*x_y_f*(1+((xhalf/(yhalf*x_y_f))**2)*x_twigtwiglength_f), endrounding,
                     xmid-xd*xhalf*(1+x_twigtwiglength_f), ymid-yd*yhalf*x_y_f*(1-((xhalf/(yhalf*x_y_f))**2)*x_twigtwiglength_f), endrounding, 0, tightness_f, 60);
    filldraw barpath(xmid-xd*xhalf*(1-x_twigtwiglength_f), ymid+yd*yhalf*x_y_f*(1+((xhalf/(yhalf*x_y_f))**2)*x_twigtwiglength_f), endrounding,
                     xmid-xd*xhalf*(1+x_twigtwiglength_f), ymid+yd*yhalf*x_y_f*(1-((xhalf/(yhalf*x_y_f))**2)*x_twigtwiglength_f), endrounding, 0, tightness_f, 70);
    filldraw barpath(xmid+xd*xhalf*(1-x_twigtwiglength_f), ymid-yd*yhalf*x_y_f*(1+((xhalf/(yhalf*x_y_f))**2)*x_twigtwiglength_f), endrounding,
                     xmid+xd*xhalf*(1+x_twigtwiglength_f), ymid-yd*yhalf*x_y_f*(1-((xhalf/(yhalf*x_y_f))**2)*x_twigtwiglength_f), endrounding, 0, tightness_f, 80);
  endchar;
enddef;

def draw_modern_aa(expr rune, xd, yd) =
  beginrunechar(rune, 0.8*base_width#+2*margin_width#);
  save aa_curve_f;
  aa_curve_f=0.5;
    filldraw barpath(xmid+xd*xhalf, ymid, jointrounding,
                     xmid-xd*xhalf, ymid+yd*yhalf, endrounding, aa_curve_f*xd*yd*curve_d, tightness_f, 20);
    filldraw barpath(xmid+xd*xhalf, ymid, jointrounding,
                     xmid-xd*xhalf, ymid-yd*yhalf, endrounding, -aa_curve_f*xd*yd*curve_d, tightness_f, 30);
  endchar;
enddef;

