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.3 stafflinethickness;
41 roundness := 2blot_diameter;
45 roundness + 2 spanwidth = beamwidth;
46 roundness + 2 spanheight = beamheight;
48 2 horizontal_protrusion + interstem * beamwidth + stemwidth
51 % wanske: whole beamheight; or ca 18 degrees
52 % z2 - z1 = (beamwidth - roundness, beamheight/2);
53 z2 - z1 = (beamwidth - roundness, beamheight);
55 beamslope = (y2-y1)/(x2-x1);
58 hspan = (spanwidth, beamslope * spanwidth);
59 vspan = (0, spanheight);
63 beam := (hspan + vspan -- -hspan
64 + vspan -- -hspan -vspan -- hspan - vspan -- cycle )
67 pickup pencircle scaled roundness;
68 filldraw (beam shifted (0,-interbeam/2));
70 pickup pencircle scaled stemwidth;
71 x3 = x4 = xpart center;
72 bot y3 = -1.5 staff_space + ypart center;
73 top y4 = 1.5 staff_space + ypart center;
76 xs := interstem* beamwidth / 2;
77 draw_gridline (z3-(xs,xs* beamslope),z4-(xs,xs*beamslope),stemwidth);
78 addto currentpicture also currentpicture rotated 180 shifted (w,0);
82 fet_beginchar( "Natural", "0", "natural")
83 set_char_box(0, 8/12 staff_space#, 1.5 staff_space#, 1.5 staff_space#);
85 save interbeam, interstem, beamheight, beamwidth,
88 beamheight = 4.5 stafflinethickness;
89 interstem + stemwidth = w;
90 stemwidth = 1.3 stafflinethickness;
92 z2 -z1 = (interstem, slope * interstem);
93 xpart .5 [z2,z1] = xcenter ;
97 pickup penrazor scaled beamheight rotated 90;
98 top y2 = staff_space - 3/2 stafflinethickness ;
99 slope = stafflinethickness / interstem;
102 draw (xpart z1, -y2) .. (xpart z2, -y1);
105 pickup pencircle scaled stemwidth;
108 top y3 = 1.5 staff_space;
111 draw_gridline((xpart z1, -y4),z3,stemwidth);
112 draw_gridline((xpart z2, -y3),z4,stemwidth);
119 % Dedicated to my mom. (3/10/97)
121 % Mamma, ik hou van je; kom je alsjeblieft terug?
125 % TODO: remove crook_fatness
126 def draw_meta_flat(expr xcenter, w, crook_fatness) =
129 save top_stem_thick, bottom_stem_thick, hair;
132 center = (xcenter, 0);
134 crook_thinness = 1.25 stafflinethickness;
135 top_stem_thick = 2 stafflinethickness;
136 bottom_stem_thick = 1.2 stafflinethickness;
139 z1 = (0, 2 staff_space) + center;
140 z2 = (0, - 1/2 staff_space)+ center;
142 penpos1(top_stem_thick, 0);
143 penpos2(bottom_stem_thick, 0);
145 fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
148 y3l = (staff_space - stafflinethickness)/2 + ypart center;
149 z3l = whatever [z2r,z1r];
151 z3r = .26 [z2r, z1r];
154 z4 = (3/8 staff_space, staff_space/2) + center;
155 penpos4(whatever, 53);
156 y4l - y4r = 2 crook_thinness ;
157 % y4l - y4r = 6/20[crook_thinness, crook_fatness] ;
159 y5r = 1/4 staff_space + ypart center;
160 x5l = w + xpart center;
161 penpos5(crook_fatness, -175);
163 z8 = (0, - staff_space/2 - stafflinethickness/2) + center;
168 ne_angle = angle(z9 - z8);
171 z6l = 18/33 [z8,z9] + .5 crook_thinness *dir(ne_angle -90);
173 penpos7(crook_thinness, ne_angle + 90);
175 z6r = .3 (z9-z8) + z7r;
177 % penpos7(crook_thinness, angle(dir(z8-center) -180);
179 penpos8(whatever, ne_angle + 90);
180 x8r = xpart center - bottom_stem_thick/2;
181 penlabels(range 0 thru 10);
183 z10 = (bottom_stem_thick/2, -1/5 staff_space) + center;
185 unfill z3r{up} .. z4r{right} .. tension .9
188 .. z10 {up} -- cycle;
190 .. tension 0.8 ..z8l{(z9-z8)}
194 .. z4l{left} .. z3l -- cycle;
201 % unfortunately, 600dpi is not enough to show the brush of the stem.
203 fet_beginchar("Flat", "-1", "flat")
204 set_char_box(1.2 stafflinethickness#, .8 staff_space#, .5 staff_space#, 2 staff_space#);
205 draw_meta_flat(0, w, 1/3 staff_space);
209 fet_beginchar("Double Flat", "-2", "flatflat")
210 save left_wid, overlap, right_wid;
214 set_char_box(1.2 stafflinethickness#, (left_wid + right_wid -overlap) *staff_space#, .5 staff_space#, 2 staff_space#);
215 draw_meta_flat(0, left_wid* staff_space, 1/3 staff_space);
216 draw_meta_flat((left_wid - overlap) *staff_space,
217 right_wid *staff_space, 1/3 staff_space);
220 fet_beginchar("Double Sharp", "2", "sharpsharp")
221 set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
222 save klaverblad, klaversteel;
224 klaversteel = 1/15 staff_space;
225 klaverblad = .35 staff_space;
227 z1 = (klaversteel, 0);
228 z2 = (w/2 - klaverblad / 10, h - klaverblad);
230 z4 = z2 reflectedabout((0,0), (1,1));
231 z5 = z1 reflectedabout((0,0), (1,1));
234 pickup pencircle scaled 1/20 staff_space;
236 z1{dir 45} .. {right}z2 -- z3 --
237 z4{down} .. {dir 225}z5 .. cycle;
240 addto currentpicture also currentpicture yscaled (-d/h);
241 addto currentpicture also currentpicture xscaled (-1);
244 currentpicture := currentpicture shifted (w/2,0);
253 leftindent# := .2 staff_space#;
254 define_pixels(leftindent);
255 set_char_box(0, .5 staff_space#+stafflinethickness#,
256 staff_space#, staff_space#);
258 z2 = (w-stafflinethickness,0);
259 z3 = (leftindent,-d);
261 penpos1(stafflinethickness, 35);
262 penpos2(2 stafflinethickness, 0);
263 penpos3(stafflinethickness, -35);
266 fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
267 .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
270 fet_beginchar("Right Parenthesis", ")", "rightparen")
274 fet_beginchar("Left Parenthesis", "(", "leftparen")
276 currentpicture := currentpicture xscaled -1;
277 set_char_box(charwd, charbp, chardp, charht);
280 fet_endgroup("accidentals");