]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
revamp flat symbol: use less points,
[lilypond.git] / mf / feta-toevallig.mf
1
2 % feta-toevallig.mf --  implement Accidentals
3
4 % source file of the Feta (Font-En-Tja) music font
5
6 % (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8
9
10 %
11 % Accidentals from various sources, notably
12 %
13 %   Baerenreiter edition of Schuberts `Auf dem Strom' (sharp, natural)
14 %   F Hofmeister edition of Muellers `Etueden fuer Horn'  (double sharp, flat)
15 %
16
17
18 %tracingall;
19 %proofing := 2;
20 %\tracingequations:= tracingonline := 1;
21
22 fet_begingroup("accidentals");
23
24 %
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 
27 % this fact
28 %
29 fet_beginchar("Sharp" , "1", "sharp");
30         set_char_box(0, 1.1 staff_space#, 1.5 staff_space#, 
31                 1.5 staff_space#);
32
33         save interbeam, interstem, beamheight, beamwidth, 
34                 stemwidth, beamslope;
35
36         interbeam := 1.05 staff_space;
37         interstem := 7/16 ;
38         beamheight := 4 stafflinethickness;
39         beamwidth := w;
40         stemwidth := 1.5 stafflinethickness;
41         roundness := 2 blot_diameter;
42
43         pair center;
44         center := (.5 w, 0);
45         
46         roundness + 2 spanwidth = beamwidth;
47         roundness + 2 spanheight = beamheight;
48
49         2 horizontal_protrusion  + interstem * beamwidth + stemwidth
50                 = beamwidth;
51         
52 % wanske: whole beamheight; or ca 18 degrees
53 %       z2 - z1 = (beamwidth - roundness, beamheight/2);
54         z2 - z1 = (beamwidth - roundness, beamheight);
55         z1 + z2 = 2*center;
56         beamslope = (y2-y1)/(x2-x1);
57
58         pair hspan, vspan;
59         hspan = (spanwidth, beamslope * spanwidth);
60         vspan = (0, spanheight);
61
62         
63         path beam;
64         beam := (hspan + vspan -- -hspan 
65                 +  vspan -- -hspan -vspan -- hspan - vspan -- cycle )
66                 shifted center;
67
68         pickup pencircle scaled roundness;
69         filldraw (beam shifted (0,-interbeam/2));
70
71         pickup pencircle scaled stemwidth;
72         x3 = x4 = xpart center;
73
74         numeric xs;
75         xs := interstem* beamwidth / 2;
76
77         (bot y3) + -xs * beamslope = -1.5 staff_space + ypart center;
78         top y4  + xs * beamslope = 1.5 staff_space + ypart center;
79
80         draw_gridline (z3-(xs,xs* beamslope),z4-(xs,xs*beamslope),stemwidth);
81         addto currentpicture also currentpicture rotated 180 shifted (w,0);
82         labels(1,2,3,4);
83
84
85 % to check that it doesn't overshoot staffline.
86 %
87 %       pickup pencircle scaled stafflinethickness;
88 %       draw (0, 1.5 staff_space ) ..  (1 staff_space, 1.5 staff_space);
89
90         fet_endchar;
91
92
93 %
94 % The stems of the natural are brushed (at least, in Barenreiter SCS )
95 %
96 %
97
98 fet_beginchar( "Natural", "0", "natural")
99         save height, xcenter;
100         save interbeam, interstem, beamheight, beamwidth, 
101         stemwidth;
102         save top_stem_thick;
103
104         beamheight# = 4.0 stafflinethickness#;
105         height# = 1.5 staff_space#;
106         set_char_box(0, 2/3 staff_space#, height#, height#);
107
108         define_pixels(height);
109         define_blacker_pixels(beamheight);
110
111         % perhaps we should have a lowres fix?
112         top_stem_thick = 1.9 stafflinethickness;
113
114         interstem + stemwidth =  w;
115         stemwidth = 1.3 stafflinethickness;
116
117         z2 -z1 = (interstem, slope * interstem);
118         xpart .5 [z2,z1] = xcenter ;
119         xcenter = w/2;
120
121
122         pickup penrazor scaled beamheight rotated 90;
123         top y2 = staff_space - 3/2 stafflinethickness ;
124         slope = stafflinethickness / interstem;
125         
126         draw z1 .. z2;
127         draw (xpart z1, -y2) .. (xpart z2, -y1);
128         beamtop = top y2;
129
130         pickup pencircle scaled stemwidth;
131         x3 := round (xpart z1);
132         x4 := round (xpart z2);
133
134         penpos3(top_stem_thick, 0);
135         penpos5(top_stem_thick, 0);     
136         penpos4(stemwidth, 0);
137         penpos6(stemwidth, 0);  
138         
139         y3 = height;
140         top y4 = beamtop;
141
142         x5 = x4;
143         x6 = x3;
144         bot y6 = -beamtop;
145         y5 = - height;
146
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;
149
150
151
152         penlabels(3,4,5,6);
153
154         labels(1,2);
155         fet_endchar;
156
157
158 %
159 % Dedicated to my mom.    (3/10/97)
160 %
161 % Mamma, ik hou van je; kom je alsjeblieft terug? 
162 %    -- HW
163 %
164
165 % TODO: remove crook_fatness
166 % TODO: document, simplify!
167 %
168 def draw_meta_flat(expr xcenter, w, crook_fatness) =
169         clearxy;
170         save crook_thinness;
171         save bottom_overshoot;
172         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
173         save zwiep; 
174         save center;
175         pair center;
176         save clearing;
177         center = (xcenter, 0);
178
179 % the shouldn't reach to the top staff line.
180 %% TODO: should take from height.
181         clearing = 1.2 stafflinethickness; 
182
183 %
184 %  TODO: parameterize  this
185 %
186         if w >= 0.75 staff_space:
187                 smaller_hole = 0.2 stafflinethickness;
188         else:
189                 smaller_hole = 0.0 stafflinethickness;
190         fi
191         crook_thinness = 1.1 stafflinethickness;
192         top_stem_thick = 2.2 stafflinethickness;
193         bottom_overshoot = stafflinethickness;
194         bottom_stem_thick = 1.2 stafflinethickness;
195
196
197         z1 = (0, 2 staff_space) + center - (0, stafflinethickness/2
198                 + clearing);
199         z2 =  (0, - 1/2 staff_space - stafflinethickness/2 )+  center;
200
201         penpos1(top_stem_thick, 0);
202         penpos2(bottom_stem_thick, 0); 
203
204         fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
205
206
207         y3l = (staff_space - stafflinethickness) / 2 + ypart center;
208         z3l = whatever [z2r,z1r];
209
210         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
211
212         z10 = whatever [z2r, z1r] + (smaller_hole , 0);
213         z11 = center + (bottom_overshoot/3,
214                 -staff_space/2 - stafflinethickness/2) - (0,bottom_overshoot);
215
216         penpos4(whatever, 53);
217         y4l - y4r = 1.5 crook_thinness ;
218
219         y5r = .20 staff_space + ypart center;
220         x5l = w + xpart center;
221         y4 = ypart center + staff_space/2;
222         x4r = .45 [x5r, x3r];
223
224         penpos5(crook_fatness, -185);
225
226         save bot_crook_dir ;
227         pair bot_crook_dir ;
228         bot_crook_dir =  unitvector ((x5l,0) - z11);
229         z8 = z11 +  whatever * bot_crook_dir;
230         y8 = - staff_space /2  +0.0* stafflinethickness;
231
232         z7 = z8 + whatever * bot_crook_dir + crook_thinness  * (bot_crook_dir rotated 90);
233
234         x7 = .5 [x11, x8];
235
236         penlabels(range 0 thru 10);
237
238         y10 = -1/5 staff_space;
239 %       draw_staff (-2, 2, 0.5);
240 %       draw_staff (-2, 2, 0.0);
241
242         unfill z3r{z3r-z10} .. z4r{right} .. z5r{down}
243
244                 ..  z7{- bot_crook_dir}
245                 & z7 .. tension 1.3
246                 .. z10{z3r-z10}  -- cycle;
247         fill z2l{down}
248                 
249                 .. z11{right}
250                 .. z8{bot_crook_dir}
251                 .. z5l{up}
252                 .. z4l{left} .. z3l -- cycle;
253                 
254         labels(11);
255 enddef;
256
257         
258 %
259 % unfortunately, 600dpi is not enough to show the brush of the stem.
260 %
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);
264         fet_endchar;
265
266
267 fet_beginchar("Double Flat", "-2", "flatflat")
268         save left_wid, overlap, right_wid;
269         left_wid = .7;
270         right_wid = .8;
271         overlap = .05;
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);
276         fet_endchar;
277
278 fet_beginchar("Double Sharp", "2", "sharpsharp")
279         set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
280         save klaverblad, klaversteel;
281
282         klaversteel = 1/15 staff_space;
283         klaverblad = .35 staff_space;
284
285         z1 = (klaversteel, 0);
286         z2 = (w/2 - klaverblad / 10, h - klaverblad);
287         z3 = (w/2, h);
288         z4 = z2 reflectedabout((0,0), (1,1));
289         z5 = z1 reflectedabout((0,0), (1,1));
290
291         labels(1,2,3,4,5);
292         pickup pencircle scaled 1/20 staff_space;
293         filldraw  
294                 z1{dir 45} .. {right}z2 -- z3 -- 
295                 z4{down} .. {dir 225}z5 .. cycle;
296         
297
298         addto currentpicture also currentpicture yscaled (-d/h);
299         addto currentpicture also currentpicture xscaled (-1);
300
301         % ugh
302         currentpicture := currentpicture  shifted (w/2,0);
303
304
305
306 fet_endchar;
307
308
309 def draw_paren =
310         save leftindent;
311         leftindent# := .2 staff_space#;
312         define_pixels(leftindent);
313         set_char_box(0, .5 staff_space#+stafflinethickness#,
314           staff_space#, staff_space#);
315         z1 = (leftindent,h);
316         z2 = (w-stafflinethickness,0);
317         z3 = (leftindent,-d);
318
319         penpos1(stafflinethickness, 35);
320         penpos2(2 stafflinethickness, 0);
321         penpos3(stafflinethickness, -35);
322
323         penlabels(1,2,3);
324         fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
325         .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
326 enddef;
327   
328 fet_beginchar("Right Parenthesis", "rightparen", "rightparen")
329         draw_paren;
330 fet_endchar;
331
332 fet_beginchar("Left Parenthesis", "leftparen", "leftparen")
333         draw_paren;
334         currentpicture := currentpicture xscaled -1;
335         set_char_box(charwd, charbp, chardp, charht);
336 fet_endchar;
337
338 fet_endgroup("accidentals");
339