]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-braces.mf
Add '-dcrop' option to ps and svg backends
[lilypond.git] / mf / feta-braces.mf
1 % Feta (not the Font-En-Tja) music font -- Staff braces
2 % This file is part of LilyPond, the GNU music typesetter.
3 %
4 % Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 %                Jan Nieuwenhuizen <janneke@gnu.org>
6 %
7 % The LilyPond font 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, or under the SIL Open Font License.
11 %
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.
16 %
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/>.
19
20 %
21 % We must let the design increase for each font to make sure that mftrace
22 % doesn't jack up the resolution too highly for the longer braces.
23 %
24
25 save code, braces_per_font;
26 code := 64;
27 braces_per_font := 64;
28
29 def draw_brace (expr height_sharp, width_sharp, slt_sharp, brace_number) =
30         save pendir, height, width, thin, thick, slt, pat;
31         save penangle;
32         pair pendir;
33         path pat;
34
35         height# := height_sharp;
36         width# := width_sharp;
37         slt# := slt_sharp;
38
39         fet_beginchar ("brace number " & decimal (brace_number),
40                        "brace" & decimal (brace_number))
41                 set_char_box (width#, 0, height# / 2, height# / 2);
42
43                 define_pixels (height, width, slt);
44                 thin = 2 slt;
45                 thick = .5 width;
46
47                 z2 = .5 [z1, z3];
48                 y3l = y1 + height / 2;
49                 x3 = x1 + width;
50                 y1 = 0;
51                 x1 = -b;
52                 y0 = y1;
53                 x0 = x1 - 2/6 thin;
54
55                 pendir = unitvector (x3 - x1, y3l / 8 - y1);
56                 penangle = angle pendir - 90;
57                 penpos3 (thin, penangle);
58                 penpos2 (thick, angle (z3 - z1) - 90);
59                 penpos1 (-2 * (x0 - x1), penangle);
60
61                 penlabels (1, 2, 3);
62                 labels (0);
63
64                 pat := z2r
65                        .. simple_serif (z3r, z3l, 90)
66                        .. z2l
67                        .. z1l{dir (angle (z1r - z1l) - 90)}
68                        .. z0{down}
69                        .. z1r{-dir (angle (z1l - z1r) + 90)}
70                        .. cycle;
71                 pat := subpath (0, 5) of pat
72                        -- subpath (6, 7) of pat
73                        .. cycle;
74
75                 fill pat;
76                 fill pat yscaled -1;
77         fet_endchar;
78 enddef;
79
80
81 save linethickness;
82 save increment;
83 save last_brace_number;
84 save min_width;
85 save max_width;
86 save min_thin;
87 save max_thin;
88
89 linethickness := 0.5 pt#;
90 increment := 0.5 pt#;
91 last_brace_number := braces_per_font * 9 - 1;
92 min_width := 2 pt#;
93 max_width := 20 pt#;
94 min_thin := 0.2 pt#;
95 max_thin := 1.25 pt#;
96 y := 10 pt#;
97
98 for i := 0 step 1 until font_count:
99         save number;
100
101         number := braces_per_font * i;
102
103         for j := 0 step 1 until (braces_per_font - 1):
104                 % message "l: "&decimal l;
105                 % note: define_pixels (x) multiplies x by hppp,
106                 % must never get bigger than infinity
107                 y := y + increment;
108                 if y > infinity / hppp:
109                         message "Resolution and/or magnification is too high";
110                         message "HPPP: "& decimal hppp &" Y: " & decimal y;
111                         errmessage "please report to <bug-lilypond@gnu.org>";
112                 fi;
113
114                 x := (y / last_brace_number) [min_width, max_width];
115
116                 increment := x / 10;
117                 linethickness := (y / last_brace_number) [min_thin, max_thin];
118                 if i = font_count:
119                         draw_brace (y, x, linethickness, number);
120                 fi;
121
122                 number := number + 1;
123         endfor;
124 endfor;