1 % Feta (not the Font-En-Tja) music font -- global parameters for both feta and parmesan fonts
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 % LilyPond is free software: you can redistribute it and/or modify
7 % it under the terms of the GNU General Public License as published by
8 % the Free Software Foundation, either version 3 of the License, or
9 % (at your option) any later version.
11 % LilyPond is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 % GNU General Public License for more details.
16 % You should have received a copy of the GNU General Public License
17 % along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
22 % The design size of a staff should really be the
23 % staff_space, but we use staffsize for historical reasons.
26 staff_space# := staffsize# / (stafflines - 1);
27 staff_space_rounded# := staff_space#;
31 % Measuring on pocket scores turns out: stafflinethickness is
32 % largely independent on staff size, and generally about 0.5 pt.
34 % By request of WL, we tune down the blackness a little
35 % for increased contrast with beams.
38 %% !! synchronize with paper.scm
40 save fixed_line_thickness, variable_line_factor;
41 fixed_line_thickness + variable_line_factor * 5 pt# = 0.50 pt#;
42 fixed_line_thickness + variable_line_factor * 4.125 pt# = 0.47 pt#;
44 stafflinethickness# := fixed_line_thickness
45 + variable_line_factor * staff_space#;
46 stafflinethickness_rounded# := stafflinethickness#;
49 % The following tunes the general blackness of the glyphs.
52 linethickness# := stafflinethickness#; %% 0.5 pt#;
53 linethickness_rounded# := linethickness#;
56 % bigger puff_up_factor, relatively thicker stafflines.
58 % 20 pt = puff_up_factor 0
59 % 10 pt = puff_up_factor 1
62 puff_up_factor = (linethickness# - 0.1 staff_space#) / (0.1 staff_space#);
65 stemthickness# := 1.3 stafflinethickness#;
66 stemthickness_rounded# := stemthickness#;
67 ledgerlinethickness# := 2 stafflinethickness#;
68 ledgerlinethickness_rounded# := ledgerlinethickness#;
70 define_pixels (staff_space, stemthickness, stafflinethickness,
71 ledgerlinethickness, linethickness);
72 define_whole_pixels (staff_space_rounded);
73 define_whole_blacker_pixels (stemthickness_rounded);
74 define_whole_vertical_blacker_pixels (stafflinethickness_rounded,
75 ledgerlinethickness_rounded,
76 linethickness_rounded);
78 if ledgerlinethickness_rounded > 2 stafflinethickness_rounded:
79 ledgerlinethickness_rounded := 2 stafflinethickness_rounded;
83 % Because of the engraving/stamping process, no traditional
84 % characters have sharp edges and corners.
85 % The following variable controls the amount of `roundness'.
87 % This is not a meta variable: it is related to absolute sizes.
89 % FIXME: According to [Wanske], only outside corners should be round
90 % I don't think we do this anywhere -- jcn
93 blot_diameter# = .40 pt#;
94 if (blot_diameter# * hppp) < 1:
95 blot_diameter# := 1 / hppp;
97 if (blot_diameter# * vppp) < 1:
98 blot_diameter# := 1 / vppp;
101 define_pixels (blot_diameter);
108 % Some glyphs have to be positioned exactly between stafflines (clefs,
109 % note heads). This needs some care at lower resolutions.
111 % Most glyphs use the staffline thickness and the space between two
112 % staff lines as the fundamental parameters. The latter is the distance
113 % between the middle of one staff line to the middle of the next. To
114 % say it differently, the value `staff_space' is the sum of one staff line
115 % thickness and the whitespace between two adjacent staff lines.
117 % Normally, feta's vertical origin for glyphs is either the middle
118 % between two staff lines or the middle of a staff line. For example, the
119 % lower edge of the central staff line is at the vertical position
120 % `-<staffline thickness> / 2', and the upper edge at
121 % `<staffline thickness> / 2'. Here we need a value rounded to an integer
122 % (the feta code uses `stafflinethickness_rounded' for that purpose).
124 % If we have an odd number of pixels as the staffline thickness, Metafont
125 % rounds `-stafflinethickness_rounded / 2' towards zero and
126 % `stafflinethickness_rounded / 2' towards infinity. Example: `round -1.5'
127 % yields -1, `round 1.5' yields 2. The whitespace between staff lines is
128 % handled similarly. If we assume that stafflinethickness_rounded is odd,
129 % we have the following cases:
131 % o The glyph is centered between three stafflines or five stafflines
132 % (clef, `c' meter). We have this:
141 % ...... ___________ 1 .................. x axis
150 % As can be seen, we get symmetry if we split staff lines into two
151 % equal parts `a' and a pixel line with thickness 1. Consequently, we
152 % use the following algorithm:
154 % . Decrease the height `h' by 1 temporarily.
156 % . Compute the path for the upper half of the glyph.
158 % . Mirror the path at the x axis.
160 % . Shift the upper half one pixel up and connect it with the lower path.
162 % . Restore height and decrease `d' by 1.
164 % o The glyph is centered between two or four staff lines, and the origin is
165 % the middle of the whitespace. Assuming that the whitespace consists of
166 % an odd number of pixels, we have this:
174 % .................. 1 ................. x axis
182 % For symmetrical glyphs, this leads to a similar algorithm as above.
183 % Glyphs which can't be constructed from an upper and lower part need
184 % to be handled differently, namely to shift up the vertical center by
191 % .................. 0.5 ................ x axis
199 feta_space_shift := 0;
201 % Use this for paths with a slant of 45 degrees to assure that
202 % the middle point of a penpos gets covered.
204 feta_offset := (0, 0);
211 if odd stafflinethickness_rounded:
215 if odd (staff_space_rounded - stafflinethickness_rounded):
216 feta_space_shift := 1;
219 feta_offset := (0.5, 0.5);
221 pickup pencircle scaled 1;
224 feta_fillpen := savepen;