1 % Feta (not the Font-En-Tja) music font -- draw flags
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
19 fet_begingroup ("flags");
25 % Flags pointing down overlap with the notehead (in x-direction), so
26 % the down-flag can be bigger.
29 upflag_width# = .65 black_notehead_width# + stemthickness# / 2;
30 downflag_width# = .833 black_notehead_width# + stemthickness# / 2;
32 right_upflag_space# = .0 upflag_width#;
33 right_downflag_space# = .0 downflag_width#;
36 % Flags pointing down cannot overlap with the notehead in y-direction,
37 % so they have less slant.
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.)
45 save hip_thickness, foot_thickness;
47 hip_thickness# = 1.0 linethickness# + 0.069 staff_space#;
48 foot_thickness# = 1.2055 linethickness# + 0.06 staff_space#;
50 define_pixels (hip_thickness, foot_thickness);
53 % Inspired by Adobe Sonata and [Wanske].
54 % For example, see POSTSCRIPT Language -- program design,
55 % page 119, and [Wanske], p 41, 42.
58 def draw_flag (expr center, flare, dims, hip_depth, foot_wid,
59 hip_thickness, foot_thickness, show_labels) =
67 penpos2 (whatever, 0);
69 x2r - x2l = hround (hip_thickness);
71 penpos3 (foot_thickness, -20.0);
74 z2r = center + (xpart (dims), -ypart (dims) * hip_depth);
75 z3r = center + (xpart (dims) * foot_wid, -ypart (dims));
80 outer_path := z3r{curl c}
89 ..tension 1.1.. z2l{down}
90 .. {curl c}simple_serif (z3l, z3r, 80)
97 % TODO: calculate intersectpoint (see TeX book, p. 137)
98 % TODO: calculate incision_depth
101 def add_flag (expr yoff, flare, hip_wid_multiplier, hip_dep_multiplier,
102 intersectpoint, hip_thickness, foot_thickness) =
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;
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;
120 wid = prev_hipwid * hip_wid_multiplier;
121 hip_dep = prev_hipdep * hip_dep_multiplier;
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;
129 draw_flag (center, flare, (wid, dep),
130 hip_dep_ratio, foot_wid_ratio,
131 hip_thickness, foot_thickness, 0);
136 fet_beginchar ("8th Flag (up)", "u3");
137 save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
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);
147 hip_width# + stemthickness# / 2 + right_upflag_space#,
148 foot_depth# + foot_thickness# / 2, stemthickness# / 2);
150 draw_flag ((0,0), flare, (hip_width, foot_depth),
151 hip_depth_ratio, foot_width_ratio,
152 hip_thickness, foot_thickness, 1);
154 draw_square_block ((-0.5 stemthickness_rounded, -staff_space_rounded),
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;
163 total_depth# = 3.5 staff_space# - blot_diameter# / 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);
175 hip_width# + stemthickness# / 2 + right_upflag_space#,
176 total_depth# + foot_thickness# / 2, stemthickness# / 2);
178 draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
179 hip_depth_ratio, foot_width_ratio,
180 hip_thickness, foot_thickness, 1);
182 add_flag (flagspace, flare, .97, 1.00, 1.25,
183 hip_thickness, foot_thickness);
185 draw_square_block ((-0.5 stemthickness_rounded, 0),
186 (0, -2 staff_space_rounded));
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;
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;
202 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
204 define_pixels (hip_width, foot_depth);
205 define_whole_vertical_pixels (flagspace);
207 set_char_box (0, hip_width# + right_upflag_space#,
208 total_depth# + foot_thickness# / 2, stemthickness# / 2);
210 draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
211 hip_depth_ratio, foot_width_ratio,
212 hip_thickness, foot_thickness, 1);
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);
219 draw_square_block ((-0.5 stemthickness_rounded, 0),
220 (0, -3 staff_space_rounded));
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;
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;
236 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
238 define_pixels (hip_width, foot_depth);
239 define_whole_vertical_pixels (flagspace);
241 set_char_box (0, hip_width# + right_upflag_space#,
242 total_depth# + foot_thickness# / 2, stemthickness# / 2);
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);
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);
256 draw_square_block ((-0.5 stemthickness_rounded, 0),
257 (0, -4 staff_space_rounded));
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;
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;
273 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
275 define_pixels (hip_width, foot_depth);
276 define_whole_vertical_pixels (flagspace);
278 set_char_box (0, hip_width# + right_upflag_space#,
279 total_depth# + foot_thickness# / 2, stemthickness# / 2);
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);
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);
295 draw_square_block ((-0.5 stemthickness_rounded, 0),
296 (0, -5 staff_space_rounded));
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;
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;
312 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
314 define_pixels (hip_width, flagspace, foot_depth);
316 set_char_box (0, hip_width# + right_downflag_space#,
317 total_depth# + foot_thickness# / 2, stemthickness# / 2)
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);
324 draw_square_block ((-0.5 stemthickness_rounded, 0),
325 (0, -staff_space_rounded));
333 % Single Stroke for Short Appogiatura
336 fet_beginchar ("grace dash (up)", "ugrace");
337 save flare, hip_depth_ratio, hip_width, foot_depth;
339 hip_depth_ratio = .72;
340 flare# = staff_space#;
341 hip_width# = upflag_width# - hip_thickness# / 2;
342 foot_depth# = 3 staff_space#;
344 define_pixels (hip_width, foot_depth);
346 set_char_box (hip_width# * hip_depth_ratio,
347 hip_width# + right_upflag_space#,
348 foot_depth# * hip_depth_ratio, -flare#)
350 pickup pencircle scaled 1.5 stemthickness;
355 penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
356 penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
372 fet_beginchar ("grace dash (down)", "dgrace");
373 save flare, hip_depth_ratio, hip_width, foot_depth;
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;
383 define_pixels (hip_width, foot_depth);
385 set_char_box (hip_width# * hip_depth_ratio,
386 hip_width# + right_downflag_space#,
387 foot_depth# * hip_depth_ratio, -flare#)
389 pickup pencircle scaled 1.5 stemthickness;
394 penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
395 penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
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;
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;
423 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
425 set_char_box (0, hip_width# + right_downflag_space#,
426 total_depth# + foot_thickness# / 2, stemthickness# / 2);
428 define_pixels (hip_width, foot_depth);
429 define_whole_vertical_pixels (flagspace);
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);
436 add_flag (flagspace, flare, .95, 1.00, 1.25,
437 hip_thickness, foot_thickness);
439 draw_square_block ((-0.5 stemthickness_rounded, 0),
440 (0, -2 staff_space_rounded));
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;
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;
458 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
460 define_pixels (hip_width, foot_depth);
461 define_whole_vertical_pixels (flagspace);
463 set_char_box (0, hip_width# + right_downflag_space#,
464 total_depth# + foot_thickness# / 2, stemthickness# / 2);
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);
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);
476 draw_square_block ((-0.5 stemthickness_rounded, 0),
477 (0, -3 staff_space_rounded));
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;
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;
495 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
497 define_pixels (hip_width, foot_depth);
498 define_whole_vertical_pixels (flagspace);
500 set_char_box (0, hip_width# + right_downflag_space#,
501 total_depth# + foot_thickness# / 2, stemthickness# / 2);
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);
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);
515 draw_square_block ((-0.5 stemthickness_rounded, 0),
516 (0, -4 staff_space_rounded));
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;
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;
534 (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
535 define_pixels (hip_width, foot_depth);
536 define_whole_vertical_pixels (flagspace);
538 set_char_box (0, hip_width# + right_downflag_space#,
539 total_depth# + foot_thickness# / 2, stemthickness# / 2);
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);
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);
555 draw_square_block ((-0.5 stemthickness_rounded, 0),
556 (0, -5 staff_space_rounded));
561 fet_endgroup ("flags");