]> 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         y10 = -1/10 staff_space;
298 %       draw_staff (-2, 2, 0.5);
299 %       draw_staff (-2, 2, 0.0);
300
301         unfill z3r{z3r - z10}
302                .. z4r{right}
303                .. z5r{down}
304                .. z7{-bot_crook_dir}
305                & z7
306                .. z10{z3r - z10}
307                -- cycle;
308
309         fill z2l{down}
310              .. z11{right}
311              .. z8{bot_crook_dir}
312              .. z5l{up}
313              .. z4l{left}
314              .. z3l
315              -- cycle;
316 enddef;
317
318
319 %
320 % unfortunately, 600dpi is not enough to show the brush of the stem.
321 %
322
323 fet_beginchar ("Flat", "-2")
324         set_char_box (1.2 stafflinethickness#, .8 staff_space#,
325                       0.6 staff_space#, 1.9 staff_space#);
326
327         draw_meta_flat (0, w, 0.31 staff_space);
328         penlabels (range 0 thru 11);
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
336         draw_meta_flat (0, w, 0.31 staff_space);
337         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
338 fet_endchar;
339
340
341 fet_beginchar ("Double Flat", "-4")
342         save left_wid, overlap, right_wid;
343         left_wid = .7;
344         right_wid = .8;
345         overlap = .05;
346
347         set_char_box (1.2 stafflinethickness#,
348                       (left_wid + right_wid -overlap) * staff_space#,
349                       .6 staff_space#, 1.9 staff_space#);
350         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space);
351         draw_meta_flat (round ((left_wid - overlap) * staff_space),
352                         right_wid * staff_space, 0.33 staff_space);
353 fet_endchar;
354
355
356 fet_beginchar ("3/4 Flat", "-3")
357         save left_wid, overlap, right_wid;
358         left_wid = .7;
359         right_wid = .8;
360         overlap = .05;
361
362         set_char_box (1.2 stafflinethickness#,
363                       (left_wid + right_wid - overlap) * staff_space#,
364                       .6 staff_space#, 1.9 staff_space#);
365         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space);
366         draw_meta_flat (round ((left_wid - overlap) * staff_space),
367                         right_wid * staff_space, 0.33 staff_space);
368
369         %% maybe we should clip part of the stems?
370         %% or make the 1st flat smaller?
371         %% or reverse it?
372         pickup pencircle scaled 2 stafflinethickness;
373         z12 = (-.25 w - b, .55 staff_space);
374         z13 = (.75 w, 1.45 staff_space);
375         penpos12 (2 stafflinethickness, angle (z13 - z12) - 90);
376         penpos13 (2 stafflinethickness, angle (z13 - z12) - 90);
377         z14 = z12 - stafflinethickness * unitvector (z13 - z12);
378         z15 = z13 + stafflinethickness * unitvector (z13 - z12);
379
380         fill z13r
381              .. z15
382              .. z13l
383              --- z12l
384              .. z14
385              .. z12 r
386              --- z13r
387              .. cycle;
388
389         penlabels (12, 13);
390         labels (14, 15);
391 fet_endchar;
392
393
394 fet_beginchar ("Double Sharp", "4")
395         set_char_box (0, staff_space#, .5 staff_space#, .5 staff_space#);
396         save klaverblad, klaversteel;
397
398         klaversteel = 1/15 staff_space;
399         klaverblad = .40 staff_space - .5 stafflinethickness;
400
401         z1 = (klaversteel, 0);
402         z2 = (w / 2 - klaverblad / 10, h - klaverblad);
403         z3 = (w / 2, h);
404         z4 = z2 reflectedabout ((0, 0), (1, 1));
405         z5 = z1 reflectedabout ((0, 0), (1, 1));
406
407         % labels (1, 2, 3, 4, 5);
408
409         save pat;
410         path pat;
411
412         pickup pencircle scaled blot_diameter;
413         pat = (rt z1){dir45}
414               .. {right}(bot z2)
415               .. rt z2
416               --- rt z3
417               .. top z3
418               --- top z4
419               .. (lft z4){down}
420               .. {dir 225}(top z5);
421         pat := pat
422                & reverse pat xscaled (-1);
423         pat := pat
424                & reverse pat yscaled (-d / h)
425                & cycle;
426         fill pat;
427
428         % ugh
429         currentpicture := currentpicture shifted (w / 2, 0);
430 fet_endchar;
431
432
433 def draw_paren =
434         save leftindent;
435         leftindent# := .2 staff_space#;
436         define_pixels (leftindent);
437
438         set_char_box (0, .5 staff_space# + stafflinethickness#,
439                       staff_space#, staff_space#);
440
441         z1 = (leftindent, h);
442         z2 = (w - stafflinethickness, 0);
443         z3 = (leftindent, -d);
444
445         penpos1 (stafflinethickness, 35);
446         penpos2 (.1 staff_space + stafflinethickness, 0);
447         penpos3 (stafflinethickness, -35);
448
449         fill z2l{down}
450              .. simple_serif (z3l, z3r, 90)
451              .. z2r{up}
452              .. simple_serif (z1r, z1l, 90)
453              .. z2l{down}
454              -- cycle;
455 enddef;
456
457
458 fet_beginchar ("Right Parenthesis", "rightparen")
459         draw_paren;
460         penlabels (1, 2, 3);
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");