1 % feta-klef.mf -- implement Clefs -*-Fundamental-*-
3 % part of LilyPond's pretty-but-neat music font
5 % source file of the Feta (not the Font-En-Tja) music font
7 % (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>,
8 % Jan Nieuwenhuizen <janneke@gnu.org>,
9 % Juergen Reuter <reuter@ipd.uka.de>
12 fet_begingroup("clefs");
15 % [Ross] says that clefs take 1 staff_space space on the left and right
17 % this is now handled in the lilypond spacing engine.
20 def set_horizontal_spacing =
21 save left_space ,right_space;
27 % [Wanske] says the bulbs should be positioned about 1/4 right of the
31 % TODO: the hair-curve at z6r looks a little awkward.
32 def draw_c_clef (expr reduction) =
33 save hair, norm, reduced_ss, right_edge;
34 reduced_ss#=staff_space#*reduction;
35 norm#:=2/3reduced_ss#;
38 set_horizontal_spacing;
39 right_edge# = 15/4norm#+2hair#;
41 set_char_box (left_space#, right_edge# + right_space#,
42 2 reduced_ss#, 2 reduced_ss#);
43 define_pixels (hair,norm,reduced_ss, right_edge);
45 draw_block ((0,-d), (3/4norm+1/2hair,h));
46 draw_block ((3/4norm+2hair,-d),
52 z1l=(xoff+norm+hair,h);
53 penpos2(norm-3/2hair,180);
56 z3=(((right_edge -xoff)/2)+xoff,2hair);
59 z4=(xoff+1/2norm+1/2hair,reduced_ss-hair);
64 penpos6(norm-hair,90);
70 p = z5l..z4l{up}..z4r{down}..z3r{right}..tension t..z2r{up}
72 flare_path(z1l,180,90,hair,norm-1/2hair, -1)
73 ..tension t..z2l{down}
74 ..z3l{left}..z6r..z5r{down};
75 pickup pencircle scaled 1pt#;
76 filldraw p..(reverse p yscaled -1)..cycle;
77 penlabels (1,2,3,4,5,6);
79 % ugh, should be bulb, not flare?
83 fet_beginchar ("C clef", "C", "altoclef")
85 draw_staff (-2,2, 0.0);
90 fet_beginchar ("C clef", "C_change", "caltoclef")
92 draw_staff (-2,2, 0.0);
100 % Insert a brushed piece of the path, and draw a bulb separately
102 % The bulb is circular form. Neat merging of the bulb and brushed path
103 % is done by playing with tension.
107 def new_bulb (expr outer_tangent_point,
108 big_radius, bulb_radius, flare, direction) =
117 center = outer_tangent_point +big_radius* dir(0) + big_radius* dir(-90)
118 - bulb_radius * dir (-90);
120 z1 = center + bulb_radius * dir 180;
121 z2 = center + bulb_radius * dir 270;
123 z9 = center + bulb_radius * dir (0);
124 z10 = center + bulb_radius * dir (90);
125 z3 = outer_tangent_point + flare * dir (0);
129 % tension is needed to open up the space between return path and the
132 z9 .. z10 .. tension 1.1 .. z1 .. z2 .. cycle;
134 p:= outer_tangent_point{down}
150 % There is some variation is shape of bass clefs. Important points
152 % * the size of the swoosh tip: in some clefs, it almost reaches the
153 % bottom staff line, in some it crosses the 2nd line from the bottom
154 % with a small overshoot.
156 % The most popular design is where the X part of the tip is aligned
157 % left bulb boundary, and the Y part ends on the 2nd staffline exactly.
158 % This is what we do.
160 % * The size of the bulb. The diameter of the bulb is the width of the
163 % * The y-alignment of the bulb. The center of the bulb can be on or slightly
164 % above the staff line.
166 % * The position of the dots. They can be symmetrical around the
167 % staffline, centered in the staff space. The Baerenreiter SCS has the
168 % bottom dot raised by approx. 0.1 ss.
170 % * uncarefully set music may have overshoots at the top. We have none.
172 % * It is not exactly clear where the vertical tangent at the right
173 % of the swoosh should be.
177 def draw_bass_clef(expr exact_center, reduction) =
178 save reduced_ss, left_tilt, left_thick, swoosh_width;
179 save right_thickness, tip_protude;
182 reduced_ss# = staff_space# * reduction;
185 2.2 dot_diam = round reduction* (staff_space - stafflinethickness);
186 right_thickness = 0.48;
188 swoosh_width# = 2.1 reduced_ss#;
189 % tip_protude := (-stafflinethickness, -.2 staff_space);
190 tip_protude := (0, 0);
191 set_horizontal_spacing;
192 bulb_y_offset := 0.15 staff_space;
193 overshoot_top := 0.0;
196 set_char_box(left_space# +
197 - xpart exact_center,
199 xpart exact_center + swoosh_width# + 7/12 reduced_ss#,
200 - ypart exact_center + 2.5 reduced_ss#,
201 ypart exact_center +reduced_ss#);
203 define_pixels(swoosh_width);
204 define_whole_pixels(reduced_ss);
213 y2l := vround_pixels (reduced_ss# + 0.5 stafflinethickness#);
214 y2l - y2r = (1.0 + overshoot_top) * stafflinethickness;
217 x3l - x1 = swoosh_width;
218 x3l - x3r = right_thickness * reduced_ss;
220 % try to correct: the top dot seems farther away if y3l = 0.
221 y3l = 0.05 staff_space;
223 z4 = - (0, 2.0 reduced_ss) + tip_protude;
225 z5 = (x3l + 1/3 reduced_ss, .5 reduced_ss);
227 penpos3(whatever, 185);
228 penpos4(stafflinethickness, 135);
230 pickup pencircle scaled 1;
233 new_bulb (z1, 0.45 reduced_ss, 0.4 reduced_ss, 2.5 stafflinethickness, 1)
236 .. z2r{right} .. tension 1.0 .. z3r{down} .. {curl 0}
237 simple_serif(z4r, z4l, 90) {curl 0}
238 .. z3l{up} .. tension 0.9 .. z2l{left}
242 labels(range 1 thru 12);
246 pickup pencircle scaled dot_diam;
248 drawdot z5 yscaled -1;
254 fet_beginchar("F clef ", "F", "bassclef")
256 draw_staff(-3,1, 0.0);
258 draw_bass_clef((0, 0), 1.0);
261 fet_beginchar("F clef (reduced)", "F_change", "cbassclef")
262 draw_bass_clef((0, 0),0.8);
268 % Inspired by Baerenreiter
270 % FIXME bulb should curve (see bass clef)
271 % FIXME start (inside) should be little thinner
275 % Beste lezers, kijk,
277 % Een bolletje hebben we bij toeval allemaal wel eens getekend, maar begint u
278 % toch eenvoudig. Eerst een eenvoudig kruis of herstellingsteken
279 % en via de dubbelslag naar een voorzichtig vlaggetje, en heb geduld!
280 % Ikzelf heb bijvoorbeeld over mijn eerste gave G-sleutel
281 % 35 kilobyte metafont, 12 patchlevels, 0 vriendinnen en 45 dagen gedaan
283 % -- vrij naar Van Kooten & De Bie
286 def draw_gclef (expr exact_center, reduction)=
287 save reduced_ss, downstroke_dir, downstroke_angle, hair, center;
288 save breapth_factor, inner_thick_end, thinness, thickness, thinnib;
289 save inner_start_angle, thinness, thinpen;
290 reduced_ss# = staff_space# * reduction;
291 define_pixels(reduced_ss);
292 pair downstroke_dir, center;
294 center := (hround_pixels(xpart exact_center),
295 vround_pixels(ypart exact_center));
297 hair = .3 stafflinethickness;
298 % hair = blot_diameter;
299 thinness = 1.3 stafflinethickness;
300 downstroke_dir = (14, -75);
301 breapth_factor = 11/7;
302 inner_thick_end = 45;
303 inner_start_angle = downstroke_angle - 43;
304 thickness = .4 reduced_ss - hair;
306 thinnib = thinness - hair;
308 set_horizontal_spacing;
312 -xpart exact_center + 1.0 * breapth_factor* reduced_ss#,
314 xpart exact_center + .66 breapth_factor* reduced_ss#,
315 -ypart exact_center + 3 * reduced_ss#,
316 ypart exact_center + 5 * reduced_ss#);
318 pickup pencircle scaled hair;
319 downstroke_angle = angle downstroke_dir;
321 z1 = center + whatever * dir (inner_start_angle);
322 x1 = xpart center -.28 reduced_ss;
324 top z2r = center + (0,reduced_ss + stafflinethickness/2);
326 x4 = xpart center - .1 reduced_ss;
327 bot y4r = -(reduced_ss + .5 stafflinethickness);
329 z3 = (z4 - center) rotated inner_thick_end + center;
331 z5r = (- breapth_factor, .37)* reduced_ss + center;
332 penpos5(thickness, 135);
334 z6 = center + whatever * downstroke_dir;
335 y6 = ypart center + 2 reduced_ss;
337 z7l - z6 = whatever *(z5- z6) ;
338 y7l = 3.5 reduced_ss;
339 z8r = .4 [z9r, z7r] + 1.5 stafflinethickness * dir 52;
342 top y9l = 5 reduced_ss;
345 y11 = -11/7 reduced_ss;
347 y12 = ypart center - 18.5/7 reduced_ss;
348 x12 = x11 - 5 /7 reduced_ss;
350 z13 = z12 + .6 reduced_ss*(-1,1);
352 (z10r - z10l) dotprod (unitvector downstroke_dir rotated 90) =
355 center - z10= whatever * downstroke_dir;
356 center - z11 = whatever * downstroke_dir;
357 center - z14 = .8 (center - z11);
358 penpos1(thinnib, inner_start_angle);
359 penpos2(thickness, 90);
360 penpos3(thinnib, -90 + inner_thick_end);
361 penpos4(thinnib, -90);
364 penpos7(thickness, 135);
365 penpos8(1.5 thinnib, - 70 + angle downstroke_dir);
366 penpos9(1.4 thickness, -80); % ugh
367 penpos10(whatever, downstroke_angle + 10);
368 penpos11(thinnib, downstroke_angle + 90);
369 penpos14(thinnib, downstroke_angle + 90);
370 penpos12(thinnib, -90);
371 penpos13(3 thinnib, 180);
373 filldraw z2l{right} .. z3l.. z4l{left} .. z5l{up} .. z7l{up}
377 {downstroke_dir}z10l --- z11l -- z11r --- z10r{- downstroke_dir}
379 .. z9r & z9r{dir (downstroke_angle+ 40)} % ugh
381 .. z7r{down} .. z5r{down} .. z4r{right}
382 .. z3r .. z2r{left} ..
385 .. tension 0.85 ..cycle;
387 filldraw simple_serif(z1r, z1l, 80) -- cycle;
389 filldraw z12r{left} .. z13r{up} -- z13l{down} .. z12l{right} .. cycle;
391 draw_bulb(-1, z13l, lft z13r, 6/14 reduced_ss, 1.0);
393 pickup pencircle scaled (thinpen);
394 draw z10 --- z14 .. z11 .. tension 0.85 .. z12{left};
396 penlabels(range 1 thru 15);
400 fet_beginchar("G clef", "G", "trebleclef")
402 draw_staff(-1,3, 0.0);
404 draw_gclef((1.7 staff_space#,0), 1.0);
406 fet_beginchar("G clef", "G_change", "ctrebleclef")
407 draw_gclef((1.3 staff_space#,0), .8);
416 def draw_percussion_clef(expr reduction) =
418 reduced_ss# = staff_space# * reduction;
419 define_pixels(reduced_ss);
420 set_char_box(-.67reduced_ss#,2.0reduced_ss#,reduced_ss#,reduced_ss#);
421 razt := 0.45reduced_ss;
422 draw_block((-b,-d),(-b+razt,h));
423 draw_block((w-razt,-d),(w,h));
426 fet_beginchar("percussion clef", "percussion", "percussionclef")
427 draw_percussion_clef(1.0);
430 fet_beginchar("percussion clef (reduced)", "percussion_change", "cpercussionclef")
431 draw_percussion_clef(.8);
434 def draw_tab_T(expr pos, siz, slant) =
438 vx=(xpart siz) * dir 0;
439 vy=(ypart siz) * dir 90;
441 penpos1(.75penh, 100);
442 z1=z2+(1/6*vx-.15*vy);
455 penpos11(.75[penh,penw],170);
458 z12l=(xpart .5[z13,z11],ypart (pos-.025*siz));
459 penpos13(.75penh,60);
462 % penlabels (1,2,3,4,5,10,11,12,13);
464 soft_penstroke (z1e..tension 1.1
466 ..z3e{right}..tension 1.5
469 ) slanted slant shifted (slant*-ypart pos,0);
471 soft_penstroke (z10e..tension 1.5
474 ..z13e{(z13r-z13l) rotated 90}
475 ) slanted slant shifted (slant*-ypart pos,0);
479 def draw_tab_A(expr pos, siz, slant) =
483 vx=(xpart siz) * dir 0;
484 vy=(ypart siz) * dir 90;
486 penpos1(.75penh,-110);
489 z2r=(.5[x1,x3],ypart pos);
490 penpos3(.25[penh,penw],-30);
491 z3=(.45[x2,x4],.15[y2,y4]);
492 penpos4(1[penh,penw],0);
495 penpos5(1[penh,penw],-180);
497 penpos6(.2[penh,penw],-150);
498 z6l=(.8[x5l,x7l],.9[y5l,y7l]);
500 z7r=(.5[x6,x8],ypart pos);
501 penpos8(.75penh,-70);
502 z8r=(xpart(pos+siz),y7r+.075ypart(siz));
506 penpos11(.9penh,-90);
507 z11=.4[z10,z6]-0.05vy;
508 penpos12(.75penh,-75);
509 z12=.3[z11,z6]+0.02vy;
511 % penlabels(1,2,3,4,5,6,7,8,10,11,12);
513 soft_penstroke (z1e {(z1r-z1l) rotated 90}
517 ) slanted slant shifted (slant*-ypart pos,0);
522 ..z8e {(z8r-z8l) rotated 90}
523 ) slanted slant shifted (slant*-ypart pos,0);
528 ) slanted slant shifted (slant*-ypart pos,0);
533 def draw_tab_B(expr pos, siz, slant) =
537 vx=(xpart siz) * dir 0;
538 vy=(ypart siz) * dir 90;
540 penpos1(.75penh, 100);
541 z1=z2+(.15*vx-.1*vy);
545 z3l = pos+.4vx+1.05vy;
546 penpos4(.8[penh,penw],-180);
547 z4=(xpart(pos+.75siz),.5[y3,y5]);
549 z5=(.5[x10,x4],ypart (pos+.55siz));
554 z7l=(xpart(pos+siz),.5[y6,y8]);
556 z8=.5[z12l,z11l]+.15vx-.05vy;
558 penpos10(.75[penh,penw],170);
559 z10=pos+.375vx+.95vy;
560 penpos11(.8[penh,penw],150);
563 z12l=(xpart .5[z13,z11],ypart pos);
564 penpos13(.75penh,60);
567 % penlabels (1,2,3,4,5,6,7,8,10,11,12,13);
569 soft_penstroke (z1e..tension 1.1
574 ) slanted slant shifted (slant*-ypart pos,0);
576 soft_penstroke (z6e{right}
578 ..z8e{(z8r-z8l) rotated 90}
579 ) slanted slant shifted (slant*-ypart pos,0);
581 soft_penstroke (z10e.. tension 1.5
584 ..z13e{(z13r-z13l) rotated 90}
585 ) slanted slant shifted (slant*-ypart pos,0);
589 def draw_tab_clef(expr reduction) =
590 save reduced_ss,vx,vy,letterheight,penw,penh;
591 reduced_ss# = staff_space# * reduction;
592 letterheight# = 1.8*reduced_ss#;
593 define_pixels(reduced_ss,letterheight);
594 set_char_box(-.2*reduced_ss#,2.8*reduced_ss#,1.6*letterheight#,1.6*letterheight#);
596 %draw_staff (-3,2, 0.5);
598 penw = .45reduced_ss;
601 draw_tab_T((-b+.15reduced_ss,h-letterheight),
602 (2.1*reduced_ss,letterheight),0.2);
603 draw_tab_A((-b-.05reduced_ss,-.5letterheight +.15reduced_ss),
604 (2.2*reduced_ss,letterheight),0.4);
605 draw_tab_B((-b+.025reduced_ss,-d),
606 (2.1*reduced_ss,letterheight),0.25);
609 fet_beginchar("tab clef", "tab", "tabclef")
613 fet_beginchar("tab clef (reduced)", "tab_change", "ctabclef")
617 fet_endgroup("clefs");