]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
*** empty log message ***
[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--2003 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, beamheight, beamwidth, 
32                 stemwidth, beamslope;
33         save spanwidth, spanheight;
34         
35         save center;
36         pair center;
37
38         interbeam := 1.05 staff_space;
39         beamheight := 4 stafflinethickness;
40         beamwidth := width;
41         stemwidth := 1.5 stafflinethickness;
42         roundness := 2 blot_diameter;
43
44         center := (.5 w, 0);
45         
46         roundness + 2 spanwidth = beamwidth;
47         roundness + 2 spanheight = beamheight;
48
49         z2 - z1 = (beamwidth - roundness, beamheight);
50         z1 + z2 = 2*center;
51         beamslope = (y2-y1)/(x2-x1);
52
53         pair hspan, vspan;
54         hspan = (spanwidth, beamslope * spanwidth);
55         vspan = (0, spanheight);
56         
57         path beam;
58         beam := (hspan + vspan -- -hspan 
59                 +  vspan -- -hspan -vspan -- hspan - vspan -- cycle )
60                 shifted center;
61
62         pickup pencircle scaled roundness;
63         filldraw (beam shifted (0,-interbeam/2));
64
65         pickup pencircle scaled stemwidth;
66         x3 = x4 = xpart center;
67
68
69         enddef;
70
71 fet_beginchar("Sharp" , "2", "sharp");
72         set_char_box(0, 1.1 staff_space#, 1.5 staff_space#, 
73                 1.5 staff_space#);
74         draw_meta_sharp (w);
75
76         save stemx;
77         stemx := 7 / 32 * w;
78
79         (bot y3) + - stemx * beamslope = -1.5 staff_space + ypart center;
80         top y4  + stemx * beamslope = 1.5 staff_space + ypart center;
81
82         labels(1,2,3,4);
83
84         draw_gridline (z3-(stemx,stemx* beamslope),z4-(stemx, stemx*beamslope), stemwidth);
85         addto currentpicture also currentpicture rotated 180 shifted (w,0);
86
87         fet_endchar;
88
89 fet_beginchar("1/2 Sharp" , "1", "semisharp");
90         set_char_box(0, 0.7 staff_space#, 1.5 staff_space#, 
91                 1.5 staff_space#);
92
93         draw_meta_sharp (w);
94         stemx := 7 / 32 * w;
95
96         (bot y3) + - stemx * beamslope = -1.5 staff_space + ypart center;
97         top y4  + stemx * beamslope = 1.5 staff_space + ypart center;
98
99         labels(1,2,3,4);
100
101         draw_gridline (z3, z4, stemwidth);
102         addto currentpicture also currentpicture rotated 180 shifted (w,0);
103
104         fet_endchar;
105
106
107 fet_beginchar("3/4 Sharp" , "3", "threequartersharp");
108         set_char_box(0, 1.6 staff_space#, 1.5 staff_space#, 
109                 1.5 staff_space#);
110
111         draw_meta_sharp (w);
112         stemx := 9 / 32 * w;
113
114         (bot y3) + - stemx * beamslope = -1.5 staff_space + ypart center;
115         top y4  + stemx * beamslope = 1.5 staff_space + ypart center;
116
117         labels(1,2,3,4);
118
119         draw_gridline (z3-(stemx,stemx* beamslope),z4-(stemx, stemx*beamslope), stemwidth);
120         draw_gridline (z3, z4, stemwidth);
121         addto currentpicture also currentpicture rotated 180 shifted (w,0);
122
123         fet_endchar;
124
125 %
126 % The stems of the natural are brushed (at least, in Barenreiter SCS )
127 %
128 %
129
130 fet_beginchar( "Natural", "0", "natural")
131         save height, xcenter;
132         save interbeam, interstem, beamheight, beamwidth, 
133         stemwidth;
134         save top_stem_thick;
135
136         beamheight# = 4.0 stafflinethickness#;
137         height# = 1.5 staff_space#;
138         set_char_box(0, 2/3 staff_space#, height#, height#);
139
140         define_pixels(height);
141         define_blacker_pixels(beamheight);
142
143         % The +0.4  is a lowres fix to ensure that
144         % the brush doesn't turn into a knob on 600dpi or lower.
145         top_stem_thick = round (1.9 stafflinethickness) + 0.4;
146         
147
148         interstem + stemwidth =  w;
149         stemwidth = 1.3 stafflinethickness;
150
151         z2 -z1 = (interstem, slope * interstem);
152         xpart .5 [z2,z1] = xcenter ;
153         xcenter = w/2;
154
155
156         pickup penrazor scaled beamheight rotated 90;
157         top y2 = staff_space - 3/2 stafflinethickness ;
158         slope = stafflinethickness / interstem;
159         
160         draw z1 .. z2;
161         draw (xpart z1, -y2) .. (xpart z2, -y1);
162         beamtop = top y2;
163
164         pickup pencircle scaled stemwidth;
165         x3 := round (xpart z1);
166         x4 := round (xpart z2);
167
168         penpos3(top_stem_thick, 0);
169         penpos5(top_stem_thick, 0);     
170         penpos4(stemwidth, 0);
171         penpos6(stemwidth, 0);  
172         
173         y3 = height;
174         top y4 = beamtop;
175
176         x5 = x4;
177         x6 = x3;
178         bot y6 = -beamtop;
179         y5 = - height;
180
181         fill simple_serif (z3l, z3r, -30) -- simple_serif(z6r, z6l, -90) -- cycle;
182         fill simple_serif (z5l, z5r, 30) -- simple_serif(z4r, z4l, 90) -- cycle;
183
184
185
186         penlabels(3,4,5,6);
187
188         labels(1,2);
189         fet_endchar;
190
191
192 %
193 % Dedicated to my mom.    (3/10/97)
194 %
195 % Mamma, ik hou van je; kom je alsjeblieft terug? 
196 %    -- HW
197 %
198
199 % TODO: remove crook_fatness
200 % TODO: document, simplify!
201 %
202 def draw_meta_flat(expr xcenter, w, crook_fatness) =
203         clearxy;
204         save crook_thinness;
205         save bottom_overshoot;
206         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
207         save top_crook_thinness;
208         save zwiep; 
209         save center;
210         pair center;
211         save clearing;
212         center = (xcenter, 0);
213
214 % the shouldn't reach to the top staff line.
215 %% TODO: should take from height.
216         clearing = 1.2 stafflinethickness; 
217
218 %
219 %  TODO: parameterize  this
220 %
221         if w >= 0.75 staff_space:
222                 smaller_hole = 0.35 stafflinethickness;
223         else:
224                 smaller_hole = 0.0 stafflinethickness;
225         fi
226         crook_thinness = 1.3 stafflinethickness;
227         top_crook_thinness = 1.65 stafflinethickness;
228
229         % this is a somewhat heuristic.  We should  probably make it
230         % straight for low resolution (300 dpi and less).
231         top_stem_thick = round (2.2 stafflinethickness) + 0.74;
232
233         bottom_overshoot = stafflinethickness;
234         bottom_stem_thick = 1.2 stafflinethickness;
235
236         z1 = (0, 2 staff_space) + center - (0, stafflinethickness/2
237                 + clearing);
238         z2 =  (0, - 1/2 staff_space - stafflinethickness/2 )+  center;
239
240         penpos1(top_stem_thick, 0);
241         penpos2(bottom_stem_thick, 0); 
242
243         fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
244
245
246         y3l = (staff_space - stafflinethickness) / 2 + ypart center;
247         z3l = whatever [z2r,z1r];
248
249         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
250
251         z10 = whatever [z2r, z1r] + (smaller_hole , 0);
252         z11 = center + (bottom_overshoot/3,
253                 -staff_space/2 - stafflinethickness/2) - (0,bottom_overshoot);
254
255         penpos4(whatever, 53);
256
257         y4l - y4r =  top_crook_thinness ;
258
259         y5r = .20 staff_space + ypart center;
260         x5l = w + xpart center;
261         y4 = ypart center + staff_space/2;
262         x4r = .45 [x5r, x3r];
263
264         penpos5(crook_fatness, -185);
265
266         save bot_crook_dir ;
267         pair bot_crook_dir ;
268         bot_crook_dir =  unitvector ((x5l,0) - z11);
269         z8 = z11 +  whatever * bot_crook_dir;
270         y8 = - staff_space /2  +0.0* stafflinethickness;
271
272         z7 = z8 + whatever * bot_crook_dir + crook_thinness  * (bot_crook_dir rotated 90);
273
274         x7 = .1 [x3r, x8];
275
276         penlabels(range 0 thru 10);
277
278         y10 = -1/10 staff_space;
279 %       draw_staff (-2, 2, 0.5);
280         draw_staff (-2, 2, 0.0);
281
282         unfill z3r{z3r-z10} .. z4r{right} .. z5r{down}
283
284                 ..  z7{- bot_crook_dir}
285                 & z7 % .. tension 1.3
286                 .. z10{z3r-z10}
287
288                 -- cycle;
289         fill z2l{down}
290                 
291                 .. z11{right}
292                 .. z8{bot_crook_dir}
293                 .. z5l{up}
294                 .. z4l{left} .. z3l -- cycle;
295                 
296         labels(10);
297 enddef;
298
299         
300 %
301 % unfortunately, 600dpi is not enough to show the brush of the stem.
302 %
303 fet_beginchar("Flat", "-2", "flat")
304         set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
305         draw_meta_flat(0, w, 0.31 staff_space);
306         fet_endchar;
307
308 fet_beginchar("Semi flat", "-1", "semiflat")
309         set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
310         draw_meta_flat(0, w, 0.31 staff_space);
311         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);  
312         fet_endchar;
313
314
315 fet_beginchar("Double Flat", "-4", "flatflat")
316         save left_wid, overlap, right_wid;
317         left_wid = .7;
318         right_wid = .8;
319         overlap = .05;
320         set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
321         draw_meta_flat(0, left_wid*  staff_space, 1/3 staff_space);
322         draw_meta_flat(round ((left_wid - overlap) *staff_space),
323                 right_wid *staff_space, 0.33 staff_space);
324         fet_endchar;
325
326 fet_beginchar("3/4 Flat", "-3", "threeqflat")
327         save left_wid, overlap, right_wid;
328         left_wid = .7;
329         right_wid = .8;
330         overlap = .05;
331         set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
332         draw_meta_flat(0, left_wid*  staff_space, 1/3 staff_space);
333         draw_meta_flat(round ((left_wid - overlap) *staff_space),
334                 right_wid *staff_space, 0.33 staff_space);
335
336         %% maybe we should clip part of the stems?
337         %% or make the 1st flat smaller?
338         %% or reverse it? 
339         pickup pencircle scaled 2 stafflinethickness;
340         z12 = ( - .25 w - b, .55 staff_space);
341         z13 = (  .75 w , 1.45 staff_space);
342         draw z12 -- z13;
343         fet_endchar;
344
345
346 fet_beginchar("Double Sharp", "4", "sharpsharp")
347         set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
348         save klaverblad, klaversteel;
349
350         klaversteel = 1/15 staff_space;
351         klaverblad = .35 staff_space;
352
353         z1 = (klaversteel, 0);
354         z2 = (w/2 - klaverblad / 10, h - klaverblad);
355         z3 = (w/2, h);
356         z4 = z2 reflectedabout((0,0), (1,1));
357         z5 = z1 reflectedabout((0,0), (1,1));
358
359         labels(1,2,3,4,5);
360         pickup pencircle scaled blot_diameter;
361         filldraw  
362                 z1{dir 45} .. {right}z2 -- z3 -- 
363                 z4{down} .. {dir 225}z5 .. cycle;
364         
365
366         addto currentpicture also currentpicture yscaled (-d/h);
367         addto currentpicture also currentpicture xscaled (-1);
368
369         % ugh
370         currentpicture := currentpicture  shifted (w/2,0);
371
372
373
374 fet_endchar;
375
376
377 def draw_paren =
378         save leftindent;
379         leftindent# := .2 staff_space#;
380         define_pixels(leftindent);
381         set_char_box(0, .5 staff_space#+stafflinethickness#,
382           staff_space#, staff_space#);
383         z1 = (leftindent,h);
384         z2 = (w-stafflinethickness,0);
385         z3 = (leftindent,-d);
386
387         penpos1(stafflinethickness, 35);
388         penpos2(2 stafflinethickness, 0);
389         penpos3(stafflinethickness, -35);
390
391         penlabels(1,2,3);
392         fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
393         .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
394 enddef;
395   
396 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
397         draw_paren;
398 fet_endchar;
399
400 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
401         draw_paren;
402         currentpicture := currentpicture xscaled -1;
403         set_char_box(charwd, charbp, chardp, charht);
404 fet_endchar;
405
406 fet_endgroup("accidentals");
407