1% omfi.ch: Primitives for extra level of infinity. 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--2000 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 [10] m.135 l.2878 - Omega fi order of infinity 24specifies the order of infinity to which glue setting applies (|normal|, 25|fil|, |fill|, or |filll|). The |subtype| field is not used. 26@y 27specifies the order of infinity to which glue setting applies (|normal|, 28|sfi|, |fil|, |fill|, or |filll|). The |subtype| field is not used. 29@z 30%--------------------------------------- 31@x [10] m.150 l.3136 - Omega fi order of infinity 32orders of infinity (|normal|, |fil|, |fill|, or |filll|) 33@y 34orders of infinity (|normal|, |sfi|, |fil|, |fill|, or |filll|) 35@z 36%--------------------------------------- 37@x [10] m.150 l.3145 - Omega fi order of infinity 38@d fil=1 {first-order infinity} 39@d fill=2 {second-order infinity} 40@d filll=3 {third-order infinity} 41@y 42@d sfi=1 {first-order infinity} 43@d fil=2 {second-order infinity} 44@d fill=3 {third-order infinity} 45@d filll=4 {fourth-order infinity} 46@z 47%--------------------------------------- 48@x [10] m.150 l.3150 - Omega fi order of infinity 49@!glue_ord=normal..filll; {infinity to the 0, 1, 2, or 3 power} 50@y 51@!glue_ord=normal..filll; {infinity to the 0, 1, 2, 3, or 4 power} 52@z 53%--------------------------------------- 54@x [11] m.162 l.3296 - Omega fi order of infinity 55@d fil_glue==zero_glue+glue_spec_size {\.{0pt plus 1fil minus 0pt}} 56@y 57@d sfi_glue==zero_glue+glue_spec_size {\.{0pt plus 1fi minus 0pt}} 58@d fil_glue==sfi_glue+glue_spec_size {\.{0pt plus 1fil minus 0pt}} 59@z 60%--------------------------------------- 61@x [11] m.164 l.3296 - Omega fi order of infinity 62stretch(fil_glue):=unity; stretch_order(fil_glue):=fil;@/ 63@y 64stretch(sfi_glue):=unity; stretch_order(sfi_glue):=sfi;@/ 65stretch(fil_glue):=unity; stretch_order(fil_glue):=fil;@/ 66@z 67%--------------------------------------- 68@x [12] m.177 l.3591 - Omega fi order of infinity 69 begin print("fil"); 70 while order>fil do 71@y 72 begin print("fi"); 73 while order>sfi do 74@z 75%--------------------------------------- 76@x [26] m.454 l.8924 - Omega fi order of infinity 77if scan_keyword("fil") then 78@.fil@> 79 begin cur_order:=fil; 80@y 81if scan_keyword("fi") then 82@.fil@> 83 begin cur_order:=sfi; 84@z 85%--------------------------------------- 86@x [33] m.650 l.12877 - Omega fi order of infinity 87total_stretch[fil]:=0; total_shrink[fil]:=0; 88@y 89total_stretch[sfi]:=0; total_shrink[sfi]:=0; 90total_stretch[fil]:=0; total_shrink[fil]:=0; 91@z 92%--------------------------------------- 93@x [33] m.659 l.12996 - Omega fi order of infinity 94else if total_stretch[fil]<>0 then o:=fil 95@y 96else if total_stretch[fil]<>0 then o:=fil 97else if total_stretch[sfi]<>0 then o:=sfi 98@z 99%--------------------------------------- 100@x [33] m.665 l.13061 - Omega fi order of infinity 101else if total_shrink[fil]<>0 then o:=fil 102@y 103else if total_shrink[fil]<>0 then o:=fil 104else if total_shrink[sfi]<>0 then o:=sfi 105@z 106%--------------------------------------- 107@x [38] m.822 l.16135 - Omega fi order of infinity 108contains six scaled numbers, since it must record the net change in glue 109stretchability with respect to all orders of infinity. The natural width 110difference appears in |mem[q+1].sc|; the stretch differences in units of 111pt, fil, fill, and filll appear in |mem[q+2..q+5].sc|; and the shrink difference 112appears in |mem[q+6].sc|. The |subtype| field of a delta node is not used. 113 114@d delta_node_size=7 {number of words in a delta node} 115@y 116contains seven scaled numbers, since it must record the net change in glue 117stretchability with respect to all orders of infinity. The natural width 118difference appears in |mem[q+1].sc|; the stretch differences in units of 119pt, sfi, fil, fill, and filll appear in |mem[q+2..q+6].sc|; and the shrink 120difference appears in |mem[q+7].sc|. The |subtype| field of a delta node 121is not used. 122 123@d delta_node_size=8 {number of words in a delta node} 124@z 125%--------------------------------------- 126@x [38] m.823 l.16144 - Omega fi order of infinity 127@ As the algorithm runs, it maintains a set of six delta-like registers 128for the length of the line following the first active breakpoint to the 129current position in the given hlist. When it makes a pass through the 130active list, it also maintains a similar set of six registers for the 131@y 132@ As the algorithm runs, it maintains a set of seven delta-like registers 133for the length of the line following the first active breakpoint to the 134current position in the given hlist. When it makes a pass through the 135active list, it also maintains a similar set of seven registers for the 136@z 137%--------------------------------------- 138@x [38] m.823 l.16154 - Omega fi order of infinity 139k:=1 to 6 do cur_active_width[k]:=cur_active_width[k]+mem[q+k].sc|};$$ and we 140want to do this without the overhead of |for| loops. The |do_all_six| 141macro makes such six-tuples convenient. 142 143@d do_all_six(#)==#(1);#(2);#(3);#(4);#(5);#(6) 144 145@<Glob...@>= 146@!active_width:array[1..6] of scaled; 147 {distance from first active node to~|cur_p|} 148@!cur_active_width:array[1..6] of scaled; {distance from current active node} 149@!background:array[1..6] of scaled; {length of an ``empty'' line} 150@!break_width:array[1..6] of scaled; {length being computed after current break} 151@y 152k:=1 to 7 do cur_active_width[k]:=cur_active_width[k]+mem[q+k].sc|};$$ and we 153want to do this without the overhead of |for| loops. The |do_all_six| 154macro makes such six-tuples convenient. 155 156@d do_all_six(#)==#(1);#(2);#(3);#(4);#(5);#(6);#(7) 157 158@<Glo...@>= 159@!active_width:array[1..7] of scaled; 160 {distance from first active node to~|cur_p|} 161@!cur_active_width:array[1..7] of scaled; {distance from current active node} 162@!background:array[1..7] of scaled; {length of an ``empty'' line} 163@!break_width:array[1..7] of scaled; {length being computed after current break} 164@z 165%--------------------------------------- 166@x [38] m.827 l.16242 - Omega fi order of infinity 167background[2]:=0; background[3]:=0; background[4]:=0; background[5]:=0;@/ 168@y 169background[2]:=0; background[3]:=0; background[4]:=0; background[5]:=0;@/ 170background[6]:=0;@/ 171@z 172%--------------------------------------- 173@x [38] m.827 l.16260 - Omega fi order of infinity 174background[6]:=shrink(q)+shrink(r); 175@y 176background[7]:=shrink(q)+shrink(r); 177@z 178%--------------------------------------- 179@x [38] m.838 l.16470 - Omega fi order of infinity 180break_width[6]:=break_width[6]-shrink(v); 181@y 182break_width[7]:=break_width[7]-shrink(v); 183@z 184%--------------------------------------- 185@x [38] m.852 l.16713 - Omega fi order of infinity 186subarray |cur_active_width[2..5]|, in units of points, fil, fill, and filll. 187@y 188subarray |cur_active_width[2..6]|, in units of points, sfi, fil, fill and filll. 189@z 190%--------------------------------------- 191@x [38] m.852 l.16722 - Omega fi order of infinity 192if (cur_active_width[3]<>0)or(cur_active_width[4]<>0)or@| 193 (cur_active_width[5]<>0) then 194@y 195if (cur_active_width[3]<>0)or(cur_active_width[4]<>0)or@| 196 (cur_active_width[5]<>0)or(cur_active_width[6]<>0) then 197@z 198%--------------------------------------- 199@x [38] m.853 l.16738 - Omega fi order of infinity 200we can shrink the line from |r| to |cur_p| by at most |cur_active_width[6]|. 201 202@<Set the value of |b| to the badness for shrinking...@>= 203begin if -shortfall>cur_active_width[6] then b:=inf_bad+1 204else b:=badness(-shortfall,cur_active_width[6]); 205@y 206we can shrink the line from |r| to |cur_p| by at most |cur_active_width[7]|. 207 208@<Set the value of |b| to the badness for shrinking...@>= 209begin if -shortfall>cur_active_width[7] then b:=inf_bad+1 210else b:=badness(-shortfall,cur_active_width[7]); 211@z 212%--------------------------------------- 213@x [39] m.868 l.17054 - Omega fi order of infinity 214active_width[6]:=active_width[6]+shrink(q) 215@y 216active_width[7]:=active_width[7]+shrink(q) 217@z 218%--------------------------------------- 219@x [44] m.975 l.18932 - Omega fi order of infinity 220 if (active_height[3]<>0) or (active_height[4]<>0) or 221 (active_height[5]<>0) then b:=0 222 else b:=badness(h-cur_height,active_height[2]) 223else if cur_height-h>active_height[6] then b:=awful_bad 224else b:=badness(cur_height-h,active_height[6]) 225@y 226 if (active_height[3]<>0) or (active_height[4]<>0) or 227 (active_height[5]<>0) or (active_height[6]<>0) then b:=0 228 else b:=badness(h-cur_height,active_height[2]) 229else if cur_height-h>active_height[7] then b:=awful_bad 230else b:=badness(cur_height-h,active_height[7]) 231@z 232%--------------------------------------- 233@x [44] m.976 l.18947 - Omega fi order of infinity 234 active_height[6]:=active_height[6]+shrink(q); 235@y 236 active_height[7]:=active_height[7]+shrink(q); 237@z 238%--------------------------------------- 239@x [48] m.1201 l.22454 - Omega fi order of infinity 240 (total_shrink[fil]<>0)or(total_shrink[fill]<>0)or 241 (total_shrink[filll]<>0)) then 242@y 243 (total_shrink[sfi]<>0)or(total_shrink[fil]<>0)or 244 (total_shrink[fill]<>0)or(total_shrink[filll]<>0)) then 245@z 246 247