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