2 % feta-toevallig.mf -- implement Accidentals
4 % source file of the Feta (Font-En-Tja) music font
6 % (c) 1997--2004 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
30 def draw_meta_sharp (expr width) =
31 save interbeam, interstem, beamheight, beamwidth,
33 save spanwidth, spanheight;
38 interbeam := 1.05 staff_space;
39 beamheight := 0.3 staff_space + stafflinethickness;
41 stemwidth := 1.0 stafflinethickness + .05 staff_space;
42 roundness := 2 blot_diameter;
46 roundness + 2 spanwidth = beamwidth;
47 roundness + 2 spanheight = beamheight;
49 z2 - z1 = (beamwidth - roundness, beamheight);
51 beamslope = (y2-y1)/(x2-x1);
54 hspan = (spanwidth, beamslope * spanwidth);
55 vspan = (0, spanheight);
58 beam := (hspan + vspan -- -hspan
59 + vspan -- -hspan -vspan -- hspan - vspan -- cycle )
62 pickup pencircle scaled roundness;
63 filldraw (beam shifted (0,-interbeam/2));
65 pickup pencircle scaled stemwidth;
66 x3 = x4 = xpart center;
71 fet_beginchar("Sharp" , "2", "sharp");
72 set_char_box(0, 1.1 staff_space#, 1.5 staff_space#,
79 (bot y3) + - stemx * beamslope = -1.5 staff_space + ypart center;
80 top y4 + stemx * beamslope = 1.5 staff_space + ypart center;
84 draw_gridline (z3-(stemx,stemx* beamslope),z4-(stemx, stemx*beamslope), stemwidth);
85 addto currentpicture also currentpicture rotated 180 shifted (w,0);
89 fet_beginchar("1/2 Sharp" , "1", "semisharp");
90 set_char_box(0, 0.7 staff_space#, 1.5 staff_space#,
96 (bot y3) + - stemx * beamslope = -1.5 staff_space + ypart center;
97 top y4 + stemx * beamslope = 1.5 staff_space + ypart center;
101 draw_gridline (z3, z4, stemwidth);
102 addto currentpicture also currentpicture rotated 180 shifted (w,0);
107 fet_beginchar("3/4 Sharp" , "3", "threequartersharp");
108 set_char_box(0, 1.6 staff_space#, 1.5 staff_space#,
114 (bot y3) + - stemx * beamslope = -1.5 staff_space + ypart center;
115 top y4 + stemx * beamslope = 1.5 staff_space + ypart center;
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);
126 % The stems of the natural are brushed (at least, in Barenreiter SCS )
130 fet_beginchar( "Natural", "0", "natural")
131 save height, xcenter;
132 save interbeam, interstem, beamheight, beamwidth,
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#);
140 define_pixels(height);
141 define_blacker_pixels(beamheight);
143 top_stem_thick = round (1 stafflinethickness + .09staff_space ) + 0.4;
144 stemwidth = 0.08 staff_space + .5 stafflinethickness;
147 interstem + stemwidth = w;
149 z2 -z1 = (interstem, slope * interstem);
150 xpart .5 [z2,z1] = xcenter ;
154 pickup penrazor scaled beamheight rotated 90;
155 top y2 = staff_space - 3/2 stafflinethickness ;
156 slope = stafflinethickness / interstem;
159 draw (xpart z1, -y2) .. (xpart z2, -y1);
162 pickup pencircle scaled stemwidth;
163 x3 := round (xpart z1);
164 x4 := round (xpart z2);
166 penpos3(top_stem_thick, 0);
167 penpos5(top_stem_thick, 0);
168 penpos4(stemwidth, 0);
169 penpos6(stemwidth, 0);
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;
191 % Dedicated to my mom. (3/10/97)
193 % Mamma, ik hou van je; kom je alsjeblieft terug?
197 % TODO: remove crook_fatness
198 % TODO: document, simplify!
200 def draw_meta_flat(expr xcenter, w, crook_fatness) =
203 save bottom_overshoot;
204 save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
205 save top_crook_thinness;
210 center = (xcenter, 0);
212 % the shouldn't reach to the top staff line.
213 %% TODO: should take from height.
214 clearing = 1.2 stafflinethickness;
217 % TODO: parameterize this
219 if w >= 0.75 staff_space:
220 smaller_hole = 0.35 stafflinethickness;
222 smaller_hole = 0.0 stafflinethickness;
224 crook_thinness = .7 stafflinethickness + .06 staff_space;
225 top_crook_thinness = 1 stafflinethickness + .065 staff_space ;
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;
231 bottom_overshoot = stafflinethickness;
232 bottom_stem_thick = 0.06 staff_space + 0.6 stafflinethickness;
234 z1 = (0, 2 staff_space) + center - (0, stafflinethickness/2
236 z2 = (0, - 1/2 staff_space - stafflinethickness/2 )+ center;
238 penpos1(top_stem_thick, 0);
239 penpos2(bottom_stem_thick, 0);
241 fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
244 y3l = (staff_space - stafflinethickness) / 2 + ypart center;
245 z3l = whatever [z2r,z1r];
247 z3r = .3 [z2r, z1r] + (smaller_hole, 0);
249 z10 = whatever [z2r, z1r] + (smaller_hole , 0);
250 z11 = center + (bottom_overshoot/3,
251 -staff_space/2 - stafflinethickness/2) - (0,bottom_overshoot);
253 penpos4(whatever, 53);
255 y4l - y4r = top_crook_thinness ;
257 y5r = .15 staff_space + ypart center;
258 x5l = w + xpart center;
259 y4 = ypart center + staff_space/2;
260 x4r = .45 [x5r, x3r];
262 penpos5(crook_fatness, -175);
266 bot_crook_dir = unitvector ((x5l,0) - z11);
267 z8 = z11 + whatever * bot_crook_dir;
268 y8 = - staff_space /2 +0.0* stafflinethickness;
270 z7 = z8 + whatever * bot_crook_dir + crook_thinness * (bot_crook_dir rotated 90);
274 penlabels(range 0 thru 10);
276 y10 = -1/10 staff_space;
277 % draw_staff (-2, 2, 0.5);
278 % draw_staff (-2, 2, 0.0);
280 unfill z3r{z3r-z10} .. z4r{right} .. z5r{down}
281 .. z7{- bot_crook_dir}
282 & z7 % .. tension 1.3
291 .. z4l{left} .. z3l -- cycle;
298 % unfortunately, 600dpi is not enough to show the brush of the stem.
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);
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);
312 fet_beginchar("Double Flat", "-4", "flatflat")
313 save left_wid, overlap, right_wid;
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);
323 fet_beginchar("3/4 Flat", "-3", "threeqflat")
324 save left_wid, overlap, right_wid;
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);
333 %% maybe we should clip part of the stems?
334 %% or make the 1st flat smaller?
336 pickup pencircle scaled 2 stafflinethickness;
337 z12 = ( - .25 w - b, .55 staff_space);
338 z13 = ( .75 w , 1.45 staff_space);
343 fet_beginchar("Double Sharp", "4", "sharpsharp")
344 set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
345 save klaverblad, klaversteel;
347 klaversteel = 1/15 staff_space;
348 klaverblad = .40 staff_space - .5 stafflinethickness;
350 z1 = (klaversteel, 0);
351 z2 = (w/2 - klaverblad / 10, h - klaverblad);
353 z4 = z2 reflectedabout((0,0), (1,1));
354 z5 = z1 reflectedabout((0,0), (1,1));
357 pickup pencircle scaled blot_diameter;
359 z1{dir 45} .. {right}z2 -- z3 --
360 z4{down} .. {dir 225}z5 .. cycle;
363 addto currentpicture also currentpicture yscaled (-d/h);
364 addto currentpicture also currentpicture xscaled (-1);
367 currentpicture := currentpicture shifted (w/2,0);
376 leftindent# := .2 staff_space#;
377 define_pixels(leftindent);
378 set_char_box(0, .5 staff_space#+stafflinethickness#,
379 staff_space#, staff_space#);
381 z2 = (w-stafflinethickness,0);
382 z3 = (leftindent,-d);
384 penpos1(stafflinethickness, 35);
385 penpos2(.1 staff_space + stafflinethickness, 0);
386 penpos3(stafflinethickness, -35);
389 fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
390 .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
393 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
397 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
399 currentpicture := currentpicture xscaled -1;
400 set_char_box(charwd, charbp, chardp, charht);
403 fet_endgroup("accidentals");