]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-accordion.mf
Merge branch 'master' into translation
[lilypond.git] / mf / feta-accordion.mf
1 % Feta (not the Font-En-Tja) music font -- draw accordion symbols
2 % This file is part of LilyPond, the GNU music typesetter.
3 %
4 % Copyright (C) 1998--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 %
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.
11 %
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.
16 %
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/>.
19
20 fet_begingroup ("accordion");
21
22 %
23 % These dimensions are the same for all register symbols.
24 % The different symbols should calculate their other dimensions from them.
25 %
26
27 accreg_dot_size# := .5 staff_space#;
28 accreg_linethickness# := 1.3 stafflinethickness#;
29 accreg_lh# := 1.0 staff_space#;
30
31 define_pixels (accreg_dot_size, accreg_linethickness, accreg_lh);
32
33
34 fet_beginchar ("accordion register discant", "discant")
35         save r, pat, lh, lt;
36         path pat;
37
38         r# = 3/2 accreg_lh#;
39         define_pixels (r);
40
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);
45
46         local_copy (transform)(currenttransform);
47         currenttransform :=
48            currenttransform shifted (0, -vround (0.35 accreg_linethickness));
49
50         lh = vround (2/3 r);
51         lt = vround (0.7 accreg_linethickness);
52
53         h := 3 lh + lt;
54         b := w := (3 lh + hround accreg_linethickness) / 2;
55
56         penpos1 (hround accreg_linethickness, 0);
57         penpos2 (lt, 90);
58         penpos3 (hround accreg_linethickness, 180);
59         penpos4 (lt, 270);
60
61         z1r = (w, h / 2);
62         z2r = (0, h);
63         z3r = (-b, h / 2);
64         z4r = (0, 0);
65
66         penlabels (1, 2, 3, 4);
67
68         % mf doesn't handle pixel dropouts in outline objects, so we use
69         % `draw' if not called by mpost
70         if known miterlimit:
71                 fill z1r
72                      .. z2r
73                      .. z3r
74                      .. z4r
75                      .. cycle;
76                 unfill z1l
77                        .. z2l
78                        .. z3l
79                        .. z4l
80                        .. cycle;
81         else:
82                 pickup pencircle xscaled accreg_linethickness yscaled lt;
83                 draw z1
84                      .. z2
85                      .. z3
86                      .. z4
87                      .. cycle;
88         fi;
89
90         pat := z4{right}
91                .. z1{up}
92                .. {left}z2;
93
94         pickup penrazor scaled lt rotated 90;
95
96         top z5 = pat intersectionpoint ((0, lh + lt) -- (w, lh + lt));
97         z6 = z5 xscaled -1;
98         bot z7 = pat intersectionpoint ((0, 2 lh) -- (w, 2 lh));
99         z8 = z7 xscaled -1;
100
101         labels (5, 6, 7, 8);
102
103         draw z5
104              -- z6;
105         draw z7
106              -- z8;
107 fet_endchar;
108
109
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);
113
114         pickup pencircle scaled accreg_dot_size;
115
116         rt x0 = hround (accreg_dot_size / 2);
117         top y0 = vround (accreg_dot_size / 2);
118
119         drawdot z0;
120 fet_endchar;
121
122
123 fet_beginchar ("accordion register freebass", "freebass")
124         save r, lh, lt;
125
126         r# = accreg_lh#;
127         define_pixels (r);
128
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#);
133
134         local_copy (transform)(currenttransform);
135         currenttransform :=
136           currenttransform shifted (0, -vround (0.35 accreg_linethickness));
137
138         lh = vround r;
139         lt = vround (0.7 accreg_linethickness);
140
141         h := 2 lh + lt;
142         b := w := (2 lh + hround accreg_linethickness) / 2;
143
144         penpos1 (hround accreg_linethickness, 0);
145         penpos2 (lt, 90);
146         penpos3 (accreg_linethickness, 180);
147         penpos4 (lt, 270);
148
149         z1r = (w, h / 2);
150         z2r = (0, h);
151         z3r = (-b, h / 2);
152         z4r = (0, 0);
153
154         penlabels (1, 2, 3, 4);
155
156         % mf doesn't handle pixel dropouts in outline objects, so we use
157         % `draw' if not called by mpost
158         if known miterlimit:
159                 fill z1r
160                      .. z2r
161                      .. z3r
162                      .. z4r
163                      .. cycle;
164                 unfill z1l
165                        .. z2l
166                        .. z3l
167                        .. z4l
168                        .. cycle;
169         else:
170                 pickup pencircle xscaled accreg_linethickness yscaled lt;
171                 draw z1
172                      .. z2
173                      .. z3
174                      .. z4
175                      .. cycle;
176         fi;
177
178         pickup penrazor scaled lt rotated 90;
179
180         draw z1
181              -- z3;
182 fet_endchar;
183
184
185 fet_beginchar ("accordion register stdbass", "stdbass")
186         save r, p, lh, lt;
187         path pat;
188
189         r# = 2 accreg_lh#;
190         define_pixels (r);
191
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#);
196
197         local_copy (transform)(currenttransform);
198         currenttransform :=
199            currenttransform shifted (0, -vround (0.35 accreg_linethickness));
200
201         lh = vround (1/2 r);
202         lt = vround (0.7 accreg_linethickness);
203
204         h := 4 lh + lt;
205         b := w := (4 lh + hround accreg_linethickness) / 2;
206
207         penpos1 (hround accreg_linethickness, 0);
208         penpos2 (lt, 90);
209         penpos3 (hround accreg_linethickness, 180);
210         penpos4 (lt, 270);
211
212         z1r = (w, h / 2);
213         z2r = (0, h);
214         z3r = (-b, h / 2);
215         z4r = (0, 0);
216
217         penlabels (1, 2, 3, 4);
218
219         % mf doesn't handle pixel dropouts in outline objects, so we use
220         % `draw' if not called by mpost
221         if known miterlimit:
222                 fill z1r
223                      .. z2r
224                      .. z3r
225                      .. z4r
226                      .. cycle;
227                 unfill z1l
228                        .. z2l
229                        .. z3l
230                        .. z4l
231                        .. cycle;
232         else:
233                 pickup pencircle xscaled accreg_linethickness yscaled lt;
234                 draw z1
235                      .. z2
236                      .. z3
237                      .. z4
238                      .. cycle;
239         fi;
240
241         pat := z4{right}
242                .. z1{up}
243                .. {left}z2;
244
245         pickup penrazor scaled lt rotated 90;
246
247         top z5 = pat intersectionpoint ((0, lh + lt) -- (w, lh + lt));
248         z6 = z5 xscaled -1;
249         bot z7 = pat intersectionpoint ((0, 3 lh) -- (w, 3 lh));
250         z8 = z7 xscaled -1;
251
252         labels (5, 6, 7, 8);
253
254         draw z1
255              -- z3;
256         draw z5
257              -- z6;
258         draw z7
259              -- z8;
260 fet_endchar;
261
262
263 fet_beginchar ("accordion register bayanbass", "bayanbass")
264         save lh, lt;
265
266         lh = vround accreg_lh;
267         lt = vround accreg_linethickness;
268
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#);
273
274         local_copy (transform)(currenttransform);
275         currenttransform :=
276            currenttransform shifted (0, -vround (0.5 accreg_linethickness));
277
278         h := 3 lh + lt;
279
280         draw_rounded_block ((-w, 0), (-w + lt, h), lt);
281         draw_rounded_block ((w - lt, 0), (w, h), lt);
282
283         pickup penrazor scaled lt rotated 90;
284
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);
289
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);
294
295         draw z1
296              -- z5;
297         draw z2
298              -- z6;
299         draw z3
300              -- z7;
301         draw z4
302              -- z8;
303 fet_endchar;
304
305
306 def def_B (expr w, h) =
307         pickup pencircle scaled 0.15 linethickness;
308
309         penpos10 (thin, -90);
310         penpos11 (thin, -90);
311         penpos12 (thick, 0);
312         penpos13 (thin, 90);
313         penpos14 (thin, 90);
314
315         penpos15 (thick, 180);
316         penpos16 (thin, -90);
317         penpos17 (thin, -90);
318         penpos18 (thick, 0);
319         penpos19 (thick, 0);
320
321         z10 = (0, 0);
322         z11 = (cOne * w, 0);
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);
328         z17 = (0, h);
329         z18 = (1.5 thick, 0);
330         z19 = (1.5 thick, h);
331 enddef;
332
333
334 def def_S (expr w, h) =
335         pickup pencircle scaled 0.03 linethickness;
336
337         penpos1 (thin, 180);
338         penpos2 (thin, -90);
339         penpos3 (thick, 0);
340         penpos4 (.5 thick, 90);
341         penpos5 (thick, 0);
342         penpos6 (thin, -90);
343         penpos7 (thin, 180);
344         penpos8 (thin, 180);
345         penpos9 (thin, 0);
346
347         z1 = (0, hs);
348         z2 = (w / 2, 0);
349         z3 = (w - .5 thick, .5 mb * h);
350         z4 = (w / 2, mb * h);
351         z5 = (.5 thick, h - .5 mt * h);
352         z6 = (w / 2, h);
353         z7 = (w, h - hs);
354         z8 = (0, y2r);
355         z9 = (w, y6l);
356
357         path bue, bueoverst;
358
359         bue := z2{left}
360                .. z1{up};
361
362         t := xpart (bue intersectiontimes (z8l -- z7l));
363
364         bueoverst := z6{right}
365                      .. z7{down};
366 enddef;
367
368
369 def def_some_vars =
370         save hs, mb, mt, thin, thick, height, width, cOne, cTwo;
371         save bx, hx;
372
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;
378
379         4 hx + bx = 1.15;
380         10 hx + bx = 1;
381         fatten := designsize * hx + bx * 1.2;
382         thick := 0.2 staff_space * fatten;
383
384         % urg: mustn't ever go thinner than blot!
385         thin# := blot_diameter#;
386         define_pixels (thin);
387
388         hs = 0.4 staff_space;
389         mb = .53;
390         mt = .47;
391         cOne = 0.65;
392         cTwo = 0.60;
393 enddef;
394
395
396 fet_beginchar ("accordion oldEE", "oldEE")
397         save r, pp, ir, lh, lt, stroke_width;
398
399         r# = staff_space#;
400         define_pixels (r);
401
402         lr = .4 staff_space - linethickness;
403         ir = .6 staff_space;
404         stroke_width = .05 staff_space + .5 linethickness;
405
406         set_char_box (r# + accreg_linethickness# / 2,
407                       r# + accreg_linethickness# / 2,
408                       0, 2 r# + 0.7 accreg_linethickness#);
409
410         z1 = (0, 0);
411         z2 = (0, ir);
412         z3 = (0, -ir);
413
414         penpos1 (blot_diameter, 0);
415         penpos2 (stroke_width + blot_diameter, 0);
416         penpos3 (stroke_width + blot_diameter, 0);
417
418         pickup pencircle scaled (lr + blot_diameter);
419
420         for pp := 0 step 45 until 135:
421                 drawdot z2 rotated pp;
422                 drawdot z3 rotated pp;
423
424                 penstroke (z2e
425                            -- z1e
426                            -- z3e) rotated pp;
427         endfor;
428
429         pickup pencircle scaled lr;
430
431         drawdot (0, 0);
432
433         currentpicture := currentpicture shifted (0, h / 2);
434
435         lh = vround (2 r);
436         lt = vround (0.7 accreg_linethickness);
437
438         h := lh + lt;
439         b := w := (lh + hround accreg_linethickness) / 2;
440
441         penpos10 (hround accreg_linethickness, 0);
442         penpos11 (lt, 90);
443         penpos12 (hround accreg_linethickness, 180);
444         penpos13 (lt, 270);
445
446         z10r = (w, h / 2);
447         z11r = (0, h);
448         z12r = (-b, h / 2);
449         z13r = (0, 0);
450
451         % penlabels (1, 2, 10, 11, 12, 13);
452
453         % mf doesn't handle pixel dropouts in outline objects, so we use
454         % `draw' if not called by mpost
455         if known miterlimit:
456                 fill z10r
457                      .. z11r
458                      .. z12r
459                      .. z13r
460                      .. cycle;
461                 unfill z10l
462                        .. z11l
463                        .. z12l
464                        .. z13l
465                        .. cycle;
466         else:
467                 pickup pencircle xscaled accreg_linethickness yscaled lt;
468                 draw z10
469                      .. z11
470                      .. z12
471                      .. z13
472                      .. cycle;
473         fi;
474 fet_endchar;
475
476
477 fet_beginchar ("accordion push", "push");
478         save width, height;
479
480         height# := 2.0 staff_space# + 3.0 stafflinethickness#;
481         width# := 0.4 height#;
482
483         define_pixels(height, width);
484
485         save linewidth;
486
487         linewidth# := stafflinethickness# + .05 staff_space#;
488         define_whole_blacker_pixels (linewidth);
489
490         set_char_box (width#, 0,
491                       0, height#);
492
493         pickup pencircle scaled linewidth;
494
495         lft x1 = -width;
496         top y1 = height;
497
498         rt x2 = 0;
499         y2 = 0.5 * (y1 + y3);
500
501         x3 = x1;
502         bot y3 = 0;
503
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;
508
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;
514
515         z4 = ((z1 - ne_offset)
516              -- (z2 - ne_offset))
517              intersectionpoint
518              ((z2 - se_offset)
519              -- (z3 - se_offset));
520
521         fill z1 + ne_offset
522              -- z2 + ne_offset
523              .. rt z2 {down}
524              .. z2 + se_offset
525              -- z3 + se_offset
526              .. z3 + sw_offset {- se_offset}
527              .. z3 - se_offset
528              -- z4
529              -- z1 - ne_offset
530              .. z1 + nw_offset {ne_offset}
531              .. cycle;
532 fet_endchar;
533
534
535 fet_beginchar ("accordion pull", "pull");
536         save width, height;
537
538         height# := 2.0 staff_space# + 3.0 stafflinethickness#;
539         width# := 0.4 height#;
540
541         define_pixels(height, width);
542
543         save linewidth;
544
545         linewidth# := stafflinethickness# + .05 staff_space#;
546         define_whole_blacker_pixels (linewidth);
547
548         set_char_box (width# - linewidth#, linewidth#,
549                       0, height#);
550
551         pickup pencircle scaled linewidth;
552
553         save penradius;
554         penradius := linewidth / 2;
555
556         rt x1 = linewidth;
557         bot y1 = 0;
558
559         x2 = x1;
560         top y2 = height;
561
562         lft x3= -width + linewidth;
563         y3 = y2;
564
565         x4 = x3;
566         y4 = y2 - linewidth;
567
568         x5 = x1;
569         y5 = y4;
570
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}
581              .. cycle;
582 fet_endchar;
583
584 fet_endgroup ("accordion");