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