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.7 accreg_linethickness# / 2,
44 2 r# + 0.7 accreg_linethickness# / 2);
47 lt = vround (0.7 accreg_linethickness);
48 d := vround (0.7 accreg_linethickness / 2);
50 b := w := (3 lh + hround accreg_linethickness) / 2;
52 penpos1 (hround accreg_linethickness, 0);
54 penpos3 (hround accreg_linethickness, 180);
57 z1r = (w, 0.5 [-d, h]);
59 z3r = (-b, 0.5 [-d, h]);
62 penlabels (1, 2, 3, 4);
64 % mf doesn't handle pixel dropouts in outline objects, so we use
65 % `draw' if not called by mpost
78 pickup pencircle xscaled accreg_linethickness yscaled lt;
90 pickup penrazor scaled lt rotated 90;
92 top z5 = pat intersectionpoint ((0, lh + lt - d) -- (w, lh + lt - d));
94 bot z7 = pat intersectionpoint ((0, 2 lh - d) -- (w, 2 lh - d));
106 fet_beginchar ("accordion register dot", "dot")
107 set_char_box (accreg_dot_size# / 2, accreg_dot_size# / 2,
108 accreg_dot_size# / 2, accreg_dot_size# / 2);
110 pickup pencircle scaled accreg_dot_size;
112 rt x0 = hround (accreg_dot_size / 2);
113 top y0 = vround (accreg_dot_size / 2);
119 fet_beginchar ("accordion register freebass", "freebass")
125 set_char_box (r# + accreg_linethickness# / 2,
126 r# + accreg_linethickness# / 2,
127 0.7 accreg_linethickness# / 2,
128 2 r# + 0.7 accreg_linethickness# / 2);
131 lt = vround (0.7 accreg_linethickness);
132 d := vround (0.7 accreg_linethickness / 2);
134 b := w := (2 lh + hround accreg_linethickness) / 2;
136 penpos1 (hround accreg_linethickness, 0);
138 penpos3 (accreg_linethickness, 180);
141 z1r = (w, 0.5 [-d, h]);
143 z3r = (-b, 0.5 [-d, h]);
146 penlabels (1, 2, 3, 4);
148 % mf doesn't handle pixel dropouts in outline objects, so we use
149 % `draw' if not called by mpost
162 pickup pencircle xscaled accreg_linethickness yscaled lt;
170 pickup penrazor scaled lt rotated 90;
177 fet_beginchar ("accordion register stdbass", "stdbass")
184 set_char_box (r# + accreg_linethickness# / 2,
185 r# + accreg_linethickness# / 2,
186 0.7 accreg_linethickness# / 2,
187 2 r# + 0.7 accreg_linethickness# / 2);
190 lt = vround (0.7 accreg_linethickness);
191 d := vround (0.7 accreg_linethickness / 2);
193 b := w := (4 lh + hround accreg_linethickness) / 2;
195 penpos1 (hround accreg_linethickness, 0);
197 penpos3 (hround accreg_linethickness, 180);
200 z1r = (w, 0.5 [-d, h]);
202 z3r = (-b, 0.5 [-d, h]);
205 penlabels (1, 2, 3, 4);
207 % mf doesn't handle pixel dropouts in outline objects, so we use
208 % `draw' if not called by mpost
221 pickup pencircle xscaled accreg_linethickness yscaled lt;
233 pickup penrazor scaled lt rotated 90;
235 top z5 = pat intersectionpoint ((0, lh + lt - d) -- (w, lh + lt - d));
237 bot z7 = pat intersectionpoint ((0, 3 lh - d) -- (w, 3 lh - d));
251 fet_beginchar ("accordion register bayanbass", "bayanbass")
254 lh = vround accreg_lh;
255 lt = vround accreg_linethickness;
257 set_char_box (accreg_lh# + accreg_linethickness# / 2,
258 accreg_lh# + accreg_linethickness# / 2,
259 accreg_linethickness# / 2,
260 3 accreg_lh# + accreg_linethickness# / 2);
262 d := vround (accreg_linethickness# / 2);
265 draw_rounded_block ((-w, -d), (-w + lt, h), lt);
266 draw_rounded_block ((w - lt, -d), (w, h), lt);
268 pickup penrazor scaled lt rotated 90;
270 bot z1 = (-w + lt / 2, -d);
271 bot z2 = (-w + lt / 2, lh - d);
272 bot z3 = (-w + lt / 2, 2 lh - d);
273 bot z4 = (-w + lt / 2, 3 lh - d);
275 bot z5 = (w - lt / 2, -d);
276 bot z6 = (w - lt / 2, lh - d);
277 bot z7 = (w - lt / 2, 2 lh - d);
278 bot z8 = (w - lt / 2, 3 lh - d);
291 def def_B (expr w, h) =
292 pickup pencircle scaled 0.15 linethickness;
294 penpos10 (thin, -90);
295 penpos11 (thin, -90);
300 penpos15 (thick, 180);
301 penpos16 (thin, -90);
302 penpos17 (thin, -90);
308 z12 = (w, .5 mb * h);
309 z13 = (cTwo * w, mb * h);
310 z14 = (2 thick, mb * h);
311 z15 = (.94 w, h - .5 mt * h);
312 z16 = z13 + (0, mt * h);
314 z18 = (1.5 thick, 0);
315 z19 = (1.5 thick, h);
319 def def_S (expr w, h) =
320 pickup pencircle scaled 0.03 linethickness;
325 penpos4 (.5 thick, 90);
334 z3 = (w - .5 thick, .5 mb * h);
335 z4 = (w / 2, mb * h);
336 z5 = (.5 thick, h - .5 mt * h);
347 t := xpart (bue intersectiontimes (z8l -- z7l));
349 bueoverst := z6{right}
355 save hs, mb, mt, thin, thick, height, width, cOne, cTwo;
358 width = .8 (4 staff_space);
359 height = 2.4 staff_space;
360 % URG. smaller sizes should be wider and fatter
361 % thin = 0.05 staff_space;
362 % thick = 0.2 staff_space;
366 fatten := designsize * hx + bx * 1.2;
367 thick := 0.2 staff_space * fatten;
369 % urg: mustn't ever go thinner than blot!
370 thin# := blot_diameter#;
371 define_pixels (thin);
373 hs = 0.4 staff_space;
381 fet_beginchar ("accordion oldEE", "oldEE")
382 save r, pp, ir, lh, lt, stroke_width;
387 lr = .4 staff_space - linethickness;
389 stroke_width = .05 staff_space + .5 linethickness;
391 set_char_box (r# + accreg_linethickness# / 2,
392 r# + accreg_linethickness# / 2,
393 0, 2 r# + 0.7 accreg_linethickness#);
399 penpos1 (blot_diameter, 0);
400 penpos2 (stroke_width + blot_diameter, 0);
401 penpos3 (stroke_width + blot_diameter, 0);
403 pickup pencircle scaled (lr + blot_diameter);
405 for pp := 0 step 45 until 135:
406 drawdot z2 rotated pp;
407 drawdot z3 rotated pp;
414 pickup pencircle scaled lr;
418 currentpicture := currentpicture shifted (0, h / 2);
421 lt = vround (0.7 accreg_linethickness);
424 b := w := (lh + hround accreg_linethickness) / 2;
426 penpos10 (hround accreg_linethickness, 0);
428 penpos12 (hround accreg_linethickness, 180);
436 % penlabels (1, 2, 10, 11, 12, 13);
438 % mf doesn't handle pixel dropouts in outline objects, so we use
439 % `draw' if not called by mpost
452 pickup pencircle xscaled accreg_linethickness yscaled lt;
462 fet_beginchar ("accordion push", "push");
465 height# := 2.0 staff_space# + 3.0 stafflinethickness#;
466 width# := 0.4 height#;
468 define_pixels(height, width);
472 linewidth# := stafflinethickness# + .05 staff_space#;
473 define_whole_blacker_pixels (linewidth);
475 set_char_box (width#, 0,
478 pickup pencircle scaled linewidth;
484 y2 = 0.5 * (y1 + y3);
489 save nw_offset, ne_offset;
490 pair nw_offset, ne_offset;
491 save sw_offset, se_offset, line_radius;
492 pair sw_offset, se_offset;
494 line_radius := linewidth / 2;
495 nw_offset := line_radius * unitvector (z1 - z2);
496 ne_offset := nw_offset rotated -90;
497 sw_offset := line_radius * unitvector (z3 - z2);
498 se_offset := sw_offset rotated 90;
500 z4 = ((z1 - ne_offset)
504 -- (z3 - se_offset));
511 .. z3 + sw_offset {- se_offset}
515 .. z1 + nw_offset {ne_offset}
520 fet_beginchar ("accordion pull", "pull");
523 height# := 2.0 staff_space# + 3.0 stafflinethickness#;
524 width# := 0.4 height#;
526 define_pixels(height, width);
530 linewidth# := stafflinethickness# + .05 staff_space#;
531 define_whole_blacker_pixels (linewidth);
533 set_char_box (width# - linewidth#, linewidth#,
536 pickup pencircle scaled linewidth;
539 penradius := linewidth / 2;
547 lft x3= -width + linewidth;
556 fill z1 + penradius * right {up}
557 -- z2 + penradius * right {up}
558 .. z2 + penradius * up {left}
559 -- z3 + penradius * up {left}
560 .. z3 + penradius * left {down}
561 -- z4 + penradius * left {down}
562 .. z4 + penradius * down {right}
563 -- z5 + penradius * (down + left)
564 -- z1 + penradius * left {down}
565 .. z1 + penradius * down {right}
569 fet_endgroup ("accordion");