summaryrefslogtreecommitdiff
path: root/muse2/share/scoreglyphs/feta-original/feta-autometric.mf
blob: 24a0e1b9ddc410dc5f47e5b4a1908f5bb177a087 (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
%
% autometric.mf -- administrative MF routines
%
% source file of the Feta (not an acronym for Font-En-Tja)
% pretty-but-neat music font
%
% (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
%          Jan Nieuwenhuizen <janneke@gnu.org>
%
% These macros help create ascii logging output
% to automate generation of the lily tables.
% The output should be parsed by the mf-to-table script.


message "******************************************************";
message "Using feta Autometric macros.";
message "order of messages: ";
message " NAME/CODE/BP/WD/DP/HT/WX/WY";
message "******************************************************";
message "";


% font or database?
def fet_beginfont (expr name, size, encod) =
	font_identifier := name & decimal size;
	font_size size;
	font_coding_scheme "asis";
	message "@{font@:GNU@:LilyPond@:" & name
		& "@:" & decimal size
		& "@:" & encod
		& "@}";
	message "";
enddef;


def fet_endfont =
	message "@{tnof@}";
enddef;


% group or table?
def fet_begingroup (expr name) =
begingroup;
	save feta_group;
	string feta_group;

	feta_group := name;

	message "@{group@:" & feta_group
		& "@}";
	message "";
enddef;


def fet_endgroup (expr name) =
	message "@{puorg@:" & name
		& "@}";
	message "";
endgroup;
enddef;


def autometric_parameter (expr name, value) =
	message "@{parameter@:" & name
		& "@:" & decimal value
		& "@}";
enddef;


def autometric_output_char =
	message "@{char@:" & charnamestr
		& "@:" & decimal charcode
		& "@:" & decimal charbp
		& "@:" & decimal charwd
		& "@:" & decimal chardp
		& "@:" & decimal charht
		& "@:" & decimal charwx
		& "@:" & decimal charwy
		& "@:" & idstr
		& "@}";
enddef;


def hround_pixels (expr sharped) =
	hround (sharped * hppp)
enddef;


def vround_pixels (expr sharped) =
	vround (sharped * vppp)
enddef;


def tand (expr alpha) =
	(sind alpha / cosd alpha)
enddef;


def to_bp (expr num) =
	decimal (num * bp_per_pixel)
enddef;


% breapth, width, depth, height
%     breapth	x-depth
def set_char_box (expr b_sharp, w_sharp, d_sharp, h_sharp) =
	save scharbp, scharht, scharwd, schardp;

	% some paranoia if someone calls set_char_box (charwd, charbp, ...)
	scharbp := b_sharp;
	scharht := h_sharp;
	schardp := d_sharp;
	scharwd := w_sharp;

	charbp := scharbp;
	charht := scharht;
	chardp := schardp;
	charwd := scharwd;

	w := hround (w_sharp * hppp);
	b := hround (b_sharp * hppp);
	h := vround (h_sharp * vppp);
	d := vround (d_sharp * vppp);

	charwx := charwd;
	charwy := 0;

	% additions for mf2pt1 (`bbox' is called `glyph_dimensions' starting
	% with version 2.4.2)
	if known bp_per_pixel:
		special "% MF2PT1: bbox "
			& to_bp (-b) & " "
			& to_bp (-d) & " "
			& to_bp (w) & " "
			& to_bp (h);
		special "% MF2PT1: glyph_dimensions "
			& to_bp (-b) & " "
			& to_bp (-d) & " "
			& to_bp (w) & " "
			& to_bp (h);
		special "% MF2PT1: font_size " & decimal designsize;
		special "% MF2PT1: font_slant " & decimal font_slant_;

		for fvar = "font_identifier",
			   "font_coding_scheme",
			   "font_version",
			   "font_comment",
			   "font_family",
			   "font_weight",
			   "font_unique_id",
			   "font_name":
			if known scantokens (fvar & "_"):
				special "% MF2PT1: "
					& fvar & " "
					& scantokens (fvar & "_");
			fi;
		endfor;

		for fvar = "font_underline_position",
			   "font_underline_thickness":
			if known scantokens (fvar & "_"):
				special "% MF2PT1: "
					& fvar & " "
					& scantokens ("decimal " & fvar & "_");
			fi;
		endfor;

		special "% MF2PT1: font_fixed_pitch "
			& (if font_fixed_pitch_: "1" else: "0" fi);

		% this must come after the `font_size' special
		special "% MF2PT1: charwd " & decimal charwd;
	fi;
enddef;


def no_dimen_beginchar (expr c) =
begingroup;
	charcode := if known c: byte c else: 0; fi;
	charic := 0;
	clearxy;
	clearit;
	clearpen;
	scantokens extra_beginchar;
enddef;


%
% we leave the ctrl characters alone.
%
code := 32;


% starts just as plain mf's beginchar:
%     charcode,
% and then adds:
%     charname	see below
%     id	index in lily's table

% The dimensions are uninitialised; you should use set_char_box manually.
def fet_beginchar (expr name, id_lit) =
	save idstr, charnamestr;
	save charbp;
	save w, b, h, d;
	save charwx, charwy;

	string idstr, charnamestr;
	charnamestr := name;
	idstr := id_lit;

	% addition for mf2pt1
	if known bp_per_pixel:
		if known feta_group:
			special "% MF2PT1: glyph_name "
				& feta_group & "." & idstr;
		else:
			special "% MF2PT1: glyph_name " & idstr;
		fi;
	fi;

	no_dimen_beginchar (incr code) name;
enddef;


def makebox_with_breapth (text r) =
	for y = -d, 0, h:
		r ((-b, y), (w, y));
	endfor;

	for x = -b, 0, w:
		r ( (x, -d), (x, h));
	endfor;
enddef;


%
% override plain endchar.  We want a different box.
%
def breapth_endchar =
	scantokens extra_endchar;

	if proofing > 0:
		makebox_with_breapth (proofrule);
	fi;

	chardx := (w + b);	% what the heck is chardx
	shipit;
endgroup;
enddef;


def fet_endchar =
	autometric_output_char;
	breapth_endchar;
enddef;