]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-autometric.mf
Remove tex and texstr backends (part 1).
[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--2008 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 the lily tables.
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 (`bbox' is called `glyph_dimensions' starting
129         % with version 2.4.2)
130         if known bp_per_pixel:
131                 special "% MF2PT1: bbox "
132                         & to_bp (-b) & " "
133                         & to_bp (-d) & " "
134                         & to_bp (w) & " "
135                         & to_bp (h);
136                 special "% MF2PT1: glyph_dimensions "
137                         & to_bp (-b) & " "
138                         & to_bp (-d) & " "
139                         & to_bp (w) & " "
140                         & to_bp (h);
141                 special "% MF2PT1: font_size " & decimal designsize;
142                 special "% MF2PT1: font_slant " & decimal font_slant_;
143
144                 for fvar = "font_identifier",
145                            "font_coding_scheme",
146                            "font_version",
147                            "font_comment",
148                            "font_family",
149                            "font_weight",
150                            "font_unique_id",
151                            "font_name":
152                         if known scantokens (fvar & "_"):
153                                 special "% MF2PT1: "
154                                         & fvar & " "
155                                         & scantokens (fvar & "_");
156                         fi;
157                 endfor;
158
159                 for fvar = "font_underline_position",
160                            "font_underline_thickness":
161                         if known scantokens (fvar & "_"):
162                                 special "% MF2PT1: "
163                                         & fvar & " "
164                                         & scantokens ("decimal " & fvar & "_");
165                         fi;
166                 endfor;
167
168                 special "% MF2PT1: font_fixed_pitch "
169                         & (if font_fixed_pitch_: "1" else: "0" fi);
170
171                 % this must come after the `font_size' special
172                 special "% MF2PT1: charwd " & decimal charwd;
173         fi;
174 enddef;
175
176
177 def no_dimen_beginchar (expr c) =
178 begingroup;
179         charcode := if known c: byte c else: 0; fi;
180         charic := 0;
181         clearxy;
182         clearit;
183         clearpen;
184         scantokens extra_beginchar;
185 enddef;
186
187
188 %
189 % we leave the ctrl characters alone.
190 %
191 code := 32;
192
193
194 % starts just as plain mf's beginchar:
195 %     charcode,
196 % and then adds:
197 %     charname  see below
198 %     id        index in lily's table
199
200 % The dimensions are uninitialised; you should use set_char_box manually.
201 def fet_beginchar (expr name, id_lit) =
202         save idstr, charnamestr;
203         save charbp;
204         save w, b, h, d;
205         save charwx, charwy;
206
207         string idstr, charnamestr;
208         charnamestr := name;
209         idstr := id_lit;
210
211         % addition for mf2pt1
212         if known bp_per_pixel:
213                 if known feta_group:
214                         special "% MF2PT1: glyph_name "
215                                 & feta_group & "." & idstr;
216                 else:
217                         special "% MF2PT1: glyph_name " & idstr;
218                 fi;
219         fi;
220
221         no_dimen_beginchar (incr code) name;
222 enddef;
223
224
225 def makebox_with_breapth (text r) =
226         for y = -d, 0, h:
227                 r ((-b, y), (w, y));
228         endfor;
229
230         for x = -b, 0, w:
231                 r ( (x, -d), (x, h));
232         endfor;
233 enddef;
234
235
236 %
237 % override plain endchar.  We want a different box.
238 %
239 def breapth_endchar =
240         scantokens extra_endchar;
241
242         if proofing > 0:
243                 makebox_with_breapth (proofrule);
244         fi;
245
246         chardx := (w + b);      % what the heck is chardx
247         shipit;
248 endgroup;
249 enddef;
250
251
252 def fet_endchar =
253         autometric_output_char;
254         breapth_endchar;
255 enddef;