]> git.donarmstrong.com Git - lilypond.git/blob - mf/parmesan-flags.mf
Add '-dcrop' option to ps and svg backends
[lilypond.git] / mf / parmesan-flags.mf
1 % Feta (not the Font-En-Tja) music font --  ancient flags
2 % This file is part of LilyPond, the GNU music typesetter.
3 %
4 % Copyright (C) 2001--2015 Juergen Reuter <reuter@ipd.uka.de>
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 fet_begingroup ("flags");
20
21 save between_staff_lines, on_staff_line, anywhere;
22
23 between_staff_lines := 0;
24 on_staff_line := 1;
25 anywhere := 2;
26
27 save dir_up, dir_down;
28
29 dir_up := 1;
30 dir_down := -1;
31
32
33 %%%%%%%%
34 %
35 %
36 %
37 % Mensural Notation
38 %
39 %
40 %
41
42 def draw_mensural_outermost_flare (expr staffline_adjustment, d_) =
43     save flag_end, flag_right;
44
45         if staffline_adjustment = between_staff_lines:
46                 flag_end := 1.9;
47                 flag_right := 0.6;
48         elseif staffline_adjustment = on_staff_line:
49                 flag_end := 1.4;
50                 flag_right := 0.5;
51         else: % staffline_adjustment = anywhere
52                 flag_end := 1.7;
53                 flag_right := 0.6;
54         fi;
55
56         penpos1 (0.25 staff_space, 90);
57         penpos2 (0.2 staff_space, 0);
58         penpos3 (0.1 staff_space, -35);
59         z1r = (0, 0);
60         z2r = (flag_right * staff_space, -0.4 staff_space);
61         z3l = (0, -1.0 * flag_end * staff_space);
62         fill z1l
63              .. tension 2.0
64              .. z2l
65              .. tension 3.0
66              .. { dir -125 }z3l{ dir -125 }
67              .. { dir 55 }z3r{dir 55 }
68              .. tension 3.0
69              .. z2r
70              .. tension 2.0
71              .. z1r
72              -- cycle ;
73         draw_square_block ((-0.5 stemthickness_rounded, 0),
74                            (0, -0.25 staff_space));
75
76 enddef;
77
78
79 def draw_mensural_inner_flare (expr il_shift, idx, d_) =
80         define_pixels (linethickness, staff_space);
81
82         save ellipse, pat, T;
83         path ellipse, pat;
84         transform T;
85
86         T := identity xscaled 1.00 linethickness
87                       yscaled 0.22 staff_space
88                       rotated -35;
89         pickup pencircle transformed T;
90         ellipse := fullcircle transformed T;    
91
92         save i;
93         numeric i[];
94
95         i0 := idx * 10;
96         i1 := idx * 10 + 1;
97         i2 := idx * 10 + 2;
98         i3 := idx * 10 + 3;
99         i4 := idx * 10 + 4;
100
101         z[i0] = (0, -il_shift * staff_space);
102         z[i1] = z[i0] + (+0.00 staff_space, -0.10 staff_space);
103         z[i2] = z[i0] + (+0.33 staff_space, -0.30 staff_space);
104         z[i3] = z[i0] + (+0.33 staff_space, -0.70 staff_space);
105         z[i4] = z[i0] + (+0.00 staff_space, -0.90 staff_space);
106
107         pat := z[i1]{2, 1}
108                .. z[i2]
109                .. z[i3]
110                .. {-2, -1}z[i4];
111
112         % we avoid cusps originally present in `draw pat'
113         fill get_subpath (ellipse,
114                           -direction 0 of pat, direction 0 of pat, z[i1])
115              .. get_subpoint (ellipse, direction 1 of pat, z[i2])
116                   {direction 1 of pat}
117              .. get_subpoint (ellipse, direction 2 of pat, z[i3])
118                   {direction 2 of pat}
119              .. get_subpath (ellipse,
120                              direction 3 of pat, -direction 3 of pat, z[i4])
121              .. get_subpoint (ellipse, -direction 2 of pat, z[i3])
122                   {-direction 2 of pat}
123              .. get_subpoint (ellipse, -direction 1 of pat, z[i2])
124                   {-direction 1 of pat}
125              .. cycle;
126
127         if d_ = dir_up:
128                 labels ([i0], [i1], [i2], [i3], [i4]);
129         fi;
130 enddef;
131
132
133 def draw_mensural_flag (expr staffline_adjustment, flares, d_) =
134         save char_box_adjust, flare_shift;
135
136         if staffline_adjustment = between_staff_lines:
137                 flare_shift := 0.5;
138         elseif staffline_adjustment = on_staff_line:
139                 flare_shift := 0.0;
140         else: % staffline_adjustment = anywhere
141                 flare_shift := 0.25;
142         fi;
143
144         char_box_adjust := flare_shift + 0.5;
145
146         if d_ = dir_up:
147                 set_char_box (0,
148                               0.60 staff_space#,
149                               (flares + char_box_adjust) * staff_space#,
150                               0.10 staff_space#);
151         else: % d_ = dir_down
152                 set_char_box (0.60 staff_space#,
153                               0,
154                               0.10 staff_space#,
155                               (flares + char_box_adjust) * staff_space#);
156         fi;
157
158         draw_mensural_outermost_flare (staffline_adjustment, d_);
159
160         for flare_count := 2 step 1 until 4:
161                 if flares >= flare_count:
162                         draw_mensural_inner_flare (flare_shift
163                                                    + flare_count - 0.5,
164                                                    flare_count, d_);
165                 fi;
166         endfor;
167
168         if d_ = dir_down:
169                 currentpicture := currentpicture xscaled -1
170                                                  yscaled -1
171                                                  shifted (-0.5 stemthickness_rounded, 0);
172         fi;
173 enddef;
174
175
176 % 8th mensural flag, upwards, between staff lines
177 fet_beginchar ("8th Mensural Flag (up)", "mensuralu03");
178         draw_mensural_flag (between_staff_lines, 1, dir_up);
179 fet_endchar;
180
181
182 % 8th mensural flag, upwards, on staff line
183 fet_beginchar ("8th Mensural Flag (up)", "mensuralu13");
184         draw_mensural_flag (on_staff_line, 1, dir_up);
185 fet_endchar;
186
187
188 % 8th mensural flag, upwards, anywhere
189 fet_beginchar ("8th Mensural Flag (up)", "mensuralu23");
190         draw_mensural_flag (anywhere, 1, dir_up);
191 fet_endchar;
192
193
194 % 8th mensural flag, downwards, between staff lines
195 fet_beginchar ("8th Mensural Flag (down)", "mensurald03");
196         draw_mensural_flag (between_staff_lines, 1, dir_down);
197 fet_endchar;
198
199
200 % 8th mensural flag, downwards, on staff line
201 fet_beginchar ("8th Mensural Flag (down)", "mensurald13");
202         draw_mensural_flag (on_staff_line, 1, dir_down);
203 fet_endchar;
204
205
206 % 8th mensural flag, downwards, anywhere
207 fet_beginchar ("8th Mensural Flag (down)", "mensurald23");
208         draw_mensural_flag (anywhere, 1, dir_down);
209 fet_endchar;
210
211
212 % 16th mensural flag, upwards, between staff lines
213 fet_beginchar ("16th Mensural Flag (up)", "mensuralu04");
214         draw_mensural_flag (between_staff_lines, 2, dir_up);
215 fet_endchar;
216
217
218 % 16th mensural flag, upwards, on staff line
219 fet_beginchar ("16th Mensural Flag (up)", "mensuralu14");
220         draw_mensural_flag (on_staff_line, 2, dir_up);
221 fet_endchar;
222
223
224 % 16th mensural flag, upwards, anywhere
225 fet_beginchar ("16th Mensural Flag (up)", "mensuralu24");
226         draw_mensural_flag (anywhere, 2, dir_up);
227 fet_endchar;
228
229
230 % 16th mensural flag, downwards, between staff lines
231 fet_beginchar ("16th Mensural Flag (down)", "mensurald04");
232         draw_mensural_flag (between_staff_lines, 2, dir_down);
233 fet_endchar;
234
235
236 % 16th mensural flag, downwards, on staff line
237 fet_beginchar ("16th Mensural Flag (down)", "mensurald14");
238         draw_mensural_flag (on_staff_line, 2, dir_down);
239 fet_endchar;
240
241
242 % 16th mensural flag, downwards, anywhere
243 fet_beginchar ("16th Mensural Flag (down)", "mensurald24");
244         draw_mensural_flag (anywhere, 2, dir_down);
245 fet_endchar;
246
247
248 % 32th mensural flag, upwards, between staff lines
249 fet_beginchar ("32th Mensural Flag (up)", "mensuralu05");
250         draw_mensural_flag (between_staff_lines, 3, dir_up);
251 fet_endchar;
252
253
254 % 32th mensural flag, upwards, on staff line
255 fet_beginchar ("32th Mensural Flag (up)", "mensuralu15");
256         draw_mensural_flag (on_staff_line, 3, dir_up);
257 fet_endchar;
258
259
260 % 32th mensural flag, upwards, anywhere
261 fet_beginchar ("32th Mensural Flag (up)", "mensuralu25");
262         draw_mensural_flag (anywhere, 3, dir_up);
263 fet_endchar;
264
265
266 % 32th mensural flag, downwards, between staff lines
267 fet_beginchar ("32th Mensural Flag (down)", "mensurald05");
268         draw_mensural_flag (between_staff_lines, 3, dir_down);
269 fet_endchar;
270
271
272 % 32th mensural flag, downwards, on staff line
273 fet_beginchar ("32th Mensural Flag (down)", "mensurald15");
274         draw_mensural_flag (on_staff_line, 3, dir_down);
275 fet_endchar;
276
277
278 % 32th mensural flag, downwards, anywhere
279 fet_beginchar ("32th Mensural Flag (down)", "mensurald25");
280         draw_mensural_flag (anywhere, 3, dir_down);
281 fet_endchar;
282
283
284 % 64th mensural flag, upwards, between staff lines
285 fet_beginchar ("64th Mensural Flag (up)", "mensuralu06");
286         draw_mensural_flag (between_staff_lines, 4, dir_up);
287 fet_endchar;
288
289
290 % 64th mensural flag, upwards, on staff line
291 fet_beginchar ("64th Mensural Flag (up)", "mensuralu16");
292         draw_mensural_flag (on_staff_line, 4, dir_up);
293 fet_endchar;
294
295
296 % 64th mensural flag, upwards, anywhere
297 fet_beginchar ("64th Mensural Flag (up)", "mensuralu26");
298         draw_mensural_flag (anywhere, 4, dir_up);
299 fet_endchar;
300
301
302 % 64th mensural flag, downwards, between staff lines
303 fet_beginchar ("64th Mensural Flag (down)", "mensurald06");
304         draw_mensural_flag (between_staff_lines, 4, dir_down);
305 fet_endchar;
306
307
308 % 64th mensural flag, downwards, on staff line
309 fet_beginchar ("64th Mensural Flag (down)", "mensurald16");
310         draw_mensural_flag (on_staff_line, 4, dir_down);
311 fet_endchar;
312
313
314 % 64th mensural flag, downwards, anywhere
315 fet_beginchar ("64th Mensural Flag (down)", "mensurald26");
316         draw_mensural_flag (anywhere, 4, dir_down);
317 fet_endchar;
318
319
320 fet_endgroup ("flags");