]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-pedals.mf
Add '-dcrop' option to ps and svg backends
[lilypond.git] / mf / feta-pedals.mf
1 % Feta (not the Font-En-Tja) music font -- piano pedal markings
2 % This file is part of LilyPond, the GNU music typesetter.
3 %
4 % Copyright (C) 2000--2015 Jan Nieuwenhuizen <janneke@gnu.org>
5 %
6 % Voor Cup
7 %
8 % The LilyPond font is free software: you can redistribute it and/or modify
9 % it under the terms of the GNU General Public License as published by
10 % the Free Software Foundation, either version 3 of the License, or
11 % (at your option) any later version, or under the SIL Open Font License.
12 %
13 % LilyPond is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 % GNU General Public License for more details.
17 %
18 % You should have received a copy of the GNU General Public License
19 % along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
20
21 % Kerning
22 %
23 % Pe = -0.034 pedalh == -0.07 staff-space
24 % ed = -0.27 pedalh == -0.53 staff-space
25
26
27 fet_begingroup ("pedal");
28
29 pedalpha = 40;
30 pedbeta = 25;
31
32 penh# = 0.7 linethickness#;
33 penw# = 2 penh# + 0.14 staff_space#;
34 define_pixels (penh, penw);
35
36 pedalh# = 2 staff_space#;
37 pedalbh# = 4/7 pedalh#;
38 define_pixels (pedalh, pedalbh);
39
40
41 fet_beginchar ("Pedal asterisk", "*");
42         save bulb, p, radius, thin, inner_r;
43         path pat;
44
45         set_char_box (0, 7/9 pedalh#, 0, 7/9 pedalh#);
46
47         z0 = (1/2 w, h - 1/2 w);
48
49         thin = 0.8 linethickness;
50
51         bulb + 2 radius = w;
52         0.9 thin + bulb = (radius * pi * 2) / 8;
53
54         pickup pencircle scaled penh;
55
56         penpos1 (bulb, 180);
57         penpos2 (bulb, 0);
58         penpos3 (thin, 0);
59
60         z1 = z0 + (0, radius);
61         z2 = z1;
62
63         inner_r = .45 radius;
64
65         z4l = z0 + inner_r * dir (90 + 360/16);
66         z4r = z0 + inner_r * dir (90 - 360/16);
67
68         z4 = .5 [z4l, z4r];
69         z3 = .75 [z1, z4];
70
71         penlabels (0, 1, 2, 3, 4);
72
73         pat := z3r{up}
74                .. z1l{up}
75                .. z2l{down}
76                .. z3l{down}
77                .. z4l{dir (180 + 360/16)};
78         for i = 1 upto 7:
79                 pat := pat
80                        .. ((z3r{up}
81                            .. z1l{up}
82                            .. z2l{down}
83                            .. z3l{down}
84                            .. z4l{dir (180 + 360/16)})
85                                 rotatedaround (z0, 360/8 i));
86         endfor;
87
88         pat := pat
89                .. cycle;
90         fill pat;
91
92         pickup pencircle scaled (7/8 inner_r);
93
94         undrawdot z0;
95 fet_endchar;
96
97
98 %% ugh. rounded corners!
99
100 fet_beginchar ("Pedal dash", "M");
101         save dash_thickness;
102
103         dash_thickness# := penw#;
104         define_whole_vertical_blacker_pixels (dash_thickness);
105
106         set_char_box (0, 3 penw#, 0, pedalbh#);
107
108         penpos1 (dash_thickness, 60);
109         penpos2 (dash_thickness, 60);
110
111         z1l = (0, vround (2/3 h - 1/2 penw));
112         z2r = (w, vround (y1l + 1.2 penw));
113
114         penlabels (1, 2, 3);
115
116         penstroke z1e{dir 40}
117                   ..tension 1.2.. z2e{dir 40};
118 fet_endchar;
119
120
121 fet_beginchar ("Pedal dot", ".");
122         set_char_box (0, penw#, 0, penw#);
123
124         pickup pencircle scaled penw;
125
126         drawdot (hround (1/2 penw), vround (1/2 penw));
127 fet_endchar;
128
129
130 def draw_pedal_P (expr show_labels) =
131 begingroup;
132         clearxy;
133
134         penpos1 (hround penh, 0);
135         penpos2 (penw, 55);
136         penpos3 (penw, pedalpha);
137         penpos4 (1.2 penh, -pedalpha);
138         penpos5 (penh, -pedalpha);
139         penpos6 (penh, 180 - pedalpha);
140         penpos7 (penh, 180 - pedalpha);
141         penpos8 (penh, 90);
142         penpos9 (4/3 penw, 50);
143         penpos10 (1.4 penw, 50);
144         penpos11 (penh, 90 + pedalpha);
145
146         z1r = (hround 0.6 w, h);
147         x2l = hround (x1l - penw) + xpart feta_offset;
148         y2 = vround (0.7 h) + ypart feta_offset;
149         x3r = hround (x2l + 2 penw);
150         y3r = 0.4 h;
151         z4l = z5r + 1/4 (z3r - z5r);
152         x5 = 1/4 w;
153         y5r = 0;
154         z6 = z5;
155         z7l = z6r + 1/3 (z8r - z6r);
156         z8r = z5r + 3/5 (z3r - z5r);
157         x9l = x10l - penh;
158         y9l = 1/4 penh;
159         x10l = w - tand (90 - pedalpha) * y11l;
160         y10l = 1/4 penh;
161         x11l = w;
162         y11 = 1/5 h;
163
164         % don't stick out at the top
165         z1' = round (0.9 [z2, z1]) + (xpart feta_offset, 0);
166         penpos1' (penh, 0);
167
168         % shift start point of pen stroke to avoid overlapping contours
169         z8'l = z8l;
170         y8'r = y8r;
171         z8'r = z8l + whatever * (z3r - z8l);
172
173         penpos12 (hround penh, 0);
174         penpos13 (penw, -90 - pedbeta);
175         penpos14 (vround penh, 90);
176         penpos15 (penw, -90 + pedbeta);
177         penpos16 (penh, 180 + pedbeta);
178
179         z12r = (hround (5/9 x1 + 1/2 hround penh), y2);
180         z13l = (1/2 x12r, y15r);
181         z14r = z1r;
182         z15l = (1/2 [x16, w], y2l + 0.5 penw);
183         x16 = 1/4 [x1, w];
184         y16r = y2r;
185
186         % We now do a correction to `center' the stem horizontally.  While
187         % this is not the most elegant solution, it is definitely the
188         % easiest...
189
190         save horz_corr;
191         horz_corr = 1/5 [x12, x16] - x2l;
192         x2 := x2 + horz_corr;
193         x2l := x2l + horz_corr;
194         x2r := x2r + horz_corr;
195
196         penstroke z1'e
197                   ..tension 2.5.. z2e
198                   ..tension 1.5.. z3e
199                   ..tension 2.5.. {dir (225)}z4e;
200
201         soft_end_penstroke z8'e{right}
202                            ..tension 1.5.. z9e{dir (-pedalpha)}
203                            .. z10e
204                            ..tension 2.5.. z11e;
205
206         fill z4r{dir (225)}
207              ..tension 1.5.. z5r{left}
208              .. z6r
209              ..tension 1.5.. z7r
210              ..tension 1.5.. z8r{right}
211              -- cycle;
212
213         soft_penstroke z12e{down}
214                        ..tension 1.1.. z13e{dir (180 - pedbeta)}
215                        ..tension 1.1.. z14e{right}
216                        ..tension 1.1.. z15e{dir (180 + pedbeta)}
217                        ..tension 1.1.. z16e{dir (90 + pedbeta)};
218
219         if show_labels = 1:
220                 penlabels (range 1 thru 16);
221                 penlabels (1', 8');
222         fi;
223 endgroup;
224 enddef;
225
226
227 def draw_pedal_d (expr show_labels) =
228 begingroup;
229         clearxy;
230
231         penpos1 (vround penh, -10 - 90);
232         penpos2 (hround penw, 190);
233         penpos3 (vround (2 penh), 90);
234         penpos4 (hround (3/4 penw), 0);
235         penpos5 (penh, -70);
236
237         x1r = 0;
238         y1l = h;
239         z2 = (w - 1/2 hround penw, 1/2 pedalbh + penh);
240         z4l = (hround (1/3 w), 1/2 pedalbh);
241         z5l = (2/3 w, pedalbh);
242         z3l = (hround x5l, 0);
243
244         if show_labels = 1:
245                 penlabels (1, 2, 3, 4, 5);
246         fi;
247
248         soft_start_penstroke z1e{dir (-10)}
249                              ..tension 1.1.. z2e{dir (-90 + 10)}
250                              ..tension 1.1.. z3e{left}
251                              ..tension 1.1.. z4e{up}
252                              ..tension 1.1.. z5e{dir (-70 + 90)};
253 endgroup;
254 enddef;
255
256
257 def draw_pedal_e (expr show_labels) =
258 begingroup;
259         clearxy;
260
261         penpos1 (penh, pedalpha - 90);
262         penpos2 (penh, pedalpha - 90);
263         penpos3 (3/5 penw, pedalpha);
264         penpos4 (1.2 penh, 90 + pedalpha);
265         penpos5 (2/3 penw, 180);
266         penpos6 (penw, 180 + pedalpha);
267         penpos7 (2/3 penw, -90 - 20);
268         penpos8 (penh, pedalpha - 90);
269
270         z1l = (0, 1/5 pedalh);
271         % this helps to make the path go through z2 at low resolutions
272         z2 = round (z1 + dir pedalpha * penw) + feta_offset;
273         z3 = (3/5 w, 8/9 h);
274         z4 = (2/9 w,  y3);
275         x4r := hround x4r;
276         x5r = 0;
277         y5 = y2;
278         x6 = 3/8 w;
279         y6r = 1/2 penh;
280         z7l = (x6l + penh, y6l);
281         x8r = w;
282         y8 = 1/5 pedalh;
283
284         soft_penstroke z1e
285                        -- z2e{z2 - z1}
286                        ..tension 1.1.. z3e
287                        ..tension 1.05.. z4e
288                        ..tension 1.1.. z5e
289                        ..tension 1.5.. z6e{dir - pedalpha}
290                        ..tension 1.1.. z7e
291                        ..tension 2.5.. z8e;
292
293         if show_labels = 1:
294                 penlabels (range 1 thru 8);
295         fi;
296 endgroup;
297 enddef;
298
299
300 fet_beginchar ("Pedal P", "P");
301         set_char_box (0, 5/6 pedalh#, 0, pedalh#);
302
303         draw_pedal_P (1);
304 fet_endchar;
305
306
307 fet_beginchar ("Pedal d", "d");
308         set_char_box (0, 2/3 pedalh#, 0, 7/8 pedalh#);
309
310         draw_pedal_d (1);
311 fet_endchar;
312
313
314 fet_beginchar ("Pedal e", "e");
315         set_char_box (0, 2/5 pedalh#, 0, pedalbh#);
316
317         draw_pedal_e (1);
318 fet_endchar;
319
320
321 fet_beginchar ("Pedal Ped", "Ped");
322         P_width# = 5/6 pedalh#;
323         e_width# = 2/5 pedalh#;
324         d_width# = 2/3 pedalh#;
325         define_pixels (P_width, e_width, d_width);
326
327         e_height = pedalbh;
328         d_height = 7/8 pedalh;
329
330         % Pe = -0.034 pedalh == -0.07 staff-space
331         % ed = -0.27 pedalh == -0.53 staff-space
332         Pe_kern# = -0.034 pedalh#;
333         ed_kern# = -0.27 pedalh#;
334         define_pixels (Pe_kern, ed_kern);
335
336         w := hround d_width;
337         h := vround d_height;
338         draw_pedal_d (0);
339         currentpicture := currentpicture
340                             shifted (hround (e_width + ed_kern), 0);
341
342         w := hround e_width;
343         h := vround e_height;
344         draw_pedal_e (0);
345         currentpicture := currentpicture
346                             shifted (hround (P_width + Pe_kern), 0);
347
348         w := hround P_width;
349         h := vround pedalh;
350         draw_pedal_P (0);
351
352         set_char_box (0, P_width# + Pe_kern# + e_width# + ed_kern# + d_width#,
353                       0, pedalh#);
354 fet_endchar;
355
356
357 fet_endgroup ("pedal");