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
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 bottom_overshoot;
172 save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
177 center = (xcenter, 0);
179 % the shouldn't reach to the top staff line.
180 %% TODO: should take from height.
181 clearing = 1.2 stafflinethickness;
184 % TODO: parameterize this
186 if w >= 0.75 staff_space:
187 smaller_hole = 0.2 stafflinethickness;
189 smaller_hole = 0.0 stafflinethickness;
191 crook_thinness = 1.1 stafflinethickness;
192 top_stem_thick = 2.2 stafflinethickness;
193 bottom_overshoot = stafflinethickness;
194 bottom_stem_thick = 1.2 stafflinethickness;
197 z1 = (0, 2 staff_space) + center - (0, stafflinethickness/2
199 z2 = (0, - 1/2 staff_space - stafflinethickness/2 )+ center;
201 penpos1(top_stem_thick, 0);
202 penpos2(bottom_stem_thick, 0);
204 fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
207 y3l = (staff_space - stafflinethickness) / 2 + ypart center;
208 z3l = whatever [z2r,z1r];
210 z3r = .3 [z2r, z1r] + (smaller_hole, 0);
212 z10 = whatever [z2r, z1r] + (smaller_hole , 0);
213 z11 = center + (bottom_overshoot/3,
214 -staff_space/2 - stafflinethickness/2) - (0,bottom_overshoot);
216 penpos4(whatever, 53);
217 y4l - y4r = 1.5 crook_thinness ;
219 y5r = .20 staff_space + ypart center;
220 x5l = w + xpart center;
221 y4 = ypart center + staff_space/2;
222 x4r = .45 [x5r, x3r];
224 penpos5(crook_fatness, -185);
228 bot_crook_dir = unitvector ((x5l,0) - z11);
229 z8 = z11 + whatever * bot_crook_dir;
230 y8 = - staff_space /2 +0.0* stafflinethickness;
232 z7 = z8 + whatever * bot_crook_dir + crook_thinness * (bot_crook_dir rotated 90);
236 penlabels(range 0 thru 10);
238 y10 = -1/5 staff_space;
239 % draw_staff (-2, 2, 0.5);
240 % draw_staff (-2, 2, 0.0);
242 unfill z3r{z3r-z10} .. z4r{right} .. z5r{down}
244 .. z7{- bot_crook_dir}
246 .. z10{z3r-z10} -- cycle;
252 .. z4l{left} .. z3l -- cycle;
259 % unfortunately, 600dpi is not enough to show the brush of the stem.
261 fet_beginchar("Flat", "-1", "flat")
262 set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#);
263 draw_meta_flat(0, w, 0.31 staff_space);
267 fet_beginchar("Double Flat", "-2", "flatflat")
268 save left_wid, overlap, right_wid;
272 set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .6 staff_space#, 1.9 staff_space#);
273 draw_meta_flat(0, left_wid* staff_space, 1/3 staff_space);
274 draw_meta_flat((left_wid - overlap) *staff_space,
275 right_wid *staff_space, 0.33 staff_space);
278 fet_beginchar("Double Sharp", "2", "sharpsharp")
279 set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
280 save klaverblad, klaversteel;
282 klaversteel = 1/15 staff_space;
283 klaverblad = .35 staff_space;
285 z1 = (klaversteel, 0);
286 z2 = (w/2 - klaverblad / 10, h - klaverblad);
288 z4 = z2 reflectedabout((0,0), (1,1));
289 z5 = z1 reflectedabout((0,0), (1,1));
292 pickup pencircle scaled 1/20 staff_space;
294 z1{dir 45} .. {right}z2 -- z3 --
295 z4{down} .. {dir 225}z5 .. cycle;
298 addto currentpicture also currentpicture yscaled (-d/h);
299 addto currentpicture also currentpicture xscaled (-1);
302 currentpicture := currentpicture shifted (w/2,0);
311 leftindent# := .2 staff_space#;
312 define_pixels(leftindent);
313 set_char_box(0, .5 staff_space#+stafflinethickness#,
314 staff_space#, staff_space#);
316 z2 = (w-stafflinethickness,0);
317 z3 = (leftindent,-d);
319 penpos1(stafflinethickness, 35);
320 penpos2(2 stafflinethickness, 0);
321 penpos3(stafflinethickness, -35);
324 fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
325 .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
328 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
332 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
334 currentpicture := currentpicture xscaled -1;
335 set_char_box(charwd, charbp, chardp, charht);
338 fet_endgroup("accidentals");