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--2014 Jan Nieuwenhuizen <janneke@gnu.org>
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.
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.
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/>.
19 % this file is included by feta-scripts.mf
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);
26 trill_thick = 1/2 staff_space;
27 trill_overlap = 1/6 staff_space;
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);
35 trill_ne := unitvector ((2, 3));
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.
42 % `ending' is either 0 for none, 1 for left, or 2 for right.
45 def draw_trillelement (expr offset, ending) =
49 save nw, pat, nw_dist, ne_dist;
50 pair nw, nw_dist, ne_dist;
53 pickup pencircle scaled trill_thin;
57 z3 = whatever * trill_ne + z1;
58 top y3 = vround trill_height;
59 z2 = z3 - (trill_thick - trill_thin) * trill_ne;
61 bot z3' = (top z3) scaled -1;
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;
67 z5 = whatever * trill_ne + (z1 - nw_dist);
68 z5 = whatever * nw + (z3' - ne_dist);
71 -- (z1 - nw_dist){-trill_ne}
72 -- (z1 + nw_dist){trill_ne}
73 -- (z3 + nw_dist){trill_ne}
75 .. (z3 + ne_dist){-nw};
77 -- pat scaled -1 shifted (-feta_eps, -feta_eps)
79 pat := pat shifted (offset, 0);
82 z4 = z1 - trill_ne * trill_overlap;
83 x4 := hround (x4 + 0.5 trill_thin) - 0.5 trill_thin;
85 pat := (z4 - nw_dist){-trill_ne}
88 .. (z4 + nw_dist){trill_ne}
89 -- (z1 + nw_dist){trill_ne}
90 -- (z1 - nw_dist){-trill_ne}
94 fill pat shifted (offset, 0);
96 pat := pat scaled -1 shifted (-feta_eps, -feta_eps);
97 fill pat shifted (offset, 0);
103 fet_beginchar ("trilelement", "trilelement");
104 set_char_box (.5 trill_width#, .5 trill_width#,
105 trill_height#, trill_height#);
107 draw_trillelement (0, 0);
108 labels (1, 2, 3, 3', 4, 5, 5');
112 fet_beginchar ("prall", "prall");
113 set_char_box (trill_width#, trill_width#,
114 trill_height#, trill_height#);
116 draw_trillelement (-hround (.5 trill_width), 1);
117 draw_trillelement (-hround (.5 trill_width) + trill_width, 2);
121 fet_beginchar ("mordent", "mordent");
122 set_char_box (trill_width#, trill_width#,
123 4/3 trill_height#, 4/3 trill_height#);
125 draw_trillelement (-hround (.5 trill_width), 1);
126 draw_trillelement (-hround (.5 trill_width) + trill_width, 2);
130 pickup pencircle scaled trill_stemwidth;
137 draw_gridline (z2, z1, trill_stemwidth);
143 fet_beginchar ("prallprall", "prallprall");
144 set_char_box (1.5 trill_width#, 1.5 trill_width#,
145 trill_height#, trill_height#);
147 draw_trillelement (-trill_width, 1);
148 draw_trillelement (0, 0);
149 draw_trillelement (trill_width, 2);
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#);
157 draw_trillelement (-trill_width, 1);
158 draw_trillelement (0, 0);
159 draw_trillelement (trill_width, 2);
163 pickup pencircle scaled trill_stemwidth;
168 x2 = good.x (.5 trill_width);
170 draw_gridline (z2, z1, trill_stemwidth);
177 picture remember_pic;
180 fet_beginchar ("upprall", "upprall");
181 set_char_box (1.5 trill_width#, 1.5 trill_width#,
182 trill_height#, trill_height#);
184 draw_trillelement (-trill_width, 1);
185 draw_trillelement (0, 0);
186 draw_trillelement (trill_width, 2);
188 z11 = z4 shifted (-trill_width, 0);
189 z12 = z11 + (0, -2 trill_height);
191 penpos11 (trill_thin, angle (trill_ne) - 90);
192 penpos12 (trill_thin, angle (trill_ne yscaled -1) + 90);
195 pickup pencircle scaled trill_stemwidth;
198 .. z12l{trill_ne yscaled -1}
201 .. z12r{-trill_ne yscaled -1}
205 remember_pic := currentpicture;
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#);
213 currentpicture := remember_pic;
217 pickup pencircle scaled trill_stemwidth;
222 x2 = good.x (.5 trill_width);
224 draw_gridline (z2, z1, trill_stemwidth);
230 fet_beginchar ("pralldown", "pralldown");
231 set_char_box (1.5 trill_width#, 1.5 trill_width#,
232 trill_height#, trill_height#);
234 currentpicture := remember_pic xscaled -1;
238 fet_beginchar ("downprall", "downprall");
239 set_char_box (1.5 trill_width#, 1.5 trill_width#,
240 trill_height#, trill_height#);
242 draw_trillelement (-trill_width, 1);
243 draw_trillelement (0, 0);
244 draw_trillelement (trill_width, 2);
246 z11 = z4 shifted (-trill_width, 0);
247 z12 = z11 + (0, 2 trill_height);
249 penpos11 (trill_thin, angle (trill_ne xscaled -1) - 90);
250 penpos12 (trill_thin, angle (trill_ne) - 90);
253 pickup pencircle scaled trill_stemwidth;
255 fill z11l{trill_ne xscaled -1}
260 .. z11r{-trill_ne xscaled -1}
263 remember_pic := currentpicture;
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#);
271 currentpicture := remember_pic;
275 pickup pencircle scaled trill_stemwidth;
280 x2 = good.x (.5 trill_width);
282 draw_gridline (z2, z1, trill_stemwidth);
288 fet_beginchar ("prallup", "prallup");
289 set_char_box (1.5 trill_width#, 1.5 trill_width#,
290 trill_height#, trill_height#);
292 currentpicture := remember_pic xscaled -1;
296 fet_beginchar ("lineprall", "lineprall");
297 set_char_box (1.5 trill_width#, 1.5 trill_width#,
298 trill_height#, 4 trill_height#);
300 draw_trillelement (-trill_width, 1);
302 labels (1, 2, 3, 3', 4, 5, 5');
304 pickup pencircle scaled trill_stemwidth;
306 penpos10 (trill_stemwidth, 0);
307 penpos11 (trill_stemwidth, 0);
309 x10l = x4 - .5 trill_thin - trill_width;
322 draw_trillelement (0, 0);
323 draw_trillelement (trill_width, 2);