]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-accordion.mf
Add '-dcrop' option to ps and svg backends
[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--2015 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.7 accreg_linethickness# / 2,
44                       2 r# + 0.7 accreg_linethickness# / 2);
45
46         lh = vround (2/3 r);
47         lt = vround (0.7 accreg_linethickness);
48         d := vround (0.7 accreg_linethickness / 2);
49         h := 3 lh + lt - d;
50         b := w := (3 lh + hround accreg_linethickness) / 2;
51
52         penpos1 (hround accreg_linethickness, 0);
53         penpos2 (lt, 90);
54         penpos3 (hround accreg_linethickness, 180);
55         penpos4 (lt, 270);
56
57         z1r = (w, 0.5 [-d, h]);
58         z2r = (0, h);
59         z3r = (-b, 0.5 [-d, h]);
60         z4r = (0, -d);
61
62         penlabels (1, 2, 3, 4);
63
64         % mf doesn't handle pixel dropouts in outline objects, so we use
65         % `draw' if not called by mpost
66         if known miterlimit:
67                 fill z1r
68                      .. z2r
69                      .. z3r
70                      .. z4r
71                      .. cycle;
72                 unfill z1l
73                        .. z2l
74                        .. z3l
75                        .. z4l
76                        .. cycle;
77         else:
78                 pickup pencircle xscaled accreg_linethickness yscaled lt;
79                 draw z1
80                      .. z2
81                      .. z3
82                      .. z4
83                      .. cycle;
84         fi;
85
86         pat := z4{right}
87                .. z1{up}
88                .. {left}z2;
89
90         pickup penrazor scaled lt rotated 90;
91
92         top z5 = pat intersectionpoint ((0, lh + lt - d) -- (w, lh + lt - d));
93         z6 = z5 xscaled -1;
94         bot z7 = pat intersectionpoint ((0, 2 lh - d) -- (w, 2 lh - d));
95         z8 = z7 xscaled -1;
96
97         labels (5, 6, 7, 8);
98
99         draw z5
100              -- z6;
101         draw z7
102              -- z8;
103 fet_endchar;
104
105
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);
109
110         pickup pencircle scaled accreg_dot_size;
111
112         rt x0 = hround (accreg_dot_size / 2);
113         top y0 = vround (accreg_dot_size / 2);
114
115         drawdot z0;
116 fet_endchar;
117
118
119 fet_beginchar ("accordion register freebass", "freebass")
120         save r, lh, lt;
121
122         r# = accreg_lh#;
123         define_pixels (r);
124
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);
129
130         lh = vround r;
131         lt = vround (0.7 accreg_linethickness);
132         d := vround (0.7 accreg_linethickness / 2);
133         h := 2 lh + lt - d;
134         b := w := (2 lh + hround accreg_linethickness) / 2;
135
136         penpos1 (hround accreg_linethickness, 0);
137         penpos2 (lt, 90);
138         penpos3 (accreg_linethickness, 180);
139         penpos4 (lt, 270);
140
141         z1r = (w, 0.5 [-d, h]);
142         z2r = (0, h);
143         z3r = (-b, 0.5 [-d, h]);
144         z4r = (0, -d);
145
146         penlabels (1, 2, 3, 4);
147
148         % mf doesn't handle pixel dropouts in outline objects, so we use
149         % `draw' if not called by mpost
150         if known miterlimit:
151                 fill z1r
152                      .. z2r
153                      .. z3r
154                      .. z4r
155                      .. cycle;
156                 unfill z1l
157                        .. z2l
158                        .. z3l
159                        .. z4l
160                        .. cycle;
161         else:
162                 pickup pencircle xscaled accreg_linethickness yscaled lt;
163                 draw z1
164                      .. z2
165                      .. z3
166                      .. z4
167                      .. cycle;
168         fi;
169
170         pickup penrazor scaled lt rotated 90;
171
172         draw z1
173              -- z3;
174 fet_endchar;
175
176
177 fet_beginchar ("accordion register stdbass", "stdbass")
178         save r, p, lh, lt;
179         path pat;
180
181         r# = 2 accreg_lh#;
182         define_pixels (r);
183
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);
188
189         lh = vround (1/2 r);
190         lt = vround (0.7 accreg_linethickness);
191         d := vround (0.7 accreg_linethickness / 2);
192         h := 4 lh + lt - d;
193         b := w := (4 lh + hround accreg_linethickness) / 2;
194
195         penpos1 (hround accreg_linethickness, 0);
196         penpos2 (lt, 90);
197         penpos3 (hround accreg_linethickness, 180);
198         penpos4 (lt, 270);
199
200         z1r = (w, 0.5 [-d, h]);
201         z2r = (0, h);
202         z3r = (-b, 0.5 [-d, h]);
203         z4r = (0, -d);
204
205         penlabels (1, 2, 3, 4);
206
207         % mf doesn't handle pixel dropouts in outline objects, so we use
208         % `draw' if not called by mpost
209         if known miterlimit:
210                 fill z1r
211                      .. z2r
212                      .. z3r
213                      .. z4r
214                      .. cycle;
215                 unfill z1l
216                        .. z2l
217                        .. z3l
218                        .. z4l
219                        .. cycle;
220         else:
221                 pickup pencircle xscaled accreg_linethickness yscaled lt;
222                 draw z1
223                      .. z2
224                      .. z3
225                      .. z4
226                      .. cycle;
227         fi;
228
229         pat := z4{right}
230                .. z1{up}
231                .. {left}z2;
232
233         pickup penrazor scaled lt rotated 90;
234
235         top z5 = pat intersectionpoint ((0, lh + lt - d) -- (w, lh + lt - d));
236         z6 = z5 xscaled -1;
237         bot z7 = pat intersectionpoint ((0, 3 lh - d) -- (w, 3 lh - d));
238         z8 = z7 xscaled -1;
239
240         labels (5, 6, 7, 8);
241
242         draw z1
243              -- z3;
244         draw z5
245              -- z6;
246         draw z7
247              -- z8;
248 fet_endchar;
249
250
251 fet_beginchar ("accordion register bayanbass", "bayanbass")
252         save lh, lt;
253
254         lh = vround accreg_lh;
255         lt = vround accreg_linethickness;
256
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);
261
262         d := vround (accreg_linethickness# / 2);
263         h := 3 lh + lt - d;
264
265         draw_rounded_block ((-w, -d), (-w + lt, h), lt);
266         draw_rounded_block ((w - lt, -d), (w, h), lt);
267
268         pickup penrazor scaled lt rotated 90;
269
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);
274
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);
279
280         draw z1
281              -- z5;
282         draw z2
283              -- z6;
284         draw z3
285              -- z7;
286         draw z4
287              -- z8;
288 fet_endchar;
289
290
291 def def_B (expr w, h) =
292         pickup pencircle scaled 0.15 linethickness;
293
294         penpos10 (thin, -90);
295         penpos11 (thin, -90);
296         penpos12 (thick, 0);
297         penpos13 (thin, 90);
298         penpos14 (thin, 90);
299
300         penpos15 (thick, 180);
301         penpos16 (thin, -90);
302         penpos17 (thin, -90);
303         penpos18 (thick, 0);
304         penpos19 (thick, 0);
305
306         z10 = (0, 0);
307         z11 = (cOne * w, 0);
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);
313         z17 = (0, h);
314         z18 = (1.5 thick, 0);
315         z19 = (1.5 thick, h);
316 enddef;
317
318
319 def def_S (expr w, h) =
320         pickup pencircle scaled 0.03 linethickness;
321
322         penpos1 (thin, 180);
323         penpos2 (thin, -90);
324         penpos3 (thick, 0);
325         penpos4 (.5 thick, 90);
326         penpos5 (thick, 0);
327         penpos6 (thin, -90);
328         penpos7 (thin, 180);
329         penpos8 (thin, 180);
330         penpos9 (thin, 0);
331
332         z1 = (0, hs);
333         z2 = (w / 2, 0);
334         z3 = (w - .5 thick, .5 mb * h);
335         z4 = (w / 2, mb * h);
336         z5 = (.5 thick, h - .5 mt * h);
337         z6 = (w / 2, h);
338         z7 = (w, h - hs);
339         z8 = (0, y2r);
340         z9 = (w, y6l);
341
342         path bue, bueoverst;
343
344         bue := z2{left}
345                .. z1{up};
346
347         t := xpart (bue intersectiontimes (z8l -- z7l));
348
349         bueoverst := z6{right}
350                      .. z7{down};
351 enddef;
352
353
354 def def_some_vars =
355         save hs, mb, mt, thin, thick, height, width, cOne, cTwo;
356         save bx, hx;
357
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;
363
364         4 hx + bx = 1.15;
365         10 hx + bx = 1;
366         fatten := designsize * hx + bx * 1.2;
367         thick := 0.2 staff_space * fatten;
368
369         % urg: mustn't ever go thinner than blot!
370         thin# := blot_diameter#;
371         define_pixels (thin);
372
373         hs = 0.4 staff_space;
374         mb = .53;
375         mt = .47;
376         cOne = 0.65;
377         cTwo = 0.60;
378 enddef;
379
380
381 fet_beginchar ("accordion oldEE", "oldEE")
382         save r, pp, ir, lh, lt, stroke_width;
383
384         r# = staff_space#;
385         define_pixels (r);
386
387         lr = .4 staff_space - linethickness;
388         ir = .6 staff_space;
389         stroke_width = .05 staff_space + .5 linethickness;
390
391         set_char_box (r# + accreg_linethickness# / 2,
392                       r# + accreg_linethickness# / 2,
393                       0, 2 r# + 0.7 accreg_linethickness#);
394
395         z1 = (0, 0);
396         z2 = (0, ir);
397         z3 = (0, -ir);
398
399         penpos1 (blot_diameter, 0);
400         penpos2 (stroke_width + blot_diameter, 0);
401         penpos3 (stroke_width + blot_diameter, 0);
402
403         pickup pencircle scaled (lr + blot_diameter);
404
405         for pp := 0 step 45 until 135:
406                 drawdot z2 rotated pp;
407                 drawdot z3 rotated pp;
408
409                 penstroke (z2e
410                            -- z1e
411                            -- z3e) rotated pp;
412         endfor;
413
414         pickup pencircle scaled lr;
415
416         drawdot (0, 0);
417
418         currentpicture := currentpicture shifted (0, h / 2);
419
420         lh = vround (2 r);
421         lt = vround (0.7 accreg_linethickness);
422
423         h := lh + lt;
424         b := w := (lh + hround accreg_linethickness) / 2;
425
426         penpos10 (hround accreg_linethickness, 0);
427         penpos11 (lt, 90);
428         penpos12 (hround accreg_linethickness, 180);
429         penpos13 (lt, 270);
430
431         z10r = (w, h / 2);
432         z11r = (0, h);
433         z12r = (-b, h / 2);
434         z13r = (0, 0);
435
436         % penlabels (1, 2, 10, 11, 12, 13);
437
438         % mf doesn't handle pixel dropouts in outline objects, so we use
439         % `draw' if not called by mpost
440         if known miterlimit:
441                 fill z10r
442                      .. z11r
443                      .. z12r
444                      .. z13r
445                      .. cycle;
446                 unfill z10l
447                        .. z11l
448                        .. z12l
449                        .. z13l
450                        .. cycle;
451         else:
452                 pickup pencircle xscaled accreg_linethickness yscaled lt;
453                 draw z10
454                      .. z11
455                      .. z12
456                      .. z13
457                      .. cycle;
458         fi;
459 fet_endchar;
460
461
462 fet_beginchar ("accordion push", "push");
463         save width, height;
464
465         height# := 2.0 staff_space# + 3.0 stafflinethickness#;
466         width# := 0.4 height#;
467
468         define_pixels(height, width);
469
470         save linewidth;
471
472         linewidth# := stafflinethickness# + .05 staff_space#;
473         define_whole_blacker_pixels (linewidth);
474
475         set_char_box (width#, 0,
476                       0, height#);
477
478         pickup pencircle scaled linewidth;
479
480         lft x1 = -width;
481         top y1 = height;
482
483         rt x2 = 0;
484         y2 = 0.5 * (y1 + y3);
485
486         x3 = x1;
487         bot y3 = 0;
488
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;
493
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;
499
500         z4 = ((z1 - ne_offset)
501              -- (z2 - ne_offset))
502              intersectionpoint
503              ((z2 - se_offset)
504              -- (z3 - se_offset));
505
506         fill z1 + ne_offset
507              -- z2 + ne_offset
508              .. rt z2 {down}
509              .. z2 + se_offset
510              -- z3 + se_offset
511              .. z3 + sw_offset {- se_offset}
512              .. z3 - se_offset
513              -- z4
514              -- z1 - ne_offset
515              .. z1 + nw_offset {ne_offset}
516              .. cycle;
517 fet_endchar;
518
519
520 fet_beginchar ("accordion pull", "pull");
521         save width, height;
522
523         height# := 2.0 staff_space# + 3.0 stafflinethickness#;
524         width# := 0.4 height#;
525
526         define_pixels(height, width);
527
528         save linewidth;
529
530         linewidth# := stafflinethickness# + .05 staff_space#;
531         define_whole_blacker_pixels (linewidth);
532
533         set_char_box (width# - linewidth#, linewidth#,
534                       0, height#);
535
536         pickup pencircle scaled linewidth;
537
538         save penradius;
539         penradius := linewidth / 2;
540
541         rt x1 = linewidth;
542         bot y1 = 0;
543
544         x2 = x1;
545         top y2 = height;
546
547         lft x3= -width + linewidth;
548         y3 = y2;
549
550         x4 = x3;
551         y4 = y2 - linewidth;
552
553         x5 = x1;
554         y5 = y4;
555
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}
566              .. cycle;
567 fet_endchar;
568
569 fet_endgroup ("accordion");