Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / mf / feta-braces.mf
blob6a095226a3b379f2df1c8cfee152071c668db558
1 % Feta (not the Font-En-Tja) music font -- Staff braces
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 %                Jan Nieuwenhuizen <janneke@gnu.org>
7 % LilyPond is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
12 % LilyPond is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 % GNU General Public License for more details.
17 % You should have received a copy of the GNU General Public License
18 % along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
21 % We have to reduce the pixel-per-point value to
22 % support large brace glyphs in case we are using MetaPost
23 % (which by default sets `hppp' to 49.80244, regardless of
24 % the used `mag' value)
26 if known miterlimit:
27         bpppix_ := 0.2;         % ten times larger than original
29         numeric mm, pt, dd, bp, cm, pc, cc, in;
31         mm * bpppix_ = 2.83464;
32         pt * bpppix_ = 0.99626;
33         dd * bpppix_ = 1.06601;
34         bp * bpppix_ = 1;
35         cm * bpppix_ = 28.34645;
36         pc * bpppix_ = 11.95517;
37         cc * bpppix_ = 12.79213;
38         in * bpppix_ = 72;
40         hppp := pt;
41         vppp := pt;
42 fi;
45 input feta-autometric;
46 input feta-macros;
48 staffsize# := 20 pt#;   %% arbitrary
50 input feta-params;
53 % We must let the design increase for each font to make sure that mftrace
54 % doesn't jack up the resolution too highly for the longer braces.
57 fet_beginfont ("feta-braces-" & char (97 + font_count),
58                (font_count + 1) * 20, "fetaBraces");
60 mode_setup;
63 save code, braces_per_font;
64 code := 64;
65 braces_per_font := 64;
67 def draw_brace (expr height_sharp, width_sharp, slt_sharp, brace_number) =
68         save pendir, height, width, thin, thick, slt, pat;
69         save penangle;
70         pair pendir;
71         path pat;
73         height# := height_sharp;
74         width# := width_sharp;
75         slt# := slt_sharp;
77         fet_beginchar ("brace number " & decimal (brace_number),
78                        "brace" & decimal (brace_number))
79                 set_char_box (width#, 0, height# / 2, height# / 2);
81                 define_pixels (height, width, slt);
82                 thin = 2 slt;
83                 thick = .5 width;
85                 z2 = .5 [z1, z3];
86                 y3l = y1 + height / 2;
87                 x3 = x1 + width;
88                 y1 = 0;
89                 x1 = -b;
90                 y0 = y1;
91                 x0 = x1 - 2/6 thin;
93                 pendir = unitvector (x3 - x1, y3l / 6 - y1);
94                 penangle = angle pendir - 90;
95                 penpos3 (thin, penangle);
96                 penpos2 (thick, angle (z3 - z1) - 90);
97                 penpos1 (2/3 thin, penangle);
99                 penlabels (1, 2, 3);
100                 labels (0);
102                 pat := z2r
103                        .. simple_serif (z3r, z3l, 90)
104                        .. z2l
105                        .. z1l{dir (angle (z1r - z1l) - 90)}
106                        .. z0{down}
107                        .. z1r{-dir (angle (z1l - z1r) + 90)}
108                        .. cycle;
109                 pat := subpath (0, 5) of pat
110                        -- subpath (6, 7) of pat
111                        .. cycle;
113                 fill pat;
114                 fill pat yscaled -1;
115         fet_endchar;
116 enddef;
119 save stafflinethickness;
120 save increment;
122 linethickness := 0.5 pt#;
123 increment := 0.5 pt#;
124 y := 10 pt#;
126 for i := 0 step 1 until font_count:
127         save number;
129         number := braces_per_font * i;
131         for j := 0 step 1 until (braces_per_font - 1):
132                 % message "l: "&decimal l;
133                 % note: define_pixels (x) multiplies x by hppp,
134                 % must never get bigger than infinity
135                 y := y + increment;
136                 if y > infinity / hppp:
137                         message "Resolution and/or magnification is too high";
138                         message "HPPP: "& decimal hppp &" Y: " & decimal y;
139                         errmessage "please report to <bug-lilypond@gnu.org>";
140                 fi;
142                 % x should be about one staff space, taking brace to have
143                 % default height of 3 staffs, this yields height / 3 / 4 = 12
144                 % but 15 looks better
145                 x := y / 15;
147                 increment := x / 10;
148                 linethickness :=  min (0.5 pt#, y / 150);
149                 if i = font_count:
150                         draw_brace (y, x, linethickness, number);
151                 fi;
153                 number := number + 1;
154         endfor;
155 endfor;
157 fet_endfont ("feta-braces");