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