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