]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
patch::: 1.5.30.uu1
[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--2002 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;
35
36         interbeam := 1.05 staff_space;
37         interstem := 7/16 ;
38         beamheight := 4 stafflinethickness;
39         beamwidth := w;
40         stemwidth := 1.3 stafflinethickness;
41         roundness := 2blot_diameter;
42         pair center;
43         center := (.5 w, 0);
44         
45         roundness + 2 spanwidth = beamwidth;
46         roundness + 2 spanheight = beamheight;
47
48         2 horizontal_protrusion  + interstem * beamwidth + stemwidth
49                 = beamwidth;
50         
51 % wanske: whole beamheight; or ca 18 degrees
52 %       z2 - z1 = (beamwidth - roundness, beamheight/2);
53         z2 - z1 = (beamwidth - roundness, beamheight);
54         z1 + z2 = 2*center;
55         beamslope = (y2-y1)/(x2-x1);
56
57         pair hspan, vspan;
58         hspan = (spanwidth, beamslope * spanwidth);
59         vspan = (0, spanheight);
60
61         
62         path beam;
63         beam := (hspan + vspan -- -hspan 
64                 +  vspan -- -hspan -vspan -- hspan - vspan -- cycle )
65                 shifted center;
66
67         pickup pencircle scaled roundness;
68         filldraw (beam shifted (0,-interbeam/2));
69
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;
74
75         numeric xs;
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);
79         labels(1,2,3,4);
80         fet_endchar;
81
82 fet_beginchar( "Natural", "0", "natural")
83         set_char_box(0, 8/12 staff_space#, 1.5 staff_space#, 1.5 staff_space#);
84
85         save interbeam, interstem, beamheight, beamwidth, 
86                 stemwidth;
87
88         beamheight = 4.5 stafflinethickness;
89         interstem + stemwidth =  w;
90         stemwidth = 1.3 stafflinethickness;
91
92         z2 -z1 = (interstem, slope * interstem);
93         xpart .5 [z2,z1] = xcenter ;
94         xcenter = w/2;
95
96
97         pickup penrazor scaled beamheight rotated 90;
98         top y2 = staff_space - 3/2 stafflinethickness ;
99         slope =  stafflinethickness / interstem;
100         
101         draw z1 .. z2;
102         draw (xpart z1, -y2) .. (xpart z2, -y1);
103         beamtop = top y2;
104         
105         pickup pencircle scaled stemwidth;
106         xpart z3 = xpart z1;
107         xpart z4 = xpart z2;
108         top y3 = 1.5 staff_space;
109         top y4 = beamtop;
110
111         draw_gridline((xpart z1, -y4),z3,stemwidth);
112         draw_gridline((xpart z2, -y3),z4,stemwidth);
113
114         labels(1,2,3,4);
115         fet_endchar;
116
117
118 %
119 % Dedicated to my mom.    (3/10/97)
120 %
121 % Mamma, ik hou van je; kom je alsjeblieft terug? 
122 %    -- HW
123 %
124
125 % TODO: remove crook_fatness
126 def draw_meta_flat(expr xcenter, w, crook_fatness) =
127         clearxy;
128         save crook_thinness;
129         save top_stem_thick, bottom_stem_thick, hair;
130         save center;
131         pair center;
132         center = (xcenter, 0);
133
134         crook_thinness = 1.25 stafflinethickness;
135         top_stem_thick = 2 stafflinethickness;
136         bottom_stem_thick = 1.2 stafflinethickness;
137
138
139         z1 = (0, 2 staff_space) + center;
140         z2 = (0, - 1/2 staff_space)+  center;
141
142         penpos1(top_stem_thick, 0);
143         penpos2(bottom_stem_thick, 0); 
144
145         fill simple_serif(z1r, z1l, 30) -- z2l -- z2r -- cycle;
146
147
148         y3l = (staff_space - stafflinethickness)/2 + ypart center;
149         z3l = whatever [z2r,z1r];
150
151         z3r = .26 [z2r, z1r];
152
153
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] ;
158
159         y5r = 1/4 staff_space + ypart center;
160         x5l = w + xpart center;
161         penpos5(crook_fatness, -175);
162
163         z8 = (0, - staff_space/2 - stafflinethickness/2) + center;
164
165         z9 = (x5,0);
166
167         save ne_angle;
168         ne_angle = angle(z9 - z8);
169
170         z7 = 8/33 [z8,z9];
171         z6l = 18/33 [z8,z9] + .5 crook_thinness *dir(ne_angle -90);
172   
173         penpos7(crook_thinness, ne_angle + 90);
174
175         z6r = .3 (z9-z8) + z7r;
176
177 %       penpos7(crook_thinness, angle(dir(z8-center) -180);
178
179         penpos8(whatever, ne_angle + 90);
180         x8r =  xpart center - bottom_stem_thick/2;
181         penlabels(range 0 thru 10);
182
183         z10 = (bottom_stem_thick/2, -1/5 staff_space) + center;
184
185         unfill z3r{up} .. z4r{right} .. tension .9 
186                 .. z6r ---
187                 z7r{left}
188                 .. z10 {up} -- cycle;
189         fill z8r{down}
190                 .. tension 0.8 ..z8l{(z9-z8)}
191                 .. z7l
192                 .. z6l
193                 .. z5l{up}
194                 .. z4l{left} .. z3l -- cycle;
195                 
196         labels(10);
197 enddef;
198
199         
200 %
201 % unfortunately, 600dpi is not enough to show the brush of the stem.
202 %
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);
206         fet_endchar;
207
208
209 fet_beginchar("Double Flat", "-2", "flatflat")
210         save left_wid, overlap, right_wid;
211         left_wid = .7;
212         right_wid = .8;
213         overlap = .05;
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);
218         fet_endchar;
219
220 fet_beginchar("Double Sharp", "2", "sharpsharp")
221         set_char_box(0, staff_space#, .5 staff_space#, .5 staff_space#);
222         save klaverblad, klaversteel;
223
224         klaversteel = 1/15 staff_space;
225         klaverblad = .35 staff_space;
226
227         z1 = (klaversteel, 0);
228         z2 = (w/2 - klaverblad / 10, h - klaverblad);
229         z3 = (w/2, h);
230         z4 = z2 reflectedabout((0,0), (1,1));
231         z5 = z1 reflectedabout((0,0), (1,1));
232
233         labels(1,2,3,4,5);
234         pickup pencircle scaled 1/20 staff_space;
235         filldraw  
236                 z1{dir 45} .. {right}z2 -- z3 -- 
237                 z4{down} .. {dir 225}z5 .. cycle;
238         
239
240         addto currentpicture also currentpicture yscaled (-d/h);
241         addto currentpicture also currentpicture xscaled (-1);
242
243         % ugh
244         currentpicture := currentpicture  shifted (w/2,0);
245
246
247
248 fet_endchar;
249
250
251 def draw_paren =
252         save leftindent;
253         leftindent# := .2 staff_space#;
254         define_pixels(leftindent);
255         set_char_box(0, .5 staff_space#+stafflinethickness#,
256           staff_space#, staff_space#);
257         z1 = (leftindent,h);
258         z2 = (w-stafflinethickness,0);
259         z3 = (leftindent,-d);
260
261         penpos1(stafflinethickness, 35);
262         penpos2(2 stafflinethickness, 0);
263         penpos3(stafflinethickness, -35);
264
265         penlabels(1,2,3);
266         fill z2l{down} .. simple_serif(z3l, z3r, 90) .. z2r{up}
267         .. simple_serif(z1r, z1l, 90) .. z2l{down} -- cycle;
268 enddef;
269   
270 fet_beginchar("Right Parenthesis", ")", "rightparen")
271         draw_paren;
272 fet_endchar;
273
274 fet_beginchar("Left Parenthesis", "(", "leftparen")
275         draw_paren;
276         currentpicture := currentpicture xscaled -1;
277         set_char_box(charwd, charbp, chardp, charht);
278 fet_endchar;
279
280 fet_endgroup("accidentals");
281