summaryrefslogtreecommitdiff
path: root/fonts/utilities/mff-29/mfbrackets.mf
blob: 3a6093bcb156cf44a9b0b4ab27543ec6452de4d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Metafont programs for () [] <> {} in the style of the METAFONT logo
%  Damian Cugley, SEH <pdc@oxford.prg> Sun 2 Jul 1989
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

def brackpoints(expr left_p) =
    pair out;
    if left_p: 
	    w - x1 = w - x1' = x2 = x2' = x3 = leftstemloc;
	    out = left
    else:   x1 = x1' = w - x2 = w - x2' = w - x3 = leftstemloc ;
	    out = right
    fi;
    top y1 = top y2 = h + o; 
    y3 = 1/2[y1,y1'] = 1/2[y2,y2'] = barheight;
enddef;

def lbrack = brackpoints(true) enddef;
def rbrack = brackpoints(false) enddef;

def make_brackets(expr lcode, rcode, desc, u_width)(text t) =
    beginlogochar(lcode,u_width); "Left " & desc & " " & lcode;
      lbrack; t
    endchar;
    beginlogochar(rcode,u_width); "Right " & desc & " " & rcode;
      rbrack; t
    endchar;
enddef;

make_brackets("(",")","parenthesis",8,
    half_super(1,3,1'); labels(1,3,1')
);
make_brackets("[","]","bracket",8,
    draw z1 -- z2 -- z3 -- z2' -- z1'; labels(1,2,3,2',1')
);
make_brackets("<",">","angle bracket",12,
    draw z1 -- z3 -- z1'; labels(1,3,1')
);
make_brackets("{","}","brace",10,
    x4 = x4' = x5 = x5' = 1/2[x1,x2];
    y4 = 2barheight - y4' = 0.8[y3,y1]; 
    y5 = 2barheight - y5' = 0.2[y3,y1];
    draw z1{out} ... z4{down} ... {down}z5 ... {out}z3 &
	 z3{-out} ... z5'{down} ... {down}z4' ... z1'{-out};
    labels(1,4,5,3,5',4',1')
);