]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
* mf/feta-macros.mf: whoops: only draw lines for test situations.
[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         % The +0.4  is a lowres fix to ensure that
112         % the brush doesn't turn into a knob on 600dpi or lower.
113         top_stem_thick = round (1.9 stafflinethickness) + 0.4;
114         
115
116         interstem + stemwidth =  w;
117         stemwidth = 1.3 stafflinethickness;
118
119         z2 -z1 = (interstem, slope * interstem);
120         xpart .5 [z2,z1] = xcenter ;
121         xcenter = w/2;
122
123
124         pickup penrazor scaled beamheight rotated 90;
125         top y2 = staff_space - 3/2 stafflinethickness ;
126         slope = stafflinethickness / interstem;
127         
128         draw z1 .. z2;
129         draw (xpart z1, -y2) .. (xpart z2, -y1);
130         beamtop = top y2;
131
132         pickup pencircle scaled stemwidth;
133         x3 := round (xpart z1);
134         x4 := round (xpart z2);
135
136         penpos3(top_stem_thick, 0);
137         penpos5(top_stem_thick, 0);     
138         penpos4(stemwidth, 0);
139         penpos6(stemwidth, 0);  
140         
141         y3 = height;
142         top y4 = beamtop;
143
144         x5 = x4;
145         x6 = x3;
146         bot y6 = -beamtop;
147         y5 = - height;
148
149         fill simple_serif (z3l, z3r, -30) -- simple_serif(z6r, z6l, -90) -- cycle;
150         fill simple_serif (z5l, z5r, 30) -- simple_serif(z4r, z4l, 90) -- cycle;
151
152
153
154         penlabels(3,4,5,6);
155
156         labels(1,2);
157         fet_endchar;
158
159
160 %
161 % Dedicated to my mom.    (3/10/97)
162 %
163 % Mamma, ik hou van je; kom je alsjeblieft terug? 
164 %    -- HW
165 %
166
167 % TODO: remove crook_fatness
168 % TODO: document, simplify!
169 %
170 def draw_meta_flat(expr xcenter, w, crook_fatness) =
171         clearxy;
172         save crook_thinness;
173         save bottom_overshoot;
174         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
175         save top_crook_thinness;
176         save zwiep; 
177         save center;
178         pair center;
179         save clearing;
180         center = (xcenter, 0);
181
182 % the shouldn't reach to the top staff line.
183 %% TODO: should take from height.
184         clearing = 1.2 stafflinethickness; 
185
186 %
187 %  TODO: parameterize  this
188 %
189         if w >= 0.75 staff_space:
190                 smaller_hole = 0.35 stafflinethickness;
191         else:
192                 smaller_hole = 0.0 stafflinethickness;
193         fi
194         crook_thinness = 1.3 stafflinethickness;
195         top_crook_thinness = 1.65 stafflinethickness;
196
197         % this is a somewhat heuristic.  We should  probably make it
198         % straight for low resolution (300 dpi and less).
199         top_stem_thick = round (2.2 stafflinethickness) + 0.74;
200
201         bottom_overshoot = stafflinethickness;
202         bottom_stem_thick = 1.2 stafflinethickness;
203
204         z1 = (0, 2 staff_space) + center - (0, stafflinethickness/2
205                 + clearing);
206         z2 =  (0, - 1/2 staff_space - stafflinethickness/2 )+  center;
207
208         penpos1(top_stem_thick, 0);
209         penpos2(bottom_stem_thick, 0); 
210
211         fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
212
213
214         y3l = (staff_space - stafflinethickness) / 2 + ypart center;
215         z3l = whatever [z2r,z1r];
216
217         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
218
219         z10 = whatever [z2r, z1r] + (smaller_hole , 0);
220         z11 = center + (bottom_overshoot/3,
221                 -staff_space/2 - stafflinethickness/2) - (0,bottom_overshoot);
222
223         penpos4(whatever, 53);
224
225         y4l - y4r =  top_crook_thinness ;
226
227         y5r = .20 staff_space + ypart center;
228         x5l = w + xpart center;
229         y4 = ypart center + staff_space/2;
230         x4r = .45 [x5r, x3r];
231
232         penpos5(crook_fatness, -185);
233
234         save bot_crook_dir ;
235         pair bot_crook_dir ;
236         bot_crook_dir =  unitvector ((x5l,0) - z11);
237         z8 = z11 +  whatever * bot_crook_dir;
238         y8 = - staff_space /2  +0.0* stafflinethickness;
239
240         z7 = z8 + whatever * bot_crook_dir + crook_thinness  * (bot_crook_dir rotated 90);
241
242         x7 = .1 [x3r, x8];
243
244         penlabels(range 0 thru 10);
245
246         y10 = -1/10 staff_space;
247 %       draw_staff (-2, 2, 0.5);
248         draw_staff (-2, 2, 0.0);
249
250         unfill z3r{z3r-z10} .. z4r{right} .. z5r{down}
251
252                 ..  z7{- bot_crook_dir}
253                 & z7 % .. tension 1.3
254                 .. z10{z3r-z10}
255
256                 -- cycle;
257         fill z2l{down}
258                 
259                 .. z11{right}
260                 .. z8{bot_crook_dir}
261                 .. z5l{up}
262                 .. z4l{left} .. z3l -- cycle;
263                 
264         labels(10);
265 enddef;
266
267         
268 %
269 % unfortunately, 600dpi is not enough to show the brush of the stem.
270 %
271 fet_beginchar("Flat", "-1", "flat")
272         set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
273         draw_meta_flat(0, w, 0.31 staff_space);
274         fet_endchar;
275
276
277 fet_beginchar("Double Flat", "-2", "flatflat")
278         save left_wid, overlap, right_wid;
279         left_wid = .7;
280         right_wid = .8;
281         overlap = .05;
282         set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
283         draw_meta_flat(0, left_wid*  staff_space, 1/3 staff_space);
284         draw_meta_flat(round ((left_wid - overlap) *staff_space),
285                 right_wid *staff_space, 0.33 staff_space);
286         fet_endchar;
287
288 fet_beginchar("Double Sharp", "2", "sharpsharp")
289         set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
290         save klaverblad, klaversteel;
291
292         klaversteel = 1/15 staff_space;
293         klaverblad = .35 staff_space;
294
295         z1 = (klaversteel, 0);
296         z2 = (w/2 - klaverblad / 10, h - klaverblad);
297         z3 = (w/2, h);
298         z4 = z2 reflectedabout((0,0), (1,1));
299         z5 = z1 reflectedabout((0,0), (1,1));
300
301         labels(1,2,3,4,5);
302         pickup pencircle scaled 1/20 staff_space;
303         filldraw  
304                 z1{dir 45} .. {right}z2 -- z3 -- 
305                 z4{down} .. {dir 225}z5 .. cycle;
306         
307
308         addto currentpicture also currentpicture yscaled (-d/h);
309         addto currentpicture also currentpicture xscaled (-1);
310
311         % ugh
312         currentpicture := currentpicture  shifted (w/2,0);
313
314
315
316 fet_endchar;
317
318
319 def draw_paren =
320         save leftindent;
321         leftindent# := .2 staff_space#;
322         define_pixels(leftindent);
323         set_char_box(0, .5 staff_space#+stafflinethickness#,
324           staff_space#, staff_space#);
325         z1 = (leftindent,h);
326         z2 = (w-stafflinethickness,0);
327         z3 = (leftindent,-d);
328
329         penpos1(stafflinethickness, 35);
330         penpos2(2 stafflinethickness, 0);
331         penpos3(stafflinethickness, -35);
332
333         penlabels(1,2,3);
334         fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
335         .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
336 enddef;
337   
338 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
339         draw_paren;
340 fet_endchar;
341
342 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
343         draw_paren;
344         currentpicture := currentpicture xscaled -1;
345         set_char_box(charwd, charbp, chardp, charht);
346 fet_endchar;
347
348 fet_endgroup("accidentals");
349