%
% source file of LilyPond's pretty-but-neat music font
%
-% (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
-% & Han-Wen Nienhuys <hanwen@cs.uu.nl>
+% (c) 1997--2009 Jan Nieuwenhuizen <janneke@gnu.org>
+% & Han-Wen Nienhuys <hanwen@xs4all.nl>
% & Juergen Reuter <reuter@ipd.uka.de>
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
save black_notehead_width, noteheight;
-save slash_thick, slash_slope, overdone_heads;
-numeric black_notehead_width, noteheight, slash_thick;
+save half_notehead_width, whole_notehead_width, slash_thick;
+save slash_slope, overdone_heads, solfa_noteheight;
+
+numeric noteheight;
+numeric slash_thick;
+numeric black_notehead_width;
+numeric whole_notehead_width;
+numeric half_notehead_width;
fet_begingroup ("noteheads");
overdone_heads = 0.0;
noteheight# := staff_space# + (1 + overdone_heads) * stafflinethickness#;
+
+%
+% solfa heads should not overlap on chords.
+%
+solfa_noteheight# := staff_space# - stafflinethickness#;
+
define_pixels (slash_thick);
define_whole_vertical_pixels (noteheight);
def draw_outside_ellipse (expr ellipticity, tilt, superness, slant) =
save attachment_y;
- save p;
- path p;
+ save pat;
+ path pat;
- p := superellipse ((ellipticity, 0), (-slant * ellipticity, 1.0),
- (-ellipticity, 0), (slant * ellipticity, -1.0),
- superness);
- p := p rotated tilt;
+ pat := superellipse ((ellipticity, 0), (-slant * ellipticity, 1.0),
+ (-ellipticity, 0), (slant * ellipticity, -1.0),
+ superness);
+ pat := pat rotated tilt;
save top_point, right_point;
pair top_point, right_point;
- top_point := directionpoint left of p;
- right_point := directionpoint up of p;
+ top_point := directionpoint left of pat;
+ right_point := directionpoint up of pat;
save scaling, width;
charwy := ypart (right_point) * scaling#;
charwx := width#;
- p := p scaled scaling shifted (w / 2, .5 (h - d));
+ pat := pat scaled scaling shifted (w / 2, .5 (h - d));
width := hround width;
if test_outlines = 1:
- draw p;
+ draw pat;
else:
- fill p;
+ fill pat;
fi;
enddef;
def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
begingroup
- save p;
- path p;
+ save pat;
+ path pat;
- p := superellipse ((ellipticity, 0), (0, 1.0),
- (-ellipticity, 0), (0, -1.0),
- superness);
- p := p rotated tilt;
+ pat := superellipse ((ellipticity, 0), (0, 1.0),
+ (-ellipticity, 0), (0, -1.0),
+ superness);
+ pat := pat rotated tilt;
save top_point, right_point;
pair top_point, right_point;
- top_point := directionpoint left of p;
- right_point := directionpoint up of p;
+ top_point := directionpoint left of pat;
+ right_point := directionpoint up of pat;
save height, scaling;
height# = staff_space# + stafflinethickness# - clearance;
scaling# = height# / (2 ypart (top_point));
define_pixels (scaling);
- p := (p scaled scaling) shifted (w / 2, .5 (h - d));
+ pat := pat scaled scaling shifted (w / 2, .5 (h - d));
if test_outlines = 1:
- draw p;
+ draw pat;
else:
- unfill p;
+ unfill pat;
fi
endgroup;
enddef;
+%
+% dimensions aren't entirely right.
+%
+def draw_longa (expr up) =
+ save stemthick, fudge;
+
+ stemthick# = 2 stafflinethickness#;
+ define_whole_blacker_pixels (stemthick);
+
+ fudge = hround (blot_diameter / 2);
+
+ draw_outside_ellipse (1.80, 0, 0.707, 0);
+ undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
+
+ pickup pencircle scaled stemthick;
+
+ if up:
+ bot y1 = -d;
+ top y2 = h;
+ rt x1 - fudge = 0;
+ x1 = x2;
+
+ fudge + lft x3 = w;
+ x4 = x3;
+ top y4 = h + 3.0 staff_space;
+ y3 = y1;
+ else:
+ bot y1 = -d - 3.0 staff_space;
+ top y2 = h;
+ rt x1 - fudge = 0;
+ x1 = x2;
+
+ fudge + lft x3 = w;
+ x4 = x3;
+ y4 = y2;
+ bot y3 = -d;
+ fi;
+
+ draw_gridline (z1, z2, stemthick);
+ draw_gridline (z3, z4, stemthick);
+
+ labels (1, 2, 3, 4);
+enddef;
+
+
+fet_beginchar ("Longa notehead", "uM2");
+ draw_longa (true);
+
+ draw_staff (-2, 2, 0);
+fet_endchar;
+
+fet_beginchar ("Longa notehead", "dM2");
+ draw_longa (false);
+
+ draw_staff (-2, 2, 0);
+fet_endchar;
+
+
+if test > 0:
+ fet_beginchar ("Longa notehead", "uM2");
+ draw_longa (true);
+
+ draw_staff (-2, 2, 0.5);
+ fet_endchar;
+
+ fet_beginchar ("Longa notehead", "dM2");
+ draw_longa (false);
+
+ draw_staff (-2, 2, 0.5);
+ fet_endchar;
+fi;
+
+
%
% dimensions aren't entirely right.
%
enddef;
-fet_beginchar ("Brevis notehead", "s-1");
+fet_beginchar ("Brevis notehead", "sM1");
draw_brevis;
draw_staff (-2, 2, 0);
if test > 0:
- fet_beginchar ("Brevis notehead", "s-1");
+ fet_beginchar ("Brevis notehead", "sM1");
draw_brevis;
draw_staff (-2, 2, 0.5);
undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
0.68, 2 stafflinethickness#);
+ whole_notehead_width# := charwd;
+
draw_staff (-2, 2, 0);
fet_endchar;
draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
+ half_notehead_width# := charwd;
+
draw_staff (-2, 2, 0);
fet_endchar;
enddef;
+%
+% UGH: xs not declared as argument.
+%
def define_triangle_shape (expr stemdir) =
save triangle_a, triangle_b, triangle_c;
save triangle_out_a, triangle_out_b, triangle_out_c;
set_char_box (0, width#, depth#, height#);
% Formerly, the shape has simply been drawn with an elliptical pen
- % (`scaled pen_thick xsaled xs'), but the envelope of such a curve
+ % (`scaled pen_thick xscaled xs'), but the envelope of such a curve
% is of 6th degree. For the sake of mf2pt1, we approximate it.
pickup pencircle scaled pen_thick xscaled xs;
% attachment Y
if stemdir = 1:
charwy := ypart exact_right_point;
- charwx := xpart exact_right_point;
+ charwx := xpart exact_right_point + .5 pen_thick# * xs;
else:
charwy := -ypart exact_down_point;
- charwx := (width# - xpart exact_down_point);
+ charwx := width# - (xpart exact_down_point - .5 pen_thick# * xs);
fi
enddef;
enddef;
-fet_beginchar ("Half trianglehead", "d1triangle");
+fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
draw_small_triangle_head (-1);
draw_staff (-2, 2, 0);
fet_endchar;
-fet_beginchar ("Half trianglehead", "u1triangle");
+fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
draw_small_triangle_head (1);
draw_staff (-2, 2, 0.5);
enddef;
-fet_beginchar ("Quart trianglehead", "u2triangle");
+fet_beginchar ("Quart trianglehead (upstem)", "u2triangle");
draw_closed_triangle_head (1);
draw_staff (-2, 2, 0);
fet_endchar;
-fet_beginchar ("Quart trianglehead", "d2triangle");
+fet_beginchar ("Quart trianglehead (downstem)", "d2triangle");
draw_closed_triangle_head (-1);
draw_staff (-2, 2, 0.5);
%
def draw_slash (expr hwid_hash) =
save exact_height;
- save ne_dir;
- pair ne_dir;
+ save ne, nw_dist;
+ pair ne, nw_dist;
exact_height = staff_space# + stafflinethickness# / 2;
set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
y4 = y1;
x3 - x2 = x4 - x1;
- ne_dir := unitvector (z3 - z4);
+ ne = unitvector (z3 - z4);
+ nw_dist = (ne rotated 90) * 0.5 blot_diameter;
fill bot z1{left}
- .. lft z1{ne_dir}
- -- lft z2{ne_dir}
+ .. (z1 + nw_dist){ne}
+ -- (z2 + nw_dist){ne}
.. top z2{right}
-- top z3{right}
- .. rt z3{-ne_dir}
- -- rt z4{-ne_dir}
+ .. (z3 - nw_dist){-ne}
+ -- (z4 - nw_dist){-ne}
.. bot z4{left}
-- cycle;
y5 = y8;
y3 - y7 = th;
y5 - y1 = th;
- z6 - z5 = whatever * ne_dir;
- z8 - z7 = whatever * ne_dir;
+ z6 - z5 = whatever * ne;
+ z8 - z7 = whatever * ne;
- z5 = z1 + whatever * ne_dir + th * (ne_dir rotated -90);
- z8 = z4 + whatever * ne_dir + th * (ne_dir rotated 90);
+ z5 = z1 + whatever * ne + th * (ne rotated -90);
+ z8 = z4 + whatever * ne + th * (ne rotated 90);
unfill z5
-- z6
% (distance between centres of lines) in multiples of stafflinethickness
%
def draw_cross (expr thick) =
- save ne_dir, nw_dir;
- save horz_dist, vert_dist;
+ save ne, nw;
+ save ne_dist, nw_dist, rt_dist, up_dist;
save crz_in, crz_out;
save thickness;
- pair ne_dir, nw_dir;
+ pair ne, nw;
+ pair ne_dist, nw_dist, rt_dist, up_dist;
path crz_in, crz_out;
pen_thick# := 1.2 stafflinethickness#;
h := h - feta_shift;
top y3 = h;
- ne_dir := unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
+ ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
rt x4 = w / 2;
y5 = 0;
- z4 - z5 = whatever * ne_dir;
+ z4 - z5 = whatever * ne;
x6 = 0;
- z6 - z3 = whatever * ne_dir;
- z3 - z4 = whatever * (ne_dir yscaled -1);
+ z6 - z3 = whatever * ne;
+ z3 - z4 = whatever * (ne yscaled -1);
- z4 - z3 = whatever * (ne_dir) + (ne_dir rotated -90) * thickness;
+ z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
x1 = charwd / 2 - .5 pen_thick#;
- z1 = whatever * ne_dir
- + thick / 2 * stafflinethickness# * (ne_dir rotated -90);
+ z1 = whatever * ne
+ + thick / 2 * stafflinethickness# * (ne rotated -90);
% labels (1, 2, 3, 4, 5, 6);
- nw_dir = unitvector (z3 - z4);
+ nw = unitvector (z3 - z4);
- vert_dist = 0.5 pen_thick / cosd (angle (ne_dir));
- horz_dist = 0.5 pen_thick / sind (angle (ne_dir));
+ up_dist = up * 0.5 pen_thick / cosd (angle (ne));
+ rt_dist = right * 0.5 pen_thick / sind (angle (ne));
+ nw_dist = (ne rotated 90) * 0.5 pen_thick;
+ ne_dist = (nw rotated -90) * 0.5 pen_thick;
x4' := x4;
x5' := x5;
y6' := y6;
x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
- x5 := hfloor (x5' + horz_dist) - horz_dist;
- y6 := vfloor (y6' + vert_dist) - vert_dist;
+ x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
+ y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
- crz_out = (z6 + up * vert_dist)
- -- (z3 + nw_dir * 0.5 pen_thick){ne_dir}
+ crz_out = (z6 + up_dist)
+ -- (z3 + nw_dist){ne}
.. (top z3)
- .. (z3 + ne_dir * 0.5 pen_thick){-nw_dir}
- -- (z4 + ne_dir * 0.5 pen_thick){-nw_dir}
+ .. (z3 + ne_dist){-nw}
+ -- (z4 + ne_dist){-nw}
.. (rt z4)
- .. (z4 - nw_dir * 0.5 pen_thick){-ne_dir}
- -- (z5 + right * horz_dist);
+ .. (z4 - nw_dist){-ne}
+ -- (z5 + rt_dist);
crz_out := crz_out shifted (0, feta_shift)
-- reverse crz_out yscaled -1 shifted (0, -feta_eps);
fill crz_out
-- cycle;
if (thick > 1):
- x4 := hround (x4' - horz_dist) + horz_dist;
+ x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
crz_in = (bot z6){right}
- .. (z6 - nw_dir * 0.5 pen_thick){ne_dir}
- -- (z3 + down * vert_dist)
- -- (z4 + left * horz_dist)
- -- (z5 + nw_dir * 0.5 pen_thick){-ne_dir}
+ .. (z6 - nw_dist){ne}
+ -- (z3 - up_dist)
+ -- (z4 - rt_dist)
+ -- (z5 + nw_dist){-ne}
.. {down}(lft z5);
crz_in := crz_in shifted (0, feta_shift)
-- reverse crz_in yscaled -1 shifted (0, -feta_eps);
%
save solfa_pen_thick;
-solfa_pen_thick# = 2 stafflinethickness#;
+solfa_pen_thick# = 1.75 stafflinethickness#;
define_blacker_pixels (solfa_pen_thick);
+save solfa_base_notewidth;
+solfa_base_notewidth# := black_notehead_width#;
+
+solfa_whole_width := whole_notehead_width# / black_notehead_width#;
+solfa_half_width := half_notehead_width# / black_notehead_width#;
+solfa_quarter_width := 1.0;
+
def draw_do_head (expr width_factor, dir) =
save p_in, p_out;
save left_dist, right_dist;
path p_in, p_out;
pair left_dist, right_dist;
- set_char_box (0, width_factor * noteheight#,
- 0.5 noteheight#, 0.5 noteheight#);
+ set_char_box (0, width_factor * solfa_base_notewidth#,
+ 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
pickup pencircle scaled solfa_pen_thick;
fet_beginchar ("Whole dohead", "s0do");
- draw_do_head (1.8, 1);
+ draw_do_head (solfa_whole_width, 1);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Half dohead", "d1do");
- draw_do_head (1.5, -1);
+ draw_do_head (solfa_half_width, -1);
fill p_out;
unfill p_in;
fet_endchar;
-fet_beginchar ("Half dohead", "s1do");
- draw_do_head (1.5, 1);
+fet_beginchar ("Half dohead", "u1do");
+ draw_do_head (solfa_half_width, 1);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Quart dohead", "d2do");
- draw_do_head (1.55, -1);
+ draw_do_head (solfa_quarter_width, -1);
fill p_out;
fet_endchar;
-fet_beginchar ("Quart dohead", "s2do");
- draw_do_head (1.55, 1);
+fet_beginchar ("Quart dohead", "u2do");
+ draw_do_head (solfa_quarter_width, 1);
fill p_out;
fet_endchar;
save p_in, p_out;
path p_in, p_out;
- set_char_box (0, width_factor * noteheight#,
- 0.5 noteheight#, 0.5 noteheight#);
+ set_char_box (0, width_factor * solfa_base_notewidth#,
+ 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
pickup pencircle scaled solfa_pen_thick;
fet_beginchar ("Whole rehead", "s0re");
- draw_re_head (1.8, 1);
+ draw_re_head (solfa_whole_width, 1);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Half up rehead", "u1re");
- draw_re_head (1.5, 1);
+ draw_re_head (solfa_half_width, 1);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Half down rehead", "d1re");
- draw_re_head (1.5, -1);
+ draw_re_head (solfa_half_width, -1);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Quart rehead", "u2re");
- draw_re_head (1.55, 1);
+ draw_re_head (solfa_quarter_width, 1);
fill p_out;
fet_endchar;
fet_beginchar ("Quart rehead", "d2re");
- draw_re_head (1.55, -1);
+ draw_re_head (solfa_quarter_width, -1);
fill p_out;
fet_endchar;
path path_out, path_in;
pair ne_dist, se_dist, ne, se;
- set_char_box (0, width_factor * noteheight#,
- 0.5 noteheight#, 0.5 noteheight#);
+ set_char_box (0, width_factor * solfa_base_notewidth#,
+ 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
pickup pencircle scaled solfa_pen_thick;
fet_beginchar ("Whole mihead", "s0mi");
- draw_mi_head (1.8);
+ draw_mi_head (solfa_whole_width);
fill path_out;
unfill path_in;
fet_endchar;
fet_beginchar ("Half mihead", "s1mi");
- draw_mi_head (1.6);
+ draw_mi_head (solfa_quarter_width);
fill path_out;
unfill path_in;
fet_endchar;
fet_beginchar ("Quart mihead", "s2mi");
- draw_mi_head (1.65);
+ draw_mi_head (solfa_quarter_width);
fill path_out;
fet_endchar;
def draw_fa_head (expr width_factor) =
- set_char_box (0, width_factor * noteheight#,
- 0.5 noteheight#, 0.5 noteheight#);
+ set_char_box (0, width_factor * solfa_base_notewidth#,
+ 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
path p_down_in, p_down_out, p_up_in, p_up_out;
enddef;
-fet_beginchar ("Whole fa up head", "d0fa");
- draw_fa_head (1.8);
+fet_beginchar ("Whole fa up head", "u0fa");
+ draw_fa_head (solfa_whole_width);
fill p_up_out;
unfill p_up_in;
fet_endchar;
-fet_beginchar ("Whole fa down head", "u0fa");
- draw_fa_head (1.8);
+fet_beginchar ("Whole fa down head", "d0fa");
+ draw_fa_head (solfa_whole_width);
fill p_down_out;
unfill p_down_in;
fet_endchar;
-fet_beginchar ("half fa up head", "d1fa");
- draw_fa_head (1.5);
+fet_beginchar ("half fa up head", "u1fa");
+ draw_fa_head (solfa_half_width);
fill p_up_out;
unfill p_up_in;
fet_endchar;
-fet_beginchar ("Half fa down head", "u1fa");
- draw_fa_head (1.5);
+fet_beginchar ("Half fa down head", "d1fa");
+ draw_fa_head (solfa_half_width);
fill p_down_out;
unfill p_down_in;
fet_endchar;
fet_beginchar ("Quarter fa up head", "u2fa");
- draw_fa_head (1.55);
+ draw_fa_head (solfa_quarter_width);
fill p_up_out;
fet_endchar;
fet_beginchar ("Quarter fa down head", "d2fa");
- draw_fa_head (1.55);
+ draw_fa_head (solfa_quarter_width);
fill p_down_out;
fet_endchar;
def draw_la_head (expr width_factor) =
- set_char_box (0, width_factor * noteheight#,
- 0.5 noteheight#, 0.5 noteheight#);
+ set_char_box (0, width_factor * solfa_base_notewidth#,
+ 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
save p_in, p_out;
path p_in, p_out;
fet_beginchar ("Whole lahead", "s0la");
- draw_la_head (1.8);
+ draw_la_head (solfa_whole_width);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Half lahead", "s1la");
- draw_la_head (1.5);
+ draw_la_head (solfa_half_width);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Quart lahead", "s2la");
- draw_la_head (1.55);
+ draw_la_head (solfa_quarter_width);
fill p_out;
fet_endchar;
def draw_ti_head (expr width_factor, dir) =
- set_char_box (0, width_factor * noteheight#,
- 0.5 noteheight#, 0.5 noteheight#);
+ set_char_box (0, width_factor * solfa_base_notewidth#,
+ 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
save p_in, p_out, p_top;
save nw_dist, sw_dist, nw, sw;
path p_in, p_out, p_top;
fet_beginchar ("Whole up tihead", "s0ti");
- draw_ti_head (1.8, 1);
+ draw_ti_head (solfa_whole_width, 1);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Half up tihead", "u1ti");
- draw_ti_head (1.5, 1);
+ draw_ti_head (solfa_half_width, 1);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Half down tihead", "d1ti");
- draw_ti_head (1.5, -1);
+ draw_ti_head (solfa_half_width, -1);
fill p_out;
unfill p_in;
fet_endchar;
fet_beginchar ("Quart up tihead", "u2ti");
- draw_ti_head (1.55, 1);
+ draw_ti_head (solfa_quarter_width, 1);
fill p_out;
fet_endchar;
fet_beginchar ("Quart down tihead", "d2ti");
- draw_ti_head (1.55, -1);
+ draw_ti_head (solfa_quarter_width, -1);
fill p_out;
fet_endchar;