1 % Feta (not the Font-En-Tja) music font -- draw accordion symbols
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1998--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 % The LilyPond font 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, or you can redistribute it under
10 % the SIL Open Font License.
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.
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/>.
20 fet_begingroup ("accordion");
23 % These dimensions are the same for all register symbols.
24 % The different symbols should calculate their other dimensions from them.
27 accreg_dot_size# := .5 staff_space#;
28 accreg_linethickness# := 1.3 stafflinethickness#;
29 accreg_lh# := 1.0 staff_space#;
31 define_pixels (accreg_dot_size, accreg_linethickness, accreg_lh);
34 fet_beginchar ("accordion register discant", "discant")
41 set_char_box (r# + accreg_linethickness# / 2,
42 r# + accreg_linethickness# / 2,
43 0, 2 r# + 0.7 accreg_linethickness#);
46 lt = vround (0.7 accreg_linethickness);
49 b := w := (3 lh + hround accreg_linethickness) / 2;
51 penpos1 (hround accreg_linethickness, 0);
53 penpos3 (hround accreg_linethickness, 180);
61 penlabels (1, 2, 3, 4);
63 % mf doesn't handle pixel dropouts in outline objects, so we use
64 % `draw' if not called by mpost
77 pickup pencircle xscaled accreg_linethickness yscaled lt;
89 pickup penrazor scaled lt rotated 90;
91 top z5 = pat intersectionpoint ((0, lh + lt) -- (w, lh + lt));
93 bot z7 = pat intersectionpoint ((0, 2 lh) -- (w, 2 lh));
105 fet_beginchar ("accordion register dot", "dot")
106 set_char_box (accreg_dot_size# / 2, accreg_dot_size# / 2,
107 accreg_dot_size# / 2, accreg_dot_size# / 2);
109 pickup pencircle scaled accreg_dot_size;
111 rt x0 = hround (accreg_dot_size / 2);
112 top y0 = vround (accreg_dot_size / 2);
118 fet_beginchar ("accordion register freebass", "freebass")
124 set_char_box (r# + accreg_linethickness# / 2,
125 r# + accreg_linethickness# / 2,
126 0, 2 r# + 0.7 accreg_linethickness#);
129 lt = vround (0.7 accreg_linethickness);
132 b := w := (2 lh + hround accreg_linethickness) / 2;
134 penpos1 (hround accreg_linethickness, 0);
136 penpos3 (accreg_linethickness, 180);
144 penlabels (1, 2, 3, 4);
146 % mf doesn't handle pixel dropouts in outline objects, so we use
147 % `draw' if not called by mpost
160 pickup pencircle xscaled accreg_linethickness yscaled lt;
168 pickup penrazor scaled lt rotated 90;
175 fet_beginchar ("accordion register stdbass", "stdbass")
182 set_char_box (r# + accreg_linethickness# / 2,
183 r# + accreg_linethickness# / 2,
184 0, 2 r# + 0.7 accreg_linethickness#);
187 lt = vround (0.7 accreg_linethickness);
190 b := w := (4 lh + hround accreg_linethickness) / 2;
192 penpos1 (hround accreg_linethickness, 0);
194 penpos3 (hround accreg_linethickness, 180);
202 penlabels (1, 2, 3, 4);
204 % mf doesn't handle pixel dropouts in outline objects, so we use
205 % `draw' if not called by mpost
218 pickup pencircle xscaled accreg_linethickness yscaled lt;
230 pickup penrazor scaled lt rotated 90;
232 top z5 = pat intersectionpoint ((0, lh + lt) -- (w, lh + lt));
234 bot z7 = pat intersectionpoint ((0, 3 lh) -- (w, 3 lh));
248 fet_beginchar ("accordion register bayanbass", "bayanbass")
251 lh = vround accreg_lh;
252 lt = vround accreg_linethickness;
254 set_char_box (accreg_lh# + accreg_linethickness# / 2,
255 accreg_lh# + accreg_linethickness# / 2,
256 0, 3 accreg_lh# + accreg_linethickness#);
260 draw_rounded_block ((-w, 0), (-w + lt, h), lt);
261 draw_rounded_block ((w - lt, 0), (w, h), lt);
263 pickup penrazor scaled lt rotated 90;
265 bot z1 = (-w + lt / 2, 0);
266 bot z2 = (-w + lt / 2, lh);
267 bot z3 = (-w + lt / 2, 2 lh);
268 bot z4 = (-w + lt / 2, 3 lh);
270 bot z5 = (w - lt / 2, 0);
271 bot z6 = (w - lt / 2, lh);
272 bot z7 = (w - lt / 2, 2 lh);
273 bot z8 = (w - lt / 2, 3 lh);
286 def def_B (expr w, h) =
287 pickup pencircle scaled 0.15 linethickness;
289 penpos10 (thin, -90);
290 penpos11 (thin, -90);
295 penpos15 (thick, 180);
296 penpos16 (thin, -90);
297 penpos17 (thin, -90);
303 z12 = (w, .5 mb * h);
304 z13 = (cTwo * w, mb * h);
305 z14 = (2 thick, mb * h);
306 z15 = (.94 w, h - .5 mt * h);
307 z16 = z13 + (0, mt * h);
309 z18 = (1.5 thick, 0);
310 z19 = (1.5 thick, h);
314 def def_S (expr w, h) =
315 pickup pencircle scaled 0.03 linethickness;
320 penpos4 (.5 thick, 90);
329 z3 = (w - .5 thick, .5 mb * h);
330 z4 = (w / 2, mb * h);
331 z5 = (.5 thick, h - .5 mt * h);
342 t := xpart (bue intersectiontimes (z8l -- z7l));
344 bueoverst := z6{right}
350 save hs, mb, mt, thin, thick, height, width, cOne, cTwo;
353 width = .8 (4 staff_space);
354 height = 2.4 staff_space;
355 % URG. smaller sizes should be wider and fatter
356 % thin = 0.05 staff_space;
357 % thick = 0.2 staff_space;
361 fatten := designsize * hx + bx * 1.2;
362 thick := 0.2 staff_space * fatten;
364 % urg: mustn't ever go thinner than blot!
365 thin# := blot_diameter#;
366 define_pixels (thin);
368 hs = 0.4 staff_space;
376 fet_beginchar ("accordion oldEE", "oldEE")
377 save r, pp, ir, lh, lt, stroke_width;
382 lr = .4 staff_space - linethickness;
384 stroke_width = .05 staff_space + .5 linethickness;
386 set_char_box (r# + accreg_linethickness# / 2,
387 r# + accreg_linethickness# / 2,
388 0, 2 r# + 0.7 accreg_linethickness#);
394 penpos1 (blot_diameter, 0);
395 penpos2 (stroke_width + blot_diameter, 0);
396 penpos3 (stroke_width + blot_diameter, 0);
398 pickup pencircle scaled (lr + blot_diameter);
400 for pp := 0 step 45 until 135:
401 drawdot z2 rotated pp;
402 drawdot z3 rotated pp;
409 pickup pencircle scaled lr;
413 currentpicture := currentpicture shifted (0, h / 2);
416 lt = vround (0.7 accreg_linethickness);
419 b := w := (lh + hround accreg_linethickness) / 2;
421 penpos10 (hround accreg_linethickness, 0);
423 penpos12 (hround accreg_linethickness, 180);
431 % penlabels (1, 2, 10, 11, 12, 13);
433 % mf doesn't handle pixel dropouts in outline objects, so we use
434 % `draw' if not called by mpost
447 pickup pencircle xscaled accreg_linethickness yscaled lt;
457 fet_beginchar ("accordion push", "push");
460 height# := 2.0 staff_space# + 3.0 stafflinethickness#;
461 width# := 0.4 height#;
463 define_pixels(height, width);
467 linewidth# := stafflinethickness# + .05 staff_space#;
468 define_whole_blacker_pixels (linewidth);
470 set_char_box (width#, 0,
473 pickup pencircle scaled linewidth;
479 y2 = 0.5 * (y1 + y3);
484 save nw_offset, ne_offset;
485 pair nw_offset, ne_offset;
486 save sw_offset, se_offset, line_radius;
487 pair sw_offset, se_offset;
489 line_radius := linewidth / 2;
490 nw_offset := line_radius * unitvector (z1 - z2);
491 ne_offset := nw_offset rotated -90;
492 sw_offset := line_radius * unitvector (z3 - z2);
493 se_offset := sw_offset rotated 90;
495 z4 = ((z1 - ne_offset)
499 -- (z3 - se_offset));
506 .. z3 + sw_offset {- se_offset}
510 .. z1 + nw_offset {ne_offset}
515 fet_beginchar ("accordion pull", "pull");
518 height# := 2.0 staff_space# + 3.0 stafflinethickness#;
519 width# := 0.4 height#;
521 define_pixels(height, width);
525 linewidth# := stafflinethickness# + .05 staff_space#;
526 define_whole_blacker_pixels (linewidth);
528 set_char_box (width# - linewidth#, linewidth#,
531 pickup pencircle scaled linewidth;
534 penradius := linewidth / 2;
542 lft x3= -width + linewidth;
551 fill z1 + penradius * right {up}
552 -- z2 + penradius * right {up}
553 .. z2 + penradius * up {left}
554 -- z3 + penradius * up {left}
555 .. z3 + penradius * left {down}
556 -- z4 + penradius * left {down}
557 .. z4 + penradius * down {right}
558 -- z5 + penradius * (down + left)
559 -- z1 + penradius * left {down}
560 .. z1 + penradius * down {right}
564 fet_endgroup ("accordion");