]> git.donarmstrong.com Git - lilypond.git/blob - mf/parmesan-custodes.mf
*** empty log message ***
[lilypond.git] / mf / parmesan-custodes.mf
1 % -%-Fundamental-%- -*-Metafont-*-
2 % parmesan-custodes.mf -- implement ancient custodes
3
4 % source file of LilyPond's pretty-but-neat music font
5
6 % (c) 2000--2005 Juergen Reuter <reuter@ipd.uka.de>
7
8
9 save black_notehead_width;
10 numeric black_notehead_width;
11
12 fet_begingroup ("custodes")
13
14 %
15 % character aligment:
16 %
17 %   The custos is assumed to be vertically centered around (0, 0).
18 %   The left-most edge of the custos should touch the vertical line
19 %   that goes though the point (0, 0).
20 %
21 % set_char_box() conventions:
22 %
23 % * breapth: Ignored (as far as I know).  Should be set to 0.
24 %
25 % * width: Should cover the horizontal range of the custos that is to
26 %   be printed in the staff.  If the custos has an appendage that is
27 %   supposed to reach beyond the right end of the staff, the width
28 %   should be set such that the appendage is outside of the char box.
29 %
30 % * depth: Should match the bottom edge of the custos.  Affects
31 %   vertical collision handling.
32 %
33 % * height: Should match the top edge of the custos.  Affects vertical
34 %   collision handling.
35 %
36
37 save between_staff_lines, on_staff_line, anywhere;
38 between_staff_lines = 0;
39 on_staff_line = 1;
40 anywhere = 2;
41
42 save dir_up, dir_down;
43 dir_up = 1;
44 dir_down = -1;
45
46
47 %%%%%%%%
48 %
49 %
50 % Hufnagel style
51 %
52 %
53
54 % parameterized hufnagel custos
55 def custos_hufnagel(expr verbose_name, internal_name, 
56                     direction, staffline_adjustment) =
57
58         fet_beginchar(verbose_name, internal_name)
59                 save alpha, dalpha, ht, wd, stem_ht, pen_size;
60                 ht# = noteheight#;
61                 wd#/ht# = 0.6;
62                 alpha# = 35;
63                 dalpha# = direction*alpha#;
64
65                 if staffline_adjustment = between_staff_lines:
66                         stem_ht# = 1.00 staff_space#;
67                 elseif staffline_adjustment = on_staff_line:
68                         stem_ht# = 1.50 staff_space#;
69                 else: % staffline_adjustment = anywhere
70                         stem_ht# = 1.25 staff_space#;
71                 fi;
72                 pen_size# = 0.5*sqrt(wd#*wd#+ht#*ht#);
73
74                 define_pixels(ht, wd, pen_size, stem_ht);
75                 pickup pencircle
76                   xscaled linethickness
77                   yscaled pen_size
78                   rotated -dalpha#;
79
80                 if direction = dir_up:
81                         top y1 = ht/2;
82                         bot y2 = -ht/2;
83                 else:
84                         bot y1 = -ht/2;
85                         top y2 = ht/2;
86                 fi;
87                 lft x1 = 0;
88                 rt  x2 = wd;
89                 y3 - y2 = direction*stem_ht;
90                 (y3 - y2) = (x3 - x2) * tand(90-dalpha#);
91                 draw z1 -- z2 -- z3;
92
93                 % The stem is intentionally outside of the char box.
94                 if direction > 0:
95                         set_char_box(0, wd#, ht#/2, stem_ht#);
96                 else:
97                         set_char_box(0, wd#, stem_ht#, ht#/2);
98                 fi;
99         fet_endchar;
100 enddef;
101
102 % custos hufnagel, stem up, between staff lines
103 custos_hufnagel("Custos Hufnagel", "hufnagel.u0", 
104                 dir_up, between_staff_lines);
105
106 % custos hufnagel, stem up, on staff line
107 custos_hufnagel("Custos Hufnagel", "hufnagel.u1", 
108                 dir_up, on_staff_line);
109
110 % custos hufnagel, stem up, anywhere
111 custos_hufnagel("Custos Hufnagel", "hufnagel.u2", 
112                 dir_up, anywhere);
113
114 % custos hufnagel, stem down, between staff lines
115 custos_hufnagel("Reverse Custos Hufnagel", "hufnagel.d0",
116                 dir_down, between_staff_lines);
117
118 % custos hufnagel, stem down, on staff line
119 custos_hufnagel("Reverse Custos Hufnagel", "hufnagel.d1",
120                 dir_down, on_staff_line);
121
122 % custos hufnagel, stem down, anywhere
123 custos_hufnagel("Reverse Custos Hufnagel", "hufnagel.d2",
124                 dir_down, anywhere);
125
126 %%%%%%%%
127 %
128 %
129 % Medicaea style
130 %
131 %
132
133 def custos_medicaea(expr verbose_name, internal_name, 
134                     direction, staffline_adjustment) =
135
136         fet_beginchar(verbose_name, internal_name)
137
138                 save ht, wd, stem_ht;
139                 ht# = noteheight#;
140                 wd#/ht# = 0.25;
141
142                 if staffline_adjustment = between_staff_lines:
143                         stem_ht# = 1.00 staff_space#;
144                 elseif staffline_adjustment = on_staff_line:
145                         stem_ht# = 1.50 staff_space#;
146                 else: % staffline_adjustment = anywhere
147                         stem_ht# = 1.25 staff_space#;
148                 fi;
149
150                 define_pixels(ht, wd, stem_ht);
151
152                 pickup pencircle xscaled 0.6linethickness yscaled ht;
153                 lft x1 = 0;
154                 y1 = 0;
155                 rt x2 = wd;
156                 y2 = y1;
157                 draw z1 -- z2;
158
159                 pickup pencircle scaled 0.6linethickness;
160                 rt x3 = wd;
161                 y3 = 0;
162                 x4 = x3;
163                 y4 = direction*stem_ht;
164                 draw z3 -- z4;
165
166                 if direction > 0:
167                         set_char_box(0, wd#, ht#/2, stem_ht#);
168                 else:
169                         set_char_box(0, wd#, stem_ht#, ht#/2);
170                 fi;
171         fet_endchar;
172 enddef;
173
174 % custos medicaea, stem up, between staff lines
175 custos_medicaea("Custos Med.", "medicaea.u0", 
176                 dir_up, between_staff_lines);
177
178 % custos medicaea, stem up, on staff line
179 custos_medicaea("Custos Med.", "medicaea.u1", 
180                 dir_up, on_staff_line);
181
182 % custos medicaea, stem up, anywhere
183 custos_medicaea("Custos Med.", "medicaea.u2", 
184                 dir_up, anywhere);
185
186 % custos medicaea, stem down, between staff lines
187 custos_medicaea("Reverse Custos Med.", "medicaea.d0", 
188                 dir_down, between_staff_lines);
189
190 % custos medicaea, stem down, on staff line
191 custos_medicaea("Reverse Custos Med.", "medicaea.d1", 
192                 dir_down, on_staff_line);
193
194 % custos medicaea, stem down, anywhere
195 custos_medicaea("Reverse Custos Med.", "medicaea.d2", 
196                 dir_down, anywhere);
197
198 %%%%%%%%
199 %
200 %
201 % Editio Vaticana style
202 %
203 %
204
205 def custos_vaticana(expr verbose_name, internal_name, 
206                     direction, staffline_adjustment) =
207
208         fet_beginchar(verbose_name, internal_name)
209                 save ht, wd, u_offs, l_offs, stem_size, stem_end;
210                 save pen_ht, l_shift, curve_ht, bend_ht;
211                 ht# = noteheight#;
212                 wd# = 0.24ht#;
213
214                 if staffline_adjustment = between_staff_lines:
215                         stem_size# = 1.00;
216                 elseif staffline_adjustment = on_staff_line:
217                         stem_size# = 1.50;
218                 else: % staffline_adjustment = anywhere
219                         stem_size# = 1.25;
220                 fi;
221                 curve_ht# = 0.6ht#;
222                 bend_ht# = 0.10ht#;
223                 l_shift# = 0.04ht#;
224                 u_offs# = +direction*0.5*(bend_ht#+l_shift#);
225                 l_offs# = -direction*0.5*(bend_ht#-l_shift#);
226                 stem_end# = direction*stem_size#*staff_space#;
227                 pen_ht# = curve_ht#-l_shift#;
228
229                 define_pixels(u_offs, l_offs, stem_end, ht, wd, pen_ht);
230
231                 pickup pencircle scaled 0.6linethickness;
232                 z1 = (0, u_offs);
233                 z2 = (0.7wd, l_offs);
234                 z3 = (wd, l_offs);
235                 penpos1(pen_ht, 90);
236                 penpos2(pen_ht, 90);
237                 penpos3(pen_ht, 90);
238                 penstroke z1e{z2 - z1} .. {right}z2e .. z3e;
239
240                 rt x4 = wd;
241                 bot y4 = 0;
242                 x5 = x4;
243                 top y5 = stem_end;
244                 draw z4 -- z5;
245
246                 if direction > 0:
247                         set_char_box(0, wd#, -l_offs#+0.5pen_ht#, stem_end#);
248                 else:
249                         set_char_box(0, wd#, -stem_end#, +l_offs#+0.5pen_ht#);
250                 fi;
251
252         fet_endchar;
253 enddef;
254
255 % custos vaticana, stem up, between staff lines
256 custos_vaticana("Custos Ed. Vat.", "vaticana.u0", 
257                 dir_up, between_staff_lines);
258
259 % custos vaticana, stem up, on staff line
260 custos_vaticana("Custos Ed. Vat.", "vaticana.u1", 
261                 dir_up, on_staff_line);
262
263 % custos vaticana, stem up, anywhere
264 custos_vaticana("Custos Ed. Vat.", "vaticana.u2", 
265                 dir_up, anywhere);
266
267 % custos vaticana, stem down, between staff lines
268 custos_vaticana("Reverse Custos Ed. Vat.", "vaticana.d0", 
269                 dir_down, between_staff_lines);
270
271 % custos vaticana, stem down, on_staff_line
272 custos_vaticana("Reverse Custos Ed. Vat.", "vaticana.d1", 
273                 dir_down, on_staff_line);
274
275 % custos vaticana, stem down, anywhere
276 custos_vaticana("Reverse Custos Ed. Vat.", "vaticana.d2", 
277                 dir_down, anywhere);
278
279 %%%%%%%%
280 %
281 %
282 % Mensural style
283 %
284 %
285
286 def custos_mensural(expr verbose_name, internal_name, 
287                     direction, staffline_adjustment) =
288
289         fet_beginchar(verbose_name, internal_name)
290                 save alpha, dalpha, ht, wd, stem_ht;
291                 ht# = noteheight#;
292                 wd#/ht# = 1.2;
293                 alpha# = 35;
294                 dalpha# = direction*alpha#;
295
296                 if staffline_adjustment = between_staff_lines:
297                         stem_ht# = 1.00 staff_space#;
298                 elseif staffline_adjustment = on_staff_line:
299                         stem_ht# = 1.50 staff_space#;
300                 else: % staffline_adjustment = anywhere
301                         stem_ht# = 1.25 staff_space#;
302                 fi;
303
304                 define_pixels(ht, wd, stem_ht);
305                 pickup pencircle
306                   xscaled linethickness
307                   yscaled 0.4ht
308                   rotated -dalpha#;
309
310                 if direction > 0:
311                         bot y1 = bot y3 = bot y5 = -direction*0.33ht;
312                         top y2 = top y4 = +direction*0.33ht;
313                 else:
314                         top y1 = top y3 = top y5 = -direction*0.33ht;
315                         bot y2 = bot y4 = +direction*0.33ht;
316                 fi;
317                 lft x1 = 0.0wd; lft x2 = 0.2wd; lft x3 = 0.4wd;
318                 lft x4 = 0.6wd; lft x5 = 0.8wd;
319                 y6 - y5 = direction*stem_ht;
320                 (y6 - y5) = (x6 - x5) * tand(90-dalpha#);
321
322                 draw z1 -- z2 -- z3 -- z4 -- z5 -- z6;
323
324                 % The stem is intentionally outside of the char box.
325                 if direction > 0:
326                         set_char_box(0, wd#, +direction*0.33ht#, stem_ht#);
327                 else:
328                         set_char_box(0, wd#, stem_ht#, -direction*0.33ht#);
329                 fi;
330         fet_endchar;
331 enddef;
332
333 % custos mensural, stem up, between staff lines
334 custos_mensural("Custos Mensural", "mensural.u0", 
335                 dir_up, between_staff_lines);
336
337 % custos mensural, stem up, on staff line
338 custos_mensural("Custos Mensural", "mensural.u1", 
339                 dir_up, on_staff_line);
340
341 % custos mensural, stem up, anywhere
342 custos_mensural("Custos Mensural", "mensural.u2", 
343                 dir_up, anywhere);
344
345 % custos mensural, stem down, between staff lines
346 custos_mensural("Reverse Custos Mensural", "mensural.d0", 
347                 dir_down, between_staff_lines);
348
349 % custos mensural, stem down, on staff line
350 custos_mensural("Reverse Custos Mensural", "mensural.d1", 
351                 dir_down, on_staff_line);
352
353 % custos mensural, stem down, anywhere
354 custos_mensural("Reverse Custos Mensural", "mensural.d2", 
355                 dir_down, anywhere);
356
357 fet_endgroup ("custodes")