]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
* Another grand 2003 update.
[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 fet_beginchar("Sharp" , "1", "sharp");
30         set_char_box(0, 1.1 staff_space#, 1.5 staff_space#, 
31                 1.5 staff_space#);
32
33         save interbeam, interstem, beamheight, beamwidth, 
34                 stemwidth, beamslope;
35
36         interbeam := 1.05 staff_space;
37         interstem := 7/16 ;
38         beamheight := 4 stafflinethickness;
39         beamwidth := w;
40         stemwidth := 1.5 stafflinethickness;
41         roundness := 2 blot_diameter;
42
43         pair center;
44         center := (.5 w, 0);
45         
46         roundness + 2 spanwidth = beamwidth;
47         roundness + 2 spanheight = beamheight;
48
49         2 horizontal_protrusion  + interstem * beamwidth + stemwidth
50                 = beamwidth;
51         
52 % wanske: whole beamheight; or ca 18 degrees
53 %       z2 - z1 = (beamwidth - roundness, beamheight/2);
54         z2 - z1 = (beamwidth - roundness, beamheight);
55         z1 + z2 = 2*center;
56         beamslope = (y2-y1)/(x2-x1);
57
58         pair hspan, vspan;
59         hspan = (spanwidth, beamslope * spanwidth);
60         vspan = (0, spanheight);
61
62         
63         path beam;
64         beam := (hspan + vspan -- -hspan 
65                 +  vspan -- -hspan -vspan -- hspan - vspan -- cycle )
66                 shifted center;
67
68         pickup pencircle scaled roundness;
69         filldraw (beam shifted (0,-interbeam/2));
70
71         pickup pencircle scaled stemwidth;
72         x3 = x4 = xpart center;
73
74         numeric xs;
75         xs := interstem* beamwidth / 2;
76
77         (bot y3) + -xs * beamslope = -1.5 staff_space + ypart center;
78         top y4  + xs * beamslope = 1.5 staff_space + ypart center;
79
80         draw_gridline (z3-(xs,xs* beamslope),z4-(xs,xs*beamslope),stemwidth);
81         addto currentpicture also currentpicture rotated 180 shifted (w,0);
82         labels(1,2,3,4);
83
84
85 % to check that it doesn't overshoot staffline.
86 %
87 %       pickup pencircle scaled stafflinethickness;
88 %       draw (0, 1.5 staff_space ) ..  (1 staff_space, 1.5 staff_space);
89
90         fet_endchar;
91
92
93 %
94 % The stems of the natural are brushed (at least, in Barenreiter SCS )
95 %
96 %
97
98 fet_beginchar( "Natural", "0", "natural")
99         save height, xcenter;
100         save interbeam, interstem, beamheight, beamwidth, 
101         stemwidth;
102         save top_stem_thick;
103
104         beamheight# = 4.0 stafflinethickness#;
105         height# = 1.5 staff_space#;
106         set_char_box(0, 2/3 staff_space#, height#, height#);
107
108         define_pixels(height);
109         define_blacker_pixels(beamheight);
110
111         % perhaps we should have a lowres fix?
112         top_stem_thick = 1.9 stafflinethickness;
113
114         interstem + stemwidth =  w;
115         stemwidth = 1.3 stafflinethickness;
116
117         z2 -z1 = (interstem, slope * interstem);
118         xpart .5 [z2,z1] = xcenter ;
119         xcenter = w/2;
120
121
122         pickup penrazor scaled beamheight rotated 90;
123         top y2 = staff_space - 3/2 stafflinethickness ;
124         slope = stafflinethickness / interstem;
125         
126         draw z1 .. z2;
127         draw (xpart z1, -y2) .. (xpart z2, -y1);
128         beamtop = top y2;
129
130         pickup pencircle scaled stemwidth;
131         x3 := round (xpart z1);
132         x4 := round (xpart z2);
133
134         penpos3(top_stem_thick, 0);
135         penpos5(top_stem_thick, 0);     
136         penpos4(stemwidth, 0);
137         penpos6(stemwidth, 0);  
138         
139         y3 = height;
140         top y4 = beamtop;
141
142         x5 = x4;
143         x6 = x3;
144         bot y6 = -beamtop;
145         y5 = - height;
146
147         fill simple_serif (z3l, z3r, -30) -- simple_serif(z6r, z6l, -90) -- cycle;
148         fill simple_serif (z5l, z5r, 30) -- simple_serif(z4r, z4l, 90) -- cycle;
149
150
151
152         penlabels(3,4,5,6);
153
154         labels(1,2);
155         fet_endchar;
156
157
158 %
159 % Dedicated to my mom.    (3/10/97)
160 %
161 % Mamma, ik hou van je; kom je alsjeblieft terug? 
162 %    -- HW
163 %
164
165 % TODO: remove crook_fatness
166 % TODO: document, simplify!
167 %
168 def draw_meta_flat(expr xcenter, w, crook_fatness) =
169         clearxy;
170         save crook_thinness;
171         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
172         save center;
173         pair center;
174         save clearing;
175         center = (xcenter, 0);
176
177 % the shouldn't reach to the top staff line.
178 %% TODO: should take from height.
179         clearing = 1.2 stafflinethickness; 
180
181 %
182 %  TODO: parameterize  this
183 %
184         if w >= 0.75 staff_space:
185                 smaller_hole = 0.2 stafflinethickness;
186         else:
187                 smaller_hole = 0.0 stafflinethickness;
188         fi
189         crook_thinness = 1.25 stafflinethickness;
190         top_stem_thick = 2.2 stafflinethickness;
191         bottom_stem_thick = 1.2 stafflinethickness;
192
193
194         z1 = (0, 2 staff_space) + center - (0, stafflinethickness/2 + clearing);
195         z2 = (0, - 1/2 staff_space)+  center;
196
197         penpos1(top_stem_thick, 0);
198         penpos2(bottom_stem_thick, 0); 
199
200         fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
201
202
203         y3l = (staff_space - stafflinethickness)/2 + ypart center;
204         z3l = whatever [z2r,z1r];
205
206         z3r = .26 [z2r, z1r] + (smaller_hole, 0);
207         z10 = whatever [z2r, z1r] + (smaller_hole , 0);
208
209         
210
211         z4 = (3/8 staff_space, staff_space/2) + center;
212         penpos4(whatever, 53);
213         y4l - y4r = 2 crook_thinness ;
214 %       y4l - y4r = 6/20[crook_thinness, crook_fatness] ;
215
216         y5r = 1/4 staff_space + ypart center;
217         x5l = w + xpart center;
218         penpos5(crook_fatness, -175);
219
220         z8 = (0, - staff_space/2 - stafflinethickness/2) + center;
221
222         z9 = (x5,0);
223
224         save ne_angle;
225         ne_angle = angle(z9 - z8);
226
227         z7 = 8/33 [z8,z9] + (1.0 smaller_hole, 0);
228         z6l = 18/33 [z8,z9] + .5 crook_thinness *dir(ne_angle -90);
229   
230         penpos7(crook_thinness, ne_angle + 90);
231
232         z6r = .3 (z9-z8) + z7r;
233
234         penpos8(whatever, ne_angle + 90);
235         x8r =  xpart center - bottom_stem_thick/2;
236         penlabels(range 0 thru 10);
237
238         y10 = -1/5 staff_space;
239
240         unfill z3r .. z4r{right} .. tension .9 
241                 .. z6r ---
242                 z7r{left} 
243                 .. z10{z3r-z10}  -- cycle;
244         fill z8r{down}
245                 .. tension 0.8 ..z8l{(z9-z8)}
246                 .. z7l
247                 .. z6l
248                 .. z5l{up}
249                 .. z4l{left} .. z3l -- cycle;
250                 
251         labels(10);
252 enddef;
253
254         
255 %
256 % unfortunately, 600dpi is not enough to show the brush of the stem.
257 %
258 fet_beginchar("Flat", "-1", "flat")
259         set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
260         draw_meta_flat(0, w, 0.31 staff_space);
261         fet_endchar;
262
263
264 fet_beginchar("Double Flat", "-2", "flatflat")
265         save left_wid, overlap, right_wid;
266         left_wid = .7;
267         right_wid = .8;
268         overlap = .05;
269         set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
270         draw_meta_flat(0, left_wid*  staff_space, 1/3 staff_space);
271         draw_meta_flat((left_wid - overlap) *staff_space,  
272                 right_wid *staff_space, 0.33 staff_space);
273         fet_endchar;
274
275 fet_beginchar("Double Sharp", "2", "sharpsharp")
276         set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
277         save klaverblad, klaversteel;
278
279         klaversteel = 1/15 staff_space;
280         klaverblad = .35 staff_space;
281
282         z1 = (klaversteel, 0);
283         z2 = (w/2 - klaverblad / 10, h - klaverblad);
284         z3 = (w/2, h);
285         z4 = z2 reflectedabout((0,0), (1,1));
286         z5 = z1 reflectedabout((0,0), (1,1));
287
288         labels(1,2,3,4,5);
289         pickup pencircle scaled 1/20 staff_space;
290         filldraw  
291                 z1{dir 45} .. {right}z2 -- z3 -- 
292                 z4{down} .. {dir 225}z5 .. cycle;
293         
294
295         addto currentpicture also currentpicture yscaled (-d/h);
296         addto currentpicture also currentpicture xscaled (-1);
297
298         % ugh
299         currentpicture := currentpicture  shifted (w/2,0);
300
301
302
303 fet_endchar;
304
305
306 def draw_paren =
307         save leftindent;
308         leftindent# := .2 staff_space#;
309         define_pixels(leftindent);
310         set_char_box(0, .5 staff_space#+stafflinethickness#,
311           staff_space#, staff_space#);
312         z1 = (leftindent,h);
313         z2 = (w-stafflinethickness,0);
314         z3 = (leftindent,-d);
315
316         penpos1(stafflinethickness, 35);
317         penpos2(2 stafflinethickness, 0);
318         penpos3(stafflinethickness, -35);
319
320         penlabels(1,2,3);
321         fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
322         .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
323 enddef;
324   
325 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
326         draw_paren;
327 fet_endchar;
328
329 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
330         draw_paren;
331         currentpicture := currentpicture xscaled -1;
332         set_char_box(charwd, charbp, chardp, charht);
333 fet_endchar;
334
335 fet_endgroup("accidentals");
336