]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-trills.mf
Add '-dcrop' option to ps and svg backends
[lilypond.git] / mf / feta-trills.mf
1 % Feta (not the Font-En-Tja) music font --  implement trill symbols
2 % This file is part of LilyPond, the GNU music typesetter.
3 %
4 % Copyright (C) 1998--2015 Jan Nieuwenhuizen <janneke@gnu.org>
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 under the SIL Open Font License.
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 % this file is included by feta-scripts.mf
20
21 trill_thin# = 0.1 staff_space# + 0.6 stafflinethickness#;
22 trill_stemwidth# = trill_thin#;
23 define_pixels (trill_thin);
24 define_whole_blacker_pixels (trill_stemwidth);
25
26 trill_thick = 1/2 staff_space;
27 trill_overlap = 1/6 staff_space;
28
29 trill_width# = 5/6 staff_space#;
30 trill_height# = 1/2 staff_space#;
31 define_pixels (trill_height);
32 define_whole_pixels (trill_width);
33
34 pair trill_ne;
35 trill_ne := unitvector ((2, 3));
36
37
38 %
39 % The trill element sticks out on both the left and right side
40 % of the normal bbox, so you can glue them together easily.
41 %
42 % `ending' is either 0 for none, 1 for left, or 2 for right.
43 %
44
45 def draw_trillelement (expr offset, ending) =
46         clearxy;
47
48 begingroup;
49         save nw, pat, nw_dist, ne_dist;
50         pair nw, nw_dist, ne_dist;
51         path pat;
52
53         pickup pencircle scaled trill_thin;
54
55         x1 = -.5 trill_width;
56         y1 = 0;
57         z3 = whatever * trill_ne + z1;
58         top y3 = vround trill_height;
59         z2 = z3 - (trill_thick - trill_thin) * trill_ne;
60
61         bot z3' = (top z3) scaled -1;
62
63         nw = unitvector (z2 - z3');
64         ne_dist = (nw rotated -90) * 0.5 trill_thin;
65         nw_dist = (trill_ne rotated 90) * 0.5 trill_thin;
66
67         z5 = whatever * trill_ne + (z1 - nw_dist);
68         z5 = whatever * nw + (z3' - ne_dist);
69
70         pat := z5
71                -- (z1 - nw_dist){-trill_ne}
72                -- (z1 + nw_dist){trill_ne}
73                -- (z3 + nw_dist){trill_ne}
74                .. top z3{right}
75                .. (z3 + ne_dist){-nw};
76         pat := pat
77                -- pat scaled -1 shifted (-feta_eps, -feta_eps)
78                -- cycle;
79         pat := pat shifted (offset, 0);
80         fill pat;
81
82         z4 = z1 - trill_ne * trill_overlap;
83         x4 := hround (x4 + 0.5 trill_thin) - 0.5 trill_thin;
84
85         pat := (z4 - nw_dist){-trill_ne}
86                .. bot z4{left}
87                .. lft z4{up}
88                .. (z4 + nw_dist){trill_ne}
89                -- (z1 + nw_dist){trill_ne}
90                -- (z1 - nw_dist){-trill_ne}
91                -- cycle;
92
93         if ending = 1:
94                 fill pat shifted (offset, 0);
95         elseif ending = 2:
96                 pat := pat scaled -1 shifted (-feta_eps, -feta_eps);
97                 fill pat shifted (offset, 0);
98         fi;
99 endgroup;
100 enddef;
101
102
103 fet_beginchar ("trilelement", "trilelement");
104         set_char_box (.5 trill_width#, .5 trill_width#,
105                       trill_height#, trill_height#);
106
107         draw_trillelement (0, 0);
108         labels (1, 2, 3, 3', 4, 5, 5');
109 fet_endchar;
110
111
112 fet_beginchar ("prall", "prall");
113         set_char_box (trill_width#, trill_width#,
114                       trill_height#, trill_height#);
115
116         draw_trillelement (-hround (.5 trill_width), 1);
117         draw_trillelement (-hround (.5 trill_width) + trill_width, 2);
118 fet_endchar;
119
120
121 fet_beginchar ("mordent", "mordent");
122         set_char_box (trill_width#, trill_width#,
123                       4/3 trill_height#, 4/3 trill_height#);
124
125         draw_trillelement (-hround (.5 trill_width), 1);
126         draw_trillelement (-hround (.5 trill_width) + trill_width, 2);
127
128         clearxy;
129
130         pickup pencircle scaled trill_stemwidth;
131
132         top y1 = h;
133         bot y2 = -d;
134         x1 = x2;
135         x2 = 0;
136
137         draw_gridline (z2, z1, trill_stemwidth);
138
139         labels (1, 2);
140 fet_endchar;
141
142
143 fet_beginchar ("prallprall", "prallprall");
144         set_char_box (1.5 trill_width#, 1.5 trill_width#,
145                       trill_height#, trill_height#);
146
147         draw_trillelement (-trill_width, 1);
148         draw_trillelement (0, 0);
149         draw_trillelement (trill_width, 2);
150 fet_endchar;
151
152
153 fet_beginchar ("prallmordent", "prallmordent");
154         set_char_box (1.5 trill_width#, 1.5 trill_width#,
155                       4/3 trill_height#, 4/3 trill_height#);
156
157         draw_trillelement (-trill_width, 1);
158         draw_trillelement (0, 0);
159         draw_trillelement (trill_width, 2);
160
161         clearxy;
162
163         pickup pencircle scaled trill_stemwidth;
164
165         top y1 = h;
166         bot y2 = -d;
167         x1 = x2 ;
168         x2 = good.x (.5 trill_width);
169
170         draw_gridline (z2, z1, trill_stemwidth);
171
172         labels (1, 2);
173 fet_endchar;
174
175
176 save remember_pic;
177 picture remember_pic;
178
179
180 fet_beginchar ("upprall", "upprall");
181         set_char_box (1.5 trill_width#, 1.5 trill_width#,
182                       trill_height#, trill_height#);
183
184         draw_trillelement (-trill_width, 1);
185         draw_trillelement (0, 0);
186         draw_trillelement (trill_width, 2);
187
188         z11 = z4 shifted (-trill_width, 0);
189         z12 = z11 + (0, -2 trill_height);
190
191         penpos11 (trill_thin, angle (trill_ne) - 90);
192         penpos12 (trill_thin, angle (trill_ne yscaled -1) + 90);
193         penlabels (11, 12);
194
195         pickup pencircle scaled trill_stemwidth;
196
197         fill z11l{-trill_ne}
198              .. z12l{trill_ne yscaled -1}
199              .. bot z12
200              .. rt z12
201              .. z12r{-trill_ne yscaled -1}
202              .. z11r{trill_ne}
203              -- cycle;
204
205         remember_pic := currentpicture;
206 fet_endchar;
207
208
209 fet_beginchar ("upmordent", "upmordent");
210         set_char_box (1.5 trill_width#, 1.5 trill_width#,
211                       4/3 trill_height#, 4/3 trill_height#);
212
213         currentpicture := remember_pic;
214
215         clearxy;
216
217         pickup pencircle scaled trill_stemwidth;
218
219         top y1 = h;
220         bot y2 = -d;
221         x1 = x2;
222         x2 = good.x (.5 trill_width);
223
224         draw_gridline (z2, z1, trill_stemwidth);
225
226         labels (1, 2);
227 fet_endchar;
228
229
230 fet_beginchar ("pralldown", "pralldown");
231         set_char_box (1.5 trill_width#, 1.5 trill_width#,
232                       trill_height#, trill_height#);
233
234         currentpicture := remember_pic xscaled -1;
235 fet_endchar;
236
237
238 fet_beginchar ("downprall", "downprall");
239         set_char_box (1.5 trill_width#, 1.5 trill_width#,
240                       trill_height#, trill_height#);
241
242         draw_trillelement (-trill_width, 1);
243         draw_trillelement (0, 0);
244         draw_trillelement (trill_width, 2);
245
246         z11 = z4 shifted (-trill_width, 0);
247         z12 = z11 + (0, 2 trill_height);
248
249         penpos11 (trill_thin, angle (trill_ne xscaled -1) - 90);
250         penpos12 (trill_thin, angle (trill_ne) - 90);
251         penlabels (11, 12);
252
253         pickup pencircle scaled trill_stemwidth;
254
255         fill z11l{trill_ne xscaled -1}
256              .. z12l{trill_ne}
257              .. top z12
258              .. rt z12
259              .. z12r{-trill_ne}
260              .. z11r{-trill_ne xscaled -1}
261              -- cycle;
262
263         remember_pic := currentpicture;
264 fet_endchar;
265
266
267 fet_beginchar ("downmordent", "downmordent");
268         set_char_box (1.5 trill_width#, 1.5 trill_width#,
269                       4/3 trill_height#, 4/3 trill_height#);
270
271         currentpicture := remember_pic;
272
273         clearxy;
274
275         pickup pencircle scaled trill_stemwidth;
276
277         top y1 = h;
278         bot y2 = -d;
279         x1 = x2;
280         x2 = good.x (.5 trill_width);
281
282         draw_gridline (z2, z1, trill_stemwidth);
283
284         labels (1, 2);
285 fet_endchar;
286
287
288 fet_beginchar ("prallup", "prallup");
289         set_char_box (1.5 trill_width#, 1.5 trill_width#,
290                       trill_height#, trill_height#);
291
292         currentpicture := remember_pic xscaled -1;
293 fet_endchar;
294
295
296 fet_beginchar ("lineprall", "lineprall");
297         set_char_box (1.5 trill_width#, 1.5 trill_width#,
298                       trill_height#, 4 trill_height#);
299
300         draw_trillelement (-trill_width, 1);
301
302         labels (1, 2, 3, 3', 4, 5, 5');
303
304         pickup pencircle scaled trill_stemwidth;
305
306         penpos10 (trill_stemwidth, 0);
307         penpos11 (trill_stemwidth, 0);
308
309         x10l = x4 - .5 trill_thin - trill_width;
310         y10 = y4;
311         z11 = z10 + (0, h);
312
313         penlabels (10, 11);
314
315         fill z11l
316              .. top z11
317              .. z11r
318              -- z10r
319              -- z10l
320              -- cycle;
321
322         draw_trillelement (0, 0);
323         draw_trillelement (trill_width, 2);
324 fet_endchar;