]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
Imported sources
[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, 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 := 0.3 staff_space + stafflinethickness;
40         beamwidth := width;
41         stemwidth := 1.0 stafflinethickness + .05 staff_space;
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# = 0.35 staff_space# + .5 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         top_stem_thick = round (1 stafflinethickness + .09staff_space ) + 0.4;
144         stemwidth = 0.08 staff_space + .5 stafflinethickness;
145         
146
147         interstem + stemwidth =  w;
148
149         z2 -z1 = (interstem, slope * interstem);
150         xpart .5 [z2,z1] = xcenter ;
151         xcenter = w/2;
152
153
154         pickup penrazor scaled beamheight rotated 90;
155         top y2 = staff_space - 3/2 stafflinethickness ;
156         slope = stafflinethickness / interstem;
157         
158         draw z1 .. z2;
159         draw (xpart z1, -y2) .. (xpart z2, -y1);
160         beamtop = top y2;
161
162         pickup pencircle scaled stemwidth;
163         x3 := round (xpart z1);
164         x4 := round (xpart z2);
165
166         penpos3(top_stem_thick, 0);
167         penpos5(top_stem_thick, 0);     
168         penpos4(stemwidth, 0);
169         penpos6(stemwidth, 0);  
170         
171         y3 = height;
172         top y4 = beamtop;
173
174         x5 = x4;
175         x6 = x3;
176         bot y6 = -beamtop;
177         y5 = - height;
178
179         fill simple_serif (z3l, z3r, -30) -- simple_serif(z6r, z6l, -90) -- cycle;
180         fill simple_serif (z5l, z5r, 30) -- simple_serif(z4r, z4l, 90) -- cycle;
181
182
183
184         penlabels(3,4,5,6);
185
186         labels(1,2);
187         fet_endchar;
188
189
190 %
191 % Dedicated to my mom.    (3/10/97)
192 %
193 % Mamma, ik hou van je; kom je alsjeblieft terug? 
194 %    -- HW
195 %
196
197 % TODO: remove crook_fatness
198 % TODO: document, simplify!
199 %
200 def draw_meta_flat(expr xcenter, w, crook_fatness) =
201         clearxy;
202         save crook_thinness;
203         save bottom_overshoot;
204         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
205         save top_crook_thinness;
206         save zwiep; 
207         save center;
208         pair center;
209         save clearing;
210         center = (xcenter, 0);
211
212 % the shouldn't reach to the top staff line.
213 %% TODO: should take from height.
214         clearing = 1.2 stafflinethickness; 
215
216 %
217 %  TODO: parameterize  this
218 %
219         if w >= 0.75 staff_space:
220                 smaller_hole = 0.35 stafflinethickness;
221         else:
222                 smaller_hole = 0.0 stafflinethickness;
223         fi
224         crook_thinness = .7 stafflinethickness + .06 staff_space;
225         top_crook_thinness = 1 stafflinethickness + .065 staff_space ;
226
227         % this is a somewhat heuristic.  We should  probably make it
228         % straight for low resolution (300 dpi and less).
229         top_stem_thick = round (0.1 staff_space + 1.2 stafflinethickness) + 0.74;
230
231         bottom_overshoot = stafflinethickness;
232         bottom_stem_thick = 0.06 staff_space +  0.6 stafflinethickness;
233
234         z1 = (0, 2 staff_space) + center - (0, stafflinethickness/2
235                 + clearing);
236         z2 =  (0, - 1/2 staff_space - stafflinethickness/2 )+  center;
237
238         penpos1(top_stem_thick, 0);
239         penpos2(bottom_stem_thick, 0); 
240
241         fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
242
243
244         y3l = (staff_space - stafflinethickness) / 2 + ypart center;
245         z3l = whatever [z2r,z1r];
246
247         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
248
249         z10 = whatever [z2r, z1r] + (smaller_hole , 0);
250         z11 = center + (bottom_overshoot/3,
251                 -staff_space/2 - stafflinethickness/2) - (0,bottom_overshoot);
252
253         penpos4(whatever, 53);
254
255         y4l - y4r =  top_crook_thinness ;
256
257         y5r = .15 staff_space + ypart center;
258         x5l = w + xpart center;
259         y4 = ypart center + staff_space/2;
260         x4r = .45 [x5r, x3r];
261
262         penpos5(crook_fatness, -175);
263
264         save bot_crook_dir ;
265         pair bot_crook_dir ;
266         bot_crook_dir =  unitvector ((x5l,0) - z11);
267         z8 = z11 +  whatever * bot_crook_dir;
268         y8 = - staff_space /2  +0.0* stafflinethickness;
269
270         z7 = z8 + whatever * bot_crook_dir + crook_thinness  * (bot_crook_dir rotated 90);
271
272         x7 = .1 [x3r, x8];
273
274         penlabels(range 0 thru 10);
275
276         y10 = -1/10 staff_space;
277 %       draw_staff (-2, 2, 0.5);
278 %       draw_staff (-2, 2, 0.0);
279
280         unfill z3r{z3r-z10} .. z4r{right} .. z5r{down}
281                 ..  z7{- bot_crook_dir}
282                 & z7 % .. tension 1.3
283                 .. z10{z3r-z10}
284
285                 -- cycle;
286         fill z2l{down}
287                 
288                 .. z11{right}
289                 .. z8{bot_crook_dir}
290                 .. z5l{up}
291                 .. z4l{left} .. z3l -- cycle;
292                 
293         labels(10);
294 enddef;
295
296         
297 %
298 % unfortunately, 600dpi is not enough to show the brush of the stem.
299 %
300 fet_beginchar("Flat", "-2", "flat")
301         set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
302         draw_meta_flat(0, w, 0.31 staff_space);
303         fet_endchar;
304
305 fet_beginchar("Semi flat", "-1", "semiflat")
306         set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
307         draw_meta_flat(0, w, 0.31 staff_space);
308         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);  
309         fet_endchar;
310
311
312 fet_beginchar("Double Flat", "-4", "flatflat")
313         save left_wid, overlap, right_wid;
314         left_wid = .7;
315         right_wid = .8;
316         overlap = .05;
317         set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
318         draw_meta_flat(0, left_wid*  staff_space, 1/3 staff_space);
319         draw_meta_flat(round ((left_wid - overlap) *staff_space),
320                 right_wid *staff_space, 0.33 staff_space);
321         fet_endchar;
322
323 fet_beginchar("3/4 Flat", "-3", "threeqflat")
324         save left_wid, overlap, right_wid;
325         left_wid = .7;
326         right_wid = .8;
327         overlap = .05;
328         set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
329         draw_meta_flat(0, left_wid*  staff_space, 1/3 staff_space);
330         draw_meta_flat(round ((left_wid - overlap) *staff_space),
331                 right_wid *staff_space, 0.33 staff_space);
332
333         %% maybe we should clip part of the stems?
334         %% or make the 1st flat smaller?
335         %% or reverse it? 
336         pickup pencircle scaled 2 stafflinethickness;
337         z12 = ( - .25 w - b, .55 staff_space);
338         z13 = (  .75 w , 1.45 staff_space);
339         draw z12 -- z13;
340         fet_endchar;
341
342
343 fet_beginchar("Double Sharp", "4", "sharpsharp")
344         set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
345         save klaverblad, klaversteel;
346
347         klaversteel = 1/15 staff_space;
348         klaverblad = .40 staff_space - .5 stafflinethickness;
349
350         z1 = (klaversteel, 0);
351         z2 = (w/2 - klaverblad / 10, h - klaverblad);
352         z3 = (w/2, h);
353         z4 = z2 reflectedabout((0,0), (1,1));
354         z5 = z1 reflectedabout((0,0), (1,1));
355
356         labels(1,2,3,4,5);
357         pickup pencircle scaled blot_diameter;
358         filldraw  
359                 z1{dir 45} .. {right}z2 -- z3 -- 
360                 z4{down} .. {dir 225}z5 .. cycle;
361         
362
363         addto currentpicture also currentpicture yscaled (-d/h);
364         addto currentpicture also currentpicture xscaled (-1);
365
366         % ugh
367         currentpicture := currentpicture  shifted (w/2,0);
368
369
370
371 fet_endchar;
372
373
374 def draw_paren =
375         save leftindent;
376         leftindent# := .2 staff_space#;
377         define_pixels(leftindent);
378         set_char_box(0, .5 staff_space#+stafflinethickness#,
379           staff_space#, staff_space#);
380         z1 = (leftindent,h);
381         z2 = (w-stafflinethickness,0);
382         z3 = (leftindent,-d);
383
384         penpos1(stafflinethickness, 35);
385         penpos2(.1 staff_space + stafflinethickness, 0);
386         penpos3(stafflinethickness, -35);
387
388         penlabels(1,2,3);
389         fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
390         .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
391 enddef;
392   
393 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
394         draw_paren;
395 fet_endchar;
396
397 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
398         draw_paren;
399         currentpicture := currentpicture xscaled -1;
400         set_char_box(charwd, charbp, chardp, charht);
401 fet_endchar;
402
403 fet_endgroup("accidentals");
404