Nitpick: ly:spanner-bound grob name slur -> spanner.
[lilypond.git] / mf / feta-beugel.mf
blobc61f756d38273c14a0300065c38c005dc6282dc8
2 % feta-beugel.mf -- Staff braces
4 % source file of the Feta (not an acronym for Font-En-Tja)
5 % pretty-but-neat music font
7 % (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 %                Jan Nieuwenhuizen <janneke@gnu.org>
11 % We have to reduce the pixel-per-point value to
12 % support large brace glyphs in case we are using MetaPost
13 % (which by default sets `hppp' to 49.80244, regardless of
14 % the used `mag' value)
16 if known miterlimit:
17         bpppix_ := 0.2;         % ten times larger than original
19         numeric mm, pt, dd, bp, cm, pc, cc, in;
21         mm * bpppix_ = 2.83464;
22         pt * bpppix_ = 0.99626;
23         dd * bpppix_ = 1.06601;
24         bp * bpppix_ = 1;
25         cm * bpppix_ = 28.34645;
26         pc * bpppix_ = 11.95517;
27         cc * bpppix_ = 12.79213;
28         in * bpppix_ = 72;
30         hppp := pt;
31         vppp := pt;
32 fi;
35 input feta-autometric;
36 input feta-macros;
38 staffsize# := 20 pt#;   %% arbitrary
40 input feta-params;
43 % We must let the design increase for each font to make sure that mftrace
44 % doesn't jack up the resolution too highly for the longer braces.
47 fet_beginfont ("feta-braces-" & char (97 + font_count),
48                (font_count + 1) * 20, "fetaBraces");
50 mode_setup;
53 save code, braces_per_font;
54 code := 64;
55 braces_per_font := 64;
57 def draw_brace (expr height_sharp, width_sharp, slt_sharp, brace_number) =
58         save pendir, height, width, thin, thick, slt, pat;
59         save penangle;
60         pair pendir;
61         path pat;
63         height# := height_sharp;
64         width# := width_sharp;
65         slt# := slt_sharp;
67         fet_beginchar ("brace number " & decimal (brace_number),
68                        "brace" & decimal (brace_number))
69                 set_char_box (width#, 0, height# / 2, height# / 2);
71                 define_pixels (height, width, slt);
72                 thin = 2 slt;
73                 thick = .5 width;
74         
75                 z2 = .5 [z1, z3];
76                 y3l = y1 + height / 2;
77                 x3 = x1 + width;
78                 y1 = 0;
79                 x1 = -b;
80                 y0 = y1;
81                 x0 = x1 - 2/6 thin;
83                 pendir = unitvector (x3 - x1, y3l / 6 - y1);
84                 penangle = angle pendir - 90;
85                 penpos3 (thin, penangle);
86                 penpos2 (thick, angle (z3 - z1) - 90);
87                 penpos1 (2/3 thin, penangle);
88         
89                 penlabels (1, 2, 3);
90                 labels (0);
92                 pat := z2r
93                        .. simple_serif (z3r, z3l, 90)
94                        .. z2l
95                        .. z1l{dir (angle (z1r - z1l) - 90)}
96                        .. z0{down}
97                        .. z1r{-dir (angle (z1l - z1r) + 90)}
98                        .. cycle;
99                 pat := subpath (0, 5) of pat
100                        -- subpath (6, 7) of pat
101                        .. cycle;
103                 fill pat;
104                 fill pat yscaled -1;
105         fet_endchar;
106 enddef;
109 save stafflinethickness;
110 save increment;
112 linethickness := 0.5 pt#;
113 increment := 0.5 pt#;
114 y := 10 pt#;
116 for i := 0 step 1 until font_count:
117         save number;
119         number := braces_per_font * i;
121         for j := 0 step 1 until (braces_per_font - 1):
122                 % message "l: "&decimal l;
123                 % note: define_pixels (x) multiplies x by hppp,
124                 % must never get bigger than infinity
125                 y := y + increment;
126                 if y > infinity / hppp:
127                         message "Resolution and/or magnification is too high";
128                         message "HPPP: "& decimal hppp &" Y: " & decimal y;
129                         errmessage "please report to <bug-lilypond@gnu.org>";
130                 fi;
132                 % x should be about one staff space, taking brace to have
133                 % default height of 3 staffs, this yields height / 3 / 4 = 12
134                 % but 15 looks better
135                 x := y / 15;
137                 increment := x / 10;
138                 linethickness :=  min (0.5 pt#, y / 150);
139                 if i = font_count:
140                         draw_brace (y, x, linethickness, number);
141                 fi;
143                 number := number + 1;
144         endfor;
145 endfor;
147 fet_endfont ("feta-braces");