% font parameters

% abcdefghijklmnopqrstuvwxy          used
%         zABCDEFGHIJKLMNOPQRSTUVWXYZ    available

mode_setup;


def flipy(expr x) = 
    begingroup save T; transform T;
    T  = identity xscaled -1 shifted (2x, 0);
    T endgroup enddef;

height# := 8pt#;
penwidth# := .5pt#;

hooklength# := 2pt#;
margin# := 1pt#;

define_corrected_pixels(penwidth);
define_pixels(height, hooklength, margin);

picture p;

beginchar("8", 2margin# + penwidth# + hooklength#, height#, 0);
pickup pencircle scaled penwidth;
bot z1 = (margin, 0);
top z2 = (margin, height);
z3 = z2 + (hooklength, -hooklength);
draw z1 -- z2;
draw z2 {down} .. {right} z3;
penlabels(1,2,3);
p := currentpicture;
endchar;


beginchar("9", 2margin# + penwidth# + hooklength#, height#, 0);
numeric u;
u = (2margin + penwidth + hooklength)/2;
currentpicture := p transformed flipy(u);
endchar;

% circle, box, diamond    (l)

pen_width# := 1pt#;
sq_width# := 8pt#;
h_width# := sq_width / 2;
margin# := 1pt#;
bottom# := -1pt#;

define_pixels(sq_width, h_width, margin, bottom);
define_corrected_pixels(pen_width);


beginchar("0", sq_width# + 2margin#, sq_width#-bottom#, -bottom#);
% pickup pensquare scaled pen_width;
pickup pencircle scaled pen_width;
bot lft z1 = (margin, bottom);    % 4  3
bot rt z2 = (margin + sq_width, bottom);% 1  2
top rt z3 = (margin + sq_width, sq_width + bottom);
top lft z4 = (margin, sq_width + bottom);

draw z1 -- z2 -- z3 -- z4 -- z1;
penlabels(1,2,3,4);
endchar;

beginchar("1", sq_width#+ 2margin#, sq_width#-bottom#, -bottom#);
%pen p;
%p = pencircle;
%pickup p scaled pen_width;
pickup pencircle scaled pen_width;
bot z1 = (margin + sq_width/2, bottom);    %    3
top z3 = bot z1 + sq_width * up;    % 4  2
lft z4 = (margin, sq_width/2 + bottom );  %    1
rt z2 = lft z4 + sq_width * right;
draw z1 -- z2 -- z3 -- z4 -- z1;
penlabels(1,2,3,4);
endchar;


beginchar("2", sq_width#+ 2margin#, sq_width#-bottom#, -bottom#);
pickup pencircle scaled pen_width;
bot z1 = (margin + sq_width/2, bottom);    %    3
top z3 = bot z1 + sq_width * up;    % 4  2
lft z4 = (margin, sq_width/2 + bottom );  %    1
rt z2 = lft z4 + sq_width * right;
draw z1{right} .. z2{up} .. z3{left} ..  z4{down} .. cycle;
penlabels(1,2,3,4);
endchar;


end
