]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
''
[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--2002 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         center = (xcenter, 0);
175
176 %
177 %  TODO: parameterize  this
178 %
179         if w >= 0.75 staff_space:
180                 smaller_hole = 0.2 stafflinethickness;
181         else:
182                 smaller_hole = 0.0 stafflinethickness;
183         fi
184         crook_thinness = 1.1 stafflinethickness;
185         top_stem_thick = 2 stafflinethickness;
186         bottom_stem_thick = 1.2 stafflinethickness;
187
188
189         z1 = (0, 2 staff_space) + center;
190         z2 = (0, - 1/2 staff_space)+  center;
191
192         penpos1(top_stem_thick, 0);
193         penpos2(bottom_stem_thick, 0); 
194
195         fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
196
197
198         y3l = (staff_space - stafflinethickness)/2 + ypart center;
199         z3l = whatever [z2r,z1r];
200
201         z3r = .26 [z2r, z1r] + (smaller_hole, 0);
202         z10 = whatever [z2r, z1r] + (smaller_hole , 0);
203
204         
205
206         z4 = (3/8 staff_space, staff_space/2) + center;
207         penpos4(whatever, 53);
208         y4l - y4r = 2 crook_thinness ;
209 %       y4l - y4r = 6/20[crook_thinness, crook_fatness] ;
210
211         y5r = 1/4 staff_space + ypart center;
212         x5l = w + xpart center;
213         penpos5(crook_fatness, -175);
214
215         z8 = (0, - staff_space/2 - stafflinethickness/2) + center;
216
217         z9 = (x5,0);
218
219         save ne_angle;
220         ne_angle = angle(z9 - z8);
221
222         z7 = 8/33 [z8,z9] + (1.0 smaller_hole, 0);
223         z6l = 18/33 [z8,z9] + .5 crook_thinness *dir(ne_angle -90);
224   
225         penpos7(crook_thinness, ne_angle + 90);
226
227         z6r = .3 (z9-z8) + z7r;
228
229         penpos8(whatever, ne_angle + 90);
230         x8r =  xpart center - bottom_stem_thick/2;
231         penlabels(range 0 thru 10);
232
233         y10 = -1/5 staff_space;
234
235         unfill z3r .. z4r{right} .. tension .9 
236                 .. z6r ---
237                 z7r{left} 
238                 .. z10{z3r-z10}  -- cycle;
239         fill z8r{down}
240                 .. tension 0.8 ..z8l{(z9-z8)}
241                 .. z7l
242                 .. z6l
243                 .. z5l{up}
244                 .. z4l{left} .. z3l -- cycle;
245                 
246         labels(10);
247 enddef;
248
249         
250 %
251 % unfortunately, 600dpi is not enough to show the brush of the stem.
252 %
253 fet_beginchar("Flat", "-1", "flat")
254         set_char_box(1.2 stafflinethickness#, .8 staff_space#, .5 staff_space#, 2 staff_space#);
255         draw_meta_flat(0, w, 1/3 staff_space);
256         fet_endchar;
257
258
259 fet_beginchar("Double Flat", "-2", "flatflat")
260         save left_wid, overlap, right_wid;
261         left_wid = .7;
262         right_wid = .8;
263         overlap = .05;
264         set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .5 staff_space#, 2 staff_space#);
265         draw_meta_flat(0, left_wid*  staff_space, 1/3 staff_space);
266         draw_meta_flat((left_wid - overlap) *staff_space,  
267                 right_wid *staff_space, 1/3 staff_space);
268         fet_endchar;
269
270 fet_beginchar("Double Sharp", "2", "sharpsharp")
271         set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
272         save klaverblad, klaversteel;
273
274         klaversteel = 1/15 staff_space;
275         klaverblad = .35 staff_space;
276
277         z1 = (klaversteel, 0);
278         z2 = (w/2 - klaverblad / 10, h - klaverblad);
279         z3 = (w/2, h);
280         z4 = z2 reflectedabout((0,0), (1,1));
281         z5 = z1 reflectedabout((0,0), (1,1));
282
283         labels(1,2,3,4,5);
284         pickup pencircle scaled 1/20 staff_space;
285         filldraw  
286                 z1{dir 45} .. {right}z2 -- z3 -- 
287                 z4{down} .. {dir 225}z5 .. cycle;
288         
289
290         addto currentpicture also currentpicture yscaled (-d/h);
291         addto currentpicture also currentpicture xscaled (-1);
292
293         % ugh
294         currentpicture := currentpicture  shifted (w/2,0);
295
296
297
298 fet_endchar;
299
300
301 def draw_paren =
302         save leftindent;
303         leftindent# := .2 staff_space#;
304         define_pixels(leftindent);
305         set_char_box(0, .5 staff_space#+stafflinethickness#,
306           staff_space#, staff_space#);
307         z1 = (leftindent,h);
308         z2 = (w-stafflinethickness,0);
309         z3 = (leftindent,-d);
310
311         penpos1(stafflinethickness, 35);
312         penpos2(2 stafflinethickness, 0);
313         penpos3(stafflinethickness, -35);
314
315         penlabels(1,2,3);
316         fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
317         .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
318 enddef;
319   
320 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
321         draw_paren;
322 fet_endchar;
323
324 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
325         draw_paren;
326         currentpicture := currentpicture xscaled -1;
327         set_char_box(charwd, charbp, chardp, charht);
328 fet_endchar;
329
330 fet_endgroup("accidentals");
331