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