Debian Codegraph @

texk/web2c/alephdir/omfont.ch

raw
1 % omfont.ch: Reading and storing font metric information
2 %
3 % This file is part of the Omega project, which
4 % is based on the web2c distribution of TeX.
5 %
6 % Copyright (c) 1994--2021 John Plaice and Yannis Haralambous
7 %
8 % This library is free software; you can redistribute it and/or
9 % modify it under the terms of the GNU Library General Public
10 % License as published by the Free Software Foundation; either
11 % version 2 of the License, or (at your option) any later version.
12 %
13 % This library is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 % Library General Public License for more details.
17 %
18 % You should have received a copy of the GNU Library General Public
19 % License along with this library; if not, write to the Free Software
20 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 %
22 %%---------------------------------------
23 @x [15] m.208 l.
24 @d min_internal=end_cs_name+1 {the smallest code that can follow \.{\\the}}
25 @y
26 @d char_ghost=end_cs_name+1
27 {\.{\\ghostleft}, \.{\\ghostright} character for kerning}
28 @d min_internal=char_ghost+1 {the smallest code that can follow \.{\\the}}
29 @z
30 %---------------------------------------
31 @x [17] m.222 l.4530 - Omega
32 {begins table of 257 permanent font identifiers}
33 @d undefined_control_sequence=frozen_null_font+257 {dummy location}
34 @y
35 {begins table of |number_fonts| permanent font identifiers}
36 @d undefined_control_sequence=frozen_null_font+number_fonts
37 {dummy location}
38 @z
39 %---------------------------------------
40 @x [18] m.265 l.5648 - Omega
41 primitive("insert",insert,0);@/
42 @!@:insert_}{\.{\\insert} primitive@>
43 @y
44 primitive("insert",insert,0);@/
45 @!@:insert_}{\.{\\insert} primitive@>
46 primitive("leftghost",char_ghost,0);@/
47 @!@:leftghost_}{\.{\\leftghost} primitive@>
48 @z
49 %---------------------------------------
50 @x [18] m.265 l.5648 - Omega
51 primitive("setbox",set_box,0);@/
52 @!@:set_box_}{\.{\\setbox} primitive@>
53 @y
54 primitive("rightghost",char_ghost,1);@/
55 @!@:rightghost_}{\.{\\rightghost} primitive@>
56 primitive("setbox",set_box,0);@/
57 @!@:set_box_}{\.{\\setbox} primitive@>
58 @z
59 %---------------------------------------
60 @x [18] m.266 l.5648 - Omega
61 char_num: print_esc("char");
62 @y
63 char_num: print_esc("char");
64 char_ghost: if cur_chr=0 then print_esc("leftghost")
65 else print_esc("rightghost");
66 @z
67 %---------------------------------------
68 @x [26] m.425 l.8524 - font parameters
69 begin find_font_dimen(false); font_info[fmem_ptr].sc:=0;
70 scanned_result(font_info[cur_val].sc)(dimen_val);
71 @y
72 begin find_font_dimen(false);
73 font_info(dimen_font)(font_file_size(dimen_font)).sc:=0;
74 scanned_result(font_info(dimen_font)(cur_val).sc)(dimen_val);
75 @z
76 %---------------------------------------
77 @x [26] m.426 l.8530 - font parameters
78 if m=0 then scanned_result(hyphen_char[cur_val])(int_val)
79 else scanned_result(skew_char[cur_val])(int_val);
80 @y
81 if m=0 then scanned_result(hyphen_char(cur_val))(int_val)
82 else scanned_result(skew_char(cur_val))(int_val);
83 @z
84 %---------------------------------------
85 @x [27] m.472 l.9258 - font parameters
86 font_name_code: begin print(font_name[cur_val]);
87 if font_size[cur_val]<>font_dsize[cur_val] then
88 begin print(" at "); print_scaled(font_size[cur_val]);
89 @y
90 font_name_code: begin print(font_name(cur_val));
91 if font_size(cur_val)<>font_dsize(cur_val) then
92 begin print(" at "); print_scaled(font_size(cur_val));
93 @z
94 %---------------------------------------
95 @x [30] m.539 l.10392 - Omega
96 @^Ramshaw, Lyle Harold@>
97 of information in a compact but useful form.
98
99 @y
100 @^Ramshaw, Lyle Harold@>
101 of information in a compact but useful form.
102
103 $\Omega$ is capable of reading not only \.{TFM} files, but also
104 \.{OFM} files, which can describe fonts with up to 65536 characters
105 and with huge lig/kern tables. These fonts will often be virtual
106 fonts built up from real fonts with 256 characters, but $\Omega$
107 is not aware of this.
108
109 The documentation below describes \.{TFM} files, with slight additions
110 to show where \.{OFM} files differ.
111
112 @z
113 %---------------------------------------
114 @x [30] m.540 l.10417 - Omega
115 Note that a font may contain as many as 256 characters (if |bc=0| and |ec=255|),
116 and as few as 0 characters (if |bc=ec+1|).
117
118 Incidentally, when two or more 8-bit bytes are combined to form an integer of
119 16 or more bits, the most significant bytes appear first in the file.
120 This is called BigEndian order.
121 @!@^BigEndian order@>
122
123 @y
124 Note that a \.{TFM} font may contain as many as 256 characters
125 (if |bc=0| and |ec=255|), and as few as 0 characters (if |bc=ec+1|).
126
127 Incidentally, when two or more 8-bit bytes are combined to form an integer of
128 16 or more bits, the most significant bytes appear first in the file.
129 This is called BigEndian order.
130 @!@^BigEndian order@>
131
132 The first 52 bytes (13 words) of an \.{OFM} file contains thirteen
133 32-bit integers that give the lengths of the various subsequent
134 portions of the file. The first word is 0 (future versions of
135 \.{OFM} files could have different values; what is important is that
136 the first two bytes be 0 to differentiate \.{TFM} and \.{OFM} files).
137 The next twelve integers are as above, all nonegative and less
138 than~$2^{31}$. We must have |bc-1<=ec<=65535|, and
139 $$\hbox{|lf=13+lh+2*(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np|.}$$
140 Note that an \.{OFM} font may contain as many as 65536 characters
141 (if |bc=0| and |ec=65535|), and as few as 0 characters (if |bc=ec+1|).
142
143 @z
144 %---------------------------------------
145 @x [30] m.543 l.10492 - Omega
146 per character. Each word in this part of the file contains six fields
147 @y
148 per character. Each word in this part of a \.{TFM} file contains six fields
149 @z
150 %---------------------------------------
151 @x [30] m.543 l.10506 - Omega
152 imposes a limit of 16 different heights, 16 different depths, and
153 64 different italic corrections.
154
155 @y
156 imposes a limit of 16 different heights, 16 different depths, and
157 64 different italic corrections.
158
159 For \.{OFM} files, two words (eight bytes) are used.
160 The arrangement is as follows.
161
162 \yskip\hang first and second bytes: |@!width_index| (16 bits)\par
163 \hang third byte: |@!height_index| (8 bits)\par
164 \hang fourth byte: |@!depth_index| (8~bits)\par
165 \hang fifth and sixth bytes:
166 |@!italic_index| (14 bits) times 4, plus |@!tag| (2~bits)\par
167 \hang seventh and eighth bytes: |@!remainder| (16 bits)\par
168 \yskip\noindent
169 Therefore the \.{OFM} format imposes a limit of 256 different heights,
170 256 different depths, and 16384 different italic corrections.
171
172 @z
173 %---------------------------------------
174 @x [30] m.545 l.10547 - Omega
175 that explains what to do for special letter pairs. Each word in this array is a
176 |@!lig_kern_command| of four bytes.
177 @y
178 that explains what to do for special letter pairs. Each word in this array,
179 in a \.{TFM} file, is a |@!lig_kern_command| of four bytes.
180 @z
181 %---------------------------------------
182 @x [30] m.545 l.10557 - Omega
183 \hang fourth byte: |remainder|.\par
184 \yskip\noindent
185 @y
186 \hang fourth byte: |remainder|.\par
187 \yskip\noindent
188 In an \.{OFM} file, eight bytes are used, two bytes for each field.
189
190 @z
191 %---------------------------------------
192 @x [30] m.545 l.10587 - Omega
193 appear in a location |<=255|.
194 @y
195 appear in a location |<=255| in a \.{TFM} file, |<=65535| in an \.{OFM} file.
196 @z
197 %---------------------------------------
198 @x [30] m.545 l.10599 - Omega
199 @d skip_byte(#)==#.b0
200 @d next_char(#)==#.b1
201 @d op_byte(#)==#.b2
202 @d rem_byte(#)==#.b3
203 @y
204 @d top_skip_byte(#)==(#.b0 div 256)
205 @d skip_byte(#)==(#.b0 mod 256)
206 @d next_char_end(#)==#.b1
207 @d next_char(#)==font_offset(#)+next_char_end
208 @d op_byte(#)==#.b2
209 @d rem_byte(#)==#.b3
210 @d rem_char_byte_end(#)==#.b3
211 @d rem_char_byte(#)==font_offset(#)+rem_char_byte_end
212 @d rem_top_byte(#)==(#.b3 div 256)
213 @d rem_bot_byte(#)==(#.b3 mod 256)
214 @z
215 %---------------------------------------
216 @x [30] m.546 l.10604 - Omega
217 consists of four bytes called |@!top|, |@!mid|, |@!bot|, and |@!rep| (in this
218 order). These bytes are the character codes of individual pieces used to
219 @y
220 consists of four bytes in a \.{TFM} file,
221 called |@!top|, |@!mid|, |@!bot|, and |@!rep| (in this order).
222 In an \.{OFM} file, each field takes two bytes, for eight in total.
223 These bytes are the character codes of individual pieces used to
224 @z
225 %---------------------------------------
226 @x [30] m.546 l.10618 - Omega
227 @d ext_top(#)==#.b0 {|top| piece in a recipe}
228 @d ext_mid(#)==#.b1 {|mid| piece in a recipe}
229 @d ext_bot(#)==#.b2 {|bot| piece in a recipe}
230 @d ext_rep(#)==#.b3 {|rep| piece in a recipe}
231 @y
232 @d ext_top_end(#)==#.b0 {|top| piece in a recipe}
233 @d ext_top(#)==font_offset(#)+ext_top_end
234 @d ext_mid_end(#)==#.b1 {|mid| piece in a recipe}
235 @d ext_mid(#)==font_offset(#)+ext_mid_end
236 @d ext_bot_end(#)==#.b2 {|bot| piece in a recipe}
237 @d ext_bot(#)==font_offset(#)+ext_bot_end
238 @d ext_rep_end(#)==#.b3 {|rep| piece in a recipe}
239 @d ext_rep(#)==font_offset(#)+ext_rep_end
240 @z
241 %---------------------------------------
242 @x [30] m.548 l.10674 - Omega
243 @!font_index=0..font_mem_size; {index into |font_info|}
244 @y
245 @!font_index=integer; {index into |font_info|}
246 @z
247 %---------------------------------------
248 @x [30] m.549 l.10678 - Omega
249 @d non_char==qi(256) {a |halfword| code that can't match a real character}
250 @y
251 @d non_char==qi(too_big_char) {a code that can't match a real character}
252 @z
253 %---------------------------------------
254 @x [30] m.549 l.10686 - Omega
255 @!font_info:array[font_index] of memory_word;
256 {the big collection of font data}
257 @!fmem_ptr:font_index; {first unused word of |font_info|}
258 @!font_ptr:internal_font_number; {largest internal font number in use}
259 @!font_check:array[internal_font_number] of four_quarters; {check sum}
260 @!font_size:array[internal_font_number] of scaled; {``at'' size}
261 @!font_dsize:array[internal_font_number] of scaled; {``design'' size}
262 @!font_params:array[internal_font_number] of font_index; {how many font
263 parameters are present}
264 @!font_name:array[internal_font_number] of str_number; {name of the font}
265 @!font_area:array[internal_font_number] of str_number; {area of the font}
266 @!font_bc:array[internal_font_number] of eight_bits;
267 {beginning (smallest) character code}
268 @!font_ec:array[internal_font_number] of eight_bits;
269 {ending (largest) character code}
270 @!font_glue:array[internal_font_number] of pointer;
271 {glue specification for interword space, |null| if not allocated}
272 @!font_used:array[internal_font_number] of boolean;
273 {has a character from this font actually appeared in the output?}
274 @!hyphen_char:array[internal_font_number] of integer;
275 {current \.{\\hyphenchar} values}
276 @!skew_char:array[internal_font_number] of integer;
277 {current \.{\\skewchar} values}
278 @!bchar_label:array[internal_font_number] of font_index;
279 {start of |lig_kern| program for left boundary character,
280 |non_address| if there is none}
281 @!font_bchar:array[internal_font_number] of min_quarterword..non_char;
282 {boundary character, |non_char| if there is none}
283 @!font_false_bchar:array[internal_font_number] of min_quarterword..non_char;
284 {|font_bchar| if it doesn't exist in the font, otherwise |non_char|}
285 @y
286 @!font_ptr:internal_font_number; {largest internal font number in use}
287 @z
288 %---------------------------------------
289 @x [30] m.550 l.10723 - Omega
290 |font_info[char_base[f]+c].qqqq|; and if |w| is the |width_index|
291 part of this word (the |b0| field), the width of the character is
292 |font_info[width_base[f]+w].sc|. (These formulas assume that
293 |min_quarterword| has already been added to |c| and to |w|, since \TeX\
294 stores its quarterwords that way.)
295
296 @<Glob...@>=
297 @!char_base:array[internal_font_number] of integer;
298 {base addresses for |char_info|}
299 @!width_base:array[internal_font_number] of integer;
300 {base addresses for widths}
301 @!height_base:array[internal_font_number] of integer;
302 {base addresses for heights}
303 @!depth_base:array[internal_font_number] of integer;
304 {base addresses for depths}
305 @!italic_base:array[internal_font_number] of integer;
306 {base addresses for italic corrections}
307 @!lig_kern_base:array[internal_font_number] of integer;
308 {base addresses for ligature/kerning programs}
309 @!kern_base:array[internal_font_number] of integer;
310 {base addresses for kerns}
311 @!exten_base:array[internal_font_number] of integer;
312 {base addresses for extensible recipes}
313 @!param_base:array[internal_font_number] of integer;
314 {base addresses for font parameters}
315 @y
316 |font_info(f)(char_base(f)+c).qqqq|; and if |w| is the |width_index|
317 part of this word (the |b0| field), the width of the character is
318 |font_info(f)(width_base(f)+w).sc|. (These formulas assume that
319 |min_quarterword| has already been added to |c| and to |w|, since \TeX\
320 stores its quarterwords that way.)
321
322 @d font_info_end(#)==#]
323 @d font_info(#)==font_tables[#,font_info_end
324 @d offset_file_size=0
325 @d offset_check=1
326 @d offset_offset=offset_check+4
327 @d offset_size=offset_offset+1
328 @d offset_dsize=offset_size+1
329 @d offset_params=offset_dsize+1
330 @d offset_name_sort=offset_params+1
331 @d offset_name=offset_name_sort+1
332 @d offset_area=offset_name+1
333 @d offset_bc=offset_area+1
334 @d offset_ec=offset_bc+1
335 @d offset_glue=offset_ec+1
336 @d offset_used=offset_glue+1
337 @d offset_hyphen=offset_used+1
338 @d offset_skew=offset_hyphen+1
339 @d offset_bchar_label=offset_skew+1
340 @d offset_bchar=offset_bchar_label+1
341 @d offset_false_bchar=offset_bchar+1
342 @d offset_ivalues_start=offset_false_bchar+1
343 @d offset_fvalues_start=offset_ivalues_start+1
344 @d offset_mvalues_start=offset_fvalues_start+1
345 @d offset_rules_start=offset_mvalues_start+1
346 @d offset_glues_start=offset_rules_start+1
347 @d offset_penalties_start=offset_glues_start+1
348 @d offset_ivalues_base=offset_penalties_start+1
349 @d offset_fvalues_base=offset_ivalues_base+1
350 @d offset_mvalues_base=offset_fvalues_base+1
351 @d offset_rules_base=offset_mvalues_base+1
352 @d offset_glues_base=offset_rules_base+1
353 @d offset_penalties_base=offset_glues_base+1
354 @d offset_char_base=offset_penalties_base+1
355 @d offset_char_attr_base=offset_char_base+1
356 @d offset_width_base=offset_char_attr_base+1
357 @d offset_height_base=offset_width_base+1
358 @d offset_depth_base=offset_height_base+1
359 @d offset_italic_base=offset_depth_base+1
360 @d offset_lig_kern_base=offset_italic_base+1
361 @d offset_kern_base=offset_lig_kern_base+1
362 @d offset_exten_base=offset_kern_base+1
363 @d offset_param_base=offset_exten_base+1
364 @d offset_charinfo_base=offset_param_base+1
365 @d font_file_size(#)==font_info(#)(offset_file_size).int
366 @d font_check_0(#)==font_info(#)(offset_check).int
367 @d font_check_1(#)==font_info(#)(offset_check+1).int
368 @d font_check_2(#)==font_info(#)(offset_check+2).int
369 @d font_check_3(#)==font_info(#)(offset_check+3).int
370 @d font_offset(#)==font_info(#)(offset_offset).int
371 @d font_size(#)==font_info(#)(offset_size).int
372 @d font_dsize(#)==font_info(#)(offset_dsize).int
373 @d font_params(#)==font_info(#)(offset_params).int
374 @d font_name_sort(#)==font_info(#)(offset_name_sort).int
375 @d font_name(#)==font_info(#)(offset_name).int
376 @d font_area(#)==font_info(#)(offset_area).int
377 @d font_bc(#)==font_info(#)(offset_bc).int
378 @d font_ec(#)==font_info(#)(offset_ec).int
379 @d font_glue(#)==font_info(#)(offset_glue).int
380 @d font_used(#)==font_info(#)(offset_used).int
381 @d hyphen_char(#)==font_info(#)(offset_hyphen).int
382 @d skew_char(#)==font_info(#)(offset_skew).int
383 @d bchar_label(#)==font_info(#)(offset_bchar_label).int
384 @d font_bchar(#)==font_info(#)(offset_bchar).int
385 @d font_false_bchar(#)==font_info(#)(offset_false_bchar).int
386 @d ivalues_start(#)==font_info(#)(offset_ivalues_start).int
387 @d fvalues_start(#)==font_info(#)(offset_fvalues_start).int
388 @d mvalues_start(#)==font_info(#)(offset_mvalues_start).int
389 @d rules_start(#)==font_info(#)(offset_rules_start).int
390 @d glues_start(#)==font_info(#)(offset_glues_start).int
391 @d penalties_start(#)==font_info(#)(offset_penalties_start).int
392 @d ivalues_base(#)==font_info(#)(offset_ivalues_base).int
393 @d fvalues_base(#)==font_info(#)(offset_fvalues_base).int
394 @d mvalues_base(#)==font_info(#)(offset_mvalues_base).int
395 @d rules_base(#)==font_info(#)(offset_rules_base).int
396 @d glues_base(#)==font_info(#)(offset_glues_base).int
397 @d penalties_base(#)==font_info(#)(offset_penalties_base).int
398 @d char_attr_base(#)==font_info(#)(offset_char_attr_base).int
399 @d char_base(#)==font_info(#)(offset_char_base).int
400 @d width_base(#)==font_info(#)(offset_width_base).int
401 @d height_base(#)==font_info(#)(offset_height_base).int
402 @d depth_base(#)==font_info(#)(offset_depth_base).int
403 @d italic_base(#)==font_info(#)(offset_italic_base).int
404 @d lig_kern_base(#)==font_info(#)(offset_lig_kern_base).int
405 @d kern_base(#)==font_info(#)(offset_kern_base).int
406 @d exten_base(#)==font_info(#)(offset_exten_base).int
407 @d param_base(#)==font_info(#)(offset_param_base).int
408
409 @<Glob...@>=
410 @!dimen_font:integer;
411 @z
412 %---------------------------------------
413 @x [30] m.551 l.10743 - Omega
414 for k:=font_base to font_max do font_used[k]:=false;
415 @y
416 @z
417 %---------------------------------------
418 @x [30] m.552 l.10749 - Omega
419 font_ptr:=null_font; fmem_ptr:=7;
420 font_name[null_font]:="nullfont"; font_area[null_font]:="";
421 hyphen_char[null_font]:="-"; skew_char[null_font]:=-1;
422 bchar_label[null_font]:=non_address;
423 font_bchar[null_font]:=non_char; font_false_bchar[null_font]:=non_char;
424 font_bc[null_font]:=1; font_ec[null_font]:=0;
425 font_size[null_font]:=0; font_dsize[null_font]:=0;
426 char_base[null_font]:=0; width_base[null_font]:=0;
427 height_base[null_font]:=0; depth_base[null_font]:=0;
428 italic_base[null_font]:=0; lig_kern_base[null_font]:=0;
429 kern_base[null_font]:=0; exten_base[null_font]:=0;
430 font_glue[null_font]:=null; font_params[null_font]:=7;
431 param_base[null_font]:=-1;
432 for k:=0 to 6 do font_info[k].sc:=0;
433 @y
434 font_ptr:=null_font;
435 allocate_font_table(null_font,offset_charinfo_base+108);
436 font_file_size(null_font):=offset_charinfo_base+108;
437 font_used(null_font):=false;
438 font_name(null_font):="nullfont"; font_area(null_font):="";
439 hyphen_char(null_font):="-"; skew_char(null_font):=-1;
440 bchar_label(null_font):=non_address;
441 font_bchar(null_font):=non_char; font_false_bchar(null_font):=non_char;
442 font_bc(null_font):=1; font_ec(null_font):=0;
443 font_size(null_font):=0; font_dsize(null_font):=0;
444 char_base(null_font):=offset_charinfo_base;
445 char_attr_base(null_font):=offset_charinfo_base;
446 ivalues_start(null_font):=offset_charinfo_base;
447 fvalues_start(null_font):=offset_charinfo_base;
448 mvalues_start(null_font):=offset_charinfo_base;
449 rules_start(null_font):=offset_charinfo_base;
450 glues_start(null_font):=offset_charinfo_base;
451 penalties_start(null_font):=offset_charinfo_base;
452 ivalues_base(null_font):=offset_charinfo_base;
453 fvalues_base(null_font):=offset_charinfo_base;
454 mvalues_base(null_font):=offset_charinfo_base;
455 rules_base(null_font):=offset_charinfo_base;
456 glues_base(null_font):=offset_charinfo_base;
457 penalties_base(null_font):=offset_charinfo_base;
458 width_base(null_font):=offset_charinfo_base;
459 height_base(null_font):=offset_charinfo_base;
460 depth_base(null_font):=offset_charinfo_base;
461 italic_base(null_font):=offset_charinfo_base;
462 lig_kern_base(null_font):=offset_charinfo_base;
463 kern_base(null_font):=offset_charinfo_base;
464 exten_base(null_font):=offset_charinfo_base;
465 font_glue(null_font):=null;
466 font_params(null_font):=7;
467 param_base(null_font):=offset_charinfo_base-1;
468 font_offset(null_font):=0;
469 for k:=1 to 7 do font_info(null_font)(param_base(null_font)+k).sc:=0;
470 @z
471 %---------------------------------------
472 @x [30] m.553 l.10767 - Omega
473 text(frozen_null_font):="nullfont"; eqtb[frozen_null_font]:=eqtb[cur_val];
474 @y
475 settext(frozen_null_font,"nullfont");
476 set_new_eqtb(frozen_null_font,new_eqtb(cur_val));
477 @z
478 %---------------------------------------
479 @x [30] m.554 l.10771 - Omega
480 $$\hbox{|font_info[width_base[f]+font_info[char_base[f]+c].qqqq.b0].sc|}$$
481 @y
482 $$\hbox{|font_info(f)(width_base(f)+font_info(f)(char_base(f)+c).qqqq.b0).sc|}$$
483 @z
484 %---------------------------------------
485 @x [30] m.554 l.10785 - Omega
486 |height_depth(q)| will be the 8-bit quantity
487 $$b=|height_index|\times16+|depth_index|,$$ and if |b| is such a byte we
488 @y
489 |height_depth(q)| will be the 16-bit quantity
490 $$b=|height_index|\times256+|depth_index|,$$ and if |b| is such a byte we
491 @z
492 %---------------------------------------
493 @x [30] m.554 l.10798 - Omega
494 @d char_info_end(#)==#].qqqq
495 @d char_info(#)==font_info[char_base[#]+char_info_end
496 @d char_width_end(#)==#.b0].sc
497 @d char_width(#)==font_info[width_base[#]+char_width_end
498 @d char_exists(#)==(#.b0>min_quarterword)
499 @d char_italic_end(#)==(qo(#.b2)) div 4].sc
500 @d char_italic(#)==font_info[italic_base[#]+char_italic_end
501 @d height_depth(#)==qo(#.b1)
502 @d char_height_end(#)==(#) div 16].sc
503 @d char_height(#)==font_info[height_base[#]+char_height_end
504 @d char_depth_end(#)==(#) mod 16].sc
505 @d char_depth(#)==font_info[depth_base[#]+char_depth_end
506 @d char_tag(#)==((qo(#.b2)) mod 4)
507 @y
508 @d char_info_end(#)==#].qqqq
509 @d char_info(#)==font_tables[#,char_base(#)-font_offset(#)+char_info_end
510 @d char_width_end(#)==#.b0].sc
511 @d char_width(#)==font_tables[#,width_base(#)+char_width_end
512 @d char_exists(#)==(#.b0>min_quarterword)
513 @d char_italic_end(#)==(qo(#.b2)) div 256].sc
514 @d char_italic(#)==font_tables[#,italic_base(#)+char_italic_end
515 @d height_depth(#)==qo(#.b1)
516 @d char_height_end(#)==(#) div 256].sc
517 @d char_height(#)==font_tables[#,height_base(#)+char_height_end
518 @d char_depth_end(#)==(#) mod 256].sc
519 @d char_depth(#)==font_tables[#,depth_base(#)+char_depth_end
520 @d char_tag(#)==((qo(#.b2)) mod 4)
521 @z
522 %---------------------------------------
523 @x [30] m.557 l.10834 - Omega
524 |i=font_info[lig_kern_start(f)(j)]| or |font_info[lig_kern_restart(f)(i)]|,
525 depending on whether or not |skip_byte(i)<=stop_flag|.
526
527 The constant |kern_base_offset| should be simplified, for \PASCAL\ compilers
528 that do not do local optimization.
529 @^system dependencies@>
530
531 @d char_kern_end(#)==256*op_byte(#)+rem_byte(#)].sc
532 @d char_kern(#)==font_info[kern_base[#]+char_kern_end
533 @d kern_base_offset==256*(128+min_quarterword)
534 @d lig_kern_start(#)==lig_kern_base[#]+rem_byte {beginning of lig/kern program}
535 @d lig_kern_restart_end(#)==256*op_byte(#)+rem_byte(#)+32768-kern_base_offset
536 @d lig_kern_restart(#)==lig_kern_base[#]+lig_kern_restart_end
537 @y
538 |i=font_info(f)(lig_kern_start(f)(j))| or
539 |font_info(f)(lig_kern_restart(f)(i))|,
540 depending on whether or not |skip_byte(i)<=stop_flag|.
541
542 The constant |kern_base_offset| should be simplified, for \PASCAL\ compilers
543 that do not do local optimization.
544 @^system dependencies@>
545
546 @d char_kern_end(#)==256*op_byte(#)+rem_byte(#)].sc
547 @d char_kern(#)==font_tables[#,kern_base(#)+char_kern_end
548 @d kern_base_offset==256*(128+min_quarterword)
549 @d lig_kern_start(#)==lig_kern_base(#)+rem_byte {beginning of lig/kern program}
550 @d lig_kern_restart_end(#)==256*op_byte(#)+rem_byte(#)+32768-kern_base_offset
551 @d lig_kern_restart(#)==lig_kern_base(#)+lig_kern_restart_end
552
553 @d attr_zero_char_ivalue_end(#)==#].int].int
554 @d attr_zero_char_ivalue(#)==
555 font_tables[#,font_tables[#,char_attr_base(#)+attr_zero_char_ivalue_end
556 @d attr_zero_ivalue_end(#)==#].int
557 @d attr_zero_ivalue(#)==font_tables[#,ivalues_base(#)+attr_zero_ivalue_end
558 @d attr_zero_penalty_end(#)==#].int
559 @d attr_zero_penalty(#)==font_tables[#,penalties_base(#)+attr_zero_penalty_end
560 @d attr_zero_kern_end(#)==#].int
561 @d attr_zero_kern(#)==font_tables[#,mvalues_base(#)+attr_zero_kern_end
562
563 @z
564 %---------------------------------------
565 @x [30] m.558 l.10843 - Omega
566 @d param_end(#)==param_base[#]].sc
567 @d param(#)==font_info[#+param_end
568 @d slant==param(slant_code) {slant to the right, per unit distance upward}
569 @d space==param(space_code) {normal space between words}
570 @d space_stretch==param(space_stretch_code) {stretch between words}
571 @d space_shrink==param(space_shrink_code) {shrink between words}
572 @d x_height==param(x_height_code) {one ex}
573 @d quad==param(quad_code) {one em}
574 @d extra_space==param(extra_space_code) {additional space at end of sentence}
575 @y
576 @d slant(#)==font_info(#)(param_base(#)+slant_code).sc
577 {slant to the right, per unit distance upward}
578 @d space(#)==font_info(#)(param_base(#)+space_code).sc
579 {normal space between words}
580 @d space_stretch(#)==font_info(#)(param_base(#)+space_stretch_code).sc
581 {stretch between words}
582 @d space_shrink(#)==font_info(#)(param_base(#)+space_shrink_code).sc
583 {shrink between words}
584 @d x_height(#)==font_info(#)(param_base(#)+x_height_code).sc
585 {one ex}
586 @d quad(#)==font_info(#)(param_base(#)+quad_code).sc
587 {one em}
588 @d extra_space(#)==font_info(#)(param_base(#)+extra_space_code).sc
589 {additional space at end of sentence}
590 @z
591 %---------------------------------------
592 @x [30] m.560 l.10876 - Omega
593 @p function read_font_info(@!u:pointer;@!nom,@!aire:str_number;
594 @!s:scaled):internal_font_number; {input a \.{TFM} file}
595 @y
596 @p function read_font_info(@!u:pointer;@!nom,@!aire:str_number;
597 @!s:scaled;offset:quarterword):internal_font_number; {input a \.{TFM} file}
598 @z
599 %---------------------------------------
600 @x [30] m.560 l.10882 - Omega
601 {sizes of subfiles}
602 @!f:internal_font_number; {the new font's number}
603 @!g:internal_font_number; {the number to return}
604 @!a,@!b,@!c,@!d:eight_bits; {byte variables}
605 @y
606 @!font_dir:halfword;
607 {sizes of subfiles}
608 @!f:internal_font_number; {the new font's number}
609 @!g:internal_font_number; {the number to return}
610 @!a,@!b,@!c,@!d:integer; {byte variables}
611 @!i,@!k_param,@!param,@!font_counter:integer; {counters}
612 @!font_level,@!header_length:integer;
613 @!nco,@!ncw,@!npc,@!nlw,@!neew:integer;
614 @!nki,@!nwi,@!nkf,@!nwf,@!nkm,@!nwm:integer;
615 @!nkr,@!nwr,@!nkg,@!nwg,@!nkp,@!nwp:integer;
616 @!table_size:array [0..31] of integer;
617 @!bytes_per_entry,@!extra_char_bytes:integer;
618 @!repeat_no,@!table_counter:integer;
619 @z
620 %---------------------------------------
621 @x [30] m.560 l.10888 - Omega
622 @!bchar:0..256; {boundary character, or 256}
623 @y
624 @!bchar:0..too_big_char; {boundary character, or |too_big_char|}
625 @!first_two:integer;
626 @z
627 %---------------------------------------
628 @x [30] m.563 l.10943 - Omega
629 if file_opened then print(" not loadable: Bad metric (TFM) file")
630 else print(" not loadable: Metric (TFM) file not found");
631 @y
632 if file_opened then print(" not loadable: Bad metric (TFM/OFM) file")
633 else print(" not loadable: Metric (TFM/OFM) file not found");
634 @z
635 %---------------------------------------
636 @x [30] m.563 l.10943 - Omega
637 if aire="" then pack_file_name(nom,TEX_font_area,".tfm")
638 else pack_file_name(nom,aire,".tfm");
639 if not b_open_in(tfm_file) then abort;
640 @y
641 if aire="" then pack_file_name(nom,TEX_font_area,".ofm")
642 else pack_file_name(nom,aire,".ofm");
643 if not b_open_in(tfm_file) then abort;
644 @z
645 %---------------------------------------
646 @x [30] m.564 l.10962 - Omega
647 @d store_four_quarters(#)==begin fget; a:=fbyte; qw.b0:=qi(a);
648 fget; b:=fbyte; qw.b1:=qi(b);
649 fget; c:=fbyte; qw.b2:=qi(c);
650 fget; d:=fbyte; qw.b3:=qi(d);
651 #:=qw;
652 end
653 @y
654 @d read_sixteen_unsigned(#)==begin #:=fbyte;
655 fget; #:=#*@'400+fbyte;
656 end
657 @d read_thirtytwo(#)==begin #:=fbyte;
658 if #>127 then abort;
659 fget; #:=#*@'400+fbyte;
660 fget; #:=#*@'400+fbyte;
661 fget; #:=#*@'400+fbyte;
662 end
663 @d store_four_bytes(#)==begin fget; a:=fbyte; qw.b0:=a;
664 fget; b:=fbyte; qw.b1:=b;
665 fget; c:=fbyte; qw.b2:=c;
666 fget; d:=fbyte; qw.b3:=d;
667 #:=qw;
668 end
669 @d store_char_info(#)==begin if (font_level<>-1) then
670 begin fget; read_sixteen_unsigned(a); qw.b0:=a;
671 fget; read_sixteen_unsigned(b); qw.b1:=b;
672 fget; read_sixteen_unsigned(c); qw.b2:=c;
673 fget; read_sixteen_unsigned(d); qw.b3:=d;
674 #:=qw
675 end
676 else
677 begin fget; a:=fbyte; qw.b0:=a;
678 fget; b:=fbyte; b:=((b div 16)*256)+(b mod 16); qw.b1:=b;
679 fget; c:=fbyte; c:=((c div 4)*256)+(c mod 4); qw.b2:=c;
680 fget; d:=fbyte; qw.b3:=d;
681 #:=qw
682 end
683 end
684 @d store_four_quarters(#)==begin if (font_level<>-1) then
685 begin fget; read_sixteen_unsigned(a); qw.b0:=a;
686 fget; read_sixteen_unsigned(b); qw.b1:=b;
687 fget; read_sixteen_unsigned(c); qw.b2:=c;
688 fget; read_sixteen_unsigned(d); qw.b3:=d;
689 #:=qw
690 end
691 else
692 begin fget; a:=fbyte; qw.b0:=a;
693 fget; b:=fbyte; qw.b1:=b;
694 fget; c:=fbyte; qw.b2:=c;
695 fget; d:=fbyte; qw.b3:=d;
696 #:=qw
697 end
698 end
699 @z
700 %---------------------------------------
701 @x [30] m.565 l.10970 - Omega
702 begin read_sixteen(lf);
703 fget; read_sixteen(lh);
704 fget; read_sixteen(bc);
705 fget; read_sixteen(ec);
706 if (bc>ec+1)or(ec>255) then abort;
707 if bc>255 then {|bc=256| and |ec=255|}
708 begin bc:=1; ec:=0;
709 end;
710 fget; read_sixteen(nw);
711 fget; read_sixteen(nh);
712 fget; read_sixteen(nd);
713 fget; read_sixteen(ni);
714 fget; read_sixteen(nl);
715 fget; read_sixteen(nk);
716 fget; read_sixteen(ne);
717 fget; read_sixteen(np);
718 if lf<>6+lh+(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np then abort;
719 if (nw=0)or(nh=0)or(nd=0)or(ni=0) then abort;
720 end
721 @y
722 nco:=0; ncw:=0; npc:=0;
723 nki:=0; nwi:=0; nkf:=0; nwf:=0; nkm:=0; nwm:=0;
724 nkr:=0; nwr:=0; nkg:=0; nwg:=0; nkp:=0; nwp:=0;
725 read_sixteen(first_two);
726 if first_two<>0 then begin
727 font_level:=-1;
728 lf:=first_two;
729 fget; read_sixteen(lh);
730 fget; read_sixteen(bc);
731 fget; read_sixteen(ec);
732 if (bc>ec+1)or(ec>255) then abort;
733 if bc>255 then {|bc=256| and |ec=255|}
734 begin bc:=1; ec:=0;
735 end;
736 fget; read_sixteen(nw);
737 fget; read_sixteen(nh);
738 fget; read_sixteen(nd);
739 fget; read_sixteen(ni);
740 fget; read_sixteen(nl);
741 fget; read_sixteen(nk);
742 fget; read_sixteen(ne);
743 fget; read_sixteen(np);
744 header_length:=6;
745 ncw:=(ec-bc+1);
746 nlw:=nl;
747 neew:=ne;
748 end
749 else begin
750 fget; read_sixteen(font_level);
751 if (font_level<>0) and (font_level<>1) then abort;
752 fget; read_thirtytwo(lf);
753 fget; read_thirtytwo(lh);
754 fget; read_thirtytwo(bc);
755 fget; read_thirtytwo(ec);
756 if (bc>ec+1)or(ec>biggest_char) then abort;
757 if bc>65535 then {|bc=65536| and |ec=65535|}
758 begin bc:=1; ec:=0;
759 end;
760 fget; read_thirtytwo(nw);
761 fget; read_thirtytwo(nh);
762 fget; read_thirtytwo(nd);
763 fget; read_thirtytwo(ni);
764 fget; read_thirtytwo(nl);
765 fget; read_thirtytwo(nk);
766 fget; read_thirtytwo(ne);
767 fget; read_thirtytwo(np);
768 fget; read_thirtytwo(font_dir);
769 nlw:=2*nl;
770 neew:=2*ne;
771 if font_level=0 then begin
772 header_length:=14;
773 ncw:=2*(ec-bc+1);
774 end
775 else begin
776 header_length:=29;
777 fget; read_thirtytwo(nco);
778 fget; read_thirtytwo(ncw);
779 fget; read_thirtytwo(npc);
780 fget; read_thirtytwo(nki); {Kinds of font ivalues}
781 fget; read_thirtytwo(nwi); {Words of font ivalues}
782 fget; read_thirtytwo(nkf); {Kinds of font fvalues}
783 fget; read_thirtytwo(nwf); {Words of font fvalues}
784 fget; read_thirtytwo(nkm); {Kinds of font mvalues}
785 fget; read_thirtytwo(nwm); {Words of font mvalues}
786 fget; read_thirtytwo(nkr); {Kinds of font rules}
787 fget; read_thirtytwo(nwr); {Words of font rules}
788 fget; read_thirtytwo(nkg); {Kinds of font glues}
789 fget; read_thirtytwo(nwg); {Words of font glues}
790 fget; read_thirtytwo(nkp); {Kinds of font penalties}
791 fget; read_thirtytwo(nwp); {Words of font penalties}
792 end
793 end;
794 if lf<>(header_length+lh+ncw+nw+nh+nd+ni+nlw+nk+neew+np+
795 nki+nwi+nkf+nwf+nkm+nwm+nkr+nwr+nkg+nwg+nkp+nwp) then abort;
796 @z
797 %---------------------------------------
798 @x [30] m.566 l.10996 - Omega
799 lf:=lf-6-lh; {|lf| words should be loaded into |font_info|}
800 if np<7 then lf:=lf+7-np; {at least seven parameters will appear}
801 if (font_ptr=font_max)or(fmem_ptr+lf>font_mem_size) then
802 @<Apologize for not loading the font, |goto done|@>;
803 f:=font_ptr+1;
804 char_base[f]:=fmem_ptr-bc;
805 width_base[f]:=char_base[f]+ec+1;
806 height_base[f]:=width_base[f]+nw;
807 depth_base[f]:=height_base[f]+nh;
808 italic_base[f]:=depth_base[f]+nd;
809 lig_kern_base[f]:=italic_base[f]+ni;
810 kern_base[f]:=lig_kern_base[f]+nl-kern_base_offset;
811 exten_base[f]:=kern_base[f]+kern_base_offset+nk;
812 param_base[f]:=exten_base[f]+ne
813 @y
814 case font_level of
815 -1: lf:=lf-6-lh; {|lf| words should be loaded into |font_info|}
816 0: lf:=lf-14-lh-(ec-bc+1)-nl-ne;
817 {some of the sections contain pairs of
818 words that become single |memory_word|s}
819 1: lf:=lf-29-lh-ncw+(1+npc)*(ec-bc+1)-nl-ne;
820 {We explode the characters}
821 end;
822 if np<7 then lf:=lf+7-np; {at least seven parameters will appear}
823 if (font_ptr=font_max) then
824 @<Apologize for not loading the font, |goto done|@>;
825 f:=font_ptr+1;
826 allocate_font_table(f,offset_charinfo_base+lf+100);
827 {leave room for 100 extra parameters -- potential bug}
828 font_file_size(f):=offset_charinfo_base+lf+100;
829 font_used(f):=false;
830 font_offset(f):=offset;
831 char_base(f):=offset_charinfo_base-bc;
832 char_attr_base(f):=char_base(f)+ec+1;
833 ivalues_start(f):=char_attr_base(f)+npc*(ec-bc+1);
834 fvalues_start(f):=ivalues_start(f)+nki;
835 mvalues_start(f):=fvalues_start(f)+nkf;
836 rules_start(f):=mvalues_start(f)+nkm;
837 glues_start(f):=rules_start(f)+nkr;
838 penalties_start(f):=glues_start(f)+nkg;
839 ivalues_base(f):=penalties_start(f)+nkp;
840 fvalues_base(f):=ivalues_base(f)+nwi;
841 mvalues_base(f):=fvalues_base(f)+nwf;
842 rules_base(f):=mvalues_base(f)+nwm;
843 glues_base(f):=rules_base(f)+nwr;
844 penalties_base(f):=glues_base(f)+nwg;
845 width_base(f):=penalties_base(f)+nwp;
846 height_base(f):=width_base(f)+nw;
847 depth_base(f):=height_base(f)+nh;
848 italic_base(f):=depth_base(f)+nd;
849 lig_kern_base(f):=italic_base(f)+ni;
850 kern_base(f):=lig_kern_base(f)+nl-kern_base_offset;
851 exten_base(f):=kern_base(f)+kern_base_offset+nk;
852 param_base(f):=exten_base(f)+ne;
853 @z
854 %---------------------------------------
855 @x [30] m.568 l.11026 - Omega
856 store_four_quarters(font_check[f]);
857 @y
858 fget; font_check_0(f):=fbyte;
859 fget; font_check_1(f):=fbyte;
860 fget; font_check_2(f):=fbyte;
861 fget; font_check_3(f):=fbyte;
862 @z
863 %---------------------------------------
864 @x [30] m.568 l.11033 - Omega
865 font_dsize[f]:=z;
866 if s<>-1000 then
867 if s>=0 then z:=s
868 else z:=xn_over_d(z,-s,1000);
869 font_size[f]:=z;
870 @y
871 font_dsize(f):=z;
872 if s<>-1000 then
873 if s>=0 then z:=s
874 else z:=xn_over_d(z,-s,1000);
875 font_size(f):=z;
876 @z
877 %---------------------------------------
878 @x [30] m.569 l.11041 - Omega
879 for k:=fmem_ptr to width_base[f]-1 do
880 begin store_four_quarters(font_info[k].qqqq);
881 if (a>=nw)or(b div @'20>=nh)or(b mod @'20>=nd)or
882 (c div 4>=ni) then abort;
883 case c mod 4 of
884 lig_tag: if d>=nl then abort;
885 ext_tag: if d>=ne then abort;
886 list_tag: @<Check for charlist cycle@>;
887 othercases do_nothing {|no_tag|}
888 endcases;
889 end
890 @y
891 if font_level=1 then begin
892 i:=0;
893 k:=ivalues_start(f);
894 font_counter:=ivalues_base(f);
895 while k<fvalues_start(f) do {IVALUE starts}
896 begin
897 read_thirtytwo(param);
898 font_info(f)(k).int := font_counter;
899 font_counter:=font_counter+param;
900 table_size[i]:=1;
901 incr(i); incr(k);
902 end;
903 while k<mvalues_start(f) do {FVALUE starts}
904 begin
905 read_thirtytwo(param);
906 font_info(f)(k).int := font_counter;
907 font_counter:=font_counter+param;
908 table_size[i]:=1;
909 incr(i); incr(k);
910 end;
911 while k<rules_start(f) do {MVALUE starts}
912 begin
913 read_thirtytwo(param);
914 font_info(f)(k).int := font_counter;
915 font_counter:=font_counter+param;
916 table_size[i]:=1;
917 incr(i); incr(k);
918 end;
919 while k<glues_start(f) do {RULE starts}
920 begin
921 read_thirtytwo(param);
922 font_info(f)(k).int := font_counter;
923 font_counter:=font_counter+param*3;
924 table_size[i]:=3;
925 incr(i); incr(k);
926 end;
927 while k<penalties_start(f) do {GLUE starts}
928 begin
929 read_thirtytwo(param);
930 font_info(f)(k).int := font_counter;
931 font_counter:=font_counter+param*4;
932 table_size[i]:=4;
933 incr(i); incr(k);
934 end;
935 while k<ivalues_base(f) do {PENALTY starts}
936 begin
937 read_thirtytwo(param);
938 font_info(f)(k).int := font_counter;
939 font_counter:=font_counter+param*1;
940 table_size[i]:=1;
941 incr(i); incr(k);
942 end;
943 while k<fvalues_base(f) do {IVALUE entries}
944 begin
945 read_thirtytwo(font_info(f)(k).int);
946 incr(k);
947 end;
948 while k<mvalues_base(f) do {FVALUE entries}
949 begin
950 read_thirtytwo(font_info(f)(k).sc);
951 incr(k);
952 end;
953 while k<rules_base(f) do {MVALUE entries}
954 begin
955 read_thirtytwo(font_info(f)(k).int);
956 incr(k);
957 end;
958 while k<glues_base(f) do {RULE entries}
959 begin
960 store_scaled(font_info(f)(k).sc);
961 store_scaled(font_info(f)(k+1).sc);
962 store_scaled(font_info(f)(k+2).sc);
963 k:=k+3;
964 end;
965 while k<penalties_base(f) do {GLUE entries}
966 begin
967 fget; read_sixteen(font_info(f)(k).hh.lhfield);
968 fget; read_sixteen(font_info(f)(k).hh.rh);
969 store_scaled(font_info(f)(k+1).sc);
970 store_scaled(font_info(f)(k+2).sc);
971 store_scaled(font_info(f)(k+3).sc);
972 k:=k+4;
973 end;
974 while k<offset_charinfo_base do {PENALTY entries}
975 begin
976 read_thirtytwo(font_info(f)(k).int);
977 incr(k);
978 end;
979 end;
980 k:=char_base(f)+bc;
981 k_param:=char_attr_base(f);
982 bytes_per_entry:=(12 + 2*npc) div 4 * 4;
983 extra_char_bytes:=bytes_per_entry - (10 + 2*npc);
984 while k<char_attr_base(f) do begin
985 store_char_info(font_info(f)(k).qqqq);
986 if (a>=nw)or((b div @"100)>=nh)or((b mod @"100)>=nd)or
987 ((c div @"100)>=ni) then abort;
988 case c mod 4 of
989 lig_tag: if d>=nl then abort;
990 ext_tag: if d>=ne then abort;
991 list_tag: @<Check for charlist cycle@>;
992 othercases do_nothing {|no_tag|}
993 endcases;
994 incr(k);
995 if font_level=1 then begin
996 fget; read_sixteen_unsigned(repeat_no);
997 for i:=0 to npc-1 do begin
998 fget; read_sixteen(param);
999 font_info(f)(k_param).int :=
1000 font_info(f)(ivalues_start(f)+i).int + param*table_size[i];
1001 incr(k_param);
1002 end;
1003 for i:=1 to extra_char_bytes do fget;
1004 for i:=1 to repeat_no do begin
1005 font_info(f)(k):=font_info(f)(k-1);
1006 incr(k);
1007 for table_counter:=0 to npc-1 do begin
1008 font_info(f)(k_param).int := font_info(f)(k_param-npc).int;
1009 incr(k_param);
1010 end;
1011 end;
1012 end;
1013 end
1014 @z
1015 %---------------------------------------
1016 @x [30] m.570 l.11059 - Omega
1017 @d current_character_being_worked_on==k+bc-fmem_ptr
1018 @y
1019 @d current_character_being_worked_on==k-char_base(f)
1020 @z
1021 %---------------------------------------
1022 @x [30] m.570 l.11065 - Omega
1023 begin qw:=char_info(f)(d);
1024 {N.B.: not |qi(d)|, since |char_base[f]| hasn't been adjusted yet}
1025 @y
1026 begin qw:=char_info(f)(d);
1027 {N.B.: not |qi(d)|, since |char_base(f)| hasn't been adjusted yet}
1028 @z
1029 %---------------------------------------
1030 @x [30] m.571 l.11098 - Omega
1031 for k:=width_base[f] to lig_kern_base[f]-1 do
1032 store_scaled(font_info[k].sc);
1033 if font_info[width_base[f]].sc<>0 then abort; {\\{width}[0] must be zero}
1034 if font_info[height_base[f]].sc<>0 then abort; {\\{height}[0] must be zero}
1035 if font_info[depth_base[f]].sc<>0 then abort; {\\{depth}[0] must be zero}
1036 if font_info[italic_base[f]].sc<>0 then abort; {\\{italic}[0] must be zero}
1037 @y
1038 for k:=width_base(f) to lig_kern_base(f)-1 do
1039 store_scaled(font_info(f)(k).sc);
1040 if font_info(f)(width_base(f)).sc<>0 then abort; {\\{width}[0] must be zero}
1041 if font_info(f)(height_base(f)).sc<>0 then abort; {\\{height}[0] must be zero}
1042 if font_info(f)(depth_base(f)).sc<>0 then abort; {\\{depth}[0] must be zero}
1043 if font_info(f)(italic_base(f)).sc<>0 then abort; {\\{italic}[0] must be zero}
1044 @z
1045 %---------------------------------------
1046 @x [30] m.573 l.11114 - Omega
1047 @ @d check_existence(#)==@t@>@;@/
1048 begin check_byte_range(#);
1049 qw:=char_info(f)(#); {N.B.: not |qi(#)|}
1050 if not char_exists(qw) then abort;
1051 end
1052
1053 @<Read ligature/kern program@>=
1054 bch_label:=@'77777; bchar:=256;
1055 if nl>0 then
1056 begin for k:=lig_kern_base[f] to kern_base[f]+kern_base_offset-1 do
1057 begin store_four_quarters(font_info[k].qqqq);
1058 if a>128 then
1059 begin if 256*c+d>=nl then abort;
1060 if a=255 then if k=lig_kern_base[f] then bchar:=b;
1061 end
1062 else begin if b<>bchar then check_existence(b);
1063 if c<128 then check_existence(d) {check ligature}
1064 else if 256*(c-128)+d>=nk then abort; {check kern}
1065 if a<128 then if k-lig_kern_base[f]+a+1>=nl then abort;
1066 end;
1067 end;
1068 if a=255 then bch_label:=256*c+d;
1069 end;
1070 for k:=kern_base[f]+kern_base_offset to exten_base[f]-1 do
1071 store_scaled(font_info[k].sc);
1072 @y
1073 @ @d check_existence(#)==@t@>@;@/
1074 begin check_byte_range(#);
1075 qw:=char_info(f)(#+font_offset(f)); {N.B.: not |qi(#)|}
1076 if not char_exists(qw) then abort;
1077 end
1078
1079 @<Read ligature/kern program@>=
1080 bch_label:=nl {infinity}; bchar:=too_big_char;
1081 if nl>0 then
1082 begin for k:=lig_kern_base(f) to kern_base(f)+kern_base_offset-1 do
1083 begin store_four_quarters(font_info(f)(k).qqqq);
1084 if a>128 then
1085 begin if 256*c+d>=nl then abort;
1086 if a=255 then if k=lig_kern_base(f) then bchar:=b;
1087 end
1088 else begin if b<>bchar then check_existence(b);
1089 if c<128 then check_existence(d) {check ligature}
1090 else if 256*(c-128)+d>=nk then abort; {check kern}
1091 if a<128 then if k-lig_kern_base(f)+a+1>=nl then abort;
1092 end;
1093 end;
1094 if a=255 then bch_label:=256*c+d;
1095 end;
1096 for k:=kern_base(f)+kern_base_offset to exten_base(f)-1 do
1097 store_scaled(font_info(f)(k).sc);
1098 @z
1099 %---------------------------------------
1100 @x [30] m.574 l.11141 - Omega
1101 for k:=exten_base[f] to param_base[f]-1 do
1102 begin store_four_quarters(font_info[k].qqqq);
1103 @y
1104 for k:=exten_base(f) to param_base(f)-1 do
1105 begin store_four_quarters(font_info(f)(k).qqqq);
1106 @z
1107 %---------------------------------------
1108 @x [30] m.575 l.11157 - Omega
1109 fget; font_info[param_base[f]].sc:=
1110 (sw*@'20)+(fbyte div@'20);
1111 end
1112 else store_scaled(font_info[param_base[f]+k-1].sc);
1113 if eof(tfm_file) then abort;
1114 for k:=np+1 to 7 do font_info[param_base[f]+k-1].sc:=0;
1115 @y
1116 fget; font_info(f)(param_base(f)).sc:=
1117 (sw*@'20)+(fbyte div@'20);
1118 end
1119 else store_scaled(font_info(f)(param_base(f)+k-1).sc);
1120 if eof(tfm_file) then abort;
1121 for k:=np+1 to 7 do font_info(f)(param_base(f)+k-1).sc:=0;
1122 @z
1123 %---------------------------------------
1124 @x [30] m.576 l.11169 - Omega
1125 @d adjust(#)==#[f]:=qo(#[f])
1126 {correct for the excess |min_quarterword| that was added}
1127
1128 @<Make final adjustments...@>=
1129 if np>=7 then font_params[f]:=np@+else font_params[f]:=7;
1130 hyphen_char[f]:=default_hyphen_char; skew_char[f]:=default_skew_char;
1131 if bch_label<nl then bchar_label[f]:=bch_label+lig_kern_base[f]
1132 else bchar_label[f]:=non_address;
1133 font_bchar[f]:=qi(bchar);
1134 font_false_bchar[f]:=qi(bchar);
1135 if bchar<=ec then if bchar>=bc then
1136 begin qw:=char_info(f)(bchar); {N.B.: not |qi(bchar)|}
1137 if char_exists(qw) then font_false_bchar[f]:=non_char;
1138 end;
1139 font_name[f]:=nom;
1140 font_area[f]:=aire;
1141 font_bc[f]:=bc; font_ec[f]:=ec; font_glue[f]:=null;
1142 adjust(char_base); adjust(width_base); adjust(lig_kern_base);
1143 adjust(kern_base); adjust(exten_base);
1144 decr(param_base[f]);
1145 fmem_ptr:=fmem_ptr+lf; font_ptr:=f; g:=f; goto done
1146 @y
1147 @d adjust(#)==#(f):=qo(#(f))
1148 {correct for the excess |min_quarterword| that was added}
1149
1150 @<Make final adjustments...@>=
1151 if np>=7 then font_params(f):=np@+else font_params(f):=7;
1152 font_offset(f):=offset;
1153 hyphen_char(f):=default_hyphen_char+offset;
1154 skew_char(f):=default_skew_char+offset;
1155 bchar:=bchar+offset;
1156 if bch_label<nl then bchar_label(f):=bch_label+lig_kern_base(f)
1157 else bchar_label(f):=non_address;
1158 font_bchar(f):=qi(bchar);
1159 font_false_bchar(f):=qi(bchar);
1160 if bchar<=ec then if bchar>=bc then
1161 begin qw:=char_info(f)(bchar); {N.B.: not |qi(bchar)|}
1162 if char_exists(qw) then font_false_bchar(f):=non_char;
1163 end;
1164 font_name(f):=nom;
1165 font_area(f):=aire;
1166 font_bc(f):=bc; font_ec(f):=ec; font_glue(f):=null;
1167 font_bc(f):=bc+offset; font_ec(f):=ec+offset; font_glue(f):=null;
1168 adjust(char_base); adjust(width_base); adjust(lig_kern_base);
1169 adjust(kern_base); adjust(exten_base);
1170 decr(param_base(f));
1171 font_ptr:=f; g:=f; goto done
1172 @z
1173 %---------------------------------------
1174 @x [30] m.577 l.11202 - Omega
1175 begin m:=cur_chr; scan_four_bit_int; f:=equiv(m+cur_val);
1176 @y
1177 begin m:=cur_chr; scan_big_four_bit_int; f:=equiv(m+cur_val);
1178 @z
1179 %---------------------------------------
1180 @x [30] m.578 l.11223 - Omega
1181 if n<=0 then cur_val:=fmem_ptr
1182 else begin if writing and(n<=space_shrink_code)and@|
1183 (n>=space_code)and(font_glue[f]<>null) then
1184 begin delete_glue_ref(font_glue[f]);
1185 font_glue[f]:=null;
1186 end;
1187 if n>font_params[f] then
1188 if f<font_ptr then cur_val:=fmem_ptr
1189 else @<Increase the number of parameters in the last font@>
1190 else cur_val:=n+param_base[f];
1191 end;
1192 @<Issue an error message if |cur_val=fmem_ptr|@>;
1193 end;
1194 @y
1195 dimen_font:=f;
1196 if n<=0 then cur_val:=font_file_size(f)
1197 else begin if writing and(n<=space_shrink_code)and@|
1198 (n>=space_code)and(font_glue(f)<>null) then
1199 begin delete_glue_ref(font_glue(f));
1200 font_glue(f):=null;
1201 end;
1202 if n>font_params(f) then
1203 if f<font_ptr then cur_val:=font_file_size(f)
1204 else @<Increase the number of parameters in the last font@>
1205 else cur_val:=n+param_base(f);
1206 end;
1207 @<Issue an error message if |cur_val=font_file_size(f)|@>;
1208 end;
1209 @z
1210 %---------------------------------------
1211 @x [30] m.579 l.11240 - Omega
1212 @ @<Issue an error message if |cur_val=fmem_ptr|@>=
1213 if cur_val=fmem_ptr then
1214 begin print_err("Font "); print_esc(font_id_text(f));
1215 print(" has only "); print_int(font_params[f]);
1216 print(" fontdimen parameters");
1217 @.Font x has only...@>
1218 help2("To increase the number of font parameters, you must")@/
1219 ("use \fontdimen immediately after the \font is loaded.");
1220 error;
1221 end
1222 @y
1223 @ @<Issue an error message if |cur_val=font_file_size(f)|@>=
1224 if cur_val=font_file_size(f) then
1225 begin print_err("Font "); print_esc(font_id_text(f));
1226 print(" has only "); print_int(font_params(f));
1227 print(" fontdimen parameters");
1228 @.Font x has only...@>
1229 help2("To increase the number of font parameters, you must")@/
1230 ("use \fontdimen immediately after the \font is loaded.");
1231 error;
1232 end
1233 @z
1234 %---------------------------------------
1235 @x [30] m.580 l.11252 - font parameters
1236 @ @<Increase the number of parameters...@>=
1237 begin repeat if fmem_ptr=font_mem_size then
1238 overflow("font memory",font_mem_size);
1239 @:TeX capacity exceeded font memory}{\quad font memory@>
1240 font_info[fmem_ptr].sc:=0; incr(fmem_ptr); incr(font_params[f]);
1241 until n=font_params[f];
1242 cur_val:=fmem_ptr-1; {this equals |param_base[f]+font_params[f]|}
1243 @y
1244 @ @<Increase the number of parameters...@>=
1245 begin if n+font_params(f)>font_file_size(f) then
1246 begin print_nl("Out of font parameter space"); succumb; end;
1247 repeat
1248 font_info(f)(param_base(f)+font_params(f)).sc:=0; incr(font_params(f));
1249 until n=font_params(f);
1250 cur_val:=param_base(f)+font_params(f);
1251 @z
1252 %---------------------------------------
1253 @x [30] m.581 l.11268 - font parameters
1254 slow_print(font_name[f]); print_char("!"); end_diagnostic(false);
1255 @y
1256 slow_print(font_name(f)); print_char("!"); end_diagnostic(false);
1257 @z
1258 %---------------------------------------
1259 @x [30] m.582 l.11276 - font parameters
1260 begin if font_bc[f]<=c then if font_ec[f]>=c then
1261 @y
1262 begin if font_bc(f)<=c then if font_ec(f)>=c then
1263 @z
1264 %---------------------------------------
1265 @x [32] m.592 l.11820 - Omega
1266 @!c,@!f:quarterword; {character and font in current |char_node|}
1267 @y
1268 @!c,@!f:quarterword; {character and font in current |char_node|}
1269 @!oval,@!ocmd:integer; {used by |out_cmd| for generating
1270 |set|, |fnt| and |fnt_def| commands}
1271 @z
1272 %---------------------------------------
1273 @x [32] m.602 l.11939 - Omega
1274 @ Here's a procedure that outputs a font definition. Since \TeX82 uses at
1275 most 256 different fonts per job, |fnt_def1| is always used as the command code.
1276 @y
1277 @ Here's a procedure that outputs a font definition. $\Omega$ allows
1278 more than 256 different fonts per job, so the right font definition
1279 command must be selected.
1280
1281 @d Incr_Decr(#) == #
1282 @d Incr(#) == #:=#+Incr_Decr {increase a variable}
1283 @d Decr(#) == #:=#-Incr_Decr {decrease a variable}
1284
1285 @d dvi_debug_out(#)==begin
1286 dvi_out(#);
1287 end
1288
1289 @d out_cmd ==
1290 begin
1291 if (oval<@"100)and(oval>=0) then begin
1292 if (ocmd<>set1)or(oval>127) then
1293 if (ocmd=fnt1)and(oval<64) then Incr(oval)(fnt_num_0) @+ else dvi_debug_out(ocmd);
1294 end
1295 else
1296 begin if (oval<@"10000)and(oval>=0) then dvi_debug_out(ocmd+1) @+ else @;
1297 begin if (oval<@"1000000)and(oval>=0) then dvi_debug_out(ocmd+2) @+ else @;
1298 begin dvi_debug_out(ocmd+3);
1299 if oval>=0 then dvi_debug_out(oval div @"1000000)
1300 else begin Incr(oval)(@"40000000); Incr(oval)(@"40000000);
1301 dvi_debug_out((oval div @"1000000) + 128); oval:=oval mod @"1000000;
1302 end;
1303 dvi_debug_out(oval div @"10000); oval:=oval mod @"10000;
1304 end;
1305 dvi_debug_out(oval div @"10000); oval:=oval mod @"10000;
1306 end;
1307 dvi_debug_out(oval div @"100); oval:=oval mod @"100;
1308 end;
1309 dvi_debug_out(oval)
1310 end
1311
1312 @z
1313 %---------------------------------------
1314 @x [32] m.602 l.11944 - Omega
1315 begin dvi_out(fnt_def1);
1316 dvi_out(f-font_base-1);@/
1317 dvi_out(qo(font_check[f].b0));
1318 dvi_out(qo(font_check[f].b1));
1319 dvi_out(qo(font_check[f].b2));
1320 dvi_out(qo(font_check[f].b3));@/
1321 dvi_four(font_size[f]);
1322 dvi_four(font_dsize[f]);@/
1323 dvi_out(length(font_area[f]));
1324 dvi_out(length(font_name[f]));
1325 @y
1326 begin
1327 oval:=f-font_base-1; ocmd:= fnt_def1; out_cmd;@/
1328 dvi_out(qo(font_check_0(f)));
1329 dvi_out(qo(font_check_1(f)));
1330 dvi_out(qo(font_check_2(f)));
1331 dvi_out(qo(font_check_3(f)));@/
1332 dvi_four(font_size(f));
1333 dvi_four(font_dsize(f));@/
1334 dvi_out(length(font_area(f)));
1335 dvi_out(length(font_name(f)));
1336 @z
1337 %---------------------------------------
1338 @x [32] m.603 l.11958 - Omega
1339 for k:=str_start[font_area[f]] to str_start[font_area[f]+1]-1 do
1340 dvi_out(so(str_pool[k]));
1341 for k:=str_start[font_name[f]] to str_start[font_name[f]+1]-1 do
1342 dvi_out(so(str_pool[k]))
1343 @y
1344 for k:=str_start(font_area(f)) to str_start(font_area(f)+1)-1 do
1345 dvi_out(so(str_pool[k]));
1346 for k:=str_start(font_name(f)) to str_start(font_name(f)+1)-1 do
1347 dvi_out(so(str_pool[k]))
1348 @z
1349 %---------------------------------------
1350 @x [32] m.620 l.12334 - Omega
1351 if c>=qi(128) then dvi_out(set1);
1352 dvi_out(qo(c));@/
1353 @y
1354 oval:=c-font_offset(f); ocmd:=set1; out_cmd;@/
1355 @z
1356 %---------------------------------------
1357 @x [32] m.621 l.12345 - Omega
1358 begin if not font_used[f] then
1359 begin dvi_font_def(f); font_used[f]:=true;
1360 end;
1361 if f<=64+font_base then dvi_out(f-font_base-1+fnt_num_0)
1362 else begin dvi_out(fnt1); dvi_out(f-font_base-1);
1363 end;
1364 @y
1365 begin if not font_used(f) then
1366 begin dvi_font_def(f); font_used(f):=true;
1367 end;
1368 oval:=f-font_base-1; ocmd:=fnt1; out_cmd;@/
1369 @z
1370 %---------------------------------------
1371 @x [32] m.643 l.12757 - Omega
1372 begin if font_used[font_ptr] then dvi_font_def(font_ptr);
1373 @y
1374 begin if font_used(font_ptr) then dvi_font_def(font_ptr);
1375 @z
1376 %---------------------------------------
1377 @x [35] m.699 l.13742 - Omega
1378 @d text_size=0 {size code for the largest size in a family}
1379 @d script_size=16 {size code for the medium size in a family}
1380 @d script_script_size=32 {size code for the smallest size in a family}
1381 @y
1382 @z
1383 %---------------------------------------
1384 @x [35] m.700 l.13762 - Omega
1385 @d mathsy_end(#)==fam_fnt(2+#)]].sc
1386 @d mathsy(#)==font_info[#+param_base[mathsy_end
1387 @y
1388 @d mathsy_end(#)==sc
1389 @d mathsy(#)==font_info(fam_fnt(2+cur_size))(#+param_base(fam_fnt(2+cur_size))).mathsy_end
1390 @z
1391 %---------------------------------------
1392 @x [35] m.701 l.13789 - Omega
1393 @d mathex(#)==font_info[#+param_base[fam_fnt(3+cur_size)]].sc
1394 @y
1395 @d mathex(#)==font_info(fam_fnt(3+cur_size))(#+param_base(fam_fnt(3+cur_size))).sc
1396 @z
1397 %---------------------------------------
1398 @x [35] m.703 l.13813 - Omega
1399 @<Set up the values of |cur_size| and |cur_mu|, based on |cur_style|@>=
1400 begin if cur_style<script_style then cur_size:=text_size
1401 else cur_size:=16*((cur_style-text_style) div 2);
1402 cur_mu:=x_over_n(math_quad(cur_size),18);
1403 end
1404 @y
1405 @<Set up the values of |cur_size| and |cur_mu|, based on |cur_style|@>=
1406 begin if cur_style<script_style then cur_size:=text_size
1407 else cur_size:=script_size*((cur_style-text_style) div 2);
1408 cur_mu:=x_over_n(math_quad(cur_size),18);
1409 end
1410 @z
1411 %---------------------------------------
1412 @x [35] m.706 l.13855 - Omega
1413 function var_delimiter(@!d:pointer;@!s:small_number;@!v:scaled):pointer;
1414 label found,continue;
1415 var b:pointer; {the box that will be constructed}
1416 @!f,@!g: internal_font_number; {best-so-far and tentative font codes}
1417 @!c,@!x,@!y: quarterword; {best-so-far and tentative character codes}
1418 @!m,@!n: integer; {the number of extensible pieces}
1419 @!u: scaled; {height-plus-depth of a tentative character}
1420 @!w: scaled; {largest height-plus-depth so far}
1421 @!q: four_quarters; {character info}
1422 @!hd: eight_bits; {height-depth byte}
1423 @!r: four_quarters; {extensible pieces}
1424 @!z: small_number; {runs through font family members}
1425 @y
1426 function var_delimiter(@!d:pointer;@!s:integer;@!v:scaled):pointer;
1427 label found,continue;
1428 var b:pointer; {the box that will be constructed}
1429 @!f,@!g: internal_font_number; {best-so-far and tentative font codes}
1430 @!c,@!x,@!y: quarterword; {best-so-far and tentative character codes}
1431 @!m,@!n: integer; {the number of extensible pieces}
1432 @!u: scaled; {height-plus-depth of a tentative character}
1433 @!w: scaled; {largest height-plus-depth so far}
1434 @!q: four_quarters; {character info}
1435 @!hd: eight_bits; {height-depth byte}
1436 @!r: four_quarters; {extensible pieces}
1437 @!z: integer; {runs through font family members}
1438 @z
1439 %---------------------------------------
1440 @x [35] m.706 l.13881 - Omega
1441 shift_amount(b):=half(height(b)-depth(b)) - axis_height(s);
1442 @y
1443 z:=cur_size; cur_size:=s;
1444 shift_amount(b):=half(height(b)-depth(b)) - axis_height(cur_size);
1445 cur_size:=z;
1446 @z
1447 %---------------------------------------
1448 @x [35] m.707 l.13889 - Omega
1449 @<Look at the variants of |(z,x)|; set |f| and |c|...@>=
1450 if (z<>0)or(x<>min_quarterword) then
1451 begin z:=z+s+16;
1452 repeat z:=z-16; g:=fam_fnt(z);
1453 if g<>null_font then
1454 @<Look at the list of characters starting with |x| in
1455 font |g|; set |f| and |c| whenever
1456 a better character is found; |goto found| as soon as a
1457 large enough variant is encountered@>;
1458 until z<16;
1459 end
1460 @y
1461 @<Look at the variants of |(z,x)|; set |f| and |c|...@>=
1462 if (z<>0)or(x<>min_quarterword) then
1463 begin z:=z+s+script_size;
1464 repeat z:=z-script_size; g:=fam_fnt(z);
1465 if g<>null_font then
1466 @<Look at the list of characters starting with |x| in
1467 font |g|; set |f| and |c| whenever
1468 a better character is found; |goto found| as soon as a
1469 large enough variant is encountered@>;
1470 until z<script_size;
1471 end
1472 @z
1473 %---------------------------------------
1474 @x [35] m.708 l.13903 - Omega
1475 if (qo(y)>=font_bc[g])and(qo(y)<=font_ec[g]) then
1476 @y
1477 if (qo(y)>=font_bc(g))and(qo(y)<=font_ec(g)) then
1478 @z
1479 %---------------------------------------
1480 @x [35] m.713 l.13974 - Omega
1481 r:=font_info[exten_base[f]+rem_byte(q)].qqqq;@/
1482 @<Compute the minimum suitable height, |w|, and the corresponding
1483 number of extension steps, |n|; also set |width(b)|@>;
1484 c:=ext_bot(r);
1485 if c<>min_quarterword then stack_into_box(b,f,c);
1486 c:=ext_rep(r);
1487 for m:=1 to n do stack_into_box(b,f,c);
1488 c:=ext_mid(r);
1489 if c<>min_quarterword then
1490 begin stack_into_box(b,f,c); c:=ext_rep(r);
1491 for m:=1 to n do stack_into_box(b,f,c);
1492 end;
1493 c:=ext_top(r);
1494 @y
1495 r:=font_info(f)(exten_base(f)+rem_byte(q)).qqqq;@/
1496 @<Compute the minimum suitable height, |w|, and the corresponding
1497 number of extension steps, |n|; also set |width(b)|@>;
1498 c:=ext_bot(f)(r);
1499 if c<>min_quarterword then stack_into_box(b,f,c);
1500 c:=ext_rep(f)(r);
1501 for m:=1 to n do stack_into_box(b,f,c);
1502 c:=ext_mid(f)(r);
1503 if c<>min_quarterword then
1504 begin stack_into_box(b,f,c); c:=ext_rep(f)(r);
1505 for m:=1 to n do stack_into_box(b,f,c);
1506 end;
1507 c:=ext_top(f)(r);
1508 @z
1509 %---------------------------------------
1510 @x [35] m.714 l.13997 - Omega
1511 c:=ext_rep(r); u:=height_plus_depth(f,c);
1512 w:=0; q:=char_info(f)(c); width(b):=char_width(f)(q)+char_italic(f)(q);@/
1513 c:=ext_bot(r);@+if c<>min_quarterword then w:=w+height_plus_depth(f,c);
1514 c:=ext_mid(r);@+if c<>min_quarterword then w:=w+height_plus_depth(f,c);
1515 c:=ext_top(r);@+if c<>min_quarterword then w:=w+height_plus_depth(f,c);
1516 n:=0;
1517 if u>0 then while w<v do
1518 begin w:=w+u; incr(n);
1519 if ext_mid(r)<>min_quarterword then w:=w+u;
1520 end
1521 @y
1522 c:=ext_rep(f)(r); u:=height_plus_depth(f,c);
1523 w:=0; q:=char_info(f)(c); width(b):=char_width(f)(q)+char_italic(f)(q);@/
1524 c:=ext_bot(f)(r);@+if c<>min_quarterword then w:=w+height_plus_depth(f,c);
1525 c:=ext_mid(f)(r);@+if c<>min_quarterword then w:=w+height_plus_depth(f,c);
1526 c:=ext_top(f)(r);@+if c<>min_quarterword then w:=w+height_plus_depth(f,c);
1527 n:=0;
1528 if u>0 then while w<v do
1529 begin w:=w+u; incr(n);
1530 if (ext_mid(f)(r))<>min_quarterword then w:=w+u;
1531 end
1532 @z
1533 %---------------------------------------
1534 @x [36] m.719 l.14107 - Omega
1535 @!cur_style:small_number; {style code at current place in the list}
1536 @!cur_size:small_number; {size code corresponding to |cur_style|}
1537 @y
1538 @!cur_style:integer; {style code at current place in the list}
1539 @!cur_size:integer; {size code corresponding to |cur_style|}
1540 @z
1541 %---------------------------------------
1542 @x [36] m.720 l.14122 - Omega
1543 function clean_box(@!p:pointer;@!s:small_number):pointer;
1544 label found;
1545 var q:pointer; {beginning of a list to be boxed}
1546 @!save_style:small_number; {|cur_style| to be restored}
1547 @y
1548 function clean_box(@!p:pointer;@!s:integer):pointer;
1549 label found;
1550 var q:pointer; {beginning of a list to be boxed}
1551 @!save_style:integer; {|cur_style| to be restored}
1552 @z
1553 %---------------------------------------
1554 @x [36] m.722 l.14172 - Omega
1555 else begin if (qo(cur_c)>=font_bc[cur_f])and(qo(cur_c)<=font_ec[cur_f]) then
1556 @y
1557 else begin if (qo(cur_c)>=font_bc(cur_f))and(qo(cur_c)<=font_ec(cur_f)) then
1558 @z
1559 %---------------------------------------
1560 @x [36] m.726 l.14228 - Omega
1561 procedure mlist_to_hlist;
1562 label reswitch, check_dimensions, done_with_noad, done_with_node, delete_q,
1563 done;
1564 var mlist:pointer; {beginning of the given list}
1565 @!penalties:boolean; {should penalty nodes be inserted?}
1566 @!style:small_number; {the given style}
1567 @!save_style:small_number; {holds |cur_style| during recursion}
1568 @!q:pointer; {runs through the mlist}
1569 @!r:pointer; {the most recent noad preceding |q|}
1570 @!r_type:small_number; {the |type| of noad |r|, or |op_noad| if |r=null|}
1571 @!t:small_number; {the effective |type| of noad |q| during the second pass}
1572 @!p,@!x,@!y,@!z: pointer; {temporary registers for list construction}
1573 @!pen:integer; {a penalty to be inserted}
1574 @!s:small_number; {the size of a noad to be deleted}
1575 @y
1576 procedure mlist_to_hlist;
1577 label reswitch, check_dimensions, done_with_noad, done_with_node, delete_q,
1578 done;
1579 var mlist:pointer; {beginning of the given list}
1580 @!penalties:boolean; {should penalty nodes be inserted?}
1581 @!style:integer; {the given style}
1582 @!save_style:integer; {holds |cur_style| during recursion}
1583 @!q:pointer; {runs through the mlist}
1584 @!r:pointer; {the most recent noad preceding |q|}
1585 @!r_type:integer; {the |type| of noad |r|, or |op_noad| if |r=null|}
1586 @!t:integer; {the effective |type| of noad |q| during the second pass}
1587 @!p,@!x,@!y,@!z: pointer; {temporary registers for list construction}
1588 @!pen:integer; {a penalty to be inserted}
1589 @!s:integer; {the size of a noad to be deleted}
1590 @z
1591 %---------------------------------------
1592 @x [36] m.741 l.14495 - Omega
1593 if math_type(nucleus(q))=math_char then
1594 begin fetch(nucleus(q));
1595 if char_tag(cur_i)=lig_tag then
1596 begin a:=lig_kern_start(cur_f)(cur_i);
1597 cur_i:=font_info[a].qqqq;
1598 if skip_byte(cur_i)>stop_flag then
1599 begin a:=lig_kern_restart(cur_f)(cur_i);
1600 cur_i:=font_info[a].qqqq;
1601 end;
1602 loop@+ begin if qo(next_char(cur_i))=skew_char[cur_f] then
1603 begin if op_byte(cur_i)>=kern_flag then
1604 if skip_byte(cur_i)<=stop_flag then s:=char_kern(cur_f)(cur_i);
1605 goto done1;
1606 end;
1607 if skip_byte(cur_i)>=stop_flag then goto done1;
1608 a:=a+qo(skip_byte(cur_i))+1;
1609 cur_i:=font_info[a].qqqq;
1610 end;
1611 end;
1612 end;
1613 done1:
1614 @y
1615 if math_type(nucleus(q))=math_char then
1616 begin fetch(nucleus(q));
1617 if char_tag(cur_i)=lig_tag then
1618 begin a:=lig_kern_start(cur_f)(cur_i);
1619 cur_i:=font_info(cur_f)(a).qqqq;
1620 if skip_byte(cur_i)>stop_flag then
1621 begin a:=lig_kern_restart(cur_f)(cur_i);
1622 cur_i:=font_info(cur_f)(a).qqqq;
1623 end;
1624 loop@+ begin if qo((next_char(cur_f)(cur_i)))=skew_char(cur_f) then
1625 begin if op_byte(cur_i)>=kern_flag then
1626 if skip_byte(cur_i)<=stop_flag then s:=char_kern(cur_f)(cur_i);
1627 goto done1;
1628 end;
1629 if skip_byte(cur_i)>=stop_flag then goto done1;
1630 a:=a+qo(skip_byte(cur_i))+1;
1631 cur_i:=font_info(cur_f)(a).qqqq;
1632 end;
1633 end;
1634 end;
1635 done1:
1636 @z
1637 %---------------------------------------
1638 @x [36] m.752 l.14722 - Omega
1639 cur_i:=font_info[a].qqqq;
1640 if skip_byte(cur_i)>stop_flag then
1641 begin a:=lig_kern_restart(cur_f)(cur_i);
1642 cur_i:=font_info[a].qqqq;
1643 end;
1644 loop@+ begin @<If instruction |cur_i| is a kern with |cur_c|, attach
1645 the kern after~|q|; or if it is a ligature with |cur_c|, combine
1646 noads |q| and~|p| appropriately; then |return| if the cursor has
1647 moved past a noad, or |goto restart|@>;
1648 if skip_byte(cur_i)>=stop_flag then return;
1649 a:=a+qo(skip_byte(cur_i))+1;
1650 cur_i:=font_info[a].qqqq;
1651 @y
1652 cur_i:=font_info(cur_f)(a).qqqq;
1653 if skip_byte(cur_i)>stop_flag then
1654 begin a:=lig_kern_restart(cur_f)(cur_i);
1655 cur_i:=font_info(cur_f)(a).qqqq;
1656 end;
1657 loop@+ begin @<If instruction |cur_i| is a kern with |cur_c|, attach
1658 the kern after~|q|; or if it is a ligature with |cur_c|, combine
1659 noads |q| and~|p| appropriately; then |return| if the cursor has
1660 moved past a noad, or |goto restart|@>;
1661 if skip_byte(cur_i)>=stop_flag then return;
1662 a:=a+qo(skip_byte(cur_i))+1;
1663 cur_i:=font_info(cur_f)(a).qqqq;
1664 @z
1665 %---------------------------------------
1666 @x [36] m.753 l.14751 - Omega
1667 if next_char(cur_i)=cur_c then if skip_byte(cur_i)<=stop_flag then
1668 @y
1669 if (next_char(cur_f)(cur_i))=cur_c then if skip_byte(cur_i)<=stop_flag then
1670 @z
1671 %---------------------------------------
1672 @x [36] m.756 l.14833 - Omega
1673 procedure make_scripts(@!q:pointer;@!delta:scaled);
1674 var p,@!x,@!y,@!z:pointer; {temporary registers for box construction}
1675 @!shift_up,@!shift_down,@!clr:scaled; {dimensions in the calculation}
1676 @!t:small_number; {subsidiary size code}
1677 begin p:=new_hlist(q);
1678 if is_char_node(p) then
1679 begin shift_up:=0; shift_down:=0;
1680 end
1681 else begin z:=hpack(p,natural);
1682 if cur_style<script_style then t:=script_size@+else t:=script_script_size;
1683 shift_up:=height(z)-sup_drop(t);
1684 shift_down:=depth(z)+sub_drop(t);
1685 @y
1686 procedure make_scripts(@!q:pointer;@!delta:scaled);
1687 var p,@!x,@!y,@!z:pointer; {temporary registers for box construction}
1688 @!shift_up,@!shift_down,@!clr:scaled; {dimensions in the calculation}
1689 @!t:integer; {subsidiary size code}
1690 begin p:=new_hlist(q);
1691 if is_char_node(p) then
1692 begin shift_up:=0; shift_down:=0;
1693 end
1694 else begin z:=hpack(p,natural);
1695 t:=cur_size;
1696 if cur_style<script_style
1697 then cur_size:=script_size@+else cur_size:=script_script_size;
1698 shift_up:=height(z)-sup_drop(cur_size);
1699 shift_down:=depth(z)+sub_drop(cur_size);
1700 cur_size:=t;
1701 @z
1702 %---------------------------------------
1703 @x [36] m.762 l.14967 - Omega
1704 function make_left_right(@!q:pointer;@!style:small_number;
1705 @!max_d,@!max_h:scaled):small_number;
1706 var delta,@!delta1,@!delta2:scaled; {dimensions used in the calculation}
1707 begin if style<script_style then cur_size:=text_size
1708 else cur_size:=16*((style-text_style) div 2);
1709 @y
1710 function make_left_right(@!q:pointer;@!style:integer;
1711 @!max_d,@!max_h:scaled):integer;
1712 var delta,@!delta1,@!delta2:scaled; {dimensions used in the calculation}
1713 begin if style<script_style then cur_size:=text_size
1714 else cur_size:=script_size*((style-text_style) div 2);
1715 @z
1716 %---------------------------------------
1717 @x [40] m.896 l.17534 - Omega
1718 done2: hyf_char:=hyphen_char[hf];
1719 @y
1720 done2: hyf_char:=hyphen_char(hf);
1721 @z
1722 %---------------------------------------
1723 @x [40] m.897 l.17555 - Omega
1724 hyf_bchar:=font_bchar[hf];
1725 @y
1726 hyf_bchar:=font_bchar(hf);
1727 @z
1728 %---------------------------------------
1729 @x [40] m.898 l.17578 - Omega
1730 if odd(subtype(s)) then hyf_bchar:=font_bchar[hf]@+else hyf_bchar:=non_char;
1731 @y
1732 if odd(subtype(s)) then hyf_bchar:=font_bchar(hf)@+else hyf_bchar:=non_char;
1733 @z
1734 %---------------------------------------
1735 @x [41] m.909 l.17800 - Omega
1736 begin k:=bchar_label[hf];
1737 if k=non_address then goto done@+else q:=font_info[k].qqqq;
1738 end
1739 else begin q:=char_info(hf)(cur_l);
1740 if char_tag(q)<>lig_tag then goto done;
1741 k:=lig_kern_start(hf)(q); q:=font_info[k].qqqq;
1742 if skip_byte(q)>stop_flag then
1743 begin k:=lig_kern_restart(hf)(q); q:=font_info[k].qqqq;
1744 @y
1745 begin k:=bchar_label(hf);
1746 if k=non_address then goto done@+else q:=font_info(hf)(k).qqqq;
1747 end
1748 else begin q:=char_info(hf)(cur_l);
1749 if char_tag(q)<>lig_tag then goto done;
1750 k:=lig_kern_start(hf)(q); q:=font_info(hf)(k).qqqq;
1751 if skip_byte(q)>stop_flag then
1752 begin k:=lig_kern_restart(hf)(q); q:=font_info(hf)(k).qqqq;
1753 @z
1754 %---------------------------------------
1755 @x [41] m.909 l.17811 - Omega
1756 loop@+begin if next_char(q)=test_char then if skip_byte(q)<=stop_flag then
1757 @y
1758 loop@+begin if (next_char(hf)(q))=test_char then if skip_byte(q)<=stop_flag then
1759 @z
1760 %---------------------------------------
1761 @x [41] m.909 l.17829 - Omega
1762 k:=k+qo(skip_byte(q))+1; q:=font_info[k].qqqq;
1763 @y
1764 k:=k+qo(skip_byte(q))+1; q:=font_info(hf)(k).qqqq;
1765 @z
1766 %---------------------------------------
1767 @x [41] m.915 l.17963 - Omega
1768 begin l:=reconstitute(l,i,font_bchar[hf],non_char)+1;
1769 @y
1770 begin l:=reconstitute(l,i,font_bchar(hf),non_char)+1;
1771 @z
1772 %---------------------------------------
1773 @x [41] m.916 l.17980 - Omega
1774 if bchar_label[hf]<>non_address then {put left boundary at beginning of new line}
1775 @y
1776 if bchar_label(hf)<>non_address then {put left boundary at beginning of new line}
1777 @z
1778 %---------------------------------------
1779 @x [46] m.1030 l.19987 - Omega
1780 hmode+no_boundary: begin get_x_token;
1781 if (cur_cmd=letter)or(cur_cmd=other_char)or(cur_cmd=char_given)or
1782 (cur_cmd=char_num) then cancel_boundary:=true;
1783 goto reswitch;
1784 end;
1785 @y
1786 hmode+no_boundary: begin get_x_token;
1787 if (cur_cmd=letter)or(cur_cmd=other_char)or(cur_cmd=char_given)or
1788 (cur_cmd=char_num) then cancel_boundary:=true;
1789 goto reswitch;
1790 end;
1791 hmode+char_ghost: begin t:=cur_chr; get_x_token;
1792 if (cur_cmd=letter)or(cur_cmd=other_char)or(cur_cmd=char_given)or
1793 (cur_cmd=char_num) then begin
1794 if t=0 then new_left_ghost:=true
1795 else new_right_ghost:=true;
1796 end;
1797 goto reswitch;
1798 end;
1799 @z
1800 %---------------------------------------
1801 @x [46] m.1032 l.20030 - Omega
1802 |font_bchar[cur_font]|,&otherwise;\cr}$$
1803 except when |character(lig_stack)=font_false_bchar[cur_font]|.
1804 @y
1805 |font_bchar(cur_font)|,&otherwise;\cr}$$
1806 except when |character(lig_stack)=font_false_bchar(cur_font)|.
1807 @z
1808 %---------------------------------------
1809 @x [46] m.1032
1810 @!cancel_boundary:boolean; {should the left boundary be ignored?}
1811 @!ins_disc:boolean; {should we insert a discretionary node?}
1812 @y
1813 @!cancel_boundary:boolean; {should the left boundary be ignored?}
1814 @!left_ghost:boolean; {character left of cursor is a left ghost}
1815 @!right_ghost:boolean; {character left of cursor is a right ghost}
1816 @!new_left_ghost:boolean; {character right of cursor is a left ghost}
1817 @!new_right_ghost:boolean; {character right of cursor is a right ghost}
1818 @!ins_disc:boolean; {should we insert a discretionary node?}
1819 @!k_glue:integer;
1820 @!font_glue_spec:pointer;
1821 @z
1822 %---------------------------------------
1823 @x [46] m.1033
1824 ligature_present:=false; cancel_boundary:=false; lft_hit:=false; rt_hit:=false;
1825 @y
1826 ligature_present:=false; cancel_boundary:=false; lft_hit:=false; rt_hit:=false;
1827 left_ghost:=false; right_ghost:=false;
1828 new_left_ghost:=false; new_right_ghost:=false;
1829 @z
1830 %---------------------------------------
1831 @x [46] m.1034 l.20075 - Omega
1832 adjust_space_factor;@/
1833 main_f:=cur_font;
1834 bchar:=font_bchar[main_f]; false_bchar:=font_false_bchar[main_f];
1835 if mode>0 then if language<>clang then fix_language;
1836 fast_get_avail(lig_stack); font(lig_stack):=main_f; cur_l:=qi(cur_chr);
1837 character(lig_stack):=cur_l;@/
1838 cur_q:=tail;
1839 if cancel_boundary then
1840 begin cancel_boundary:=false; main_k:=non_address;
1841 end
1842 else main_k:=bchar_label[main_f];
1843 if main_k=non_address then goto main_loop_move+2; {no left boundary processing}
1844 cur_r:=cur_l; cur_l:=non_char;
1845 goto main_lig_loop+1; {begin with cursor after left boundary}
1846 @y
1847 adjust_space_factor;@/
1848 main_f:=cur_font;
1849 bchar:=font_bchar(main_f); false_bchar:=font_false_bchar(main_f);
1850 if mode>0 then if language<>clang then fix_language;
1851 fast_get_avail(lig_stack); font(lig_stack):=main_f; cur_l:=qi(cur_chr);
1852 character(lig_stack):=cur_l;@/
1853 cur_q:=tail;
1854 if cancel_boundary then
1855 begin cancel_boundary:=false; main_k:=non_address;
1856 left_ghost:=new_left_ghost; right_ghost:=new_right_ghost;
1857 new_left_ghost:=false; new_right_ghost:=false;
1858 end
1859 else main_k:=bchar_label(main_f);
1860 if main_k=non_address then goto main_loop_move+2; {no left boundary processing}
1861 cur_r:=cur_l; cur_l:=non_char;
1862 if not new_right_ghost then
1863 goto main_lig_loop+1; {begin with cursor after left boundary}
1864 @z
1865 %---------------------------------------
1866 @x [46] m.1035 l.20122 - Omega
1867 begin if link(cur_q)>null then
1868 if character(tail)=qi(hyphen_char[main_f]) then ins_disc:=true;
1869 @y
1870 begin if link(cur_q)>null then
1871 if character(tail)=qi(hyphen_char(main_f)) then ins_disc:=true;
1872 @z
1873 %---------------------------------------
1874 @x [46] m.1036 l.20135 - Omega
1875 if lig_stack=null then goto reswitch;
1876 cur_q:=tail; cur_l:=character(lig_stack);
1877 main_loop_move+1:if not is_char_node(lig_stack) then goto main_loop_move_lig;
1878 main_loop_move+2:if(cur_chr<font_bc[main_f])or(cur_chr>font_ec[main_f]) then
1879 begin char_warning(main_f,cur_chr); free_avail(lig_stack); goto big_switch;
1880 end;
1881 main_i:=char_info(main_f)(cur_l);
1882 if not char_exists(main_i) then
1883 begin char_warning(main_f,cur_chr); free_avail(lig_stack); goto big_switch;
1884 end;
1885 link(tail):=lig_stack; tail:=lig_stack {|main_loop_lookahead| is next}
1886 @y
1887 if lig_stack=null then goto reswitch;
1888 cur_q:=tail; cur_l:=character(lig_stack);
1889 main_loop_move+1:if not is_char_node(lig_stack) then goto main_loop_move_lig;
1890 main_loop_move+2:
1891 left_ghost:=new_left_ghost; right_ghost:=new_right_ghost;
1892 new_left_ghost:=false; new_right_ghost:=false;
1893 if(cur_chr<font_bc(main_f))or(cur_chr>font_ec(main_f)) then
1894 begin char_warning(main_f,cur_chr); free_avail(lig_stack); goto big_switch;
1895 end;
1896 main_i:=char_info(main_f)(cur_l);
1897 if not char_exists(main_i) then
1898 begin char_warning(main_f,cur_chr); free_avail(lig_stack); goto big_switch;
1899 end;
1900 if not (left_ghost or right_ghost) then
1901 tail_append(lig_stack) {|main_loop_lookahead| is next}
1902 @z
1903 %---------------------------------------
1904 @x [46] m.1038 l.20177 - Omega
1905 if cur_cmd=no_boundary then bchar:=non_char;
1906 @y
1907 if cur_cmd=char_ghost then begin t:=cur_chr; get_x_token;
1908 if (cur_cmd=letter)or(cur_cmd=other_char)or(cur_cmd=char_given)or
1909 (cur_cmd=char_num) then begin
1910 if t=0 then new_left_ghost:=true
1911 else new_right_ghost:=true;
1912 back_input;
1913 goto main_loop_lookahead;
1914 end;
1915 end;
1916 if cur_cmd=no_boundary then bchar:=non_char;
1917 @z
1918 %---------------------------------------
1919 @x [46] m.1039 l.20193 - Omega
1920 @<If there's a ligature/kern command...@>=
1921 if char_tag(main_i)<>lig_tag then goto main_loop_wrapup;
1922 if cur_r=non_char then goto main_loop_wrapup;
1923 main_k:=lig_kern_start(main_f)(main_i); main_j:=font_info[main_k].qqqq;
1924 if skip_byte(main_j)<=stop_flag then goto main_lig_loop+2;
1925 main_k:=lig_kern_restart(main_f)(main_j);
1926 main_lig_loop+1:main_j:=font_info[main_k].qqqq;
1927 main_lig_loop+2:if next_char(main_j)=cur_r then
1928 if skip_byte(main_j)<=stop_flag then
1929 @<Do ligature or kern command, returning to |main_lig_loop|
1930 or |main_loop_wrapup| or |main_loop_move|@>;
1931 if skip_byte(main_j)=qi(0) then incr(main_k)
1932 else begin if skip_byte(main_j)>=stop_flag then goto main_loop_wrapup;
1933 main_k:=main_k+qo(skip_byte(main_j))+1;
1934 end;
1935 goto main_lig_loop+1
1936 @y
1937 @<If there's a ligature/kern command...@>=
1938 if new_right_ghost or left_ghost then goto main_loop_wrapup;
1939 if char_tag(main_i)<>lig_tag then goto main_loop_wrapup;
1940 main_k:=lig_kern_start(main_f)(main_i);
1941 main_j:=font_info(main_f)(main_k).qqqq;
1942 if skip_byte(main_j)<=stop_flag then goto main_lig_loop+2;
1943 main_k:=lig_kern_restart(main_f)(main_j);
1944 main_lig_loop+1: main_j:=font_info(main_f)(main_k).qqqq;
1945 main_lig_loop+2:if top_skip_byte(main_j)=0 then begin
1946 if next_char(main_f)(main_j)=cur_r then
1947 if skip_byte(main_j)<=stop_flag then
1948 @<Do ligature or kern command, returning to |main_lig_loop|
1949 or |main_loop_wrapup| or |main_loop_move|@>;
1950 end
1951 else begin
1952 if (font_bc(main_f)<=cur_r) then
1953 if (font_ec(main_f)>=cur_r) then
1954 if (char_exists(char_info(main_f)(cur_r))) then
1955 if cur_r<>bchar then
1956 if next_char(main_f)(main_j)=
1957 attr_zero_char_ivalue(main_f)(cur_r) then
1958 @<Do glue or penalty command@>;
1959 end;
1960 if skip_byte(main_j)=qi(0) then incr(main_k)
1961 else begin if skip_byte(main_j)>=stop_flag then goto main_loop_wrapup;
1962 main_k:=main_k+qo(skip_byte(main_j))+1;
1963 end;
1964 goto main_lig_loop+1
1965
1966 @ There are currently three commands. Command 17 will add a penalty
1967 node between the two characters. Command 18 will add a glue
1968 node between the two characters. Command 19 will add a penalty node,
1969 then a glue node between the two characters. Command 20
1970 will add a kern nore between the two characters.
1971
1972 @<Do glue or penalty command@>=
1973 begin
1974 if new_left_ghost or right_ghost then goto main_loop_wrapup;
1975 case op_byte(main_j) of
1976 qi(20): begin wrapup(rt_hit);
1977 tail_append(new_kern(attr_zero_kern(main_f)(rem_byte(main_j))));
1978 end;
1979 qi(18): begin wrapup(rt_hit);
1980 k_glue:=glues_base(main_f) + (rem_byte(main_j)*4);
1981 font_glue_spec:=new_spec(zero_glue);
1982 width(font_glue_spec):= font_info(main_f)(k_glue+1).sc;
1983 stretch(font_glue_spec):=font_info(main_f)(k_glue+2).sc;
1984 shrink(font_glue_spec):=font_info(main_f)(k_glue+3).sc;
1985 tail_append(new_glue(font_glue_spec));
1986 end;
1987 qi(19): begin wrapup(rt_hit);
1988 tail_append(new_penalty(attr_zero_penalty(main_f)(rem_top_byte(main_j))));
1989 k_glue:=glues_base(main_f) + (rem_bot_byte(main_j)*4);
1990 font_glue_spec:=new_spec(zero_glue);
1991 width(font_glue_spec):= font_info(main_f)(k_glue+1).sc;
1992 stretch(font_glue_spec):=font_info(main_f)(k_glue+2).sc;
1993 shrink(font_glue_spec):=font_info(main_f)(k_glue+3).sc;
1994 tail_append(new_glue(font_glue_spec));
1995 end;
1996 qi(17): begin wrapup(rt_hit);
1997 tail_append(new_penalty(attr_zero_penalty(main_f)(rem_byte(main_j))));
1998 end;
1999 end;
2000 goto main_loop_move;
2001 end
2002 @z
2003 %---------------------------------------
2004 @x [46] m.1040 l.20219 - Omega
2005 begin if op_byte(main_j)>=kern_flag then
2006 begin wrapup(rt_hit);
2007 tail_append(new_kern(char_kern(main_f)(main_j))); goto main_loop_move;
2008 end;
2009 if cur_l=non_char then lft_hit:=true
2010 else if lig_stack=null then rt_hit:=true;
2011 check_interrupt; {allow a way out in case there's an infinite ligature loop}
2012 case op_byte(main_j) of
2013 qi(1),qi(5):begin cur_l:=rem_byte(main_j); {\.{=:\?}, \.{=:\?>}}
2014 main_i:=char_info(main_f)(cur_l); ligature_present:=true;
2015 end;
2016 qi(2),qi(6):begin cur_r:=rem_byte(main_j); {\.{\?=:}, \.{\?=:>}}
2017 if lig_stack=null then {right boundary character is being consumed}
2018 begin lig_stack:=new_lig_item(cur_r); bchar:=non_char;
2019 end
2020 else if is_char_node(lig_stack) then {|link(lig_stack)=null|}
2021 begin main_p:=lig_stack; lig_stack:=new_lig_item(cur_r);
2022 lig_ptr(lig_stack):=main_p;
2023 end
2024 else character(lig_stack):=cur_r;
2025 end;
2026 qi(3):begin cur_r:=rem_byte(main_j); {\.{\?=:\?}}
2027 main_p:=lig_stack; lig_stack:=new_lig_item(cur_r);
2028 link(lig_stack):=main_p;
2029 end;
2030 qi(7),qi(11):begin wrapup(false); {\.{\?=:\?>}, \.{\?=:\?>>}}
2031 cur_q:=tail; cur_l:=rem_byte(main_j);
2032 main_i:=char_info(main_f)(cur_l); ligature_present:=true;
2033 end;
2034 othercases begin cur_l:=rem_byte(main_j); ligature_present:=true; {\.{=:}}
2035 if lig_stack=null then goto main_loop_wrapup
2036 else goto main_loop_move+1;
2037 end
2038 endcases;
2039 if op_byte(main_j)>qi(4) then
2040 if op_byte(main_j)<>qi(7) then goto main_loop_wrapup;
2041 if cur_l<non_char then goto main_lig_loop;
2042 main_k:=bchar_label[main_f]; goto main_lig_loop+1;
2043 end
2044 @y
2045 begin if op_byte(main_j)>=kern_flag then
2046 begin wrapup(rt_hit);
2047 tail_append(new_kern(char_kern(main_f)(main_j)));
2048 if new_left_ghost or right_ghost then begin
2049 subtype(tail):=explicit;
2050 end;
2051 goto main_loop_move;
2052 end;
2053 if new_left_ghost or right_ghost then goto main_loop_wrapup;
2054 if cur_l=non_char then lft_hit:=true
2055 else if lig_stack=null then rt_hit:=true;
2056 check_interrupt; {allow a way out in case there's an infinite ligature loop}
2057 case op_byte(main_j) of
2058 qi(1),qi(5):begin cur_l:=rem_char_byte(main_f)(main_j); {\.{=:\?}, \.{=:\?>}}
2059 main_i:=char_info(main_f)(cur_l); ligature_present:=true;
2060 end;
2061 qi(2),qi(6):begin cur_r:=rem_char_byte(main_f)(main_j); {\.{\?=:}, \.{\?=:>}}
2062 if lig_stack=null then {right boundary character is being consumed}
2063 begin lig_stack:=new_lig_item(cur_r); bchar:=non_char;
2064 end
2065 else if is_char_node(lig_stack) then {|link(lig_stack)=null|}
2066 begin main_p:=lig_stack; lig_stack:=new_lig_item(cur_r);
2067 lig_ptr(lig_stack):=main_p;
2068 end
2069 else character(lig_stack):=cur_r;
2070 end;
2071 qi(3):begin cur_r:=rem_char_byte(main_f)(main_j); {\.{\?=:\?}}
2072 main_p:=lig_stack; lig_stack:=new_lig_item(cur_r);
2073 link(lig_stack):=main_p;
2074 end;
2075 qi(7),qi(11):begin wrapup(false); {\.{\?=:\?>}, \.{\?=:\?>>}}
2076 cur_q:=tail; cur_l:=rem_char_byte(main_f)(main_j);
2077 main_i:=char_info(main_f)(cur_l); ligature_present:=true;
2078 end;
2079 othercases begin cur_l:=rem_char_byte(main_f)(main_j);
2080 ligature_present:=true; {\.{=:}}
2081 if lig_stack=null then goto main_loop_wrapup
2082 else goto main_loop_move+1;
2083 end
2084 endcases;
2085 if op_byte(main_j)>qi(4) then
2086 if op_byte(main_j)<>qi(7) then goto main_loop_wrapup;
2087 if cur_l<non_char then goto main_lig_loop;
2088 main_k:=bchar_label(main_f); goto main_lig_loop+1;
2089 end
2090 @z
2091 %---------------------------------------
2092 @x [46] m.1042 l.20285 - Omega
2093 begin main_p:=font_glue[cur_font];
2094 if main_p=null then
2095 begin main_p:=new_spec(zero_glue); main_k:=param_base[cur_font]+space_code;
2096 width(main_p):=font_info[main_k].sc; {that's |space(cur_font)|}
2097 stretch(main_p):=font_info[main_k+1].sc; {and |space_stretch(cur_font)|}
2098 shrink(main_p):=font_info[main_k+2].sc; {and |space_shrink(cur_font)|}
2099 font_glue[cur_font]:=main_p;
2100 @y
2101 begin main_p:=font_glue(cur_font);
2102 if main_p=null then
2103 begin main_p:=new_spec(zero_glue); main_k:=param_base(cur_font)+space_code;
2104 width(main_p):=font_info(cur_font)(main_k).sc; {that's |space(cur_font)|}
2105 stretch(main_p):=font_info(cur_font)(main_k+1).sc;
2106 {and |space_stretch(cur_font)|}
2107 shrink(main_p):=font_info(cur_font)(main_k+2).sc;
2108 {and |space_shrink(cur_font)|}
2109 font_glue(cur_font):=main_p;
2110 @z
2111 %---------------------------------------
2112 @x [47] m.1090
2113 vmode+letter,vmode+other_char,vmode+char_num,vmode+char_given,
2114 @y
2115 vmode+letter,vmode+other_char,vmode+char_num,vmode+char_given,
2116 vmode+char_ghost,
2117 @z
2118 %---------------------------------------
2119 @x [48] m.1117 l.21343 - Omega
2120 begin c:=hyphen_char[cur_font];
2121 @y
2122 begin c:=hyphen_char(cur_font);
2123 @z
2124 %---------------------------------------
2125 @x [49] m.1195 l.22361 - Omega
2126 if (font_params[fam_fnt(2+text_size)]<total_mathsy_params)or@|
2127 (font_params[fam_fnt(2+script_size)]<total_mathsy_params)or@|
2128 (font_params[fam_fnt(2+script_script_size)]<total_mathsy_params) then
2129 begin print_err("Math formula deleted: Insufficient symbol fonts");@/
2130 @.Math formula deleted...@>
2131 help3("Sorry, but I can't typeset math unless \textfont 2")@/
2132 ("and \scriptfont 2 and \scriptscriptfont 2 have all")@/
2133 ("the \fontdimen values needed in math symbol fonts.");
2134 error; flush_math; danger:=true;
2135 end
2136 else if (font_params[fam_fnt(3+text_size)]<total_mathex_params)or@|
2137 (font_params[fam_fnt(3+script_size)]<total_mathex_params)or@|
2138 (font_params[fam_fnt(3+script_script_size)]<total_mathex_params) then
2139 @y
2140 if (font_params(fam_fnt(2+text_size))<total_mathsy_params)or@|
2141 (font_params(fam_fnt(2+script_size))<total_mathsy_params)or@|
2142 (font_params(fam_fnt(2+script_script_size))<total_mathsy_params) then
2143 begin print_err("Math formula deleted: Insufficient symbol fonts");@/
2144 @.Math formula deleted...@>
2145 help3("Sorry, but I can't typeset math unless \textfont 2")@/
2146 ("and \scriptfont 2 and \scriptscriptfont 2 have all")@/
2147 ("the \fontdimen values needed in math symbol fonts.");
2148 error; flush_math; danger:=true;
2149 end
2150 else if (font_params(fam_fnt(3+text_size))<total_mathex_params)or@|
2151 (font_params(fam_fnt(3+script_size))<total_mathex_params)or@|
2152 (font_params(fam_fnt(3+script_script_size))<total_mathex_params) then
2153 @z
2154 %---------------------------------------
2155 @x [49] m.1253 l.23250 - Omega
2156 assign_font_dimen: begin find_font_dimen(true); k:=cur_val;
2157 scan_optional_equals; scan_normal_dimen; font_info[k].sc:=cur_val;
2158 end;
2159 assign_font_int: begin n:=cur_chr; scan_font_ident; f:=cur_val;
2160 scan_optional_equals; scan_int;
2161 if n=0 then hyphen_char[f]:=cur_val@+else skew_char[f]:=cur_val;
2162 @y
2163 assign_font_dimen: begin find_font_dimen(true); k:=cur_val;
2164 scan_optional_equals; scan_normal_dimen;
2165 font_info(dimen_font)(k).sc:=cur_val;
2166 end;
2167 assign_font_int: begin n:=cur_chr; scan_font_ident; f:=cur_val;
2168 scan_optional_equals; scan_int;
2169 if n=0 then hyphen_char(f):=cur_val@+else skew_char(f):=cur_val;
2170 @z
2171 %---------------------------------------
2172 @x [49] m.1257 l.23269 - Omega
2173 @!flushable_string:str_number; {string not yet referenced}
2174 begin if job_name=0 then open_log_file;
2175 {avoid confusing \.{texput} with the font name}
2176 @.texput@>
2177 get_r_token; u:=cur_cs;
2178 if u>=hash_base then t:=text(u)
2179 @y
2180 @!offset:integer;
2181 @!flushable_string:str_number; {string not yet referenced}
2182 begin if job_name=0 then open_log_file;
2183 {avoid confusing \.{texput} with the font name}
2184 @.texput@>
2185 get_r_token; u:=cur_cs;
2186 if u>=hash_base then t:=newtext(u)
2187 @z
2188 %---------------------------------------
2189 @x [49] m.1257 l.23290 - Omega
2190 @<Scan the font size specification@>;
2191 @<If this font has already been loaded, set |f| to the internal
2192 font number and |goto common_ending|@>;
2193 f:=read_font_info(u,cur_name,cur_area,s);
2194 common_ending: equiv(u):=f; eqtb[font_id_base+f]:=eqtb[u]; font_id_text(f):=t;
2195 @y
2196 @<Scan the font size specification@>;
2197 name_in_progress:=true;
2198 if scan_keyword("offset") then begin
2199 scan_int;
2200 offset:=cur_val;
2201 if (cur_val<0) then begin
2202 print_err("Illegal offset has been changed to 0");
2203 help1("The offset must be bigger than 0."); int_error(cur_val);
2204 offset:=0;
2205 end
2206 end
2207 else offset:=0;
2208 name_in_progress:=false;
2209 @<If this font has already been loaded, set |f| to the internal
2210 font number and |goto common_ending|@>;
2211 f:=read_font_info(u,cur_name,cur_area,s,offset);
2212 common_ending: set_equiv(u,f);
2213 set_new_eqtb(font_id_base+f,new_eqtb(u)); settext(font_id_base+f,t);
2214 @z
2215 %---------------------------------------
2216 @x [49] m.1260 l.23333 - Omega
2217 for f:=font_base+1 to font_ptr do
2218 if str_eq_str(font_name[f],cur_name)and str_eq_str(font_area[f],cur_area) then
2219 begin if cur_name=flushable_string then
2220 begin flush_string; cur_name:=font_name[f];
2221 end;
2222 if s>0 then
2223 begin if s=font_size[f] then goto common_ending;
2224 end
2225 else if font_size[f]=xn_over_d(font_dsize[f],-s,1000) then
2226 goto common_ending;
2227 end
2228 @y
2229 for f:=font_base+1 to font_ptr do begin
2230 if str_eq_str(font_name(f),cur_name) and
2231 str_eq_str(font_area(f),cur_area) then
2232 begin if cur_name=flushable_string then
2233 begin flush_string; cur_name:=font_name(f);
2234 end;
2235 if s>0 then
2236 begin if s=font_size(f) then goto common_ending;
2237 end
2238 else if font_size(f)=xn_over_d(font_dsize(f),-s,1000) then
2239 goto common_ending;
2240 end
2241 end
2242 @z
2243 %---------------------------------------
2244 @x [49] m.1261 l.23345 - Omega
2245 set_font:begin print("select font "); slow_print(font_name[chr_code]);
2246 if font_size[chr_code]<>font_dsize[chr_code] then
2247 begin print(" at "); print_scaled(font_size[chr_code]);
2248 @y
2249 set_font:begin print("select font "); slow_print(font_name(chr_code));
2250 if font_size(chr_code)<>font_dsize(chr_code) then
2251 begin print(" at "); print_scaled(font_size(chr_code));
2252 @z
2253 %---------------------------------------
2254 @x [50] m.1320 l.23983 - Omega
2255 @ @<Dump the font information@>=
2256 dump_int(fmem_ptr);
2257 for k:=0 to fmem_ptr-1 do dump_wd(font_info[k]);
2258 dump_int(font_ptr);
2259 for k:=null_font to font_ptr do
2260 @<Dump the array info for internal font number |k|@>;
2261 print_ln; print_int(fmem_ptr-7); print(" words of font info for ");
2262 print_int(font_ptr-font_base); print(" preloaded font");
2263 if font_ptr<>font_base+1 then print_char("s")
2264 @y
2265 @ @<Dump the font information@>=
2266 dump_int(font_ptr);
2267 for k:=null_font to font_ptr do
2268 @<Dump the array info for internal font number |k|@>;
2269 print_ln; print_int(font_ptr-font_base); print(" preloaded font");
2270 if font_ptr<>font_base+1 then print_char("s")
2271 @z
2272 %---------------------------------------
2273 @x [50] m.1321 l.23993 - Omega
2274 @ @<Undump the font information@>=
2275 undump_size(7)(font_mem_size)('font mem size')(fmem_ptr);
2276 for k:=0 to fmem_ptr-1 do undump_wd(font_info[k]);
2277 undump_size(font_base)(font_max)('font max')(font_ptr);
2278 for k:=null_font to font_ptr do
2279 @<Undump the array info for internal font number |k|@>
2280 @y
2281 @ @<Undump the font information@>=
2282 undump_size(font_base)(font_max)('font max')(font_ptr);
2283 for k:=null_font to font_ptr do
2284 @<Undump the array info for internal font number |k|@>
2285 @z
2286 %---------------------------------------
2287 @x [50] m.1322 l.24000 - Omega
2288 @ @<Dump the array info for internal font number |k|@>=
2289 begin dump_qqqq(font_check[k]);
2290 dump_int(font_size[k]);
2291 dump_int(font_dsize[k]);
2292 dump_int(font_params[k]);@/
2293 dump_int(hyphen_char[k]);
2294 dump_int(skew_char[k]);@/
2295 dump_int(font_name[k]);
2296 dump_int(font_area[k]);@/
2297 dump_int(font_bc[k]);
2298 dump_int(font_ec[k]);@/
2299 dump_int(char_base[k]);
2300 dump_int(width_base[k]);
2301 dump_int(height_base[k]);@/
2302 dump_int(depth_base[k]);
2303 dump_int(italic_base[k]);
2304 dump_int(lig_kern_base[k]);@/
2305 dump_int(kern_base[k]);
2306 dump_int(exten_base[k]);
2307 dump_int(param_base[k]);@/
2308 dump_int(font_glue[k]);@/
2309 dump_int(bchar_label[k]);
2310 dump_int(font_bchar[k]);
2311 dump_int(font_false_bchar[k]);@/
2312 print_nl("\font"); print_esc(font_id_text(k)); print_char("=");
2313 print_file_name(font_name[k],font_area[k],"");
2314 if font_size[k]<>font_dsize[k] then
2315 begin print(" at "); print_scaled(font_size[k]); print("pt");
2316 end;
2317 end
2318 @y
2319 @ @<Dump the array info for internal font number |k|@>=
2320 begin dump_font_table(k,param_base(k)+font_params(k)+1);
2321 print_nl("\font"); print_esc(font_id_text(k)); print_char("=");
2322 print_file_name(font_name(k),font_area(k),"");
2323 if font_size(k)<>font_dsize(k) then
2324 begin print(" at "); print_scaled(font_size(k)); print("pt");
2325 end;
2326 end
2327 @z
2328 %---------------------------------------
2329 @x [50] m.1323 l.24031 - Omega
2330 @ @<Undump the array info for internal font number |k|@>=
2331 begin undump_qqqq(font_check[k]);@/
2332 undump_int(font_size[k]);
2333 undump_int(font_dsize[k]);
2334 undump(min_halfword)(max_halfword)(font_params[k]);@/
2335 undump_int(hyphen_char[k]);
2336 undump_int(skew_char[k]);@/
2337 undump(0)(str_ptr)(font_name[k]);
2338 undump(0)(str_ptr)(font_area[k]);@/
2339 undump(0)(255)(font_bc[k]);
2340 undump(0)(255)(font_ec[k]);@/
2341 undump_int(char_base[k]);
2342 undump_int(width_base[k]);
2343 undump_int(height_base[k]);@/
2344 undump_int(depth_base[k]);
2345 undump_int(italic_base[k]);
2346 undump_int(lig_kern_base[k]);@/
2347 undump_int(kern_base[k]);
2348 undump_int(exten_base[k]);
2349 undump_int(param_base[k]);@/
2350 undump(min_halfword)(lo_mem_max)(font_glue[k]);@/
2351 undump(0)(fmem_ptr-1)(bchar_label[k]);
2352 undump(min_quarterword)(non_char)(font_bchar[k]);
2353 undump(min_quarterword)(non_char)(font_false_bchar[k]);
2354 end
2355 @y
2356 @ @<Undump the array info for internal font number |k|@>=
2357 begin undump_font_table(k);@/
2358 end
2359 @z
2360 %---------------------------------------
2361 @x [51] m.1334 l.24277 - Omega
2362 wlog(' ',fmem_ptr:1,' words of font info for ',
2363 font_ptr-font_base:1,' font');
2364 if font_ptr<>font_base+1 then wlog('s');
2365 @y
2366 wlog(font_ptr-font_base:1,' font');
2367 if font_ptr<>font_base+1 then wlog('s');
2368 @z
2369 %---------------------------------------
2370 @x [52] m.1339 l.24429 - Omega
2371 4: print_word(eqtb[n]);
2372 5: print_word(font_info[n]);
2373 @y
2374 4: print_word(new_eqtb(n));
2375 5: ;
2376 @z
2377 %---------------------------------------