]> git.donarmstrong.com Git - lilypond.git/blob - mf/parmesan-custodes.mf
* mf/parmesan-custodes.mf, mf/parmesan-heads.mf,
[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--2003 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 noteheight#:=staff_space#+ (1 + overdone_heads) *stafflinethickness#;
38 define_pixels(noteheight);
39
40 save between_staff_lines, on_staff_line, anywhere;
41 between_staff_lines = 0;
42 on_staff_line = 1;
43 anywhere = 2;
44
45 save dir_up, dir_down;
46 dir_up = 1;
47 dir_down = -1;
48
49
50 %%%%%%%%
51 %
52 %
53 % Hufnagel style
54 %
55 %
56
57 % parameterized hufnagel custos
58 def custos_hufnagel(expr verbose_name, internal_name, ly_name,
59                     direction, staffline_adjustment) =
60
61         fet_beginchar(verbose_name, internal_name, ly_name)
62                 save alpha, dalpha, ht, wd, stem_ht, pen_size;
63                 ht# = noteheight#;
64                 wd#/ht# = 0.6;
65                 alpha# = 35;
66                 dalpha# = direction*alpha#;
67
68                 if staffline_adjustment = between_staff_lines:
69                         stem_ht# = 1.00 staff_space#;
70                 elseif staffline_adjustment = on_staff_line:
71                         stem_ht# = 1.50 staff_space#;
72                 else: % staffline_adjustment = anywhere
73                         stem_ht# = 1.25 staff_space#;
74                 fi;
75                 pen_size# = 0.5*sqrt(wd#*wd#+ht#*ht#);
76
77                 define_pixels(ht, wd, pen_size, stem_ht);
78                 pickup pencircle
79                   xscaled stafflinethickness
80                   yscaled pen_size
81                   rotated -dalpha#;
82
83                 if direction = dir_up:
84                         top y1 = ht/2;
85                         bot y2 = -ht/2;
86                 else:
87                         bot y1 = -ht/2;
88                         top y2 = ht/2;
89                 fi;
90                 lft x1 = 0;
91                 rt  x2 = wd;
92                 y3 - y2 = direction*stem_ht;
93                 (y3 - y2) = (x3 - x2) * tand(90-dalpha#);
94                 draw z1 -- z2 -- z3;
95
96                 % The stem is intentionally outside of the char box.
97                 if direction > 0:
98                         set_char_box(0, wd#, ht#/2, stem_ht#);
99                 else:
100                         set_char_box(0, wd#, stem_ht#, ht#/2);
101                 fi;
102         fet_endchar;
103 enddef;
104
105 % custos hufnagel, stem up, between staff lines
106 custos_hufnagel("Custos Hufnagel", "hufnagel-u0", "hufnagelu0",
107                 dir_up, between_staff_lines);
108
109 % custos hufnagel, stem up, on staff line
110 custos_hufnagel("Custos Hufnagel", "hufnagel-u1", "hufnagelu1",
111                 dir_up, on_staff_line);
112
113 % custos hufnagel, stem up, anywhere
114 custos_hufnagel("Custos Hufnagel", "hufnagel-u2", "hufnagelu2",
115                 dir_up, anywhere);
116
117 % custos hufnagel, stem down, between staff lines
118 custos_hufnagel("Reverse Custos Hufnagel", "hufnagel-d0", "hufnageld0",
119                 dir_down, between_staff_lines);
120
121 % custos hufnagel, stem down, on staff line
122 custos_hufnagel("Reverse Custos Hufnagel", "hufnagel-d1", "hufnageld1",
123                 dir_down, on_staff_line);
124
125 % custos hufnagel, stem down, anywhere
126 custos_hufnagel("Reverse Custos Hufnagel", "hufnagel-d2", "hufnageld2",
127                 dir_down, anywhere);
128
129 %%%%%%%%
130 %
131 %
132 % Medicaea style
133 %
134 %
135
136 def custos_medicaea(expr verbose_name, internal_name, ly_name,
137                     direction, staffline_adjustment) =
138
139         fet_beginchar(verbose_name, internal_name, ly_name)
140
141                 save ht, wd, stem_ht;
142                 ht# = noteheight#;
143                 wd#/ht# = 0.25;
144
145                 if staffline_adjustment = between_staff_lines:
146                         stem_ht# = 1.00 staff_space#;
147                 elseif staffline_adjustment = on_staff_line:
148                         stem_ht# = 1.50 staff_space#;
149                 else: % staffline_adjustment = anywhere
150                         stem_ht# = 1.25 staff_space#;
151                 fi;
152
153                 define_pixels(ht, wd, stem_ht);
154
155                 pickup pencircle xscaled 0.6stafflinethickness yscaled ht;
156                 lft x1 = 0;
157                 y1 = 0;
158                 rt x2 = wd;
159                 y2 = y1;
160                 draw z1 -- z2;
161
162                 pickup pencircle scaled 0.6stafflinethickness;
163                 rt x3 = wd;
164                 y3 = 0;
165                 x4 = x3;
166                 y4 = direction*stem_ht;
167                 draw z3 -- z4;
168
169                 if direction > 0:
170                         set_char_box(0, wd#, ht#/2, stem_ht#);
171                 else:
172                         set_char_box(0, wd#, stem_ht#, ht#/2);
173                 fi;
174         fet_endchar;
175 enddef;
176
177 % custos medicaea, stem up, between staff lines
178 custos_medicaea("Custos Med.", "medicaea-u0", "medicaeau0",
179                 dir_up, between_staff_lines);
180
181 % custos medicaea, stem up, on staff line
182 custos_medicaea("Custos Med.", "medicaea-u1", "medicaeau1",
183                 dir_up, on_staff_line);
184
185 % custos medicaea, stem up, anywhere
186 custos_medicaea("Custos Med.", "medicaea-u2", "medicaeau2",
187                 dir_up, anywhere);
188
189 % custos medicaea, stem down, between staff lines
190 custos_medicaea("Reverse Custos Med.", "medicaea-d0", "medicaead0",
191                 dir_down, between_staff_lines);
192
193 % custos medicaea, stem down, on staff line
194 custos_medicaea("Reverse Custos Med.", "medicaea-d1", "medicaead1",
195                 dir_down, on_staff_line);
196
197 % custos medicaea, stem down, anywhere
198 custos_medicaea("Reverse Custos Med.", "medicaea-d2", "medicaead2",
199                 dir_down, anywhere);
200
201 %%%%%%%%
202 %
203 %
204 % Editio Vaticana style
205 %
206 %
207
208 def custos_vaticana(expr verbose_name, internal_name, ly_name,
209                     direction, staffline_adjustment) =
210
211         fet_beginchar(verbose_name, internal_name, ly_name)
212                 save ht, wd, u_offs, l_offs, stem_size, stem_end;
213                 save pen_ht, l_shift, curve_ht, bend_ht;
214                 ht# = noteheight#;
215                 wd# = 0.24ht#;
216
217                 if staffline_adjustment = between_staff_lines:
218                         stem_size# = 1.00;
219                 elseif staffline_adjustment = on_staff_line:
220                         stem_size# = 1.50;
221                 else: % staffline_adjustment = anywhere
222                         stem_size# = 1.25;
223                 fi;
224                 curve_ht# = 0.6ht#;
225                 bend_ht# = 0.10ht#;
226                 l_shift# = 0.04ht#;
227                 u_offs# = +direction*0.5*(bend_ht#+l_shift#);
228                 l_offs# = -direction*0.5*(bend_ht#-l_shift#);
229                 stem_end# = direction*stem_size#*staff_space#;
230                 pen_ht# = curve_ht#-l_shift#;
231
232                 define_pixels(u_offs, l_offs, stem_end, ht, wd, pen_ht);
233
234                 pickup pencircle scaled 0.6stafflinethickness;
235                 z1 = (0, u_offs);
236                 z2 = (0.7wd, l_offs);
237                 z3 = (wd, l_offs);
238                 penpos1(pen_ht, 90);
239                 penpos2(pen_ht, 90);
240                 penpos3(pen_ht, 90);
241                 penstroke z1e{z2 - z1} .. {right}z2e .. z3e;
242
243                 rt x4 = wd;
244                 bot y4 = 0;
245                 x5 = x4;
246                 top y5 = stem_end;
247                 draw z4 -- z5;
248
249                 if direction > 0:
250                         set_char_box(0, wd#, -l_offs#+0.5pen_ht#, stem_end#);
251                 else:
252                         set_char_box(0, wd#, -stem_end#, +l_offs#+0.5pen_ht#);
253                 fi;
254
255         fet_endchar;
256 enddef;
257
258 % custos vaticana, stem up, between staff lines
259 custos_vaticana("Custos Ed. Vat.", "vaticana-u0", "vaticanau0",
260                 dir_up, between_staff_lines);
261
262 % custos vaticana, stem up, on staff line
263 custos_vaticana("Custos Ed. Vat.", "vaticana-u1", "vaticanau1",
264                 dir_up, on_staff_line);
265
266 % custos vaticana, stem up, anywhere
267 custos_vaticana("Custos Ed. Vat.", "vaticana-u2", "vaticanau2",
268                 dir_up, anywhere);
269
270 % custos vaticana, stem down, between staff lines
271 custos_vaticana("Reverse Custos Ed. Vat.", "vaticana-d0", "vaticanad0",
272                 dir_down, between_staff_lines);
273
274 % custos vaticana, stem down, on_staff_line
275 custos_vaticana("Reverse Custos Ed. Vat.", "vaticana-d1", "vaticanad1",
276                 dir_down, on_staff_line);
277
278 % custos vaticana, stem down, anywhere
279 custos_vaticana("Reverse Custos Ed. Vat.", "vaticana-d2", "vaticanad2",
280                 dir_down, anywhere);
281
282 %%%%%%%%
283 %
284 %
285 % Mensural style
286 %
287 %
288
289 def custos_mensural(expr verbose_name, internal_name, ly_name,
290                     direction, staffline_adjustment) =
291
292         fet_beginchar(verbose_name, internal_name, ly_name)
293                 save alpha, dalpha, ht, wd, stem_ht;
294                 ht# = noteheight#;
295                 wd#/ht# = 1.2;
296                 alpha# = 35;
297                 dalpha# = direction*alpha#;
298
299                 if staffline_adjustment = between_staff_lines:
300                         stem_ht# = 1.00 staff_space#;
301                 elseif staffline_adjustment = on_staff_line:
302                         stem_ht# = 1.50 staff_space#;
303                 else: % staffline_adjustment = anywhere
304                         stem_ht# = 1.25 staff_space#;
305                 fi;
306
307                 define_pixels(ht, wd, stem_ht);
308                 pickup pencircle
309                   xscaled stafflinethickness
310                   yscaled 0.4ht
311                   rotated -dalpha#;
312
313                 if direction > 0:
314                         bot y1 = bot y3 = bot y5 = -direction*0.33ht;
315                         top y2 = top y4 = +direction*0.33ht;
316                 else:
317                         top y1 = top y3 = top y5 = -direction*0.33ht;
318                         bot y2 = bot y4 = +direction*0.33ht;
319                 fi;
320                 lft x1 = 0.0wd; lft x2 = 0.2wd; lft x3 = 0.4wd;
321                 lft x4 = 0.6wd; lft x5 = 0.8wd;
322                 y6 - y5 = direction*stem_ht;
323                 (y6 - y5) = (x6 - x5) * tand(90-dalpha#);
324
325                 draw z1 -- z2 -- z3 -- z4 -- z5 -- z6;
326
327                 % The stem is intentionally outside of the char box.
328                 if direction > 0:
329                         set_char_box(0, wd#, +direction*0.33ht#, stem_ht#);
330                 else:
331                         set_char_box(0, wd#, stem_ht#, -direction*0.33ht#);
332                 fi;
333         fet_endchar;
334 enddef;
335
336 % custos mensural, stem up, between staff lines
337 custos_mensural("Custos Mensural", "mensural-u0", "mensuralu0",
338                 dir_up, between_staff_lines);
339
340 % custos mensural, stem up, on staff line
341 custos_mensural("Custos Mensural", "mensural-u1", "mensuralu1",
342                 dir_up, on_staff_line);
343
344 % custos mensural, stem up, anywhere
345 custos_mensural("Custos Mensural", "mensural-u2", "mensuralu2",
346                 dir_up, anywhere);
347
348 % custos mensural, stem down, between staff lines
349 custos_mensural("Reverse Custos Mensural", "mensural-d0", "mensurald0",
350                 dir_down, between_staff_lines);
351
352 % custos mensural, stem down, on staff line
353 custos_mensural("Reverse Custos Mensural", "mensural-d1", "mensurald1",
354                 dir_down, on_staff_line);
355
356 % custos mensural, stem down, anywhere
357 custos_mensural("Reverse Custos Mensural", "mensural-d2", "mensurald2",
358                 dir_down, anywhere);
359
360 fet_endgroup ("custodes")