2 % feta-toevallig.mf -- implement Accidentals
4 % source file of the Feta (Font-En-Tja) music font
6 % (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 % Accidentals from various sources, notably
13 % Baerenreiter edition of Schuberts `Auf dem Strom' (sharp, natural)
14 % F Hofmeister edition of Muellers `Etueden fuer Horn' (double sharp, flat)
20 %\tracingequations:= tracingonline := 1;
22 fet_begingroup("accidentals");
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
29 fet_beginchar("Sharp" , "1", "sharp");
30 set_char_box(0, 1.1 staff_space#, 1.5 staff_space#,
33 save interbeam, interstem, beamheight, beamwidth,
36 interbeam := 1.05 staff_space;
38 beamheight := 4 stafflinethickness;
40 stemwidth := 1.5 stafflinethickness;
41 roundness := 2 blot_diameter;
46 roundness + 2 spanwidth = beamwidth;
47 roundness + 2 spanheight = beamheight;
49 2 horizontal_protrusion + interstem * beamwidth + stemwidth
52 % wanske: whole beamheight; or ca 18 degrees
53 % z2 - z1 = (beamwidth - roundness, beamheight/2);
54 z2 - z1 = (beamwidth - roundness, beamheight);
56 beamslope = (y2-y1)/(x2-x1);
59 hspan = (spanwidth, beamslope * spanwidth);
60 vspan = (0, spanheight);
64 beam := (hspan + vspan -- -hspan
65 + vspan -- -hspan -vspan -- hspan - vspan -- cycle )
68 pickup pencircle scaled roundness;
69 filldraw (beam shifted (0,-interbeam/2));
71 pickup pencircle scaled stemwidth;
72 x3 = x4 = xpart center;
75 xs := interstem* beamwidth / 2;
77 (bot y3) + -xs * beamslope = -1.5 staff_space + ypart center;
78 top y4 + xs * beamslope = 1.5 staff_space + ypart center;
80 draw_gridline (z3-(xs,xs* beamslope),z4-(xs,xs*beamslope),stemwidth);
81 addto currentpicture also currentpicture rotated 180 shifted (w,0);
85 % to check that it doesn't overshoot staffline.
87 % pickup pencircle scaled stafflinethickness;
88 % draw (0, 1.5 staff_space ) .. (1 staff_space, 1.5 staff_space);
94 % The stems of the natural are brushed (at least, in Barenreiter SCS )
98 fet_beginchar( "Natural", "0", "natural")
100 save interbeam, interstem, beamheight, beamwidth,
104 beamheight# = 4.0 stafflinethickness#;
105 height# = 1.5 staff_space#;
106 set_char_box(0, 2/3 staff_space#, height#, height#);
108 define_pixels(height);
109 define_blacker_pixels(beamheight);
111 % perhaps we should have a lowres fix?
112 top_stem_thick = 1.9 stafflinethickness;
114 interstem + stemwidth = w;
115 stemwidth = 1.3 stafflinethickness;
117 z2 -z1 = (interstem, slope * interstem);
118 xpart .5 [z2,z1] = xcenter ;
122 pickup penrazor scaled beamheight rotated 90;
123 top y2 = staff_space - 3/2 stafflinethickness ;
124 slope = stafflinethickness / interstem;
127 draw (xpart z1, -y2) .. (xpart z2, -y1);
130 pickup pencircle scaled stemwidth;
131 x3 := round (xpart z1);
132 x4 := round (xpart z2);
134 penpos3(top_stem_thick, 0);
135 penpos5(top_stem_thick, 0);
136 penpos4(stemwidth, 0);
137 penpos6(stemwidth, 0);
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;
159 % Dedicated to my mom. (3/10/97)
161 % Mamma, ik hou van je; kom je alsjeblieft terug?
165 % TODO: remove crook_fatness
166 % TODO: document, simplify!
168 def draw_meta_flat(expr xcenter, w, crook_fatness) =
171 save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
174 center = (xcenter, 0);
177 % TODO: parameterize this
179 if w >= 0.75 staff_space:
180 smaller_hole = 0.2 stafflinethickness;
182 smaller_hole = 0.0 stafflinethickness;
184 crook_thinness = 1.1 stafflinethickness;
185 top_stem_thick = 2 stafflinethickness;
186 bottom_stem_thick = 1.2 stafflinethickness;
189 z1 = (0, 2 staff_space) + center;
190 z2 = (0, - 1/2 staff_space)+ center;
192 penpos1(top_stem_thick, 0);
193 penpos2(bottom_stem_thick, 0);
195 fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
198 y3l = (staff_space - stafflinethickness)/2 + ypart center;
199 z3l = whatever [z2r,z1r];
201 z3r = .26 [z2r, z1r] + (smaller_hole, 0);
202 z10 = whatever [z2r, z1r] + (smaller_hole , 0);
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] ;
211 y5r = 1/4 staff_space + ypart center;
212 x5l = w + xpart center;
213 penpos5(crook_fatness, -175);
215 z8 = (0, - staff_space/2 - stafflinethickness/2) + center;
220 ne_angle = angle(z9 - z8);
222 z7 = 8/33 [z8,z9] + (1.0 smaller_hole, 0);
223 z6l = 18/33 [z8,z9] + .5 crook_thinness *dir(ne_angle -90);
225 penpos7(crook_thinness, ne_angle + 90);
227 z6r = .3 (z9-z8) + z7r;
229 penpos8(whatever, ne_angle + 90);
230 x8r = xpart center - bottom_stem_thick/2;
231 penlabels(range 0 thru 10);
233 y10 = -1/5 staff_space;
235 unfill z3r .. z4r{right} .. tension .9
238 .. z10{z3r-z10} -- cycle;
240 .. tension 0.8 ..z8l{(z9-z8)}
244 .. z4l{left} .. z3l -- cycle;
251 % unfortunately, 600dpi is not enough to show the brush of the stem.
253 fet_beginchar("Flat", "-1", "flat")
254 set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 2 staff_space#);
255 draw_meta_flat(0, w, 1/3 staff_space);
259 fet_beginchar("Double Flat", "-2", "flatflat")
260 save left_wid, overlap, right_wid;
264 set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 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);
270 fet_beginchar("Double Sharp", "2", "sharpsharp")
271 set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
272 save klaverblad, klaversteel;
274 klaversteel = 1/15 staff_space;
275 klaverblad = .35 staff_space;
277 z1 = (klaversteel, 0);
278 z2 = (w/2 - klaverblad / 10, h - klaverblad);
280 z4 = z2 reflectedabout((0,0), (1,1));
281 z5 = z1 reflectedabout((0,0), (1,1));
284 pickup pencircle scaled 1/20 staff_space;
286 z1{dir 45} .. {right}z2 -- z3 --
287 z4{down} .. {dir 225}z5 .. cycle;
290 addto currentpicture also currentpicture yscaled (-d/h);
291 addto currentpicture also currentpicture xscaled (-1);
294 currentpicture := currentpicture shifted (w/2,0);
303 leftindent# := .2 staff_space#;
304 define_pixels(leftindent);
305 set_char_box(0, .5 staff_space#+stafflinethickness#,
306 staff_space#, staff_space#);
308 z2 = (w-stafflinethickness,0);
309 z3 = (leftindent,-d);
311 penpos1(stafflinethickness, 35);
312 penpos2(2 stafflinethickness, 0);
313 penpos3(stafflinethickness, -35);
316 fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
317 .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
320 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
324 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
326 currentpicture := currentpicture xscaled -1;
327 set_char_box(charwd, charbp, chardp, charht);
330 fet_endgroup("accidentals");