]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
Prepare glyph shapes for mf2pt1 conversion.
[lilypond.git] / mf / feta-toevallig.mf
1 %
2 % feta-toevallig.mf -- implement Accidentals
3 %
4 % source file of the Feta (Font-En-Tja) music font
5 %
6 % (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 %
8
9
10 %
11 % Accidentals from various sources, notably
12 %
13 %   Baerenreiter edition of Schuberts `Auf dem Strom' (sharp, natural)
14 %   F Hofmeister edition of Muellers `Etueden fuer Horn'  (double sharp, flat)
15 %
16
17
18 %tracingall;
19 %proofing := 2;
20 %\tracingequations:= tracingonline := 1;
21
22 fet_begingroup ("accidentals");
23
24 %
25 % The beams of most sharps have horizontal endings (as if drawn with
26 % a square pen).  [Wanske] does not mention this, so we'll just ignore
27 % this fact.
28 %
29
30 def draw_meta_sharp (expr width) =
31         save interbeam, interstem;
32         save beamheight, beamwidth, beamslope;
33         save spanheight, spanwidth;
34         save stemwidth;
35
36         save center;
37         pair center;
38
39         interbeam := 1.05 staff_space;
40         beamheight := 0.3 staff_space + stafflinethickness;
41         beamwidth := width;
42         stemwidth := stafflinethickness + .05 staff_space;
43         roundness := 2 blot_diameter;
44
45         center := (.5 w, 0);
46
47         roundness + 2 spanwidth = beamwidth;
48         roundness + 2 spanheight = beamheight;
49
50         z2 - z1 = (beamwidth - roundness, beamheight);
51         z1 + z2 = 2 * center;
52         beamslope = (y2 - y1) / (x2 - x1);
53
54         pair hspan, vspan;
55         hspan = (spanwidth, beamslope * spanwidth);
56         vspan = (0, spanheight);
57
58         pickup pencircle scaled roundness;
59         path beam;
60         beam := (rt (hspan + vspan)
61                  .. top (hspan + vspan)
62                  --- top (-hspan + vspan)
63                  .. lft (-hspan + vspan)
64                  --- lft (-hspan - vspan)
65                  .. bot (-hspan - vspan)
66                  --- bot (hspan - vspan)
67                  .. rt (hspan - vspan)
68                  --- cycle) shifted center;
69         fill (beam shifted (0, -interbeam / 2));
70
71         pickup pencircle scaled stemwidth;
72         x3 = x4 = xpart center;
73 enddef;
74
75
76 fet_beginchar ("Sharp" , "2");
77         set_char_box (0, 1.1 staff_space#,
78                       1.5 staff_space#, 1.5 staff_space#);
79         draw_meta_sharp (w);
80
81         save stemx;
82         stemx := 7 / 32 * w;
83
84         (bot y3) + -stemx * beamslope = -1.5 staff_space + ypart center;
85         (top y4) + stemx * beamslope = 1.5 staff_space + ypart center;
86
87         labels (1, 2, 3, 4);
88
89         draw_gridline (z3 - (stemx, stemx * beamslope),
90                        z4 - (stemx, stemx * beamslope),
91                        stemwidth);
92         addto currentpicture also currentpicture rotated 180 shifted (w, 0);
93 fet_endchar;
94
95
96 fet_beginchar ("1/2 Sharp" , "1");
97         set_char_box (0, 0.7 staff_space#,
98                       1.5 staff_space#, 1.5 staff_space#);
99
100         draw_meta_sharp (w);
101         stemx := 7 / 32 * w;
102
103         (bot y3) + -stemx * beamslope = -1.5 staff_space + ypart center;
104         (top y4) + stemx * beamslope = 1.5 staff_space + ypart center;
105
106         labels (1, 2, 3, 4);
107
108         draw_gridline (z3, z4, stemwidth);
109         addto currentpicture also currentpicture rotated 180 shifted (w, 0);
110 fet_endchar;
111
112
113 fet_beginchar ("3/4 Sharp", "3");
114         set_char_box (0, 1.6 staff_space#,
115                       1.5 staff_space#, 1.5 staff_space#);
116
117         draw_meta_sharp (w);
118         stemx := 9 / 32 * w;
119
120         (bot y3) + -stemx * beamslope = -1.5 staff_space + ypart center;
121         (top y4) + stemx * beamslope = 1.5 staff_space + ypart center;
122
123         labels (1, 2, 3, 4);
124
125         draw_gridline (z3 - (stemx, stemx * beamslope),
126                        z4 - (stemx, stemx * beamslope),
127                        stemwidth);
128         draw_gridline (z3, z4, stemwidth);
129         addto currentpicture also currentpicture rotated 180 shifted (w,0);
130 fet_endchar;
131
132
133 %
134 % The stems of the natural are brushed (at least, in Barenreiter SCS)
135 %
136
137 fet_beginchar ("Natural", "0")
138         save height, xcenter;
139         save interbeam, interstem;
140         save beamheight, beamwidth;
141         save stemwidth, top_stem_thick;
142
143         beamheight# = 0.35 staff_space# + .5 stafflinethickness#;
144         height# = 1.5 staff_space#;
145
146         set_char_box (0, 2/3 staff_space#, height#, height#);
147
148         define_pixels (height);
149         define_blacker_pixels (beamheight);
150
151         top_stem_thick = round (stafflinethickness + .09 staff_space) + 0.4;
152         stemwidth = 0.08 staff_space + .5 stafflinethickness;
153
154         interstem + stemwidth = w;
155
156         z2 - z1 = (interstem, slope * interstem);
157         xpart .5 [z2, z1] = xcenter;
158         xcenter = w / 2;
159
160         pickup penrazor scaled beamheight rotated 90;
161         top y2 = staff_space - 3/2 stafflinethickness;
162         slope = stafflinethickness / interstem;
163
164         draw z1
165              .. z2;
166         draw (xpart z1, -y2)
167              .. (xpart z2, -y1);
168
169         beamtop = top y2;
170
171         pickup pencircle scaled stemwidth;
172         x3 := round (xpart z1);
173         x4 := round (xpart z2);
174
175         penpos3 (top_stem_thick, 0);
176         penpos5 (top_stem_thick, 0);
177         penpos4 (stemwidth, 0);
178         penpos6 (stemwidth, 0);
179
180         y3 = height;
181         top y4 = beamtop;
182
183         x5 = x4;
184         x6 = x3;
185         bot y6 = -beamtop;
186         y5 = - height;
187
188         fill simple_serif (z3l, z3r, -30)
189              -- z6r
190              .. bot z6
191              .. z6l
192              -- cycle;
193         fill simple_serif (z5l, z5r, 30)
194              -- z4r
195              .. top z4
196              .. z4l
197              -- cycle;
198
199         penlabels (3, 4, 5, 6);
200         labels (1, 2);
201 fet_endchar;
202
203
204 %
205 % Dedicated to my mom.    (3/10/97)
206 %
207 % Mamma, ik hou van je; kom je alsjeblieft terug?
208 %    -- HW
209 %
210
211 % TODO: remove crook_fatness
212 % TODO: document, simplify!
213 %
214 def draw_meta_flat (expr xcenter, w, crook_fatness) =
215         clearxy;
216         save crook_thinness;
217         save bottom_overshoot;
218         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
219         save top_crook_thinness;
220         save zwiep;
221         save center;
222         pair center;
223         save clearing;
224
225         center = (xcenter, 0);
226
227 % the shouldn't reach to the top staff line.
228 %% TODO: should take from height.
229         clearing = 1.2 stafflinethickness;
230
231 %
232 %  TODO: parameterize this
233 %
234         if w >= 0.75 staff_space:
235                 smaller_hole = 0.35 stafflinethickness;
236         else:
237                 smaller_hole = 0.0 stafflinethickness;
238         fi
239         crook_thinness = .7 stafflinethickness + .06 staff_space;
240         top_crook_thinness = 1 stafflinethickness + .065 staff_space;
241
242         % this is a somewhat heuristic.  We should probably make it
243         % straight for low resolution (300 dpi and less).
244         top_stem_thick =
245           round (0.1 staff_space + 1.2 stafflinethickness) + 0.74;
246
247         bottom_overshoot = stafflinethickness;
248         bottom_stem_thick = 0.06 staff_space + 0.6 stafflinethickness;
249
250         z1 = (0, 2 staff_space)
251              + center
252              - (0, stafflinethickness / 2 + clearing);
253         z2 = (0, -1/2 staff_space - stafflinethickness / 2)
254              + center;
255
256         penpos1 (top_stem_thick, 0);
257         penpos2 (bottom_stem_thick, 0);
258
259         y3l = (staff_space - stafflinethickness) / 2 + ypart center;
260         z3l = whatever [z2r, z1r];
261         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
262
263         % we insert z3l to get better conversion with mf2pt1
264         fill simple_serif (z1r, z1l, 30)
265              -- z2l
266              -- z2r
267              -- z3l
268              -- cycle;
269
270         z10 = whatever [z2r, z1r] + (smaller_hole, 0);
271         z11 = center
272               + (bottom_overshoot / 3,
273                  -staff_space / 2 - stafflinethickness / 2)
274               - (0, bottom_overshoot);
275
276         penpos4 (whatever, 53);
277
278         y4l - y4r = top_crook_thinness;
279         y5r = .15 staff_space + ypart center;
280         x5l = w + xpart center;
281         y4 = ypart center + staff_space / 2;
282         x4r = .45 [x5r, x3r];
283
284         penpos5 (crook_fatness, -175);
285
286         save bot_crook_dir;
287         pair bot_crook_dir;
288         bot_crook_dir = unitvector ((x5l, 0) - z11);
289         z8 = z11 + whatever * bot_crook_dir;
290         y8 = -staff_space / 2 + 0.0 * stafflinethickness;
291
292         z7 = z8
293              + whatever * bot_crook_dir
294              + crook_thinness * (bot_crook_dir rotated 90);
295         x7 = .1 [x3r, x8];
296
297         penlabels (range 0 thru 11);
298
299         y10 = -1/10 staff_space;
300 %       draw_staff (-2, 2, 0.5);
301 %       draw_staff (-2, 2, 0.0);
302
303         unfill z3r{z3r - z10}
304                .. z4r{right}
305                .. z5r{down}
306                .. z7{-bot_crook_dir}
307                & z7
308                .. z10{z3r - z10}
309                -- cycle;
310
311         fill z2l{down}
312              .. z11{right}
313              .. z8{bot_crook_dir}
314              .. z5l{up}
315              .. z4l{left}
316              .. z3l
317              -- cycle;
318 enddef;
319
320
321 %
322 % unfortunately, 600dpi is not enough to show the brush of the stem.
323 %
324
325 fet_beginchar ("Flat", "-2")
326         set_char_box (1.2 stafflinethickness#, .8 staff_space#,
327                       0.6 staff_space#, 1.9 staff_space#);
328         draw_meta_flat (0, w, 0.31 staff_space);
329 fet_endchar;
330
331
332 fet_beginchar ("Semi flat", "-1")
333         set_char_box (1.2 stafflinethickness#, .8 staff_space#,
334                       0.6 staff_space#, 1.9 staff_space#);
335         draw_meta_flat(0, w, 0.31 staff_space);
336         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
337 fet_endchar;
338
339
340 fet_beginchar ("Double Flat", "-4")
341         save left_wid, overlap, right_wid;
342         left_wid = .7;
343         right_wid = .8;
344         overlap = .05;
345
346         set_char_box (1.2 stafflinethickness#,
347                       (left_wid + right_wid -overlap) * staff_space#,
348                       .6 staff_space#, 1.9 staff_space#);
349         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space);
350         draw_meta_flat (round ((left_wid - overlap) * staff_space),
351                         right_wid * staff_space, 0.33 staff_space);
352 fet_endchar;
353
354
355 fet_beginchar ("3/4 Flat", "-3")
356         save left_wid, overlap, right_wid;
357         left_wid = .7;
358         right_wid = .8;
359         overlap = .05;
360
361         set_char_box (1.2 stafflinethickness#,
362                       (left_wid + right_wid - overlap) * staff_space#,
363                       .6 staff_space#, 1.9 staff_space#);
364         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space);
365         draw_meta_flat (round ((left_wid - overlap) * staff_space),
366                         right_wid * staff_space, 0.33 staff_space);
367
368         %% maybe we should clip part of the stems?
369         %% or make the 1st flat smaller?
370         %% or reverse it?
371         pickup pencircle scaled 2 stafflinethickness;
372         z12 = (-.25 w - b, .55 staff_space);
373         z13 = (.75 w, 1.45 staff_space);
374         penpos12 (2 stafflinethickness, angle (z13 - z12) - 90);
375         penpos13 (2 stafflinethickness, angle (z13 - z12) - 90);
376         z14 = z12 - stafflinethickness * unitvector (z13 - z12);
377         z15 = z13 + stafflinethickness * unitvector (z13 - z12);
378
379         fill z13r
380              .. z15
381              .. z13l
382              --- z12l
383              .. z14
384              .. z12 r
385              --- z13r
386              .. cycle;
387
388         penlabels (12, 13);
389         labels (14, 15);
390 fet_endchar;
391
392
393 fet_beginchar ("Double Sharp", "4")
394         set_char_box (0, staff_space#, .5 staff_space#, .5 staff_space#);
395         save klaverblad, klaversteel;
396
397         klaversteel = 1/15 staff_space;
398         klaverblad = .40 staff_space - .5 stafflinethickness;
399
400         z1 = (klaversteel, 0);
401         z2 = (w / 2 - klaverblad / 10, h - klaverblad);
402         z3 = (w / 2, h);
403         z4 = z2 reflectedabout ((0, 0), (1, 1));
404         z5 = z1 reflectedabout ((0, 0), (1, 1));
405
406         labels (1, 2, 3, 4, 5);
407
408         save pat;
409         path pat;
410
411         pickup pencircle scaled blot_diameter;
412         pat = (rt z1){dir45}
413               .. {right}(bot z2)
414               .. rt z2
415               --- rt z3
416               .. top z3
417               --- top z4
418               .. (lft z4){down}
419               .. {dir 225}(top z5);
420         pat := pat
421                & reverse pat xscaled (-1);
422         pat := pat
423                & reverse pat yscaled (-d / h)
424                & cycle;
425         fill pat;
426
427         % ugh
428         currentpicture := currentpicture shifted (w / 2, 0);
429 fet_endchar;
430
431
432 def draw_paren =
433         save leftindent;
434         leftindent# := .2 staff_space#;
435         define_pixels (leftindent);
436
437         set_char_box (0, .5 staff_space# + stafflinethickness#,
438                       staff_space#, staff_space#);
439
440         z1 = (leftindent, h);
441         z2 = (w - stafflinethickness, 0);
442         z3 = (leftindent, -d);
443
444         penpos1 (stafflinethickness, 35);
445         penpos2 (.1 staff_space + stafflinethickness, 0);
446         penpos3 (stafflinethickness, -35);
447
448         penlabels (1, 2, 3);
449
450         fill z2l{down}
451              .. simple_serif (z3l, z3r, 90)
452              .. z2r{up}
453              .. simple_serif (z1r, z1l, 90)
454              .. z2l{down}
455              -- cycle;
456 enddef;
457
458
459 fet_beginchar ("Right Parenthesis", "rightparen")
460         draw_paren;
461 fet_endchar;
462
463
464 fet_beginchar ("Left Parenthesis", "leftparen")
465         draw_paren;
466         currentpicture := currentpicture xscaled -1;
467         set_char_box (charwd, charbp, chardp, charht);
468 fet_endchar;
469
470
471 fet_endgroup ("accidentals");