2 % feta-toevallig.mf -- implement Accidentals
4 % source file of the Feta (Font-En-Tja) music font
6 % (c) 1997--2003 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 := 4 stafflinethickness;
41 stemwidth := 1.5 stafflinethickness;
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# = 4.0 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 % The +0.4 is a lowres fix to ensure that
144 % the brush doesn't turn into a knob on 600dpi or lower.
145 top_stem_thick = round (1.9 stafflinethickness) + 0.4;
148 interstem + stemwidth = w;
149 stemwidth = 1.3 stafflinethickness;
151 z2 -z1 = (interstem, slope * interstem);
152 xpart .5 [z2,z1] = xcenter ;
156 pickup penrazor scaled beamheight rotated 90;
157 top y2 = staff_space - 3/2 stafflinethickness ;
158 slope = stafflinethickness / interstem;
161 draw (xpart z1, -y2) .. (xpart z2, -y1);
164 pickup pencircle scaled stemwidth;
165 x3 := round (xpart z1);
166 x4 := round (xpart z2);
168 penpos3(top_stem_thick, 0);
169 penpos5(top_stem_thick, 0);
170 penpos4(stemwidth, 0);
171 penpos6(stemwidth, 0);
181 fill simple_serif (z3l, z3r, -30) -- simple_serif(z6r, z6l, -90) -- cycle;
182 fill simple_serif (z5l, z5r, 30) -- simple_serif(z4r, z4l, 90) -- cycle;
193 % Dedicated to my mom. (3/10/97)
195 % Mamma, ik hou van je; kom je alsjeblieft terug?
199 % TODO: remove crook_fatness
200 % TODO: document, simplify!
202 def draw_meta_flat(expr xcenter, w, crook_fatness) =
205 save bottom_overshoot;
206 save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
207 save top_crook_thinness;
212 center = (xcenter, 0);
214 % the shouldn't reach to the top staff line.
215 %% TODO: should take from height.
216 clearing = 1.2 stafflinethickness;
219 % TODO: parameterize this
221 if w >= 0.75 staff_space:
222 smaller_hole = 0.35 stafflinethickness;
224 smaller_hole = 0.0 stafflinethickness;
226 crook_thinness = 1.3 stafflinethickness;
227 top_crook_thinness = 1.65 stafflinethickness;
229 % this is a somewhat heuristic. We should probably make it
230 % straight for low resolution (300 dpi and less).
231 top_stem_thick = round (2.2 stafflinethickness) + 0.74;
233 bottom_overshoot = stafflinethickness;
234 bottom_stem_thick = 1.2 stafflinethickness;
236 z1 = (0, 2 staff_space) + center - (0, stafflinethickness/2
238 z2 = (0, - 1/2 staff_space - stafflinethickness/2 )+ center;
240 penpos1(top_stem_thick, 0);
241 penpos2(bottom_stem_thick, 0);
243 fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
246 y3l = (staff_space - stafflinethickness) / 2 + ypart center;
247 z3l = whatever [z2r,z1r];
249 z3r = .3 [z2r, z1r] + (smaller_hole, 0);
251 z10 = whatever [z2r, z1r] + (smaller_hole , 0);
252 z11 = center + (bottom_overshoot/3,
253 -staff_space/2 - stafflinethickness/2) - (0,bottom_overshoot);
255 penpos4(whatever, 53);
257 y4l - y4r = top_crook_thinness ;
259 y5r = .20 staff_space + ypart center;
260 x5l = w + xpart center;
261 y4 = ypart center + staff_space/2;
262 x4r = .45 [x5r, x3r];
264 penpos5(crook_fatness, -185);
268 bot_crook_dir = unitvector ((x5l,0) - z11);
269 z8 = z11 + whatever * bot_crook_dir;
270 y8 = - staff_space /2 +0.0* stafflinethickness;
272 z7 = z8 + whatever * bot_crook_dir + crook_thinness * (bot_crook_dir rotated 90);
276 penlabels(range 0 thru 10);
278 y10 = -1/10 staff_space;
279 % draw_staff (-2, 2, 0.5);
280 draw_staff (-2, 2, 0.0);
282 unfill z3r{z3r-z10} .. z4r{right} .. z5r{down}
284 .. z7{- bot_crook_dir}
285 & z7 % .. tension 1.3
294 .. z4l{left} .. z3l -- cycle;
301 % unfortunately, 600dpi is not enough to show the brush of the stem.
303 fet_beginchar("Flat", "-2", "flat")
304 set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
305 draw_meta_flat(0, w, 0.31 staff_space);
308 fet_beginchar("Semi flat", "-1", "semiflat")
309 set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
310 draw_meta_flat(0, w, 0.31 staff_space);
311 currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
315 fet_beginchar("Double Flat", "-4", "flatflat")
316 save left_wid, overlap, right_wid;
320 set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
321 draw_meta_flat(0, left_wid* staff_space, 1/3 staff_space);
322 draw_meta_flat(round ((left_wid - overlap) *staff_space),
323 right_wid *staff_space, 0.33 staff_space);
326 fet_beginchar("3/4 Flat", "-3", "threeqflat")
327 save left_wid, overlap, right_wid;
331 set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
332 draw_meta_flat(0, left_wid* staff_space, 1/3 staff_space);
333 draw_meta_flat(round ((left_wid - overlap) *staff_space),
334 right_wid *staff_space, 0.33 staff_space);
336 %% maybe we should clip part of the stems?
337 %% or make the 1st flat smaller?
339 pickup pencircle scaled 2 stafflinethickness;
340 z12 = ( - .25 w - b, .55 staff_space);
341 z13 = ( .75 w , 1.45 staff_space);
346 fet_beginchar("Double Sharp", "4", "sharpsharp")
347 set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
348 save klaverblad, klaversteel;
350 klaversteel = 1/15 staff_space;
351 klaverblad = .35 staff_space;
353 z1 = (klaversteel, 0);
354 z2 = (w/2 - klaverblad / 10, h - klaverblad);
356 z4 = z2 reflectedabout((0,0), (1,1));
357 z5 = z1 reflectedabout((0,0), (1,1));
360 pickup pencircle scaled blot_diameter;
362 z1{dir 45} .. {right}z2 -- z3 --
363 z4{down} .. {dir 225}z5 .. cycle;
366 addto currentpicture also currentpicture yscaled (-d/h);
367 addto currentpicture also currentpicture xscaled (-1);
370 currentpicture := currentpicture shifted (w/2,0);
379 leftindent# := .2 staff_space#;
380 define_pixels(leftindent);
381 set_char_box(0, .5 staff_space#+stafflinethickness#,
382 staff_space#, staff_space#);
384 z2 = (w-stafflinethickness,0);
385 z3 = (leftindent,-d);
387 penpos1(stafflinethickness, 35);
388 penpos2(2 stafflinethickness, 0);
389 penpos3(stafflinethickness, -35);
392 fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
393 .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
396 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
400 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
402 currentpicture := currentpicture xscaled -1;
403 set_char_box(charwd, charbp, chardp, charht);
406 fet_endgroup("accidentals");