summaryrefslogtreecommitdiff
path: root/mf/feta-params.mf
blob: c771e4e44aeb726f12634743866e6c4e419941d7 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
% Feta (not the Font-En-Tja) music font -- global parameters for both feta and parmesan fonts
% This file is part of LilyPond, the GNU music typesetter.
%
% Copyright (C) 1997--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
%
% The LilyPond font is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version, or under the SIL Open Font License.
%
% LilyPond is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.

stafflines := 5;

%
% The design size of a staff should really be the
% staff_space, but we use staffsize for historical reasons.
%

staff_space# := staffsize# / (stafflines - 1);
staff_space_rounded# := staff_space#;


%
% Measuring on pocket scores turns out: stafflinethickness is
% largely independent on staff size, and generally about 0.5 pt.
%
% By request of WL, we tune down the blackness a little
% for increased contrast with beams.
%

%% !! synchronize with paper.scm

save fixed_line_thickness, variable_line_factor;
fixed_line_thickness + variable_line_factor * 5 pt# = 0.50 pt#;
fixed_line_thickness + variable_line_factor * 4.125 pt# = 0.47 pt#;

stafflinethickness# := fixed_line_thickness
		       + variable_line_factor * staff_space#;
stafflinethickness_rounded# := stafflinethickness#;

%
% The following tunes the general blackness of the glyphs.
%

linethickness# := stafflinethickness#;		%% 0.5 pt#;
linethickness_rounded# := linethickness#;

%
% bigger puff_up_factor, relatively thicker stafflines.
%
%   20 pt = puff_up_factor 0
%   10 pt = puff_up_factor 1
%

puff_up_factor = (linethickness# - 0.1 staff_space#) / (0.1 staff_space#);


stemthickness# := 1.3 stafflinethickness#;
stemthickness_rounded# := stemthickness#;
ledgerlinethickness# := 2 stafflinethickness#;
ledgerlinethickness_rounded# := ledgerlinethickness#;

define_pixels (staff_space, stemthickness, stafflinethickness,
	       ledgerlinethickness, linethickness);
define_whole_pixels (staff_space_rounded);
define_whole_blacker_pixels (stemthickness_rounded);
define_whole_vertical_blacker_pixels (stafflinethickness_rounded,
				      ledgerlinethickness_rounded,
				      linethickness_rounded);

if ledgerlinethickness_rounded > 2 stafflinethickness_rounded:
	ledgerlinethickness_rounded := 2 stafflinethickness_rounded;
fi;

%
% Because of the engraving/stamping process, no traditional
% characters have sharp edges and corners.
% The following variable controls the amount of `roundness'.
%
% This is not a meta variable: it is related to absolute sizes.
%
% FIXME: According to [Wanske], only outside corners should be round
%        I don't think we do this anywhere -- jcn
%

blot_diameter# = .40 pt#;
if (blot_diameter# * hppp) < 1:
	blot_diameter# := 1 / hppp;
fi
if (blot_diameter# * vppp) < 1:
	blot_diameter# := 1 / vppp;
fi

define_pixels (blot_diameter);


%
% symmetry
% --------
%
% Some glyphs have to be positioned exactly between stafflines (clefs,
% note heads).  This needs some care at lower resolutions.
%
% Most glyphs use the staffline thickness and the space between two
% staff lines as the fundamental parameters.  The latter is the distance
% between the middle of one staff line to the middle of the next.  To
% say it differently, the value `staff_space' is the sum of one staff line
% thickness and the whitespace between two adjacent staff lines.
%
% Normally, feta's vertical origin for glyphs is either the middle
% between two staff lines or the middle of a staff line.  For example, the
% lower edge of the central staff line is at the vertical position
% `-<staffline thickness> / 2', and the upper edge at
% `<staffline thickness> / 2'.  Here we need a value rounded to an integer
% (the feta code uses `stafflinethickness_rounded' for that purpose).
%
% If we have an odd number of pixels as the staffline thickness, Metafont
% rounds `-stafflinethickness_rounded / 2' towards zero and
% `stafflinethickness_rounded / 2' towards infinity.  Example: `round -1.5'
% yields -1, `round 1.5' yields 2.  The whitespace between staff lines is
% handled similarly.  If we assume that stafflinethickness_rounded is odd,
% we have the following cases:
%
% o The glyph is centered between three stafflines or five stafflines
%   (clef, `c' meter).  We have this:
%
%          ___________  a
%          ___________  1
%          ___________  a
%
%                            whitespace
%
%          ___________  a
%   ...... ___________  1 ..................  x axis
%          ___________  a
%
%                            whitespace
%
%          ___________  a
%          ___________  1
%          ___________  a
%
%   As can be seen, we get symmetry if we split staff lines into two
%   equal parts `a' and a pixel line with thickness 1.  Consequently, we
%   use the following algorithm:
%
%   . Decrease the height `h' by 1 temporarily.
%
%   . Compute the path for the upper half of the glyph.
%
%   . Mirror the path at the x axis.
%
%   . Shift the upper half one pixel up and connect it with the lower path.
%
%   . Restore height and decrease `d' by 1.
%
% o The glyph is centered between two or four staff lines, and the origin is
%   the middle of the whitespace.  Assuming that the whitespace consists of
%   an odd number of pixels, we have this:
%
%          -----------
%                       b
%                       1
%                       b
%          ___________
%                       b
%   ..................  1  .................  x axis
%                       b
%          ___________
%                       b
%                       1
%                       b
%          ___________
%
%   For symmetrical glyphs, this leads to a similar algorithm as above.
%   Glyphs which can't be constructed from an upper and lower part need
%   to be handled differently, namely to shift up the vertical center by
%   half a pixel:
%
%          ___________
%                       b
%
%                       0.5
%   ..................  0.5 ................  x axis
%
%                       b
%          ___________
%

feta_eps := 0;
feta_shift := 0;
feta_space_shift := 0;

% Use this for paths with a slant of 45 degrees to assure that
% the middle point of a penpos gets covered.
pair feta_offset;
feta_offset := (0, 0);

if known miterlimit:
	pickup nullpen;
else:
	feta_eps := eps;

	if odd stafflinethickness_rounded:
		feta_shift := 1;
	fi;

	if odd (staff_space_rounded - stafflinethickness_rounded):
		feta_space_shift := 1;
	fi;

	feta_offset := (0.5, 0.5);

	pickup pencircle scaled 1;
fi;

feta_fillpen := savepen;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Notehead width and height are defined here.
%
%
% Slope of slash.  From scm/grob-description.scm.  How to auto-copy?
slash_slope := 1.7;

% Thickness of slash lines.  Quarter notes get 1.5slt width.
slash_thick# := 2/3 * 0.48 staff_space#;

%
% Hand-engraved music often has balls extending above and below
% the lines.  If you like that, modify overdone heads (unit:
% stafflinethickness).
%
overdone_heads = 0.0;
noteheight# := staff_space# + (1 + overdone_heads) * stafflinethickness#;

define_pixels (slash_thick);
define_whole_vertical_pixels (noteheight);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This is used to draw all elliptical notes; it also sets
% black_notehead_width, so it should be called in any file that
% needs the value of black_notehead_width.
%
% SLANT moves both extrema on the long axis (by SLANT * ELLIPTICITY,
% so SLANT = -1, puts the extreme on the long axis next to the short
% axis one).
%

def draw_outside_ellipse (expr ellipticity, tilt, superness, slant) =
        save attachment_y;
        save pat;
        path pat;

        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 pat;
        right_point := directionpoint up of pat;

        save scaling, width;

        scaling# := noteheight# / (2 ypart (top_point));
        width# := 2 xpart (right_point) * scaling#;
        define_pixels (scaling, width);
       set_char_box (0, width#, noteheight# / 2, noteheight# / 2);

        d := d - feta_space_shift;

        % attachment Y
        charwy := ypart (right_point) * scaling#;
        charwx := width#;

        pat := pat scaled scaling shifted (w / 2, .5 (h - d));

        width := hround width;

        if test_outlines = 1:
                draw pat;
        else:
                fill pat;
        fi;
enddef;


def draw_quarter_path =
        draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, 0.707, 0);
enddef;

test_outlines := 0;
draw_quarter_path;
black_notehead_width# := charwd;

define_pixels (slash_thick);
define_whole_vertical_pixels (noteheight);