]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-sharps.mf
font: rename draw_staff to draw_staff_if_debugging
[lilypond.git] / mf / feta-sharps.mf
1
2 save sharp_beamheight;
3 sharp_beamheight# := 0.3 staff_space# + stafflinethickness#;
4
5 %
6 % The beams of most sharps have horizontal endings (as if drawn with
7 % a square pen).  [Wanske] does not mention this, so we'll just ignore
8 % this fact.
9 %
10
11 def draw_meta_sharp (expr width, offset) =
12         save beamwidth, beamslope;
13         save ne, nw_dist;
14         pair ne, nw_dist;
15
16         beamwidth := width;
17
18         define_whole_vertical_blacker_pixels (sharp_beamheight);
19
20         clearxy;
21
22         beamslope = sharp_beamheight / beamwidth;
23
24         pickup pencircle scaled 2 blot_diameter;
25
26         rt x2 - lft x1 = beamwidth;
27         z2 = z1 + whatever * (beamwidth, sharp_beamheight);
28         .5 [z1, z3] = (.5 w, offset);
29         x3 = x2;
30         top y2 - bot y3 = sharp_beamheight;
31         x4 = x1;
32         top y1 - bot y4 = sharp_beamheight;
33
34         ne = unitvector (z2 - z1);
35         nw_dist = (ne rotated 90) * blot_diameter;
36
37         fill lft z1{up}
38              ... (z1 + nw_dist){ne}
39              -- (z2 + nw_dist){ne}
40              ... rt z2{down}
41              -- rt z3{down}
42              ... (z3 - nw_dist){-ne}
43              -- (z4 - nw_dist){-ne}
44              ... lft z4{up}
45              -- cycle;
46
47         labels (1, 2, 3, 4);
48 enddef;
49
50
51 def draw_sharp(expr arrowup, arrowdown) =
52         save stem, stemx, stemwidth;
53         save outer_space, interbeam;
54         save stemlength, extendleft, extendright, height, depth;
55
56         stemwidth# := stafflinethickness# + .05 staff_space#;
57         define_whole_blacker_pixels (stemwidth);
58
59         interbeam := 1.05 staff_space_rounded;
60
61         stemlength# := 1.5 staff_space#;
62         define_pixels (stemlength);
63
64         height# = stemlength#;
65         depth# = stemlength#;
66         extendright# = 0;
67         extendleft# = 0;
68         if arrowup:
69                 height# := height# + 1.2 staff_space#;
70                 extendright# := extendright# + 1.5 stafflinethickness#;
71         fi;
72         if arrowdown:
73                 depth# := depth# + 1.2 staff_space#;
74                 extendleft# := extendleft# + 1.5 stafflinethickness#;
75         fi;
76         define_pixels (extendleft, extendright);
77         set_char_box (extendleft#, 1.1 staff_space#, depth#, height#);
78
79         stem := 7 / 16 * w;
80         stemx := hround stem;
81         outer_space := hround ((w - stemx - stemwidth) / 2);
82
83         w := 2 outer_space + stemx + stemwidth;
84         d := d - feta_space_shift;
85
86         draw_meta_sharp (w, -.5 interbeam);
87         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
88
89         % expand the charbox so that it encloses the whole arrow;
90         % this must not happen earlier because some commands above
91         % still rely on the old width
92         w := w + extendright;
93
94         pickup pencircle scaled stemwidth;
95
96         lft x5 = lft x6 = outer_space;
97         lft x7 = lft x8 = outer_space + stemx;
98         bot y5 = -stemlength;
99         top y6 = vround (1.5 staff_space - stem * beamslope);
100         bot y7 = -top y6 + feta_space_shift;
101         top y8 = stemlength;
102
103         labels (5, 6, 7, 8);
104
105         draw_gridline (z5, z6, stemwidth);
106         draw_gridline (z7, z8, stemwidth);
107
108         if arrowup:
109                 draw_arrow (z8, stemwidth, up,
110                             stafflinethickness / 2 + stemwidth / 2, false);
111         fi;
112         if arrowdown:
113                 draw_arrow (z5, stemwidth, up,
114                             stafflinethickness / 2 + stemwidth / 2, true);
115         fi;
116
117         remember_pic := currentpicture;
118
119         draw_staff_if_debugging (-2, 2, 0);
120 enddef;
121
122
123 fet_beginchar ("Sharp", "sharp");
124         draw_sharp (false, false);
125 fet_endchar;
126
127
128 draw_shifted_too;
129
130
131 fet_beginchar ("Arrowed Sharp (arrow up)", "sharp.arrowup");
132         draw_sharp (true, false);
133 fet_endchar;
134
135
136 draw_shifted_too;
137
138
139 fet_beginchar ("Arrowed Sharp (arrow down)", "sharp.arrowdown");
140         draw_sharp (false, true);
141 fet_endchar;
142
143
144 draw_shifted_too;
145
146
147 fet_beginchar ("Arrowed Sharp (arrows up and down)", "sharp.arrowboth");
148         draw_sharp (true, true);
149 fet_endchar;
150
151
152 draw_shifted_too;
153
154
155 fet_beginchar ("1/2 Sharp", "sharp.slashslash.stem");
156         save stem, stemwidth;
157         save outer_space, interbeam;
158
159         stemwidth# := stafflinethickness# + .05 staff_space#;
160         define_whole_blacker_pixels (stemwidth);
161
162         interbeam := 1.05 staff_space_rounded;
163
164         set_char_box (0, 0.7 staff_space#,
165                       1.5 staff_space#, 1.5 staff_space#);
166
167         stem := 7 / 16 * w;
168         outer_space := hround ((w - stemwidth) / 2);
169
170         w := 2 outer_space + stemwidth;
171         d := d - feta_space_shift;
172
173         draw_meta_sharp (w, -.5 interbeam);
174         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
175
176         pickup pencircle scaled stemwidth;
177
178         lft x5 = lft x6 = outer_space;
179         top y6 = vround (1.5 staff_space - .5 stem);
180         bot y5 = -top y6 + feta_space_shift;
181
182         labels (5, 6);
183
184         draw_gridline (z5, z6, stemwidth);
185
186         remember_pic := currentpicture;
187
188         draw_staff_if_debugging (-2, 2, 0);
189 fet_endchar;
190
191
192 draw_shifted_too;
193
194
195 fet_beginchar ("Sharp (3 beams)", "sharp.slashslashslash.stemstem");
196         save stem, stemx, stemwidth;
197         save outer_space, interbeam;
198         save sharp_beamheight;
199
200         sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
201
202         stemwidth# := stafflinethickness# + .05 staff_space#;
203         define_whole_blacker_pixels (stemwidth);
204
205         interbeam := 1.2 staff_space_rounded;
206
207         set_char_box (0, 1.1 staff_space#,
208                       1.5 staff_space#, 1.5 staff_space#);
209
210         stem := 7 / 16 * w;
211         stemx := hround stem;
212         outer_space := hround ((w - stemx - stemwidth) / 2);
213
214         w := 2 outer_space + stemx + stemwidth;
215         d := d - feta_space_shift;
216
217         draw_meta_sharp (.88 w, -.5 interbeam);
218         draw_meta_sharp (.88 w, -.5 interbeam + vround interbeam);
219         sharp_beamheight# := 1/.88 sharp_beamheight#;
220         draw_meta_sharp (w, 0);
221
222         pickup pencircle scaled stemwidth;
223
224         lft x5 = lft x6 = outer_space;
225         lft x7 = lft x8 = outer_space + stemx;
226         bot y5 = -d;
227         top y6 = vround (1.5 staff_space - stem * beamslope);
228         bot y7 = -top y6 + feta_space_shift;
229         top y8 = h;
230
231         labels (5, 6, 7, 8);
232
233         draw_gridline (z5, z6, stemwidth);
234         draw_gridline (z7, z8, stemwidth);
235
236         remember_pic := currentpicture;
237
238         draw_staff_if_debugging (-2, 2, 0);
239 fet_endchar;
240
241
242 draw_shifted_too;
243
244
245 fet_beginchar ("1/2 Sharp (3 beams)", "sharp.slashslashslash.stem");
246         save stem, stemx, stemwidth;
247         save outer_space, interbeam;
248         save sharp_beamheight;
249
250         sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
251
252         stemwidth# := stafflinethickness# + .05 staff_space#;
253         define_whole_blacker_pixels (stemwidth);
254
255         interbeam := 1.2 staff_space_rounded;
256
257         set_char_box (0, 0.95 staff_space#,
258                       1.3 staff_space#, 1.3 staff_space#);
259
260         stem := 7 / 16 * w;
261         outer_space := hround ((w - stemwidth) / 2);
262
263         w := 2 outer_space + stemwidth;
264         d := d - feta_space_shift;
265
266         draw_meta_sharp (.8 w, -.5 interbeam);
267         draw_meta_sharp (.8 w, -.5 interbeam + vround interbeam);
268         sharp_beamheight# := 1/.8 sharp_beamheight#;
269         draw_meta_sharp (w, 0);
270
271         pickup pencircle scaled stemwidth;
272
273         lft x5 = lft x6 = outer_space;
274         top y6 = vround (1.5 staff_space - .5 stem);
275         bot y5 = -top y6 + feta_space_shift;
276         labels (5, 6);
277
278         draw_gridline (z5, z6, stemwidth);
279
280         remember_pic := currentpicture;
281
282         draw_staff_if_debugging (-2, 2, 0);
283 fet_endchar;
284
285
286 draw_shifted_too;
287
288
289 fet_beginchar ("3/4 Sharp", "sharp.slashslash.stemstemstem");
290         save stem, stemx, stemwidth;
291         save outer_space, interbeam;
292
293         stemwidth# := stafflinethickness# + .05 staff_space#;
294         define_whole_blacker_pixels (stemwidth);
295
296         interbeam := 1.05 staff_space_rounded;
297
298         set_char_box (0, 1.6 staff_space#,
299                       1.5 staff_space#, 1.5 staff_space#);
300
301         stem := 9 / 32 * w;
302         stemx := hround stem;
303         outer_space := hround ((w - 2 stemx - stemwidth) / 2);
304
305         w := 2 outer_space + 2 stemx + stemwidth;
306         d := d - feta_space_shift;
307
308         draw_meta_sharp (w, -.5 interbeam);
309         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
310
311         pickup pencircle scaled stemwidth;
312
313         lft x5 = lft x6 = outer_space;
314         lft x7 = lft x8 = outer_space + stemx;
315         lft x9 = lft x10 = outer_space + 2 stemx;
316         bot y5 = -d;
317         top y6 = vround (1.5 staff_space - 2 stem * beamslope);
318         bot y9 = -top y6 + feta_space_shift;
319         top y10 = h;
320         y7 = .5 [y5, y9];
321         y8 = .5 [y6, y10];
322
323         labels (5, 6, 7, 8, 9, 10);
324
325         draw_gridline (z5, z6, stemwidth);
326         draw_gridline (z7, z8, stemwidth);
327         draw_gridline (z9, z10, stemwidth);
328
329         remember_pic := currentpicture;
330
331         draw_staff_if_debugging (-2, 2, 0);
332 fet_endchar;
333
334
335 draw_shifted_too;
336
337
338 fet_beginchar ("Double Sharp", "doublesharp");
339         save klaverblad, klaversteel;
340         save pat;
341         path pat;
342
343         klaversteel = 1/15 staff_space;
344         klaverblad = .4 staff_space - .5 stafflinethickness;
345
346         set_char_box (0, staff_space#, .5 staff_space#, .5 staff_space#);
347
348         z1 = (klaversteel, 0);
349         z2 = (w / 2 - klaverblad / 10, h - klaverblad);
350         z3 = (w / 2, h);
351         z4 = z2 reflectedabout ((0, 0), (1, 1));
352         z5 = z1 reflectedabout ((0, 0), (1, 1));
353
354         labels (1, 2, 3, 4, 5);
355
356         pickup pencircle scaled blot_diameter;
357
358         x2 := hfloor (rt x2) - blot_diameter / 2;
359         x3 := hfloor (rt x3) - blot_diameter / 2;
360         y3 := vfloor (top y3) - blot_diameter / 2;
361         y4 := vfloor (top y4) - blot_diameter / 2;
362
363         pat = (rt z1){dir45}
364               .. {right}(bot z2)
365               .. rt z2
366               -- rt z3{z3 - z2}
367               .. top z3{z4 - z3}
368               -- top z4{z4 - z3}
369               .. (lft z4){down}
370               .. {dir 225}(top z5);
371         pat := pat
372                -- reverse pat xscaled -1 shifted (-feta_eps, 0);
373
374         % assure symmetry -- it's more important to center the glyph on the
375         % staff line than centering it between staff lines, so we use
376         % feta_shift, not feta_space_shift.
377         h := h + feta_shift;
378
379         fill pat shifted (0, feta_shift)
380              -- reverse pat yscaled -1 shifted (0, -feta_eps)
381              -- cycle;
382
383         % ugh
384         currentpicture := currentpicture shifted (hround (w / 2), 0);
385
386         remember_pic := currentpicture;
387
388         draw_staff_if_debugging (-2, 2, 0);
389 fet_endchar;
390
391
392 draw_shifted_too;