]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-beugel.mf
* The grand 2005-2006 replace.
[lilypond.git] / mf / feta-beugel.mf
1 %
2 % feta-beugel.mf -- Staff braces
3 %
4 % source file of the Feta (not an acronym for Font-En-Tja)
5 % pretty-but-neat music font
6 %
7 % (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 %                Jan Nieuwenhuizen <janneke@gnu.org>
9
10 input feta-autometric;
11 input feta-macros;
12
13 staffsize# := 20 pt#;   %% arbitrary
14
15 input feta-params;
16
17 %
18 % We must let the design increase for each font to make sure that mftrace
19 % doesn't jack up the resolution too highly for the longer braces.
20 %
21
22 fet_beginfont ("feta-braces-" & char (97 + font_count),
23                (font_count + 1) * 20, "fetaBraces");
24
25 mode_setup;
26
27
28 save code, braces_per_font;
29 code := 64;
30 braces_per_font := 64;
31
32 def draw_brace (expr height_sharp, width_sharp, slt_sharp, brace_number) =
33         save pendir, height, width, thin, thick, slt, pat;
34         save penangle;
35         pair pendir;
36         path pat;
37
38         height# := height_sharp;
39         width# := width_sharp;
40         slt# := slt_sharp;
41
42         fet_beginchar ("brace number " & decimal (brace_number),
43                        "brace" & decimal (brace_number))
44                 set_char_box (width#, 0, height# / 2, height# / 2);
45
46                 define_pixels (height, width, slt);
47                 thin = 2 slt;
48                 thick = .5 width;
49         
50                 z2 = .5 [z1, z3];
51                 y3l = y1 + height / 2;
52                 x3 = x1 + width;
53                 y1 = 0;
54                 x1 = -b;
55                 y0 = y1;
56                 x0 = x1 - 2/6 thin;
57
58                 pendir = unitvector (x3 - x1, y3l / 6 - y1);
59                 penangle = angle pendir - 90;
60                 penpos3 (thin, penangle);
61                 penpos2 (thick, angle (z3 - z1) - 90);
62                 penpos1 (2/3 thin, penangle);
63         
64                 penlabels (1, 2, 3);
65                 labels (0);
66
67                 pat := z2r
68                        .. simple_serif (z3r, z3l, 90)
69                        .. z2l
70                        .. z1l{dir (angle (z1r - z1l) - 90)}
71                        .. z0{down}
72                        .. z1r{-dir (angle (z1l - z1r) + 90)}
73                        .. cycle;
74                 pat := subpath (0, 5) of pat
75                        -- subpath (6, 7) of pat
76                        .. cycle;
77
78                 fill pat;
79                 fill pat yscaled -1;
80         fet_endchar;
81 enddef;
82
83
84 save stafflinethickness;
85 save increment;
86
87 linethickness := 0.5 pt#;
88 increment := 0.5 pt#;
89 y := 10 pt#;
90
91 for i := 0 step 1 until font_count:
92         save number;
93
94         number := braces_per_font * i;
95
96         for j := 0 step 1 until (braces_per_font - 1):
97                 % message "l: "&decimal l;
98                 % note: define_pixels (x) multiplies x by hppp,
99                 % must never get bigger than infinity
100                 y := y + increment;
101                 if y > infinity / hppp:
102                         message "Resolution and/or magnification is too high";
103                         message "HPP: "& decimal hpp &" Y: " & y;
104                         error "please report to <bug-lilypond@gnu.org>";
105                 fi;
106
107                 % x should be about one staff space, taking brace to have
108                 % default height of 3 staffs, this yields height / 3 / 4 = 12
109                 % but 15 looks better
110                 x := y / 15;
111
112                 increment := x / 10;
113                 linethickness :=  min (0.5 pt#, y / 150);
114                 if i = font_count:
115                         draw_brace (y, x, linethickness, number);
116                 fi;
117
118                 number := number + 1;
119         endfor;
120 endfor;
121
122 fet_endfont ("feta-braces");