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