1 % Feta (not the Font-En-Tja) music font -- implement trill symbols
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1998--2010 Jan Nieuwenhuizen <janneke@gnu.org>
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.
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.
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/>.
20 % this file is included by feta-scripts.mf
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);
27 trill_thick = 1/2 staff_space;
28 trill_overlap = 1/6 staff_space;
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);
36 trill_ne := unitvector ((2, 3));
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.
43 % `ending' is either 0 for none, 1 for left, or 2 for right.
46 def draw_trillelement (expr offset, ending) =
50 save nw, pat, nw_dist, ne_dist;
51 pair nw, nw_dist, ne_dist;
54 pickup pencircle scaled trill_thin;
58 z3 = whatever * trill_ne + z1;
59 top y3 = vround trill_height;
60 z2 = z3 - (trill_thick - trill_thin) * trill_ne;
62 bot z3' = (top z3) scaled -1;
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;
68 z5 = whatever * trill_ne + (z1 - nw_dist);
69 z5 = whatever * nw + (z3' - ne_dist);
72 -- (z1 - nw_dist){-trill_ne}
73 -- (z1 + nw_dist){trill_ne}
74 -- (z3 + nw_dist){trill_ne}
76 .. (z3 + ne_dist){-nw};
78 -- pat scaled -1 shifted (-feta_eps, -feta_eps)
80 pat := pat shifted (offset, 0);
83 z4 = z1 - trill_ne * trill_overlap;
84 x4 := hround (x4 + 0.5 trill_thin) - 0.5 trill_thin;
86 pat := (z4 - nw_dist){-trill_ne}
89 .. (z4 + nw_dist){trill_ne}
90 -- (z1 + nw_dist){trill_ne}
91 -- (z1 - nw_dist){-trill_ne}
95 fill pat shifted (offset, 0);
97 pat := pat scaled -1 shifted (-feta_eps, -feta_eps);
98 fill pat shifted (offset, 0);
104 fet_beginchar ("trilelement", "trilelement");
105 set_char_box (.5 trill_width#, .5 trill_width#,
106 trill_height#, trill_height#);
108 draw_trillelement (0, 0);
109 labels (1, 2, 3, 3', 4, 5, 5');
113 fet_beginchar ("prall", "prall");
114 set_char_box (trill_width#, trill_width#,
115 trill_height#, trill_height#);
117 draw_trillelement (-hround (.5 trill_width), 1);
118 draw_trillelement (-hround (.5 trill_width) + trill_width, 2);
122 fet_beginchar ("mordent", "mordent");
123 set_char_box (trill_width#, trill_width#,
124 4/3 trill_height#, 4/3 trill_height#);
126 draw_trillelement (-hround (.5 trill_width), 1);
127 draw_trillelement (-hround (.5 trill_width) + trill_width, 2);
131 pickup pencircle scaled trill_stemwidth;
138 draw_gridline (z2, z1, trill_stemwidth);
144 fet_beginchar ("prallprall", "prallprall");
145 set_char_box (1.5 trill_width#, 1.5 trill_width#,
146 trill_height#, trill_height#);
148 draw_trillelement (-trill_width, 1);
149 draw_trillelement (0, 0);
150 draw_trillelement (trill_width, 2);
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#);
158 draw_trillelement (-trill_width, 1);
159 draw_trillelement (0, 0);
160 draw_trillelement (trill_width, 2);
164 pickup pencircle scaled trill_stemwidth;
169 x2 = good.x (.5 trill_width);
171 draw_gridline (z2, z1, trill_stemwidth);
178 picture remember_pic;
181 fet_beginchar ("upprall", "upprall");
182 set_char_box (1.5 trill_width#, 1.5 trill_width#,
183 trill_height#, trill_height#);
185 draw_trillelement (-trill_width, 1);
186 draw_trillelement (0, 0);
187 draw_trillelement (trill_width, 2);
189 z11 = z4 shifted (-trill_width, 0);
190 z12 = z11 + (0, -2 trill_height);
192 penpos11 (trill_thin, angle (trill_ne) - 90);
193 penpos12 (trill_thin, angle (trill_ne yscaled -1) + 90);
196 pickup pencircle scaled trill_stemwidth;
199 .. z12l{trill_ne yscaled -1}
202 .. z12r{-trill_ne yscaled -1}
206 remember_pic := currentpicture;
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#);
214 currentpicture := remember_pic;
218 pickup pencircle scaled trill_stemwidth;
223 x2 = good.x (.5 trill_width);
225 draw_gridline (z2, z1, trill_stemwidth);
231 fet_beginchar ("pralldown", "pralldown");
232 set_char_box (1.5 trill_width#, 1.5 trill_width#,
233 trill_height#, trill_height#);
235 currentpicture := remember_pic xscaled -1;
239 fet_beginchar ("downprall", "downprall");
240 set_char_box (1.5 trill_width#, 1.5 trill_width#,
241 trill_height#, trill_height#);
243 draw_trillelement (-trill_width, 1);
244 draw_trillelement (0, 0);
245 draw_trillelement (trill_width, 2);
247 z11 = z4 shifted (-trill_width, 0);
248 z12 = z11 + (0, 2 trill_height);
250 penpos11 (trill_thin, angle (trill_ne xscaled -1) - 90);
251 penpos12 (trill_thin, angle (trill_ne) - 90);
254 pickup pencircle scaled trill_stemwidth;
256 fill z11l{trill_ne xscaled -1}
261 .. z11r{-trill_ne xscaled -1}
264 remember_pic := currentpicture;
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#);
272 currentpicture := remember_pic;
276 pickup pencircle scaled trill_stemwidth;
281 x2 = good.x (.5 trill_width);
283 draw_gridline (z2, z1, trill_stemwidth);
289 fet_beginchar ("prallup", "prallup");
290 set_char_box (1.5 trill_width#, 1.5 trill_width#,
291 trill_height#, trill_height#);
293 currentpicture := remember_pic xscaled -1;
297 fet_beginchar ("lineprall", "lineprall");
298 set_char_box (1.5 trill_width#, 1.5 trill_width#,
299 trill_height#, 4 trill_height#);
301 draw_trillelement (-trill_width, 1);
303 labels (1, 2, 3, 3', 4, 5, 5');
305 pickup pencircle scaled trill_stemwidth;
307 penpos10 (trill_stemwidth, 0);
308 penpos11 (trill_stemwidth, 0);
310 x10l = x4 - .5 trill_thin - trill_width;
323 draw_trillelement (0, 0);
324 draw_trillelement (trill_width, 2);