]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-autometric.mf
* mf/feta-autometric.mf (fet_beginchar): Check whether `feta_group'
[lilypond.git] / mf / feta-autometric.mf
1 %
2 % autometric.mf -- administrative MF routines
3 %
4 % source file of the Feta (not an acronym for Font-En-Tja)
5 % pretty-but-neat music font
6 %
7 % (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 %          Jan Nieuwenhuizen <janneke@gnu.org>
9 %
10 % these macros help create ascii logging output
11 % to automate generation of lily tables and tex backend
12 % The output should be parsed by the mf-to-table script
13
14
15 message "******************************************************";
16 message "Using feta Autometric macros.";
17 message "Do not worry about the @ signs in the output, they are not errors.";
18 message "******************************************************";
19 message "";
20
21
22 % font or database?
23 def fet_beginfont (expr name, size, encod) =
24         font_identifier := name & decimal size;
25         font_size size;
26         font_coding_scheme "asis";
27         message "@{font@:GNU@:LilyPond@:" & name
28                 & "@:" & decimal size
29                 & "@:" & encod
30                 & "@}";
31         message "";
32 enddef;
33
34
35 def fet_endfont =
36         message "@{tnof@}";
37 enddef;
38
39
40 % group or table?
41 def fet_begingroup (expr name) =
42 begingroup;
43         save feta_group;
44         string feta_group;
45
46         feta_group := name;
47
48         message "@{group@:" & feta_group
49                 & "@}";
50         message "";
51 enddef;
52
53
54 def fet_endgroup (expr name) =
55         message "@{puorg@:" & name
56                 & "@}";
57         message "";
58 endgroup;
59 enddef;
60
61
62 def autometric_parameter (expr name, value) =
63         message "@{parameter@:" & name
64                 & "@:" & decimal value
65                 & "@}";
66 enddef;
67
68
69 def autometric_output_char=
70         message "@{char@:" & charnamestr
71                 & "@:" & decimal charcode
72                 & "@:" & decimal charbp
73                 & "@:" & decimal charwd
74                 & "@:" & decimal chardp
75                 & "@:" & decimal charht
76                 & "@:" & decimal charwx
77                 & "@:" & decimal charwy
78                 & "@:" & idstr
79                 & "@}";
80 enddef;
81
82
83 def hround_pixels (expr sharped) =
84         hround (sharped * hppp)
85 enddef;
86
87
88 def vround_pixels (expr sharped) =
89         vround (sharped * vppp)
90 enddef;
91
92
93 def tand (expr alpha) =
94         (sind alpha / cosd alpha)
95 enddef;
96
97
98 def to_bp (expr num) =
99         decimal (num * bp_per_pixel)
100 enddef;
101
102
103 % breapth, width, depth, height
104 %     breapth   x-depth
105 def set_char_box (expr b_sharp, w_sharp, d_sharp, h_sharp) =
106         save scharbp, scharht, scharwd, schardp;
107
108         % some paranoia if someone calls set_char_box (charwd, charbp, ...)
109         scharbp := b_sharp;
110         scharht := h_sharp;
111         schardp := d_sharp;
112         scharwd := w_sharp;
113
114         charbp := scharbp;
115         charht := scharht;
116         chardp := schardp;
117         charwd := scharwd;
118
119         w := hround (w_sharp * hppp);
120         b := hround (b_sharp * hppp);
121         h := vround (h_sharp * vppp);
122         d := vround (d_sharp * vppp);
123
124         charwx := charwd;
125         charwy := 0;
126
127         % additions for mf2pt1
128         if known bp_per_pixel:
129                 special "% MF2PT1: bbox "
130                         & to_bp (-b) & " "
131                         & to_bp (-d) & " "
132                         & to_bp (w) & " "
133                         & to_bp (h);
134                 special "% MF2PT1: font_size " & decimal designsize;
135                 special "% MF2PT1: font_slant " & decimal font_slant_;
136
137                 for fvar = "font_identifier",
138                            "font_coding_scheme",
139                            "font_version",
140                            "font_comment",
141                            "font_family",
142                            "font_weight",
143                            "font_unique_id",
144                            "font_name":
145                         if known scantokens (fvar & "_"):
146                                 special "% MF2PT1: "
147                                         & fvar & " "
148                                         & scantokens (fvar & "_");
149                         fi;
150                 endfor;
151
152                 for fvar = "font_underline_position",
153                            "font_underline_thickness":
154                         if known scantokens (fvar & "_"):
155                                 special "% MF2PT1: "
156                                         & fvar & " "
157                                         & scantokens ("decimal " & fvar & "_");
158                         fi;
159                 endfor;
160
161                 special "% MF2PT1: font_fixed_pitch "
162                         & (if font_fixed_pitch_: "1" else: "0" fi);
163
164                 % this must come after the `font_size' special
165                 special "% MF2PT1: charwd " & decimal charwd;
166         fi;
167 enddef;
168
169
170 def no_dimen_beginchar (expr c) =
171 begingroup;
172         charcode := if known c: byte c else: 0; fi;
173         charic := 0;
174         clearxy;
175         clearit;
176         clearpen;
177         scantokens extra_beginchar;
178 enddef;
179
180
181 %
182 % we leave the ctrl characters alone.
183 %
184 code := 32;
185
186
187 % starts just as plain mf's beginchar:
188 %     charcode,
189 % and then adds:
190 %     charname  see below
191 %     id        index in lily's table
192
193 % The dimensions are uninitialised; you should use set_char_box manually.
194 def fet_beginchar (expr name, id_lit) =
195         save idstr, charnamestr;
196         save charbp;
197         save w, b, h, d;
198         save charwx, charwy;
199
200         string idstr, charnamestr;
201         charnamestr := name;
202         idstr := id_lit;
203
204         % addition for mf2pt1
205         if known bp_per_pixel:
206                 if known feta_group:
207                         special "% MF2PT1: glyph_name "
208                                 & feta_group & "." & idstr;
209                 else:
210                         special "% MF2PT1: glyph_name " & idstr;
211                 fi;
212         fi;
213
214         no_dimen_beginchar (incr code) name;
215 enddef;
216
217
218 def makebox_with_breapth (text r) =
219         for y = -d, 0, h:
220                 r ((-b, y), (w, y));
221         endfor;
222
223         for x = -b, 0, w:
224                 r ( (x, -d), (x, h));
225         endfor;
226 enddef;
227
228
229 %
230 % override plain endchar.  We want a different box.
231 %
232 def breapth_endchar =
233         scantokens extra_endchar;
234
235         if proofing > 0:
236                 makebox_with_breapth (proofrule);
237         fi;
238
239         chardx := (w + b);      % what the heck is chardx
240         shipit;
241 endgroup;
242 enddef;
243
244
245 def fet_endchar=
246         autometric_output_char;
247         breapth_endchar;
248 enddef;