% Feta (not the Font-En-Tja) music font -- implement Clefs -*-Fundamental-*-
% This file is part of LilyPond, the GNU music typesetter.
%
-% Copyright (C) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>,
+% Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>,
% Jan Nieuwenhuizen <janneke@gnu.org>,
% Juergen Reuter <reuter@ipd.uka.de>
%
def draw_gclef (expr reduction) =
save reduced_ss, downstroke_dir, downstroke_angle, center;
save breapth_factor, inner_thick_end, thinness, thickness, thinnib;
- save start_angle, inner_start_angle, thinness;
+ save start_angle, inner_start_angle;
save upward_swoosh_angle, bot_angle;
save pat;
+ save corr_angle, corr, left_, right_, up_, down_, bot_angle_;
path pat;
pair downstroke_dir, center;
+ transform corr;
+ pair left_, right_, up_, down_;
reduced_ss# = staff_space# * reduction;
define_pixels (reduced_ss);
+ % G clef has now a smaller upper loop than it used to have.
+ % Too small loop in reduced clef (G_change) interacts badly
+ % with stafflines, so we make reduced clef's loop a bit bigger.
+ reduced_loop_correction := min (max (0.94, (0.6 + 0.46 * reduction)), 1);
+
thinness = 0.095 staff_space + 0.75 linethickness;
downstroke_dir = unitvector (14, -75);
downstroke_angle = angle downstroke_dir;
breapth_factor = 21/14;
inner_thick_end = 45;
inner_start_angle = downstroke_angle - 43;
- thickness = .32 reduced_ss + 1.1 linethickness;
+ thickness = .33 reduced_ss + 1.1 linethickness;
thinnib = thinness;
set_char_box (0, 1.71 * breapth_factor * reduced_ss#,
- 2.6 * reduced_ss#, 5 * reduced_ss#);
+ 2.55 * reduced_ss#, 4.8 * reduced_ss# / reduced_loop_correction);
center := (breapth_factor * reduced_ss, 0);
y5r = .37 reduced_ss + ypart center;
penpos5 (thickness, upward_swoosh_angle);
- z6 = center + whatever * downstroke_dir;
- y6 = ypart center + 2 reduced_ss;
+ z6 = center + whatever * downstroke_dir + (-0.02, 0) * reduced_ss;
+ y6 = ypart center + 1.95 reduced_ss / reduced_loop_correction;
% penpos6 is computed later
- z7l - z6 = whatever * (z5 - z6) ;
- y7l = 3.5 reduced_ss;
+ z7l - z6 = whatever * (z5 - z6);
+ y7l = 3.38 reduced_ss / reduced_loop_correction;
penpos7 (thickness, upward_swoosh_angle);
- x9 = .7 [x10, x7r];
- top y9l = 5 reduced_ss;
+ x9 = .75 [x10, x7r];
+ top y9l = 4.78 reduced_ss / reduced_loop_correction;
penpos9 (1.45 thickness, -70);
- x11 - x13r = 1.5 reduced_ss + 0.5 thinnib;
- y11 = ypart center - 47/28 reduced_ss;
- y12 = ypart center - 71/28 reduced_ss;
+ x11 - x13r = 1.44 * reduced_ss + 0.5 thinnib;
+ y11 = ypart center - 45/28 reduced_ss;
+ y12 = ypart center - 69/28 reduced_ss;
y13 = .48 [y12, y4r];
x12r = xpart (.45 [z13r, z11] + .75 reduced_ss * downstroke_dir);
% z10 = center + whatever * dir (downstroke_angle - 1.5);
- x10 = x6 - 2 thinnib;
- y10 = ypart center + 3.5 reduced_ss;
+ x10 = x6 - 1.85 thinnib * reduction / reduced_loop_correction;
+ y10 = ypart center + 3.32 reduced_ss / reduced_loop_correction;
y10l - y10r = 1.0 thickness;
z10r - z10l = .7 thinnib * dir (downstroke_angle + 90)
+ whatever * downstroke_dir;
z10 = .5 [z10l, z10r];
- z11 = center + whatever * downstroke_dir + (-0.05 reduced_ss, 0);
+ z11 = center + whatever * downstroke_dir + (0.03 reduced_ss, 0);
penpos11 (thinnib, start_angle + 90);
penpos12 (thinnib, bot_angle + 90);
z10' = point 0.3 of pat;
penpos10' (1.3 thinnib, angle (direction 0.3 of pat) + 50);
- z11' = point 1.5 of pat;
+ z11' = point 1.5 of pat + (0.033, -0.5) * reduced_ss;
penpos11' (thinnib, angle (direction 1.5 of pat) + 90);
z21l = z20l;
z21r = z9r;
- pat := z21l
- .. z10l{down}
- .. z10'l;
-
- fill z2l{right}
- .. z3l
- .. z4l{left}
- ..tension 1.07.. z5l{up} % inside curve
- .. z7l{up}
- ..tension 1.2.. z20r{curl 1}
- .. {direction 0 of pat}z20l
- -- z8
- -- z9r % {dir (downstroke_angle + 0)}
- ..tension 0.8.. z7r{down}
- .. z5r{down}
- .. z4r{right}
- .. z3r
- .. z2r{left}
- ..tension .95.. z1r
- -- simple_serif (z1r, z1l, 80)
- -- z1l
+ % after computing all points, we want to rotate the clef
+ % rotating the whole picture won't work due to the complexity
+ % of the path and metafont's memory limitations, so we transform
+ % each point and draw the clef thereafter
+ corr_angle := 1.5;
+ corr := identity rotatedabout (center, -corr_angle);
+
+ bot_angle_ := bot_angle + corr_angle;
+
+ left_ := left rotated corr_angle;
+ right_ := right rotated corr_angle;
+ up_ := up rotated corr_angle;
+ down_ := down rotated corr_angle;
+
+ % transform points; we transform every point and save it
+ % to a shifted index range: z1 -> z101, z2 -> z102, etc.
+ for n := 1 upto 21:
+ forsuffixes e := l,,r:
+ z[n+100]e = z[n]e transformed corr;
+ endfor
+ endfor
+
+ % transform helper points
+ for n := 10, 11:
+ forsuffixes e := l,,r:
+ z[n+100]'e = z[n]'e transformed corr;
+ endfor
+ endfor
+
+ pat := z121l
+ .. z110l{down}
+ .. z110'l;
+
+ fill z102l{right}
+ .. z103l
+ .. z104l{left_}
+ ..tension 1.07.. z105l{up_}% inside curve
+ .. z107l{up_}
+ ..tension 1.2.. z120r{curl 1}
+ .. {direction 0 of pat}z120l
+ -- z108
+ -- z109r % {dir (downstroke_angle + 0)}
+ ..tension 0.8.. z107r{down_}
+ .. z105r{down_}
+ .. z104r{right_}
+ .. z103r
+ .. z102r{left_}
+ ..tension .95.. z101r
+ -- simple_serif (z101r, z101l, 80)
+ -- z101l
..tension 0.85.. cycle;
- penstroke z21e
- .. z10e{down}
- .. z10'e
- .. z6e
- .. z11'e
- .. z11e{dir (-95)}
- .. z12e{dir (bot_angle)};
+ penstroke z121e
+ .. z110e{down_}
+ .. z110'e
+ .. z106e
+ .. z111'e
+ .. z111e{dir (-95 + corr_angle)}
+ .. z112e{dir (bot_angle_)};
- fill new_bulb (z12r, bot_angle, z13r, z12l, bot_angle + 180,
+ fill new_bulb (z112r, bot_angle_, z113r, z112l, bot_angle_ + 180,
0.45 reduced_ss, 0.38 reduced_ss,
thinnib + .05 staff_space, 1, -1)
-- cycle;
- penlabels (range 1 thru 21);
- penlabels (10', 11');
+ penlabels (range 101 thru 121);
+ penlabels (110', 111');
draw_staff (-1, 3, 0);
enddef;