%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /data/old/usr/share/texlive/texmf-dist/fonts/source/public/mnsymbol/
Upload File :
Create Path :
Current File : //data/old/usr/share/texlive/texmf-dist/fonts/source/public/mnsymbol/Sym-Delim.mf

% brackets

def draw_bracket(expr sign, thick, draw_top, draw_mid, draw_bot, draw_double) =
  penpos0(thick, 90 - sign * 90);
  penpos1(thick, 90 - sign * 90);
  penpos2(3/2thick, 90);
  penpos3(1/2thick, 90);
  penpos4(3/2thick, 90);
  penpos5(1/2thick, 90);
  penpos6(1/2thick, 0);
  penpos7(1/2thick, 0);

  x3 - x2 = x5 - x4 = sign * (w - 2side_bearing); % - 2u + thick);

  1/2[x2,x3] = w/2 + sign * 1/2u;

  if draw_top:
    y1 = h;
  else:
    y1 = h + 1/3rule_thickness;
  fi;

  if draw_bot:
    y0 = -d;
  else:
    y0 = -d - 1/3rule_thickness;
  fi;

  x1 = x0;

  z6 = 1/3[z2l,z3l] + sign * thick * dir 0;
  z7 = 1/3[z4r,z5r] + sign * thick * dir 0;

  y2l = y3l;
  y4r = y5r;
  z2l = z0l;
  z4r = z1l;

  if draw_mid:
    fill stroke z0e -- z1e;
  else:
    if draw_bot: fill stroke z0e -- 1/4[z0e,z1e]; fi;
    if draw_top: fill stroke 3/4[z0e,z1e] -- z1e; fi;
  fi;
  if draw_top: fill stroke z4e .. {sign * dir 0}z5e; fi;
  if draw_bot: fill stroke z2e .. {sign * dir 0}z3e; fi;
  if draw_double: fill stroke z6e -- z7e; fi;
enddef;

lsquare_char = current_char + 1;
rsquare_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "square bracket";
      draw_bracket(sign, 5/4rule_thickness * sqrt (scale/2), true, true, true, false);
    endchar;
  endfor;
endfor;

lfloor_char = current_char + 1;
rfloor_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "floor";
      draw_bracket(sign, 5/4rule_thickness * sqrt (scale/2), false, true, true, false);
    endchar;
  endfor;
endfor;

lceil_char = current_char + 1;
rceil_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "ceiling";
      draw_bracket(sign, 5/4rule_thickness * sqrt (scale/2), true, true, false, false);
    endchar;
  endfor;
endfor;

ulcorner_char = current_char + 1;
urcorner_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "upper corner";
      draw_bracket(sign, 5/4rule_thickness * sqrt (scale/2), true, false, false, false);
    endchar;
  endfor;
endfor;

charlist urcorner_char: urcorner_char + 1: urcorner_char + 2: urcorner_char + 3: urcorner_char + 4;
charlist ulcorner_char: ulcorner_char + 1: ulcorner_char + 2: ulcorner_char + 3: ulcorner_char + 4;

llcorner_char = current_char + 1;
lrcorner_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "lower corner";
      draw_bracket(sign, 5/4rule_thickness * sqrt (scale/2), false, false, true, false);
    endchar;
  endfor;
endfor;

charlist lrcorner_char: lrcorner_char + 1: lrcorner_char + 2: lrcorner_char + 3: lrcorner_char + 4;
charlist llcorner_char: llcorner_char + 1: llcorner_char + 2: llcorner_char + 3: llcorner_char + 4;

ullcorner_char = current_char + 1;
ulrcorner_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "upper/lower corner";
      draw_bracket(sign, 5/4rule_thickness * sqrt (scale/2), true, false, true, false);
    endchar;
  endfor;
endfor;

charlist ulrcorner_char: ulrcorner_char + 1: ulrcorner_char + 2: ulrcorner_char + 3: ulrcorner_char + 4;
charlist ullcorner_char: ullcorner_char + 1: ullcorner_char + 2: ullcorner_char + 3: ullcorner_char + 4;

for sign = 1, -1:
  beginsymbol((6 + 6)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "square bracket -- top";
    draw_bracket(sign, 5/4rule_thickness * sqrt (6/2), true, true, false, false);
  endchar;
endfor;

for sign = 1, -1:
  beginsymbol((6 + 6)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "square bracket -- bot";
    draw_bracket(sign, 5/4rule_thickness * sqrt (6/2), false, true, true, false);
  endchar;
endfor;

for sign = 1, -1:
  beginsymbol((6 + 6)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "square bracket -- module";
    draw_bracket(sign, 5/4rule_thickness * sqrt (6/2), false, true, false, false);
  endchar;
endfor;

extensible current_char:     current_char - 4, 0, current_char - 2, current_char;     %right square bracket
extensible current_char - 1: current_char - 5, 0, current_char - 3, current_char - 1; %left square bracket
extensible current_char - 2: 0,                0, current_char - 2, current_char;     %right floor
extensible current_char - 3: 0,                0, current_char - 3, current_char - 1; %left floor
extensible current_char - 4: current_char - 4, 0, 0,                current_char;     %right ceiling
extensible current_char - 5: current_char - 5, 0, 0,                current_char - 1; %left ceiling

charlist rsquare_char: rsquare_char + 1: rsquare_char + 2: rsquare_char + 3: rsquare_char + 4: current_char;
charlist lsquare_char: lsquare_char + 1: lsquare_char + 2: lsquare_char + 3: lsquare_char + 4: current_char - 1;
charlist rfloor_char:  rfloor_char  + 1: rfloor_char  + 2: rfloor_char  + 3: rfloor_char  + 4: current_char - 2;
charlist lfloor_char:  lfloor_char  + 1: lfloor_char  + 2: lfloor_char  + 3: lfloor_char  + 4: current_char - 3;
charlist rceil_char:   rceil_char   + 1: rceil_char   + 2: rceil_char   + 3: rceil_char   + 4: current_char - 4;
charlist lceil_char:   lceil_char   + 1: lceil_char   + 2: lceil_char   + 3: lceil_char   + 4: current_char - 5;

% semantic brackets

lsem_char = current_char + 1;
rsem_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 8)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "semantic bracket";
      draw_bracket(sign, rule_thickness * sqrt (scale/2), true, true, true, true);
    endchar;
  endfor;
endfor;

for sign = 1, -1:
  beginsymbol((6 + 8)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "semantic bracket -- top";
    draw_bracket(sign, 5/4rule_thickness * sqrt (6/2), true, true, false, true);
  endchar;
endfor;

for sign = 1, -1:
  beginsymbol((6 + 8)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "semantic bracket -- bot";
    draw_bracket(sign, 5/4rule_thickness * sqrt (6/2), false, true, true, true);
  endchar;
endfor;

for sign = 1, -1:
  beginsymbol((6 + 8)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "semantic bracket -- module";
    draw_bracket(sign, 5/4rule_thickness * sqrt (6/2), false, true, false, true);
  endchar;
endfor;

extensible current_char:     current_char - 4, 0, current_char - 2, current_char;     %right semanic bracket
extensible current_char - 1: current_char - 5, 0, current_char - 3, current_char - 1; %left semanic bracket
extensible current_char - 2: 0,                0, current_char - 2, current_char;     %right semanic floor
extensible current_char - 3: 0,                0, current_char - 3, current_char - 1; %left semanic floor
extensible current_char - 4: current_char - 4, 0, 0,                current_char;     %right semanic ceiling
extensible current_char - 5: current_char - 5, 0, 0,                current_char - 1; %left semanic ceiling

charlist rsem_char: rsem_char + 1: rsem_char + 2: rsem_char + 3: rsem_char + 4: current_char;
charlist lsem_char: lsem_char + 1: lsem_char + 2: lsem_char + 3: lsem_char + 4: current_char - 1;

beginsymbol(6/2 * u# + 2side_bearing#, vcentre(1/2delim_height#)); "vertical bar -- module";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  pickup pencircle scaled 1/12thick;

  penpos2 (thick, 0);
  penpos3 (thick, 0);

  x2 = x3 = w/2;

  top y2 =  h + 1/3rule_thickness;
  bot y3 = -d - 1/3rule_thickness;

  filldraw stroke z2e -- z3e;
endchar;

extensible current_char: 0, 0, 0, current_char; % vertical bar

for scale = 2, 2.5, 3.3, 4.2, 5.1:
  beginsymbol(scale/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "vertical bar";
    thick := 5/8rule_thickness * sqrt scale;

    pickup pencircle scaled 1/12thick;

    penpos2 (thick, 0);
    penpos3 (thick, 0);

    x2 = x3 = w/2;

    top y2 =  h;
    bot y3 = -d;

    filldraw stroke z2e -- z3e;
  endchar;
endfor;

charlist current_char - 4: current_char - 3: current_char - 2: current_char - 1: current_char:
         current_char - 5;

beginsymbol((5.1 + 8)/2 * u# + 2side_bearing#, vcentre(1/2delim_height#));
  "double vertical bar -- module";

  thick := 3/8rule_thickness * sqrt 5.1;

  pickup pencircle scaled 1/12thick;

  penpos0 (thick, 0);
  penpos1 (thick, 0);
  penpos2 (thick, 0);
  penpos3 (thick, 0);

  x0 = x1;
  x2 = x3;
  1/2[x0,x2] = w/2;
  x2 - x0 = 4thick;

  top y0 = top y2 =  h + 1/3rule_thickness;
  bot y1 = bot y3 = -d - 1/3rule_thickness;

  filldraw stroke z0e -- z1e;
  filldraw stroke z2e -- z3e;
endchar;

extensible current_char: 0, 0, 0, current_char; % double vertical line

for scale = 2, 2.5, 3.3, 4.2, 5.1:
  beginsymbol((scale + 8)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "double vertical bar";
    thick := 4/8rule_thickness * sqrt scale;

    pickup pencircle scaled 1/12thick;

    penpos0 (thick, 0);
    penpos1 (thick, 0);
    penpos2 (thick, 0);
    penpos3 (thick, 0);

    x0 = x1;
    x2 = x3;
    1/2[x0,x2] = w/2;
    x2 - x0 = 4thick;

    top y0 = top y2 =  h;
    bot y1 = bot y3 = -d;

    filldraw stroke z0e -- z1e;
    filldraw stroke z2e -- z3e;
  endchar;
endfor;

charlist current_char - 4: current_char - 3: current_char - 2: current_char - 1: current_char:
         current_char - 5;

beginsymbol(5u# + 2side_bearing#, vcentre(delim_height#)); "wavy line";
  thick := rule_thickness;

  pickup pencircle scaled thick;

  x0 = x1 = x2 = x3 = w/2;
  1/2[y0,y1] = h;
  1/2[y2,y3] = -d;
  y2 - y1 = y1 - y0 = y3 - y2;

  draw (subpath (0.5,2.5) of
         (z0{dir (270-30)}
          .. {dir (270+30)}z1{dir (270+30)}
          .. {dir (270-30)}z2{dir (270-30)}
          .. {dir (270+30)}z3));
endchar;

extensible current_char: 0, 0, 0, current_char;

beginsymbol(8u# + 2side_bearing#, vcentre(delim_height#)); "double wavy line";
  thick := rule_thickness;

  pickup pencircle scaled thick;

  x0a = x1a = x2a = x3a = 1/3w;
  x0b = x1b = x2b = x3b = 2/3w;
  1/2[y0a,y1a] = 1/2[y0b,y1b] = h;
  1/2[y2a,y3a] = 1/2[y2b,y3b] = -d;

  y2a - y1a = y1a - y0a = y3a - y2a;
  y2b - y1b = y1b - y0b = y3b - y2b;

  draw (subpath (0.5,2.5) of
         (z0a{dir (270-30)}
          .. {dir (270+30)}z1a{dir (270+30)}
          .. {dir (270-30)}z2a{dir (270-30)}
          .. {dir (270+30)}z3a));
  draw (subpath (0.5,2.5) of
         (z0b{dir (270-30)}
          .. {dir (270+30)}z1b{dir (270+30)}
          .. {dir (270-30)}z2b{dir (270-30)}
          .. {dir (270+30)}z3b));
endchar;

extensible current_char: 0, 0, 0, current_char;

def draw_angle(suffix $)(expr shift, sign, thick) =
  pickup pencircle scaled (7/8thick);

  x0$ = x1$ = x2$ + sign * (w - 2side_bearing - 2abs shift - thick);

  x3$ = x2$ + sign * 3/8thick;

  top y1$ =  h;
  bot y0$ = -d;
  1/2[y0$,y1$] = y2$ = y3$;
  1/2[x0$,x2$] = w/2;

  draw (z0$ + shift * right) -- (z2$ + shift * right) -- (z1$ + shift * right) -- (z3$ + shift * right) -- cycle;
enddef;

for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "angle";
      draw_angle(a, 0, sign, 7/8rule_thickness * sqrt scale);
    endchar;
  endfor;
  charlist current_char - 4: current_char - 3: current_char - 2: current_char - 1: current_char;
endfor;

for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "angle bar";
      draw_angle(a, 0, sign, 7/8rule_thickness * sqrt scale);

      z3 = whatever[z0a,z2a];
      z4 = whatever[z1a,z2a];

      x3 = x4 = (1/(2*scale))[x0a,x2a];

      pickup pencircle scaled (11/25rule_thickness * sqrt scale);

      draw z3 -- z4;
    endchar;
  endfor;
  charlist current_char - 4: current_char - 3: current_char - 2: current_char - 1: current_char;
endfor;

for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 6)/2 * u# + 5/2rule_thickness# * sqrt scale + 2side_bearing#,
                vcentre(scale * delim_height#));
      "double angle";
      thick := 5/8rule_thickness * sqrt scale;
      draw_angle(a, -2thick, sign, thick);
      draw_angle(b,  2thick, sign, thick);
    endchar;
  endfor;
  charlist current_char - 4: current_char - 3: current_char - 2: current_char - 1: current_char;
endfor;

for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol(3scale * u# + side_bearing#, vcentre(scale * delim_height#)); "slash";
      thick := 5/4rule_thickness * sqrt (scale/2);

      pickup pencircle scaled thick;

      x1 - x0 = sign * (w - side_bearing - thick);

      top y1 =  h;
      bot y0 = -d;
      1/2[x0,x1] = w/2;

      draw z0 -- z1;
    endchar;
  endfor;
  charlist current_char - 4: current_char - 3: current_char - 2: current_char - 1: current_char;
endfor;

def draw_paren(expr sign, thick) =
  penpos0(1/2thick,  90 - sign * 40);
  penpos1(1/2thick, -90 + sign * 40);
  penpos2(4/3thick,  90 - sign * 90);

  x0 = x1 = x2 + sign * (w - 2side_bearing - thick);

  top y1l =  h;
  bot y0l = -d;
  1/2[y0,y1] = y2;
  1/2[x0l,x2l] = w/2;

  fill stroke z0e{3(x2e - x0e), y2e - y0e} .. z2e .. {3(x1e - x2e), y1e - y2e}z1e;

  penlabels(0,1,2);
enddef;

lparen_char = current_char + 1;
rparen_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol(2/3*(scale + 5.5) * u# + 2side_bearing#, vcentre(scale * delim_height#)); "parenthesis";
      draw_paren(sign, 9/20rule_thickness * sqrt (4*scale));
    endchar;
  endfor;
endfor;

% extensible parenthesis

for sign = 1, -1:
  beginsymbol(2/3*(6 + 5.5) * u# + 2side_bearing#, vcentre(6/2 * delim_height#)); "parenthesis -- top";
    thick := 9/20rule_thickness * sqrt 24;

    penpos1(1/2thick, -90 + sign * 40);
    penpos2(4/3thick, 90 - sign * 90);

    x1 = x2 + sign * (w - 2side_bearing - thick);

    top y1l = h + eps;
    y2 = -d - 1/2rule_thickness;
    1/2[x1l,x2l] = w/2;

    fill stroke z2e{up} .. {3(x1e - x2e), y1e - y2e}z1e;
  endchar;
endfor;

for sign = 1, -1:
  beginsymbol(2/3*(6 + 5.5) * u# + 2side_bearing#, vcentre(6/2 * delim_height#)); "parenthesis -- bot";
    thick := 9/20rule_thickness * sqrt 24;

    penpos0(1/2thick, 90 - sign * 40);
    penpos2(4/3thick, 90 - sign * 90);

    x0 = x2 + sign * (w - 2side_bearing - thick);

    y2 =  h + 1/2rule_thickness;
    bot y0l = -d - eps;
    1/2[x0l,x2l] = w/2;

    fill stroke z0e{3(x2e - x0e), y2e - y0e} .. {up}z2e;
  endchar;
endfor;

for sign = 1, -1:
  beginsymbol(2/3*(6 + 5.5) * u# + 2side_bearing#, vcentre(delim_height#)); "parenthesis -- module";
    thick := 9/20rule_thickness * sqrt 24;

    penpos1(1/2thick, 90 - sign * 40);
    penpos2(4/3thick, 90 - sign * 90);
    penpos3(4/3thick, 90 - sign * 90);

    x2 = x3 = x1 - sign * (w - 2side_bearing - thick);

    y2 =  h + 1/2rule_thickness;
    y3 = -d - 1/2rule_thickness;
    1/2[x1l,x2l] = w/2;

    fill stroke z2e -- z3e;
  endchar;
endfor;

extensible current_char:     current_char - 4, 0, current_char - 2, current_char;     %right parenthesis
extensible current_char - 1: current_char - 5, 0, current_char - 3, current_char - 1; %left parenthesis

charlist rparen_char: rparen_char + 1: rparen_char + 2: rparen_char + 3: rparen_char + 4: current_char;
charlist lparen_char: lparen_char + 1: lparen_char + 2: lparen_char + 3: lparen_char + 4: current_char - 1;

% curly braces

def draw_brace_tip(suffix $,@)(expr alpha,thick) =
  pickup pencircle scaled 1/12thick;

  penpos$ (1/2thick, alpha);
  penpos$'(1/2thick, alpha);
  penpos@ (thick, alpha);
  penpos@'(thick, alpha);

  beta := angle (5(x$l-x@l), y$-y@) - alpha;

  filldraw z$l{-dir (alpha + beta)} ... z@l --- z@'l -- z@'r
    --- z@r ... {dir (alpha + beta)}z$'r -- z$r -- cycle;
enddef;

def draw_brace(expr center, size, width, alpha, thick, top_size, mid_size, bot_size) =

  pickup pencircle scaled 1/12thick;

  penpos1 (1/2thick, alpha);
  penpos1'(1/2thick, alpha);
  penpos4 (1/2thick, alpha);
  penpos4'(1/2thick, alpha);
  penpos7 (1/2thick, alpha);
  penpos7'(1/2thick, alpha);
  penpos2 (thick, alpha);
  penpos2'(thick, alpha);
  penpos3 (thick, alpha);
  penpos3'(thick, alpha);
  penpos5 (thick, alpha);
  penpos5'(thick, alpha);
  penpos6 (thick, alpha);
  penpos6'(thick, alpha);

  z1 - z7 = (size - 1/6thick) * dir (alpha + 90);

  center - 1/2[z1l,z7l] = 1/2[z4r,z4'r] - center = width/2 * dir alpha;

  z2  = center + whatever * dir (alpha + 90);
  z3  = center + whatever * dir (alpha + 90);

  z3' = center + (mid_size/2 + 1/2rule_thickness) * dir (alpha + 90);
  z5' = center - (mid_size/2 + 1/2rule_thickness) * dir (alpha + 90);

  z2' = center + (size/2 - top_size - 1/2rule_thickness) * dir (alpha + 90);
  z6' = center - (size/2 - bot_size - 1/2rule_thickness) * dir (alpha + 90);

  1/2[z2,z6] = 1/2[z3,z5] = center;

  z2 - z3 = z5 - z6 = 5/24(size - 1/3thick) * dir (alpha + 90);

  z1 - z2 = z3 - z4;
  z7 - z6 = z5 - z4';

  z1 - z1' = z4 - z4' = z7' - z7 = 1/4thick * dir (alpha + 90);

  beta := angle (5 (z1l-z2l) dotprod dir alpha, (z1l-z2l) dotprod dir (alpha+90));

  if top_size > 0:
    filldraw z1r{-dir (alpha + beta)} ... z2r --- z2'r -- z2'l
      --- z2l ... {dir (alpha + beta)}z1'l -- z1l -- cycle;
    penlabels(1,2,2');
  elseif bot_size > 0:
    filldraw 
      z6'r --- z6r ... {dir (alpha - beta)}z7r
      -- z7l -- z7'l{-dir (alpha - beta)} ... z6l --- z6'l -- cycle;
    penlabels(6',6,7);
  elseif mid_size > 0:
    filldraw z3'r --- z3r{dir (alpha-90)} ... {dir alpha}z4r
      -- z4'r{-dir alpha} ... {dir (alpha-90)}z5r --- z5'r -- z5'l --- z5l{dir (alpha+90)}
      ... {dir alpha}1/2[z4l, z4'l]{-dir alpha}
      ... {dir (alpha+90)}z3l --- z3'l -- cycle;
    penlabels(3',3,4,5,5');
  else:
    filldraw z1r{-dir (alpha + beta)} ... z2r --- z3r{dir (alpha-90)} ... {dir alpha}z4r
      -- z4'r{-dir alpha} ... {dir (alpha-90)}z5r --- z6r ... {dir (alpha - beta)}z7r
      -- z7l -- z7'l{-dir (alpha - beta)} ... z6l --- z5l{dir (alpha+90)}
      ... {dir alpha}1/2[z4l, z4'l]{-dir alpha}
      ... {dir (alpha+90)}z3l --- z2l ... {dir (alpha + beta)}z1'l -- z1l -- cycle;
    penlabels(1,2,3,4,5,6,7);
  fi;

enddef;

lcurly_char = current_char + 1;
rcurly_char = current_char + 6;
for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol((scale + 10)/2 * u# + 2side_bearing#, vcentre(scale * delim_height#)); "curly brace";
      thick := 5/4rule_thickness * sqrt sqrt (scale/2);

      draw_brace((w/2, (h-d)/2), h+d, w - 2side_bearing, 90 + sign * 90, thick, 0, 0, 0)
    endchar;
  endfor;
endfor;

beginsymbol((6 + 10)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "curly brace -- top";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  draw_brace((w/2, h - 3delim_height), 6delim_height, w - 2side_bearing, 180, thick, 0, 0, h+d);
endchar;

beginsymbol((6 + 10)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "curly brace -- top";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  draw_brace((w/2, h - 3delim_height), 6delim_height, w - 2side_bearing,   0, thick, h+d, 0, 0);
endchar;

beginsymbol((6 + 10)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "curly brace -- bot";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  draw_brace((w/2, 3delim_height - d), 6delim_height, w - 2side_bearing, 180, thick, h+d, 0, 0)
endchar;

beginsymbol((6 + 10)/2 * u# + 2side_bearing#, vcentre(delim_height#)); "curly brace -- bot";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  draw_brace((w/2, 3delim_height - d), 6delim_height, w - 2side_bearing,   0, thick, 0, 0, h+d)
endchar;

for sign = 1, -1:
  beginsymbol((6 + 10)/2 * u# + 2side_bearing#, vcentre(2delim_height#)); "curly brace -- middle";
    thick := 5/4rule_thickness * sqrt sqrt (6/2);

    draw_brace((w/2, (h-d)/2), 6delim_height, w - 2side_bearing, 90 + sign * 90, thick, 0, h+d, 0);
  endchar;
endfor;

beginsymbol((6 + 10)/2 * u# + 2side_bearing#, vcentre(1/2delim_height#)); "curly brace -- module";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  pickup pencircle scaled 1/12thick;

  penpos2 (thick, 0);
  penpos3 (thick, 0);

  x2 = x3 = w/2;

  top y2 =  h + 1/2rule_thickness;
  bot y3 = -d - 1/2rule_thickness;

  filldraw stroke z2e -- z3e;
endchar;

extensible current_char - 6: current_char - 6, 0,                current_char - 4, current_char; %sharp left parenthesis
extensible current_char - 5: current_char - 5, 0,                current_char - 3, current_char; %sharp right parenthesis
extensible current_char - 4: current_char - 5, 0,                current_char - 4, current_char; %right moustache
extensible current_char - 3: current_char - 6, 0,                current_char - 3, current_char; %left moustache
extensible current_char - 2: current_char - 6, current_char - 2, current_char - 4, current_char; %left curly brace
extensible current_char - 1: current_char - 5, current_char - 1, current_char - 3, current_char; %right curly brace
extensible current_char:     0,                0,                0,                current_char; %vertical line

charlist rcurly_char: rcurly_char + 1: rcurly_char + 2: rcurly_char + 3: rcurly_char + 4: current_char - 1;
charlist lcurly_char: lcurly_char + 1: lcurly_char + 2: lcurly_char + 3: lcurly_char + 4: current_char - 2;

for sign = 1, -1:
  for scale = 2, 2.5, 3.3, 4.2, 5.1:
    beginsymbol(scale * delim_height#, vcentre((scale + 10)/2 * u# + 2side_bearing#));
      "horizontal curly brace";

      thick := 5/4rule_thickness * sqrt sqrt (scale/2);

      draw_brace((w/2, (h-d)/2), w, (h+d) - 2side_bearing, sign * 90, thick, 0, 0, 0)
    endchar;
  endfor;
endfor;

beginsymbol(delim_height#, vcentre((6 + 10)/2 * u# + 2side_bearing#)); "curly brace -- left";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  draw_brace((3delim_height, (h-d)/2), 6delim_height, (h+d) - 2side_bearing,  90, thick, w, 0, 0);
endchar;

beginsymbol(delim_height#, vcentre((6 + 10)/2 * u# + 2side_bearing#)); "curly brace -- left";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  draw_brace((3delim_height, (h-d)/2), 6delim_height, (h+d) - 2side_bearing, -90, thick, 0, 0, w);
endchar;

beginsymbol(delim_height#, vcentre((6 + 10)/2 * u# + 2side_bearing#)); "curly brace -- right";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  draw_brace((w - 3delim_height, (h-d)/2), 6delim_height, (h+d) - 2side_bearing,  90, thick, 0, 0, w);
endchar;

beginsymbol(delim_height#, vcentre((6 + 10)/2 * u# + 2side_bearing#)); "curly brace -- right";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  draw_brace((w - 3delim_height, (h-d)/2), 6delim_height, (h+d) - 2side_bearing, -90, thick, w, 0, 0);
endchar;

for sign = 1, -1:
  beginsymbol(2delim_height#, vcentre((6 + 10)/2 * u# + 2side_bearing#));
    "curly brace -- horizontal middle";

    thick := 5/4rule_thickness * sqrt sqrt (6/2);

    draw_brace((w/2, (h-d)/2), 6delim_height, (h+d) - 2side_bearing, sign * 90, thick, 0, w, 0);
  endchar;
endfor;

beginsymbol(u#, vcentre((6 + 10)/2 * u# + 2side_bearing#));
  "curly brace -- horizontal module";
  thick := 5/4rule_thickness * sqrt sqrt (6/2);

  pickup pencircle scaled 1/12thick;

  penpos1 (thick, 90);
  penpos2 (thick, 90);

  x1 = -u/2;
  x2 = w + u/2;
  y1 = y2 = (h-d)/2;

  filldraw stroke z1e -- z2e;
endchar;


% roots

def draw_root_top(expr scale, thick, vertical) =
  pickup pencircle scaled thick;

  top y0 = h;
  x0 = w;

  bot y1 = -d;

  if vertical:
    x1 = 6/9w;
    draw z0 -- (x1, y0) -- z1;
  else:
    x1 = 4/9w;
    draw z0 -- z1;
  fi;
enddef;

def draw_root_bot(expr scale, thick, vertical) =
  penpos2(3/2thick, 0);
  penpos3(thick, 0);

  x2l = 1/9w;
  y2  = 1/2[y0, y1];
  x3  = x1;
  bot y3 = -d;

  z4 = whatever[z0, z1] = z2r + whatever * (z2l - z3l);

  penpos5(1/2thick, angle (z3l - z2l));
  z5l = z2r + 5/2thick * dir (angle (z3l - z2l) - 90);

  z6 = whatever[z2l, z3l] = z5r + whatever * dir (angle (z3l - z2l) - 90);

  fill z5r -- z6 -- z3l -- z3 -- z4 -- z2r -- z5l -- cycle;
enddef;

root_char = current_char + 1;

for scale = 2, 2.5, 3.3, 4.2, 5.1:
  beginsymbol((2scale + 10) * u# + side_bearing#,
              sqrt (scale/2) * rule_thickness#,
              scale * delim_height# - sqrt (scale/2) * rule_thickness#);
    "root";

    draw_root_top(scale, sqrt (scale/2) * rule_thickness, false);
    draw_root_bot(scale, sqrt (scale/2) * rule_thickness, false);
    labels(0,1,2,3,4,5,6);

  endchar;
endfor;

beginsymbol((12 + 10) * u# + side_bearing#,
            sqrt (6/2) * rule_thickness#,
            delim_height# - sqrt (6/2) * rule_thickness#);
  "root -- top";

  thick := vround (sqrt (6/2) * rule_thickness# * hppp);

  draw_root_top(6, thick, true);
endchar;

beginsymbol((12 + 10) * u# + side_bearing#, 0, 3 * delim_height#);
  "root -- bottom";

  thick := vround (sqrt (6/2) * rule_thickness# * hppp);

  pickup pencircle scaled thick;

  x0 = x1 = 6/9w;
  bot y0 = d;
  bot y1 = -d;

  draw 1/2[z0, z1] -- z1;

  draw_root_bot(6, thick, true);
endchar;

beginsymbol((12 + 10) * u# + side_bearing#, vcentre(delim_height#));
  "root -- module";

  thick := vround (sqrt (6/2) * rule_thickness# * hppp);

  pickup pencircle scaled thick;

  x0 = x1 = 6/9w;
  y0 = h;
  y1 = -d;

  draw z0 -- z1;
endchar;

extensible current_char - 2: current_char - 2, 0, current_char - 1, current_char;

charlist root_char: root_char + 1: root_char + 2: root_char + 3: root_char + 4: current_char - 2;

% reserve space for accents
current_char := 212;

for arrow_dir = 90, 270:
  beginsymbol(8u# + 2side_bearing#, vcentre(delim_height#)); "arrow up/down";
    pickup rule_pen;

    pair foot, head;

    if arrow_dir = 90:
      head = (w/2, h);
      foot = (w/2, -d);
    else:
      head = (w/2, -d);
      foot = (w/2, h);
    fi;

    draw foot -- head;
    draw arrowhead(head, arrow_dir, arrow_spread);
  endchar;
endfor;

beginsymbol(8u# + 2side_bearing#, vcentre(delim_height#)); "arrow module";
  pickup rule_pen;

  z0 = (w/2,  h + 1/2rule_thickness);
  z1 = (w/2, -d - 1/2rule_thickness);

  draw z0 -- z1;
endchar;

extensible current_char-2: current_char-2, 0, current_char,   current_char;
extensible current_char-1: current_char,   0, current_char-1, current_char;
extensible current_char:   current_char-2, 0, current_char-1, current_char;

for arrow_dir = 90, 270:
  beginsymbol(8u# + 2side_bearing#, vcentre(delim_height#)); "double arrow up/down";
    pickup rule_pen;

    pair foot, head;

    if arrow_dir = 90:
      head = (w/2, h);
      foot = (w/2, -d);
    else:
      head = (w/2, -d);
      foot = (w/2, h);
    fi;

    z1 - z0 = z3 - z2 = equal_spread * dir (arrow_dir + 90);

    1/2[z0,z1] = foot - 1/2rule_thickness * dir arrow_dir;
    1/2[z2,z3] = head;

    draw z0 -- arrowhead_intersection(head, arrow_dir, 13/10arrow_spread, z0 -- z2);
    draw z1 -- arrowhead_intersection(head, arrow_dir, 13/10arrow_spread, z1 -- z3);

    draw arrowhead(head, arrow_dir, 13/10arrow_spread);
  endchar;
endfor;

beginsymbol(8u# + 2side_bearing#, vcentre(delim_height#)); "double arrow module";
  pickup rule_pen;

  z1 - z0 = z3 - z2 = equal_spread * right;

  1/2[z0,z1] = (w/2,  h + 1/2rule_thickness);
  1/2[z2,z3] = (w/2, -d - 1/2rule_thickness);

  draw z0 -- z2;
  draw z1 -- z3;
endchar;

extensible current_char-2: current_char-2, 0, current_char,   current_char;
extensible current_char-1: current_char,   0, current_char-1, current_char;
extensible current_char:   current_char-2, 0, current_char-1, current_char;


Zerion Mini Shell 1.0