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.35 accreg_linethickness# / 2,
44 2 r# + 0.35 accreg_linethickness# / 2);
46 local_copy (transform)(currenttransform);
48 currenttransform shifted (0, -vround (0.35 accreg_linethickness));
51 lt = vround (0.7 accreg_linethickness);
54 b := w := (3 lh + hround accreg_linethickness) / 2;
56 penpos1 (hround accreg_linethickness, 0);
58 penpos3 (hround accreg_linethickness, 180);
66 penlabels (1, 2, 3, 4);
68 % mf doesn't handle pixel dropouts in outline objects, so we use
69 % `draw' if not called by mpost
82 pickup pencircle xscaled accreg_linethickness yscaled lt;
94 pickup penrazor scaled lt rotated 90;
96 top z5 = pat intersectionpoint ((0, lh + lt) -- (w, lh + lt));
98 bot z7 = pat intersectionpoint ((0, 2 lh) -- (w, 2 lh));
110 fet_beginchar ("accordion register dot", "dot")
111 set_char_box (accreg_dot_size# / 2, accreg_dot_size# / 2,
112 accreg_dot_size# / 2, accreg_dot_size# / 2);
114 pickup pencircle scaled accreg_dot_size;
116 rt x0 = hround (accreg_dot_size / 2);
117 top y0 = vround (accreg_dot_size / 2);
123 fet_beginchar ("accordion register freebass", "freebass")
129 set_char_box (r# + accreg_linethickness# / 2,
130 r# + accreg_linethickness# / 2,
131 0.35 accreg_linethickness#,
132 2 r# + 0.35 accreg_linethickness#);
134 local_copy (transform)(currenttransform);
136 currenttransform shifted (0, -vround (0.35 accreg_linethickness));
139 lt = vround (0.7 accreg_linethickness);
142 b := w := (2 lh + hround accreg_linethickness) / 2;
144 penpos1 (hround accreg_linethickness, 0);
146 penpos3 (accreg_linethickness, 180);
154 penlabels (1, 2, 3, 4);
156 % mf doesn't handle pixel dropouts in outline objects, so we use
157 % `draw' if not called by mpost
170 pickup pencircle xscaled accreg_linethickness yscaled lt;
178 pickup penrazor scaled lt rotated 90;
185 fet_beginchar ("accordion register stdbass", "stdbass")
192 set_char_box (r# + accreg_linethickness# / 2,
193 r# + accreg_linethickness# / 2,
194 0.35 accreg_linethickness#,
195 2 r# + 0.35 accreg_linethickness#);
197 local_copy (transform)(currenttransform);
199 currenttransform shifted (0, -vround (0.35 accreg_linethickness));
202 lt = vround (0.7 accreg_linethickness);
205 b := w := (4 lh + hround accreg_linethickness) / 2;
207 penpos1 (hround accreg_linethickness, 0);
209 penpos3 (hround accreg_linethickness, 180);
217 penlabels (1, 2, 3, 4);
219 % mf doesn't handle pixel dropouts in outline objects, so we use
220 % `draw' if not called by mpost
233 pickup pencircle xscaled accreg_linethickness yscaled lt;
245 pickup penrazor scaled lt rotated 90;
247 top z5 = pat intersectionpoint ((0, lh + lt) -- (w, lh + lt));
249 bot z7 = pat intersectionpoint ((0, 3 lh) -- (w, 3 lh));
263 fet_beginchar ("accordion register bayanbass", "bayanbass")
266 lh = vround accreg_lh;
267 lt = vround accreg_linethickness;
269 set_char_box (accreg_lh# + accreg_linethickness# / 2,
270 accreg_lh# + accreg_linethickness# / 2,
271 0.5 accreg_linethickness#,
272 3 accreg_lh# + 0.5 accreg_linethickness#);
274 local_copy (transform)(currenttransform);
276 currenttransform shifted (0, -vround (0.5 accreg_linethickness));
280 draw_rounded_block ((-w, 0), (-w + lt, h), lt);
281 draw_rounded_block ((w - lt, 0), (w, h), lt);
283 pickup penrazor scaled lt rotated 90;
285 bot z1 = (-w + lt / 2, 0);
286 bot z2 = (-w + lt / 2, lh);
287 bot z3 = (-w + lt / 2, 2 lh);
288 bot z4 = (-w + lt / 2, 3 lh);
290 bot z5 = (w - lt / 2, 0);
291 bot z6 = (w - lt / 2, lh);
292 bot z7 = (w - lt / 2, 2 lh);
293 bot z8 = (w - lt / 2, 3 lh);
306 def def_B (expr w, h) =
307 pickup pencircle scaled 0.15 linethickness;
309 penpos10 (thin, -90);
310 penpos11 (thin, -90);
315 penpos15 (thick, 180);
316 penpos16 (thin, -90);
317 penpos17 (thin, -90);
323 z12 = (w, .5 mb * h);
324 z13 = (cTwo * w, mb * h);
325 z14 = (2 thick, mb * h);
326 z15 = (.94 w, h - .5 mt * h);
327 z16 = z13 + (0, mt * h);
329 z18 = (1.5 thick, 0);
330 z19 = (1.5 thick, h);
334 def def_S (expr w, h) =
335 pickup pencircle scaled 0.03 linethickness;
340 penpos4 (.5 thick, 90);
349 z3 = (w - .5 thick, .5 mb * h);
350 z4 = (w / 2, mb * h);
351 z5 = (.5 thick, h - .5 mt * h);
362 t := xpart (bue intersectiontimes (z8l -- z7l));
364 bueoverst := z6{right}
370 save hs, mb, mt, thin, thick, height, width, cOne, cTwo;
373 width = .8 (4 staff_space);
374 height = 2.4 staff_space;
375 % URG. smaller sizes should be wider and fatter
376 % thin = 0.05 staff_space;
377 % thick = 0.2 staff_space;
381 fatten := designsize * hx + bx * 1.2;
382 thick := 0.2 staff_space * fatten;
384 % urg: mustn't ever go thinner than blot!
385 thin# := blot_diameter#;
386 define_pixels (thin);
388 hs = 0.4 staff_space;
396 fet_beginchar ("accordion oldEE", "oldEE")
397 save r, pp, ir, lh, lt, stroke_width;
402 lr = .4 staff_space - linethickness;
404 stroke_width = .05 staff_space + .5 linethickness;
406 set_char_box (r# + accreg_linethickness# / 2,
407 r# + accreg_linethickness# / 2,
408 0, 2 r# + 0.7 accreg_linethickness#);
414 penpos1 (blot_diameter, 0);
415 penpos2 (stroke_width + blot_diameter, 0);
416 penpos3 (stroke_width + blot_diameter, 0);
418 pickup pencircle scaled (lr + blot_diameter);
420 for pp := 0 step 45 until 135:
421 drawdot z2 rotated pp;
422 drawdot z3 rotated pp;
429 pickup pencircle scaled lr;
433 currentpicture := currentpicture shifted (0, h / 2);
436 lt = vround (0.7 accreg_linethickness);
439 b := w := (lh + hround accreg_linethickness) / 2;
441 penpos10 (hround accreg_linethickness, 0);
443 penpos12 (hround accreg_linethickness, 180);
451 % penlabels (1, 2, 10, 11, 12, 13);
453 % mf doesn't handle pixel dropouts in outline objects, so we use
454 % `draw' if not called by mpost
467 pickup pencircle xscaled accreg_linethickness yscaled lt;
477 fet_beginchar ("accordion push", "push");
480 height# := 2.0 staff_space# + 3.0 stafflinethickness#;
481 width# := 0.4 height#;
483 define_pixels(height, width);
487 linewidth# := stafflinethickness# + .05 staff_space#;
488 define_whole_blacker_pixels (linewidth);
490 set_char_box (width#, 0,
493 pickup pencircle scaled linewidth;
499 y2 = 0.5 * (y1 + y3);
504 save nw_offset, ne_offset;
505 pair nw_offset, ne_offset;
506 save sw_offset, se_offset, line_radius;
507 pair sw_offset, se_offset;
509 line_radius := linewidth / 2;
510 nw_offset := line_radius * unitvector (z1 - z2);
511 ne_offset := nw_offset rotated -90;
512 sw_offset := line_radius * unitvector (z3 - z2);
513 se_offset := sw_offset rotated 90;
515 z4 = ((z1 - ne_offset)
519 -- (z3 - se_offset));
526 .. z3 + sw_offset {- se_offset}
530 .. z1 + nw_offset {ne_offset}
535 fet_beginchar ("accordion pull", "pull");
538 height# := 2.0 staff_space# + 3.0 stafflinethickness#;
539 width# := 0.4 height#;
541 define_pixels(height, width);
545 linewidth# := stafflinethickness# + .05 staff_space#;
546 define_whole_blacker_pixels (linewidth);
548 set_char_box (width# - linewidth#, linewidth#,
551 pickup pencircle scaled linewidth;
554 penradius := linewidth / 2;
562 lft x3= -width + linewidth;
571 fill z1 + penradius * right {up}
572 -- z2 + penradius * right {up}
573 .. z2 + penradius * up {left}
574 -- z3 + penradius * up {left}
575 .. z3 + penradius * left {down}
576 -- z4 + penradius * left {down}
577 .. z4 + penradius * down {right}
578 -- z5 + penradius * (down + left)
579 -- z1 + penradius * left {down}
580 .. z1 + penradius * down {right}
584 fet_endgroup ("accordion");