Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / mf / feta-autometric.mf
blobd5cbb7f2d5259a4115686280fe9a56185bd49c4a
1 % Feta (not the Font-En-Tja) music font -- administrative MF routines
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 %          Jan Nieuwenhuizen <janneke@gnu.org>
7 % These macros help create ascii logging output
8 % to automate generation of the lily tables.
9 % The output should be parsed by the mf-to-table script.
11 % LilyPond is free software: you can redistribute it and/or modify
12 % it under the terms of the GNU General Public License as published by
13 % the Free Software Foundation, either version 3 of the License, or
14 % (at your option) any later version.
16 % LilyPond is distributed in the hope that it will be useful,
17 % but WITHOUT ANY WARRANTY; without even the implied warranty of
18 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 % GNU General Public License for more details.
21 % You should have received a copy of the GNU General Public License
22 % along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
25 message "******************************************************";
26 message "Using feta Autometric macros.";
27 message "order of messages: ";
28 message " NAME/CODE/BP/WD/DP/HT/WX/WY";
29 message "******************************************************";
30 message "";
33 % font or database?
34 def fet_beginfont (expr name, size, encod) =
35         font_identifier := name & decimal size;
36         font_size size;
37         font_coding_scheme "asis";
38         message "@{font@:GNU@:LilyPond@:" & name
39                 & "@:" & decimal size
40                 & "@:" & encod
41                 & "@}";
42         message "";
43 enddef;
46 def fet_endfont =
47         message "@{tnof@}";
48 enddef;
51 % group or table?
52 def fet_begingroup (expr name) =
53 begingroup;
54         save feta_group;
55         string feta_group;
57         feta_group := name;
59         message "@{group@:" & feta_group
60                 & "@}";
61         message "";
62 enddef;
65 def fet_endgroup (expr name) =
66         message "@{puorg@:" & name
67                 & "@}";
68         message "";
69 endgroup;
70 enddef;
73 def autometric_parameter (expr name, value) =
74         message "@{parameter@:" & name
75                 & "@:" & decimal value
76                 & "@}";
77 enddef;
80 def autometric_output_char =
81         message "@{char@:" & charnamestr
82                 & "@:" & decimal charcode
83                 & "@:" & decimal charbp
84                 & "@:" & decimal charwd
85                 & "@:" & decimal chardp
86                 & "@:" & decimal charht
87                 & "@:" & decimal charwx
88                 & "@:" & decimal charwy
89                 & "@:" & idstr
90                 & "@}";
91 enddef;
94 def hround_pixels (expr sharped) =
95         hround (sharped * hppp)
96 enddef;
99 def vround_pixels (expr sharped) =
100         vround (sharped * vppp)
101 enddef;
104 def tand (expr alpha) =
105         (sind alpha / cosd alpha)
106 enddef;
109 def to_bp (expr num) =
110         decimal (num * bp_per_pixel)
111 enddef;
114 % breapth, width, depth, height
115 %     breapth   x-depth
116 def set_char_box (expr b_sharp, w_sharp, d_sharp, h_sharp) =
117         save scharbp, scharht, scharwd, schardp;
119         % some paranoia if someone calls set_char_box (charwd, charbp, ...)
120         scharbp := b_sharp;
121         scharht := h_sharp;
122         schardp := d_sharp;
123         scharwd := w_sharp;
125         charbp := scharbp;
126         charht := scharht;
127         chardp := schardp;
128         charwd := scharwd;
130         w := hround (w_sharp * hppp);
131         b := hround (b_sharp * hppp);
132         h := vround (h_sharp * vppp);
133         d := vround (d_sharp * vppp);
135         charwx := charwd;
136         charwy := 0;
138         % additions for mf2pt1 (`bbox' is called `glyph_dimensions' starting
139         % with version 2.4.2)
140         if known bp_per_pixel:
141                 special "% MF2PT1: bbox "
142                         & to_bp (-b) & " "
143                         & to_bp (-d) & " "
144                         & to_bp (w) & " "
145                         & to_bp (h);
146                 special "% MF2PT1: glyph_dimensions "
147                         & to_bp (-b) & " "
148                         & to_bp (-d) & " "
149                         & to_bp (w) & " "
150                         & to_bp (h);
151                 special "% MF2PT1: font_size " & decimal designsize;
152                 special "% MF2PT1: font_slant " & decimal font_slant_;
154                 for fvar = "font_identifier",
155                            "font_coding_scheme",
156                            "font_version",
157                            "font_comment",
158                            "font_family",
159                            "font_weight",
160                            "font_unique_id",
161                            "font_name":
162                         if known scantokens (fvar & "_"):
163                                 special "% MF2PT1: "
164                                         & fvar & " "
165                                         & scantokens (fvar & "_");
166                         fi;
167                 endfor;
169                 for fvar = "font_underline_position",
170                            "font_underline_thickness":
171                         if known scantokens (fvar & "_"):
172                                 special "% MF2PT1: "
173                                         & fvar & " "
174                                         & scantokens ("decimal " & fvar & "_");
175                         fi;
176                 endfor;
178                 special "% MF2PT1: font_fixed_pitch "
179                         & (if font_fixed_pitch_: "1" else: "0" fi);
181                 % this must come after the `font_size' special
182                 special "% MF2PT1: charwd " & decimal charwd;
183         fi;
184 enddef;
187 def no_dimen_beginchar (expr c) =
188 begingroup;
189         charcode := if known c: byte c else: 0; fi;
190         charic := 0;
191         clearxy;
192         clearit;
193         clearpen;
194         scantokens extra_beginchar;
195 enddef;
199 % we leave the ctrl characters alone
201 code := 32;
204 % starts just as plain mf's beginchar:
205 %     charcode,
206 % and then adds:
207 %     charname  see below
208 %     id        index in lily's table
210 % The dimensions are uninitialised; you should use set_char_box manually.
211 def fet_beginchar (expr name, id_lit) =
212         save idstr, charnamestr;
213         save charbp;
214         save w, b, h, d;
215         save charwx, charwy;
217         string idstr, charnamestr;
218         charnamestr := name;
219         idstr := id_lit;
221         % addition for mf2pt1
222         if known bp_per_pixel:
223                 if known feta_group:
224                         special "% MF2PT1: glyph_name "
225                                 & feta_group & "." & idstr;
226                 else:
227                         special "% MF2PT1: glyph_name " & idstr;
228                 fi;
229         fi;
231         no_dimen_beginchar (incr code) name;
232 enddef;
235 def makebox_with_breapth (text r) =
236         for y = -d, 0, h:
237                 r ((-b, y), (w, y));
238         endfor;
240         for x = -b, 0, w:
241                 r ( (x, -d), (x, h));
242         endfor;
243 enddef;
247 % override plain endchar.  We want a different box.
249 def breapth_endchar =
250         scantokens extra_endchar;
252         if proofing > 0:
253                 makebox_with_breapth (proofrule);
254         fi;
256         chardx := (w + b);      % what the heck is chardx
257         shipit;
258 endgroup;
259 enddef;
262 def fet_endchar =
263         autometric_output_char;
264         breapth_endchar;
265 enddef;