]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-params.mf
Run `make grand-replace'.
[lilypond.git] / mf / feta-params.mf
1 %
2 % feta-params.mf -- global parameters for both feta and parmesan fonts
3 %
4 % source file of the GNU LilyPond music typesetter
5 %
6 % (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 stafflines := 5;
9
10 %
11 % The design size of a staff should really be the 
12 % staff_space, but we use staffsize for historical reasons.
13
14
15 staff_space# := staffsize# / (stafflines - 1);
16 staff_space_rounded# := staff_space#;
17
18
19 %
20 % Measuring on pocket scores turns out: stafflinethickness is
21 % largely independent on staff size, and generally about 0.5 pt.
22 %
23 % By request of WL, we tune down the blackness a little
24 % for increased contrast with beams.
25 %
26
27 %% !! synchronize with paper.scm
28
29 save fixed_line_thickness, variable_line_factor;
30 fixed_line_thickness + variable_line_factor * 5 pt# = 0.50 pt#;
31 fixed_line_thickness + variable_line_factor * 4.125 pt# = 0.47 pt#;
32
33 stafflinethickness# := fixed_line_thickness
34                        + variable_line_factor * staff_space#; 
35 stafflinethickness_rounded# := stafflinethickness#;
36
37 %
38 % The following tunes the general blackness of the glyphs. 
39 %
40
41 linethickness# := stafflinethickness#;          %% 0.5 pt#;
42 linethickness_rounded# := linethickness#;
43
44 %
45 % bigger puff_up_factor, relatively thicker stafflines.
46 %
47 %   20 pt = puff_up_factor 0
48 %   10 pt = puff_up_factor 1
49 %
50
51 puff_up_factor = (linethickness# - 0.1 staff_space#) / (0.1 staff_space#);
52
53
54 stemthickness# := 1.3 stafflinethickness#;
55 stemthickness_rounded# := stemthickness#;
56 ledgerlinethickness# := 2 stafflinethickness#;
57 ledgerlinethickness_rounded# := ledgerlinethickness#;
58
59 define_pixels (staff_space, stemthickness, stafflinethickness,
60                ledgerlinethickness, linethickness);
61 define_whole_pixels (staff_space_rounded);
62 define_whole_blacker_pixels (stemthickness_rounded);
63 define_whole_vertical_blacker_pixels (stafflinethickness_rounded,
64                                       ledgerlinethickness_rounded,
65                                       linethickness_rounded);
66
67 if ledgerlinethickness_rounded > 2 stafflinethickness_rounded:
68         ledgerlinethickness_rounded := 2 stafflinethickness_rounded;
69 fi;
70
71
72 % Because of the engraving/stamping process, no traditional
73 % characters have sharp edges and corners.
74 % The following variable controls the amount of `roundness'.
75 %
76 % This is not a meta variable: it is related to absolute sizes.
77 %
78 % FIXME: According to [Wanske], only outside corners should be round
79 %        I don't think we do this anywhere -- jcn
80 %
81
82 blot_diameter# = .40 pt#;
83 if (blot_diameter# * hppp) < 1:
84         blot_diameter# := 1 / hppp;
85 fi
86 if (blot_diameter# * vppp) < 1:
87         blot_diameter# := 1 / vppp;
88 fi
89
90 define_pixels (blot_diameter);
91
92
93 %
94 % symmetry
95 % --------
96 %
97 % Some glyphs have to be positioned exactly between stafflines (clefs,
98 % note heads).  This needs some care at lower resolutions.
99 %
100 % Most glyphs use the staffline thickness and the space between two
101 % staff lines as the fundamental parameters.  The latter is the distance
102 % between the middle of one staff line to the middle of the next.  To
103 % say it differently, the value `staff_space' is the sum of one staff line
104 % thickness and the whitespace between two adjacent staff lines.
105 %
106 % Normally, feta's vertical origin for glyphs is either the middle
107 % between two staff lines or the middle of a staff line.  For example, the
108 % lower edge of the central staff line is at the vertical position
109 % `-<staffline thickness> / 2', and the upper edge at
110 % `<staffline thickness> / 2'.  Here we need a value rounded to an integer
111 % (the feta code uses `stafflinethickness_rounded' for that purpose).
112 %
113 % If we have an odd number of pixels as the staffline thickness, Metafont
114 % rounds `-stafflinethickness_rounded / 2' towards zero and
115 % `stafflinethickness_rounded / 2' towards infinity.  Example: `round -1.5'
116 % yields -1, `round 1.5' yields 2.  The whitespace between staff lines is
117 % handled similarly.  If we assume that stafflinethickness_rounded is odd,
118 % we have the following cases:
119 %
120 % o The glyph is centered between three stafflines or five stafflines
121 %   (clef, `c' meter).  We have this:
122 %
123 %          ___________  a
124 %          ___________  1
125 %          ___________  a
126 %
127 %                            whitespace
128 %
129 %          ___________  a
130 %   ...... ___________  1 ..................  x axis
131 %          ___________  a
132 %
133 %                            whitespace
134 %
135 %          ___________  a
136 %          ___________  1
137 %          ___________  a
138 %
139 %   As can be seen, we get symmetry if we split staff lines into two
140 %   equal parts `a' and a pixel line with thickness 1.  Consequently, we
141 %   use the following algorithm:
142 %
143 %   . Decrease the height `h' by 1 temporarily.
144 %
145 %   . Compute the path for the upper half of the glyph.
146 %
147 %   . Mirror the path at the x axis.
148 %
149 %   . Shift the upper half one pixel up and connect it with the lower path.
150 %
151 %   . Restore height and decrease `d' by 1.
152 %
153 % o The glyph is centered between two or four staff lines, and the origin is
154 %   the middle of the whitespace.  Assuming that the the whitespace consists
155 %   of an odd number of pixels, we have this:
156 %
157 %          -----------
158 %                       b
159 %                       1
160 %                       b
161 %          ___________
162 %                       b
163 %   ..................  1  .................  x axis
164 %                       b
165 %          ___________
166 %                       b
167 %                       1
168 %                       b
169 %          ___________
170 %
171 %   For symmetrical glyphs, this leads to a similar algorithm as above.
172 %   Glyphs which can't be constructed from an upper and lower part need
173 %   to be handled differently, namely to shift up the vertical center by
174 %   half a pixel:
175 %
176 %          ___________
177 %                       b
178 %
179 %                       0.5
180 %   ..................  0.5 ................  x axis
181 %
182 %                       b
183 %          ___________
184 %
185
186 feta_eps := 0;
187 feta_shift := 0;
188 feta_space_shift := 0;
189
190 % Use this for paths with a slant of 45 degrees to assure that
191 % the middle point of a penpos gets covered.
192 pair feta_offset;
193 feta_offset := (0, 0);
194
195 if known miterlimit:
196         pickup nullpen;
197 else:
198         feta_eps := eps;
199
200         if odd stafflinethickness_rounded:
201                 feta_shift := 1;
202         fi;
203
204         if odd (staff_space_rounded - stafflinethickness_rounded):
205                 feta_space_shift := 1;
206         fi;
207
208         feta_offset := (0.5, 0.5);
209
210         pickup pencircle scaled 1;
211 fi;
212
213 feta_fillpen := savepen;