]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-banier.mf
Prepare glyph shapes for mf2pt1 conversion.
[lilypond.git] / mf / feta-banier.mf
1 % flags
2 %
3
4
5 fet_begingroup ("flags")
6
7 save outer_path;
8 path outer_path;
9
10 %
11 % Flags pointing down overlap with the notehead (in x-direction), so
12 % the down-flag can be bigger.
13 %
14
15 upflag_width# = .65 black_notehead_width# + stemthickness# / 2;
16 downflag_width# = .833 black_notehead_width# + stemthickness# / 2;
17
18 right_upflag_space# = .0 upflag_width#;
19 right_downflag_space# = .0 downflag_width#;
20
21 %
22 % Flags pointing down cannot overlap with the notehead in y-direction,
23 % so they have less slant.
24 %
25 % Because of optical illusion, the utmost flag (bottom for
26 % down-pointing, top for up-pointing) should be smaller than the other
27 % flags.  Adobe Sonata doesn't do this correctly.  (Instead they have
28 % an extension flag, which looks less elegant)
29 %
30
31 save hip_thickness, foot_thickness;
32
33 hip_thickness# = 1.0 linethickness# + 0.069 staff_space#;
34 foot_thickness# = 1.2055 linethickness# + 0.06 staff_space#;
35
36 %
37 % Inspired by Adobe Sonata and [Wanske].
38 % For example, see POSTSCRIPT Language -- program design,
39 % page 119, and [Wanske], p 41, 42.
40 %
41
42 def draw_flag (expr center, flare, dims, hip_depth, foot_wid,
43                hip_thickness, foot_thickness, show_labels) =
44         save c;
45
46         clearxy;
47
48         c = 0.7;
49
50         penpos1 (flare, 90);
51         penpos2 (whatever, 0);
52
53         x2r - x2l = hip_thickness;
54
55         penpos3 (foot_thickness, -20.0);
56
57         z1r = center;
58         z2r = center + (xpart (dims), -ypart (dims) * hip_depth);
59         z3r = center + (xpart (dims) * foot_wid, -ypart (dims));
60
61         outer_path := z3r{curl c} .. z2r{up} .. {up}z1r;
62
63         if show_labels = 1:
64                 penlabels (1, 2, 3);
65         fi;
66
67         fill z1l{curl 0}
68              ..tension 1.1.. z2l{down}
69              .. {curl c}simple_serif (z3l, z3r, 80)
70              & outer_path
71              & z1r
72              -- cycle;
73 enddef;
74
75 %
76 % TODO: calculate intersectpoint (see TeX book, p. 137)
77 % TODO: calculate incision_depth
78 %
79
80 def add_flag (expr yoff, flare, hip_wid_multiplier, hip_dep_multiplier,
81               intersectpoint, hip_thickness, foot_thickness) =
82 begingroup
83         save prev_center, prev_xextreme, prev_yextreme;
84         save rel_foot, ip, center, incision_depth;
85         save prev_hipwid, prev_footdep, prev_hipdep, wid, dep, hip_dep;
86         save hip_dep_ratio, foot_wid_ratio;
87         pair prev_center, center, foot, prev_xextreme, prev_yextreme;
88         pair ip, rel_foot;
89
90         incision_depth = 1.013;
91         prev_center = point 2 of outer_path;
92         prev_xextreme = point 1 of outer_path;
93         prev_yextreme = point 0 of outer_path;
94         prev_hipwid = xpart (prev_xextreme - prev_center);
95         prev_footdep = -ypart (prev_yextreme - prev_center);
96         prev_hipdep = -ypart (prev_xextreme - prev_center);
97         ip = point intersectpoint of outer_path;
98
99         wid = prev_hipwid * hip_wid_multiplier;
100         hip_dep = prev_hipdep * hip_dep_multiplier;
101
102         center = prev_center + (0, yoff);
103         rel_foot = incision_depth [(wid, hip_dep), ip - center];
104         dep = -ypart (rel_foot);
105         foot_wid_ratio = xpart (rel_foot) / wid;
106         hip_dep_ratio = hip_dep / dep;
107
108         draw_flag (center, flare, (wid, dep),
109                    hip_dep_ratio, foot_wid_ratio,
110                    hip_thickness, foot_thickness, 0);
111 endgroup
112 enddef;
113
114
115 fet_beginchar ("8th Flag (up)", "u3")
116         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
117
118         flare# = 1.0 staff_space#;
119         hip_depth_ratio = .72;
120         foot_width_ratio = .8;
121         hip_width# = upflag_width# - hip_thickness# / 2;
122         foot_depth# = 3 staff_space# - blot_diameter# / 2;
123         define_pixels (flare, hip_width, hip_thickness,
124                        foot_depth, foot_thickness);
125
126         set_char_box (0, hip_width# + stemthickness# / 2 + right_upflag_space#,
127                       foot_depth# + foot_thickness# / 2, stemthickness# / 2);
128
129         draw_flag ((0,0), flare, (hip_width, foot_depth),
130                    hip_depth_ratio, foot_width_ratio,
131                    hip_thickness, foot_thickness, 1);
132
133         draw_square_block ((-.5 stemthickness, -staff_space), (0, 0));
134 fet_endchar;
135
136
137 fet_beginchar ("16th Flag (up)", "u4")
138         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
139         save flagspace, total_depth, flag_count;
140         total_depth# = 3.5 staff_space# - blot_diameter# / 2;
141         flag_count = 2;
142         flare# = .85 staff_space#;
143         flagspace# = .85 staff_space#;
144         hip_depth_ratio = .72;
145         hip_width# = upflag_width# - hip_thickness# / 2;
146         flagspace# + foot_depth# = total_depth#;
147         foot_width_ratio = .8;
148         define_pixels (flare, hip_width, hip_thickness, flagspace,
149                        foot_depth,  foot_thickness);
150
151         set_char_box (0,
152                       hip_width# + stemthickness# / 2 + right_upflag_space#,
153                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
154
155         draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
156                    hip_depth_ratio, foot_width_ratio,
157                    hip_thickness, foot_thickness, 1);
158
159         add_flag (flagspace, flare, .97, 1.00, 1.25,
160                   hip_thickness, foot_thickness);
161
162         draw_square_block ((-.5 stemthickness, 0), (0, -2 staff_space));
163 fet_endchar;
164
165
166 fet_beginchar ("32nd Flag (up)", "u5")
167         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
168         save flagspace, total_depth, flag_count;
169
170         flag_count = 3;
171         total_depth# = 4.25 staff_space#;
172         flare# = .85 staff_space#;
173         flagspace# = .87 staff_space#;
174         hip_depth_ratio = .72;
175         hip_width# = upflag_width# - hip_thickness# / 2;
176         foot_width_ratio = .8;
177
178         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
179
180         define_pixels (flare, hip_width, hip_thickness, flagspace,
181                        foot_depth, foot_thickness);
182
183         set_char_box (0, hip_width# + right_upflag_space#,
184                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
185
186         draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
187                    hip_depth_ratio, foot_width_ratio,
188                    hip_thickness, foot_thickness, 1);
189
190         add_flag (flagspace, flare, .97, 1.00, 1.25,
191                   hip_thickness, foot_thickness);
192         add_flag (flagspace, flare, .95, 1.05, 1.25,
193                   hip_thickness, foot_thickness);
194
195         draw_square_block ((-.5 stemthickness, 0), (0, -3 staff_space));
196 fet_endchar;
197
198
199 fet_beginchar ("64th Flag (up)", "u6")
200         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
201         save flagspace, total_depth, flag_count;
202
203         flag_count = 4;
204         flare# = .85 staff_space#;
205         flagspace# = .9 staff_space#;
206         hip_depth_ratio = .72;
207         hip_width# = upflag_width# - hip_thickness# / 2;
208         total_depth# = 5.25 staff_space#;
209         foot_width_ratio = .8;
210
211         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
212
213         define_pixels (flare, hip_width, hip_thickness, flagspace,
214                        foot_depth,  foot_thickness);
215
216         set_char_box (0, hip_width# + right_upflag_space#,
217                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
218
219         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
220                    (hip_width, foot_depth),
221                    hip_depth_ratio, foot_width_ratio,
222                    hip_thickness, foot_thickness, 1);
223
224         add_flag (flagspace, flare, .97, 1.00, 1.3,
225                   hip_thickness, foot_thickness);
226         add_flag (flagspace, flare, 1.00, 1.00, 1.25,
227                   hip_thickness, foot_thickness);
228         add_flag (flagspace, flare, .95, 1.05, 1.25,
229                   hip_thickness, foot_thickness);
230
231         draw_square_block ((-.5 stemthickness, 0), (0, -4 staff_space));
232 fet_endchar;
233
234
235 fet_beginchar ("8th (down)", "d3")
236         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
237         save flagspace, total_depth, flag_count;
238
239         flag_count = 1;
240         flare# = .99 staff_space#;
241         flagspace# = .9 staff_space#;
242         hip_depth_ratio = .72 ;
243         hip_width# = downflag_width# - hip_thickness# / 2;
244         total_depth# = 2.85 staff_space#;
245         foot_width_ratio = .8;
246
247         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
248
249         define_pixels (flare, hip_width, hip_thickness, flagspace,
250                        foot_depth, foot_thickness);
251
252         set_char_box (0, hip_width# + right_downflag_space#,
253                       total_depth# + foot_thickness# / 2, stemthickness# / 2)
254
255         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
256                    (hip_width, foot_depth),
257                    hip_depth_ratio, foot_width_ratio,
258                    hip_thickness, foot_thickness, 0);
259
260         draw_square_block ((-.5 stemthickness, 0), (0, -staff_space));
261
262         y_mirror_char;
263 fet_endchar;
264
265
266 %%%%%%%%
267 %
268 % Single Stroke for Short Appogiatura
269 %
270
271 fet_beginchar ("grace dash (up)", "ugrace")
272         save flare, hip_depth_ratio, hip_width, foot_depth;
273
274         flare# = staff_space#;
275         hip_depth_ratio = .72;
276         hip_width# = upflag_width# - hip_thickness# / 2;
277         foot_depth# = 3 staff_space#;
278
279         define_pixels (flare, hip_width, hip_thickness,
280                        foot_depth, foot_thickness);
281
282         set_char_box (hip_width# * hip_depth_ratio,
283                       hip_width# + right_upflag_space#,
284                       foot_depth# * hip_depth_ratio, -flare#)
285
286         pickup pencircle scaled 1.5 stemthickness;
287
288         z1 = (-b, -d);
289         z2 = (w, h);
290
291         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
292         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
293
294         fill z1l
295              --- z2l
296              .. top z2
297              .. rt z2
298              .. z2r
299              --- z1r
300              .. bot z1
301              .. lft z1
302              .. cycle;
303
304         penlabels (1, 2);
305 fet_endchar;
306
307
308 fet_beginchar ("grace dash (down)", "dgrace")
309         save flare, hip_depth_ratio, hip_width, foot_depth;
310         save flagspace, total_depth;
311
312         flare# = .99 staff_space#;
313         flagspace# = .9 staff_space#;
314         hip_depth_ratio = .72 ;
315         hip_width# = downflag_width# - hip_thickness# / 2;
316         total_depth# = 2.85 staff_space#;
317         foot_depth# = total_depth#;
318         foot_width_ratio = .8;
319
320         define_pixels (flare, hip_width, hip_thickness,
321                        flagspace, foot_depth);
322
323         set_char_box (hip_width# * hip_depth_ratio,
324                       hip_width# + right_downflag_space#,
325                       foot_depth# * hip_depth_ratio, -flare#)
326
327         pickup pencircle scaled 1.5 stemthickness;
328
329         z1 = (-b, -d);
330         z2 = (w, h);
331
332         penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
333         penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
334
335         fill z1l
336              --- z2l
337              .. top z2
338              .. rt z2
339              .. z2r
340              --- z1r
341              .. bot z1
342              .. lft z1
343              .. cycle;
344
345         y_mirror_char;
346 fet_endchar;
347
348
349 fet_beginchar ("16th (down)", "d4")
350         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
351         save flagspace, total_depth, flag_count;
352
353         flag_count = 2;
354         flare# = .8 staff_space#;
355         flagspace# = .9 staff_space#;
356         hip_depth_ratio = .85;
357         hip_width# = downflag_width# - hip_thickness# / 2;
358         total_depth# = 3.0 staff_space# - blot_diameter# / 2;
359         foot_width_ratio = .95;
360
361         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
362
363         set_char_box (0, hip_width# + right_downflag_space#,
364                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
365
366         define_pixels (flare, hip_width, hip_thickness, flagspace,
367                        foot_depth, foot_thickness);
368
369         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
370                    (hip_width, foot_depth),
371                    hip_depth_ratio, foot_width_ratio,
372                    hip_thickness, foot_thickness, 0);
373
374         add_flag (flagspace, flare, .95, 1.00, 1.25,
375                   hip_thickness, foot_thickness);
376
377         draw_square_block ((-.5 stemthickness, 0), (0, -2 staff_space));
378
379         y_mirror_char;
380 fet_endchar;
381
382
383 fet_beginchar ("32nd (down)", "d5")
384         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
385         save flagspace, total_depth, flag_count;
386
387         flag_count = 3;
388         flare# = .84 staff_space#;
389         flagspace# = .9 staff_space#;
390         hip_depth_ratio = .85;
391         hip_width# = downflag_width# - hip_thickness# / 2;
392         total_depth# = 3.85 staff_space#;
393         foot_width_ratio = .95;
394
395         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
396
397         define_pixels (flare, hip_width, hip_thickness, flagspace,
398                        foot_depth,  foot_thickness);
399
400         set_char_box (0, hip_width# + right_downflag_space#,
401                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
402
403         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
404                    (hip_width, foot_depth),
405                    hip_depth_ratio, foot_width_ratio,
406                    hip_thickness, foot_thickness, 0);
407
408         add_flag (flagspace, flare, .97, 1.00, 1.25,
409                   hip_thickness, foot_thickness);
410         add_flag (flagspace, flare, .95, 1.05, 1.25,
411                   hip_thickness, foot_thickness);
412
413         draw_square_block ((-.5 stemthickness, 0), (0, -3 staff_space));
414
415         y_mirror_char;
416 fet_endchar;
417
418
419 fet_beginchar ("64th (down)", "d6")
420         save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
421         save flagspace, total_depth, flag_count;
422
423         flag_count = 4;
424         flare# = .8 staff_space#;
425         flagspace# = .9 staff_space#;
426         hip_depth_ratio = .85;
427         hip_width# = downflag_width# - hip_thickness# / 2;
428         total_depth# = 4.35 staff_space#;
429         foot_width_ratio = .98;
430
431         (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
432
433         define_pixels (flare, hip_width, hip_thickness, flagspace,
434                        foot_depth, foot_thickness);
435
436         set_char_box (0, hip_width# + right_downflag_space#,
437                       total_depth# + foot_thickness# / 2, stemthickness# / 2);
438
439         draw_flag ((0, -(flag_count - 1) * flagspace), flare,
440                    (hip_width, foot_depth),
441                    hip_depth_ratio, foot_width_ratio,
442                    hip_thickness, foot_thickness, 0);
443
444         add_flag (flagspace, flare, .97, 1.20, 1.175,
445                   hip_thickness, foot_thickness);
446         add_flag (flagspace, flare, .97, 1.10, 1.175,
447                   hip_thickness, foot_thickness);
448         add_flag (.98 flagspace, flare, .91, 1.05, 1.2,
449                   hip_thickness, foot_thickness);
450
451         draw_square_block ((-.5 stemthickness, 0), (0, -4 staff_space));
452
453         y_mirror_char;
454 fet_endchar;
455
456 fet_endgroup ("flags");