]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-flags.mf
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / mf / feta-flags.mf
1 % Feta (not the Font-En-Tja) music font -- draw flags
2 % This file is part of LilyPond, the GNU music typesetter.
3 %
4 % Copyright (C) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 %
6 % LilyPond is free software: you can redistribute it and/or modify
7 % it under the terms of the GNU General Public License as published by
8 % the Free Software Foundation, either version 3 of the License, or
9 % (at your option) any later version.
10 %
11 % LilyPond is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 % GNU General Public License for more details.
15 %
16 % You should have received a copy of the GNU General Public License
17 % along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18
19 fet_begingroup ("flags");
20
21 save outer_path;
22 path outer_path;
23
24 %
25 % Flags pointing down overlap with the notehead (in x-direction), so
26 % the down-flag can be bigger.
27 %
28
29 upflag_width# = .65 black_notehead_width# + stemthickness# / 2;
30 downflag_width# = .833 black_notehead_width# + stemthickness# / 2;
31
32 right_upflag_space# = .0 upflag_width#;
33 right_downflag_space# = .0 downflag_width#;
34
35 %
36 % Flags pointing down cannot overlap with the notehead in y-direction,
37 % so they have less slant.
38 %
39 % Because of optical illusion, the utmost flag (bottom for
40 % down-pointing, top for up-pointing) should be smaller than the other
41 % flags.  Adobe Sonata doesn't do this correctly.  (Instead they have
42 % an extension flag, which looks less elegant.)
43 %
44
45 save hip_thickness, foot_thickness;
46
47 hip_thickness# = 1.0 linethickness# + 0.069 staff_space#;
48 foot_thickness# = 1.2055 linethickness# + 0.06 staff_space#;
49
50 define_pixels (hip_thickness, foot_thickness);
51
52 %
53 % Inspired by Adobe Sonata and [Wanske].
54 % For example, see POSTSCRIPT Language -- program design,
55 % page 119, and [Wanske], p 41, 42.
56 %
57
58 def draw_flag (expr center, flare, dims, hip_depth, foot_wid,
59                hip_thickness, foot_thickness, show_labels) =
60         save c;
61
62         clearxy;
63
64         c = 0.7;
65
66         penpos1 (flare, 90);
67         penpos2 (whatever, 0);
68
69         x2r - x2l = hround (hip_thickness);
70
71         penpos3 (foot_thickness, -20.0);
72
73         z1r = center;
74         z2r = center + (xpart (dims), -ypart (dims) * hip_depth);
75         z3r = center + (xpart (dims) * foot_wid, -ypart (dims));
76
77         x2r := hround x2r;
78         y2r := vround y2r;
79
80         outer_path := z3r{curl c}
81                       .. z2r{up}
82                       .. {up}z1r;
83
84         if show_labels = 1:
85                 penlabels (1, 2, 3);
86         fi;
87
88         fill z1l{curl 0}
89              ..tension 1.1.. z2l{down}
90              .. {curl c}simple_serif (z3l, z3r, 80)
91              & outer_path
92              & z1r
93              -- cycle;
94 enddef;
95
96 %
97 % TODO: calculate intersectpoint (see TeX book, p. 137)
98 % TODO: calculate incision_depth
99 %
100
101 def add_flag (expr yoff, flare, hip_wid_multiplier, hip_dep_multiplier,
102               intersectpoint, hip_thickness, foot_thickness) =
103 begingroup
104         save prev_center, prev_xextreme, prev_yextreme;
105         save rel_foot, ip, center, incision_depth;
106         save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
107         save hip_dep_ratio, foot_wid_ratio;
108         pair prev_center, center, foot, prev_xextreme, prev_yextreme;
109         pair ip, rel_foot;
110
111         incision_depth = 1.013;
112         prev_center = point 2 of outer_path;
113         prev_xextreme = point 1 of outer_path;
114         prev_yextreme = point 0 of outer_path;
115         prev_hipwid = xpart (prev_xextreme - prev_center);
116         prev_footdep = -ypart (prev_yextreme - prev_center);
117         prev_hipdep = -ypart (prev_xextreme - prev_center);
118         ip = point intersectpoint of outer_path;
119
120         wid = prev_hipwid * hip_wid_multiplier;
121         hip_dep = prev_hipdep * hip_dep_multiplier;
122
123         center = prev_center + (0, yoff);
124         rel_foot = incision_depth [(wid, hip_dep), ip - center];
125         dep = -ypart (rel_foot);
126         foot_wid_ratio = xpart (rel_foot) / wid;
127         hip_dep_ratio = hip_dep / dep;
128
129         draw_flag (center, flare, (wid, dep),
130                    hip_dep_ratio, foot_wid_ratio,
131                    hip_thickness, foot_thickness, 0);
132 endgroup
133 enddef;
134
135
136 fet_beginchar ("8th Flag (up)", "u3");
137         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
138
139         flare = staff_space;
140         hip_depth_ratio = .72;
141         foot_width_ratio = .8;
142         hip_width# = upflag_width# - hip_thickness# / 2;
143         foot_depth# = 3 staff_space# - blot_diameter# / 2;
144         define_pixels (hip_width, foot_depth);
145
146         set_char_box (0,
147                       hip_width# + stemthickness# / 2 + right_upflag_space#,
148                       foot_depth# + foot_thickness# / 2, stemthickness# / 2);
149
150         draw_flag ((0,0), flare, (hip_width, foot_depth),
151                    hip_depth_ratio, foot_width_ratio,
152                    hip_thickness, foot_thickness, 1);
153
154         draw_square_block ((-0.5 stemthickness_rounded, -staff_space_rounded),
155                            (0, 0));
156 fet_endchar;
157
158
159 fet_beginchar ("16th Flag (up)", "u4");
160         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
161         save flagspace, total_depth, flag_count;
162
163         total_depth# = 3.5 staff_space# - blot_diameter# / 2;
164         flag_count = 2;
165         flare = .85 staff_space;
166         flagspace# = .85 staff_space#;
167         hip_depth_ratio = .72;
168         hip_width# = upflag_width# - hip_thickness# / 2;
169         flagspace# + foot_depth# = total_depth#;
170         foot_width_ratio = .8;
171         define_pixels (hip_width, foot_depth);
172         define_whole_vertical_pixels (flagspace);
173
174         set_char_box (0,
175                       hip_width# + stemthickness# / 2 + right_upflag_space#,
176                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
177
178         draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
179                    hip_depth_ratio, foot_width_ratio,
180                    hip_thickness, foot_thickness, 1);
181
182         add_flag (flagspace, flare, .97, 1.00, 1.25,
183                   hip_thickness, foot_thickness);
184
185         draw_square_block ((-0.5 stemthickness_rounded, 0),
186                            (0, -2 staff_space_rounded));
187 fet_endchar;
188
189
190 fet_beginchar ("32nd Flag (up)", "u5");
191         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
192         save flagspace, total_depth, flag_count;
193
194         flag_count = 3;
195         total_depth# = 4.25 staff_space#;
196         flare = .85 staff_space;
197         flagspace# = .87 staff_space#;
198         hip_depth_ratio = .72;
199         hip_width# = upflag_width# - hip_thickness# / 2;
200         foot_width_ratio = .8;
201
202         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
203
204         define_pixels (hip_width, foot_depth);
205         define_whole_vertical_pixels (flagspace);
206
207         set_char_box (0, hip_width# + right_upflag_space#,
208                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
209
210         draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
211                    hip_depth_ratio, foot_width_ratio,
212                    hip_thickness, foot_thickness, 1);
213
214         add_flag (flagspace, flare, .97, 1.00, 1.25,
215                   hip_thickness, foot_thickness);
216         add_flag (flagspace, flare, .95, 1.05, 1.25,
217                   hip_thickness, foot_thickness);
218
219         draw_square_block ((-0.5 stemthickness_rounded, 0),
220                            (0, -3 staff_space_rounded));
221 fet_endchar;
222
223
224 fet_beginchar ("64th Flag (up)", "u6");
225         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
226         save flagspace, total_depth, flag_count;
227
228         flag_count = 4;
229         flare = .85 staff_space;
230         flagspace# = .9 staff_space#;
231         hip_depth_ratio = .72;
232         hip_width# = upflag_width# - hip_thickness# / 2;
233         total_depth# = 5.25 staff_space#;
234         foot_width_ratio = .8;
235
236         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
237
238         define_pixels (hip_width, foot_depth);
239         define_whole_vertical_pixels (flagspace);
240
241         set_char_box (0, hip_width# + right_upflag_space#,
242                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
243
244         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
245                    (hip_width, foot_depth),
246                    hip_depth_ratio, foot_width_ratio,
247                    hip_thickness, foot_thickness, 1);
248
249         add_flag (flagspace, flare, .97, 1.00, 1.3,
250                   hip_thickness, foot_thickness);
251         add_flag (flagspace, flare, 1.00, 1.00, 1.25,
252                   hip_thickness, foot_thickness);
253         add_flag (flagspace, flare, .95, 1.05, 1.25,
254                   hip_thickness, foot_thickness);
255
256         draw_square_block ((-0.5 stemthickness_rounded, 0),
257                            (0, -4 staff_space_rounded));
258 fet_endchar;
259
260
261 fet_beginchar ("128th Flag (up)", "u7");
262         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
263         save flagspace, total_depth, flag_count;
264
265         flag_count = 5;
266         flare = .85 staff_space;
267         flagspace# = .93 staff_space#;
268         hip_depth_ratio = .72;
269         hip_width# = upflag_width# - hip_thickness# / 2;
270         total_depth# = 6.25 staff_space#;
271         foot_width_ratio = .8;
272
273         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
274
275         define_pixels (hip_width, foot_depth);
276         define_whole_vertical_pixels (flagspace);
277
278         set_char_box (0, hip_width# + right_upflag_space#,
279                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
280
281         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
282                    (hip_width, foot_depth),
283                    hip_depth_ratio, foot_width_ratio,
284                    hip_thickness, foot_thickness, 1);
285
286         add_flag (flagspace, flare, .97, 1.00, 1.3,
287                   hip_thickness, foot_thickness);
288         add_flag (flagspace, flare, 1.00, 1.00, 1.25,
289                   hip_thickness, foot_thickness);
290         add_flag (flagspace, flare, 1.00, 1.00, 1.25,
291                   hip_thickness, foot_thickness);
292         add_flag (flagspace, flare, 0.95, 1.05, 1.25,
293                   hip_thickness, foot_thickness);
294
295         draw_square_block ((-0.5 stemthickness_rounded, 0),
296                            (0, -5 staff_space_rounded));
297 fet_endchar;
298
299
300 fet_beginchar ("8th (down)", "d3");
301         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
302         save flagspace, total_depth, flag_count;
303
304         flag_count = 1;
305         flare = staff_space;
306         flagspace# = .9 staff_space#;
307         hip_depth_ratio = .72;
308         hip_width# = downflag_width# - hip_thickness# / 2;
309         total_depth# = 2.85 staff_space#;
310         foot_width_ratio = .8;
311
312         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
313
314         define_pixels (hip_width, flagspace, foot_depth);
315
316         set_char_box (0, hip_width# + right_downflag_space#,
317                       total_depth# + foot_thickness# / 2, stemthickness# / 2)
318
319         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
320                    (hip_width, foot_depth),
321                    hip_depth_ratio, foot_width_ratio,
322                    hip_thickness, foot_thickness, 0);
323
324         draw_square_block ((-0.5 stemthickness_rounded, 0),
325                            (0, -staff_space_rounded));
326
327         y_mirror_char;
328 fet_endchar;
329
330
331 %%%%%%%%
332 %
333 % Single Stroke for Short Appogiatura
334 %
335
336 fet_beginchar ("grace dash (up)", "ugrace");
337         save flare, hip_depth_ratio, hip_width, foot_depth;
338
339         hip_depth_ratio = .72;
340         flare# = staff_space#;
341         hip_width# = upflag_width# - hip_thickness# / 2;
342         foot_depth# = 3 staff_space#;
343
344         define_pixels (hip_width, foot_depth);
345
346         set_char_box (hip_width# * hip_depth_ratio,
347                       hip_width# + right_upflag_space#,
348                       foot_depth# * hip_depth_ratio, -flare#)
349
350         pickup pencircle scaled 1.5 stemthickness;
351
352         z1 = (-b, -d);
353         z2 = (w, h);
354
355         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
356         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
357
358         fill z1l
359              -- z2l
360              .. top z2
361              .. rt z2
362              .. z2r
363              -- z1r
364              .. bot z1
365              .. lft z1
366              .. cycle;
367
368         penlabels (1, 2);
369 fet_endchar;
370
371
372 fet_beginchar ("grace dash (down)", "dgrace");
373         save flare, hip_depth_ratio, hip_width, foot_depth;
374         save total_depth;
375
376         hip_depth_ratio = .72 ;
377         flare# = .99 staff_space#;
378         hip_width# = downflag_width# - hip_thickness# / 2;
379         total_depth# = 2.85 staff_space#;
380         foot_depth# = total_depth#;
381         foot_width_ratio = .8;
382
383         define_pixels (hip_width, foot_depth);
384
385         set_char_box (hip_width# * hip_depth_ratio,
386                       hip_width# + right_downflag_space#,
387                       foot_depth# * hip_depth_ratio, -flare#)
388
389         pickup pencircle scaled 1.5 stemthickness;
390
391         z1 = (-b, -d);
392         z2 = (w, h);
393
394         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
395         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
396
397         fill z1l
398              -- z2l
399              .. top z2
400              .. rt z2
401              .. z2r
402              -- z1r
403              .. bot z1
404              .. lft z1
405              .. cycle;
406
407         y_mirror_char;
408 fet_endchar;
409
410
411 fet_beginchar ("16th (down)", "d4");
412         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
413         save flagspace, total_depth, flag_count;
414
415         flag_count = 2;
416         flare = .8 staff_space;
417         flagspace# = .9 staff_space#;
418         hip_depth_ratio = .85;
419         hip_width# = downflag_width# - hip_thickness# / 2;
420         total_depth# = 3.0 staff_space# - blot_diameter# / 2;
421         foot_width_ratio = .95;
422
423         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
424
425         set_char_box (0, hip_width# + right_downflag_space#,
426                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
427
428         define_pixels (hip_width, foot_depth);
429         define_whole_vertical_pixels (flagspace);
430
431         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
432                    (hip_width, foot_depth),
433                    hip_depth_ratio, foot_width_ratio,
434                    hip_thickness, foot_thickness, 0);
435
436         add_flag (flagspace, flare, .95, 1.00, 1.25,
437                   hip_thickness, foot_thickness);
438
439         draw_square_block ((-0.5 stemthickness_rounded, 0),
440                            (0, -2 staff_space_rounded));
441
442         y_mirror_char;
443 fet_endchar;
444
445
446 fet_beginchar ("32nd (down)", "d5");
447         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
448         save flagspace, total_depth, flag_count;
449
450         flag_count = 3;
451         flare = .84 staff_space;
452         flagspace# = .9 staff_space#;
453         hip_depth_ratio = .85;
454         hip_width# = downflag_width# - hip_thickness# / 2;
455         total_depth# = 3.85 staff_space#;
456         foot_width_ratio = .95;
457
458         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
459
460         define_pixels (hip_width, foot_depth);
461         define_whole_vertical_pixels (flagspace);
462
463         set_char_box (0, hip_width# + right_downflag_space#,
464                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
465
466         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
467                    (hip_width, foot_depth),
468                    hip_depth_ratio, foot_width_ratio,
469                    hip_thickness, foot_thickness, 0);
470
471         add_flag (flagspace, flare, .97, 1.00, 1.25,
472                   hip_thickness, foot_thickness);
473         add_flag (flagspace, flare, .95, 1.05, 1.25,
474                   hip_thickness, foot_thickness);
475
476         draw_square_block ((-0.5 stemthickness_rounded, 0),
477                            (0, -3 staff_space_rounded));
478
479         y_mirror_char;
480 fet_endchar;
481
482
483 fet_beginchar ("64th (down)", "d6");
484         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
485         save flagspace, total_depth, flag_count;
486
487         flag_count = 4;
488         flare = .8 staff_space;
489         flagspace# = .9 staff_space#;
490         hip_depth_ratio = .85;
491         hip_width# = downflag_width# - hip_thickness# / 2;
492         total_depth# = 4.35 staff_space#;
493         foot_width_ratio = .98;
494
495         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
496
497         define_pixels (hip_width, foot_depth);
498         define_whole_vertical_pixels (flagspace);
499
500         set_char_box (0, hip_width# + right_downflag_space#,
501                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
502
503         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
504                    (hip_width, foot_depth),
505                    hip_depth_ratio, foot_width_ratio,
506                    hip_thickness, foot_thickness, 0);
507
508         add_flag (flagspace, flare, .97, 1.20, 1.175,
509                   hip_thickness, foot_thickness);
510         add_flag (flagspace, flare, .97, 1.10, 1.175,
511                   hip_thickness, foot_thickness);
512         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
513                   hip_thickness, foot_thickness);
514
515         draw_square_block ((-0.5 stemthickness_rounded, 0),
516                            (0, -4 staff_space_rounded));
517
518         y_mirror_char;
519 fet_endchar;
520
521
522 fet_beginchar ("128th (down)", "d7");
523         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
524         save flagspace, total_depth, flag_count;
525
526         flag_count = 5;
527         flare = .8 staff_space;
528         flagspace# = .9 staff_space#;
529         hip_depth_ratio = .85;
530         hip_width# = downflag_width# - hip_thickness# / 2;
531         total_depth# = 5.25 staff_space#;
532         foot_width_ratio = .98;
533
534         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
535         define_pixels (hip_width, foot_depth);
536         define_whole_vertical_pixels (flagspace);
537
538         set_char_box (0, hip_width# + right_downflag_space#,
539                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
540
541         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
542                    (hip_width, foot_depth),
543                    hip_depth_ratio, foot_width_ratio,
544                    hip_thickness, foot_thickness, 0);
545
546         add_flag (flagspace, flare, .97, 1.20, 1.175,
547                   hip_thickness, foot_thickness);
548         add_flag (flagspace, flare, .97, 1.10, 1.175,
549                   hip_thickness, foot_thickness);
550         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
551                   hip_thickness, foot_thickness);
552         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
553                   hip_thickness, foot_thickness);
554
555         draw_square_block ((-0.5 stemthickness_rounded, 0),
556                            (0, -5 staff_space_rounded));
557
558         y_mirror_char;
559 fet_endchar;
560
561 fet_endgroup ("flags");