summaryrefslogtreecommitdiff
path: root/mf/parmesan-custodes.mf
blob: a2bfff9078ad2e3df760626b4aba6bf9b16f711b (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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
% -%-Fundamental-%- -*-Metafont-*-
% parmesan-custodes.mf -- implement ancient custodes
% 
% source file of LilyPond's pretty-but-neat music font
% 
% (c) 2000--2004 Juergen Reuter <reuter@ipd.uka.de>
% 

save black_notehead_width;
numeric black_notehead_width;

fet_begingroup ("custodes")

%
% character aligment:
%
%   The custos is assumed to be vertically centered around (0, 0).
%   The left-most edge of the custos should touch the vertical line
%   that goes though the point (0, 0).
%
% set_char_box() conventions:
%
% * breapth: Ignored (as far as I know).  Should be set to 0.
%
% * width: Should cover the horizontal range of the custos that is to
%   be printed in the staff.  If the custos has an appendage that is
%   supposed to reach beyond the right end of the staff, the width
%   should be set such that the appendage is outside of the char box.
%
% * depth: Should match the bottom edge of the custos.  Affects
%   vertical collision handling.
%
% * height: Should match the top edge of the custos.  Affects vertical
%   collision handling.
%

save between_staff_lines, on_staff_line, anywhere;
between_staff_lines = 0;
on_staff_line = 1;
anywhere = 2;

save dir_up, dir_down;
dir_up = 1;
dir_down = -1;


%%%%%%%%
%
%
% Hufnagel style
%
%

% parameterized hufnagel custos
def custos_hufnagel(expr verbose_name, internal_name, 
		    direction, staffline_adjustment) =

	fet_beginchar(verbose_name, internal_name)
		save alpha, dalpha, ht, wd, stem_ht, pen_size;
		ht# = noteheight#;
		wd#/ht# = 0.6;
		alpha# = 35;
		dalpha# = direction*alpha#;

		if staffline_adjustment = between_staff_lines:
			stem_ht# = 1.00 staff_space#;
		elseif staffline_adjustment = on_staff_line:
			stem_ht# = 1.50 staff_space#;
		else: % staffline_adjustment = anywhere
			stem_ht# = 1.25 staff_space#;
		fi;
		pen_size# = 0.5*sqrt(wd#*wd#+ht#*ht#);

		define_pixels(ht, wd, pen_size, stem_ht);
		pickup pencircle
		  xscaled linethickness
		  yscaled pen_size
		  rotated -dalpha#;

		if direction = dir_up:
			top y1 = ht/2;
			bot y2 = -ht/2;
		else:
			bot y1 = -ht/2;
			top y2 = ht/2;
		fi;
		lft x1 = 0;
		rt  x2 = wd;
		y3 - y2 = direction*stem_ht;
		(y3 - y2) = (x3 - x2) * tand(90-dalpha#);
		draw z1 -- z2 -- z3;

		% The stem is intentionally outside of the char box.
		if direction > 0:
			set_char_box(0, wd#, ht#/2, stem_ht#);
		else:
			set_char_box(0, wd#, stem_ht#, ht#/2);
		fi;
	fet_endchar;
enddef;

% custos hufnagel, stem up, between staff lines
custos_hufnagel("Custos Hufnagel", "hufnagel.u0", 
		dir_up, between_staff_lines);

% custos hufnagel, stem up, on staff line
custos_hufnagel("Custos Hufnagel", "hufnagel.u1", 
		dir_up, on_staff_line);

% custos hufnagel, stem up, anywhere
custos_hufnagel("Custos Hufnagel", "hufnagel.u2", 
		dir_up, anywhere);

% custos hufnagel, stem down, between staff lines
custos_hufnagel("Reverse Custos Hufnagel", "hufnagel.d0",
		dir_down, between_staff_lines);

% custos hufnagel, stem down, on staff line
custos_hufnagel("Reverse Custos Hufnagel", "hufnagel.d1",
		dir_down, on_staff_line);

% custos hufnagel, stem down, anywhere
custos_hufnagel("Reverse Custos Hufnagel", "hufnagel.d2",
		dir_down, anywhere);

%%%%%%%%
%
%
% Medicaea style
%
%

def custos_medicaea(expr verbose_name, internal_name, 
		    direction, staffline_adjustment) =

	fet_beginchar(verbose_name, internal_name)

		save ht, wd, stem_ht;
		ht# = noteheight#;
		wd#/ht# = 0.25;

		if staffline_adjustment = between_staff_lines:
			stem_ht# = 1.00 staff_space#;
		elseif staffline_adjustment = on_staff_line:
			stem_ht# = 1.50 staff_space#;
		else: % staffline_adjustment = anywhere
			stem_ht# = 1.25 staff_space#;
		fi;

		define_pixels(ht, wd, stem_ht);

		pickup pencircle xscaled 0.6linethickness yscaled ht;
		lft x1 = 0;
		y1 = 0;
		rt x2 = wd;
		y2 = y1;
		draw z1 -- z2;

		pickup pencircle scaled 0.6linethickness;
		rt x3 = wd;
		y3 = 0;
		x4 = x3;
		y4 = direction*stem_ht;
		draw z3 -- z4;

		if direction > 0:
			set_char_box(0, wd#, ht#/2, stem_ht#);
		else:
			set_char_box(0, wd#, stem_ht#, ht#/2);
		fi;
	fet_endchar;
enddef;

% custos medicaea, stem up, between staff lines
custos_medicaea("Custos Med.", "medicaea.u0", 
		dir_up, between_staff_lines);

% custos medicaea, stem up, on staff line
custos_medicaea("Custos Med.", "medicaea.u1", 
		dir_up, on_staff_line);

% custos medicaea, stem up, anywhere
custos_medicaea("Custos Med.", "medicaea.u2", 
		dir_up, anywhere);

% custos medicaea, stem down, between staff lines
custos_medicaea("Reverse Custos Med.", "medicaea.d0", 
		dir_down, between_staff_lines);

% custos medicaea, stem down, on staff line
custos_medicaea("Reverse Custos Med.", "medicaea.d1", 
		dir_down, on_staff_line);

% custos medicaea, stem down, anywhere
custos_medicaea("Reverse Custos Med.", "medicaea.d2", 
		dir_down, anywhere);

%%%%%%%%
%
%
% Editio Vaticana style
%
%

def custos_vaticana(expr verbose_name, internal_name, 
		    direction, staffline_adjustment) =

	fet_beginchar(verbose_name, internal_name)
		save ht, wd, u_offs, l_offs, stem_size, stem_end;
		save pen_ht, l_shift, curve_ht, bend_ht;
		ht# = noteheight#;
		wd# = 0.24ht#;

		if staffline_adjustment = between_staff_lines:
			stem_size# = 1.00;
		elseif staffline_adjustment = on_staff_line:
			stem_size# = 1.50;
		else: % staffline_adjustment = anywhere
			stem_size# = 1.25;
		fi;
		curve_ht# = 0.6ht#;
		bend_ht# = 0.10ht#;
		l_shift# = 0.04ht#;
		u_offs# = +direction*0.5*(bend_ht#+l_shift#);
		l_offs# = -direction*0.5*(bend_ht#-l_shift#);
		stem_end# = direction*stem_size#*staff_space#;
		pen_ht# = curve_ht#-l_shift#;

		define_pixels(u_offs, l_offs, stem_end, ht, wd, pen_ht);

		pickup pencircle scaled 0.6linethickness;
		z1 = (0, u_offs);
		z2 = (0.7wd, l_offs);
		z3 = (wd, l_offs);
		penpos1(pen_ht, 90);
		penpos2(pen_ht, 90);
		penpos3(pen_ht, 90);
		penstroke z1e{z2 - z1} .. {right}z2e .. z3e;

		rt x4 = wd;
		bot y4 = 0;
		x5 = x4;
		top y5 = stem_end;
		draw z4 -- z5;

		if direction > 0:
			set_char_box(0, wd#, -l_offs#+0.5pen_ht#, stem_end#);
		else:
			set_char_box(0, wd#, -stem_end#, +l_offs#+0.5pen_ht#);
		fi;

	fet_endchar;
enddef;

% custos vaticana, stem up, between staff lines
custos_vaticana("Custos Ed. Vat.", "vaticana.u0", 
		dir_up, between_staff_lines);

% custos vaticana, stem up, on staff line
custos_vaticana("Custos Ed. Vat.", "vaticana.u1", 
		dir_up, on_staff_line);

% custos vaticana, stem up, anywhere
custos_vaticana("Custos Ed. Vat.", "vaticana.u2", 
		dir_up, anywhere);

% custos vaticana, stem down, between staff lines
custos_vaticana("Reverse Custos Ed. Vat.", "vaticana.d0", 
		dir_down, between_staff_lines);

% custos vaticana, stem down, on_staff_line
custos_vaticana("Reverse Custos Ed. Vat.", "vaticana.d1", 
		dir_down, on_staff_line);

% custos vaticana, stem down, anywhere
custos_vaticana("Reverse Custos Ed. Vat.", "vaticana.d2", 
		dir_down, anywhere);

%%%%%%%%
%
%
% Mensural style
%
%

def custos_mensural(expr verbose_name, internal_name, 
		    direction, staffline_adjustment) =

	fet_beginchar(verbose_name, internal_name)
		save alpha, dalpha, ht, wd, stem_ht;
		ht# = noteheight#;
		wd#/ht# = 1.2;
		alpha# = 35;
		dalpha# = direction*alpha#;

		if staffline_adjustment = between_staff_lines:
			stem_ht# = 1.00 staff_space#;
		elseif staffline_adjustment = on_staff_line:
			stem_ht# = 1.50 staff_space#;
		else: % staffline_adjustment = anywhere
			stem_ht# = 1.25 staff_space#;
		fi;

		define_pixels(ht, wd, stem_ht);
		pickup pencircle
		  xscaled linethickness
		  yscaled 0.4ht
		  rotated -dalpha#;

		if direction > 0:
			bot y1 = bot y3 = bot y5 = -direction*0.33ht;
			top y2 = top y4 = +direction*0.33ht;
		else:
			top y1 = top y3 = top y5 = -direction*0.33ht;
			bot y2 = bot y4 = +direction*0.33ht;
		fi;
		lft x1 = 0.0wd; lft x2 = 0.2wd; lft x3 = 0.4wd;
		lft x4 = 0.6wd; lft x5 = 0.8wd;
		y6 - y5 = direction*stem_ht;
		(y6 - y5) = (x6 - x5) * tand(90-dalpha#);

		draw z1 -- z2 -- z3 -- z4 -- z5 -- z6;

		% The stem is intentionally outside of the char box.
		if direction > 0:
			set_char_box(0, wd#, +direction*0.33ht#, stem_ht#);
		else:
			set_char_box(0, wd#, stem_ht#, -direction*0.33ht#);
		fi;
	fet_endchar;
enddef;

% custos mensural, stem up, between staff lines
custos_mensural("Custos Mensural", "mensural.u0", 
		dir_up, between_staff_lines);

% custos mensural, stem up, on staff line
custos_mensural("Custos Mensural", "mensural.u1", 
		dir_up, on_staff_line);

% custos mensural, stem up, anywhere
custos_mensural("Custos Mensural", "mensural.u2", 
		dir_up, anywhere);

% custos mensural, stem down, between staff lines
custos_mensural("Reverse Custos Mensural", "mensural.d0", 
		dir_down, between_staff_lines);

% custos mensural, stem down, on staff line
custos_mensural("Reverse Custos Mensural", "mensural.d1", 
		dir_down, on_staff_line);

% custos mensural, stem down, anywhere
custos_mensural("Reverse Custos Mensural", "mensural.d2", 
		dir_down, anywhere);

fet_endgroup ("custodes")