| 1 |
% This is a change file for DVItype. |
| 2 |
% |
| 3 |
% 09/27/95 (KA) Supporting ASCII pTeX |
| 4 |
% 2020-08-24 (HY) Support \dtou |
| 5 |
% 2022-12-03 (TTK) Merge pDVItype source/binary into upDVItype |
| 6 |
% |
| 7 |
@x |
| 8 |
@d my_name=='dvitype' |
| 9 |
@d banner=='This is DVItype, Version 3.6' {printed when the program starts} |
| 10 |
@y |
| 11 |
@d my_name=='updvitype' |
| 12 |
@d banner=='This is upDVItype, Version 3.6-p240427' |
| 13 |
{printed when the program starts} |
| 14 |
@z |
| 15 |
|
| 16 |
@x procedure initialize |
| 17 |
parse_arguments; |
| 18 |
print (banner); |
| 19 |
print_ln (version_string); |
| 20 |
@y |
| 21 |
init_kanji; |
| 22 |
parse_arguments; |
| 23 |
print (banner); |
| 24 |
print (' ('); |
| 25 |
print (conststringcast(get_enc_string)); |
| 26 |
print (')'); |
| 27 |
print_ln (version_string); |
| 28 |
@z |
| 29 |
|
| 30 |
@x |
| 31 |
for i:=@'177 to 255 do xchr[i]:='?'; |
| 32 |
@y |
| 33 |
for i:=@'177 to 255 do xchr[i]:=i; |
| 34 |
@z |
| 35 |
|
| 36 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 37 |
% pTeX |
| 38 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 39 |
@x |
| 40 |
@d undefined_commands==250,251,252,253,254,255 |
| 41 |
@y |
| 42 |
@d dir=255 {pTeX direction} |
| 43 |
@d undefined_commands==250,251,252,253,254 |
| 44 |
@z |
| 45 |
|
| 46 |
@x |
| 47 |
@d id_byte=2 {identifies the kind of \.{DVI} files described here} |
| 48 |
@y |
| 49 |
@d id_byte=2 {identifies the kind of \.{DVI} files described here} |
| 50 |
@d ptex_id_byte=3 {identifies the kind of pTeX \.{DVI} files described here} |
| 51 |
@z |
| 52 |
|
| 53 |
@x |
| 54 |
@!eight_bits=0..255; {unsigned one-byte quantity} |
| 55 |
@y |
| 56 |
@!eight_bits=0..255; {unsigned one-byte quantity} |
| 57 |
@!sixteen_bits=0..65535; {unsigned double-byte quantity} |
| 58 |
@z |
| 59 |
|
| 60 |
@x |
| 61 |
full_name := kpse_find_tfm (cur_name); |
| 62 |
if full_name then begin |
| 63 |
tfm_file := fopen (full_name, FOPEN_RBIN_MODE); |
| 64 |
end else begin |
| 65 |
tfm_file := nil; |
| 66 |
end; |
| 67 |
@y |
| 68 |
full_name := kpse_find_ofm (cur_name); |
| 69 |
if full_name then begin |
| 70 |
tfm_file := fopen (full_name, FOPEN_RBIN_MODE); |
| 71 |
end else begin |
| 72 |
full_name := kpse_find_tfm (cur_name); |
| 73 |
if full_name then begin |
| 74 |
tfm_file := fopen (full_name, FOPEN_RBIN_MODE); |
| 75 |
end else begin |
| 76 |
tfm_file := nil; |
| 77 |
end |
| 78 |
end; |
| 79 |
@z |
| 80 |
|
| 81 |
@x |
| 82 |
@!b0,@!b1,@!b2,@!b3: eight_bits; {four bytes input at once} |
| 83 |
@y |
| 84 |
@!b0,@!b1,@!b2,@!b3: eight_bits; {four bytes input at once} |
| 85 |
@!c0: sixteen_bits; |
| 86 |
@!cur_ofm_lv,@!kk:integer; |
| 87 |
@z |
| 88 |
|
| 89 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 90 |
% JFM and pTeX |
| 91 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 92 |
@x |
| 93 |
@!width_ptr:0..max_widths; {the number of known character widths} |
| 94 |
@y |
| 95 |
@!width_ptr:0..max_widths; {the number of known character widths} |
| 96 |
@!fnt_jfm_p:array [0..max_fonts] of boolean; |
| 97 |
@!fnt_ofm_p:array [0..max_fonts] of boolean; |
| 98 |
@!fnt_ofm_lv:array [0..max_fonts] of integer; |
| 99 |
@!jfm_char_code:array [0..max_widths] of integer; |
| 100 |
@!jfm_char_type:array [0..max_widths] of integer; |
| 101 |
@!jfm_char_font:array [0..max_widths] of integer; |
| 102 |
@!jfm_char_type_count:integer; |
| 103 |
@!cur_jfm_char_type:integer; |
| 104 |
|
| 105 |
@ @d jfm_hash_size=347 |
| 106 |
|
| 107 |
@ @<Types...@>= |
| 108 |
@!jfm_char_type_hash_value=0..jfm_hash_size-1; |
| 109 |
|
| 110 |
@ @<Glob...@>= |
| 111 |
@!jfm_char_type_hash_table:array[jfm_char_type_hash_value] of integer; |
| 112 |
{ first pointer to character information. 0 means null pointer. } |
| 113 |
@!jfm_char_type_hash_link:array[0..max_widths] of integer; |
| 114 |
{ next pointer to character information. 0 means null pointer. } |
| 115 |
|
| 116 |
@ @<Set init...@>= |
| 117 |
for i:=0 to jfm_hash_size-1 do |
| 118 |
jfm_char_type_hash_table[i] := 0; |
| 119 |
jfm_char_type[0]:=0; |
| 120 |
jfm_char_type_count:=1; |
| 121 |
|
| 122 |
@ Refer char_type table. |
| 123 |
|
| 124 |
@p function get_jfm_char_type(@!fntn:integer;@!jfmc:integer):integer; |
| 125 |
var p:integer; ct:integer; |
| 126 |
begin |
| 127 |
p:=jfm_char_type_hash_table[(jfmc+fntn) mod jfm_hash_size]; |
| 128 |
ct:=0; { default char_type is 0 } |
| 129 |
while p <> 0 do |
| 130 |
if (jfm_char_code[p] = jfmc) and (jfm_char_font[p] = fntn) then |
| 131 |
begin ct:=jfm_char_type[p]; p:=0; end |
| 132 |
else |
| 133 |
p:=jfm_char_type_hash_link[p]; |
| 134 |
get_jfm_char_type:=ct; |
| 135 |
end; |
| 136 |
|
| 137 |
@ @<Glob...@>= |
| 138 |
@!ptex_p:boolean; |
| 139 |
@!dd:eight_bits; |
| 140 |
@!ddstack:array [0..stack_size] of eight_bits; |
| 141 |
@z |
| 142 |
|
| 143 |
@x |
| 144 |
@!lh:integer; {length of the header data, in four-byte words} |
| 145 |
@y |
| 146 |
@!lh:integer; {length of the header data, in four-byte words} |
| 147 |
@!nt:integer; |
| 148 |
@!jfm_h:integer; |
| 149 |
@z |
| 150 |
|
| 151 |
@x [35] JFM by K.A. |
| 152 |
read_tfm_word; lh:=b2*256+b3; |
| 153 |
read_tfm_word; font_bc[nf]:=b0*256+b1; font_ec[nf]:=b2*256+b3; |
| 154 |
if font_ec[nf]<font_bc[nf] then font_bc[nf]:=font_ec[nf]+1; |
| 155 |
if width_ptr+font_ec[nf]-font_bc[nf]+1>max_widths then |
| 156 |
begin print_ln('---not loaded, DVItype needs larger width table'); |
| 157 |
@.DVItype needs larger...@> |
| 158 |
goto 9998; |
| 159 |
end; |
| 160 |
@y |
| 161 |
cur_ofm_lv := -1; |
| 162 |
read_tfm_word; lh:=b0*256+b1; |
| 163 |
if (lh = 11) or (lh = 9) then |
| 164 |
begin |
| 165 |
print(' (JFM'); |
| 166 |
fnt_jfm_p[nf] := true; |
| 167 |
fnt_ofm_p[nf] := false; |
| 168 |
if lh = 9 then print(' tate'); |
| 169 |
print(')'); |
| 170 |
nt:=b2*256+b3; |
| 171 |
read_tfm_word; |
| 172 |
end |
| 173 |
else if (lh = 0) then |
| 174 |
begin |
| 175 |
nt:=0; |
| 176 |
fnt_jfm_p[nf] := false; |
| 177 |
fnt_ofm_p[nf] := true; |
| 178 |
cur_ofm_lv := b2*256+b3; |
| 179 |
fnt_ofm_lv[nf] := cur_ofm_lv; |
| 180 |
print(' (OFM level'); |
| 181 |
print((fnt_ofm_lv[nf]):1); |
| 182 |
print(')'); |
| 183 |
end |
| 184 |
else |
| 185 |
begin |
| 186 |
nt:=0; |
| 187 |
fnt_jfm_p[nf] := false; |
| 188 |
fnt_ofm_p[nf] := false; |
| 189 |
end; |
| 190 |
if fnt_ofm_p[nf] then begin |
| 191 |
read_tfm_word; { lf } |
| 192 |
read_tfm_word; lh:=((b0*256+b1)*256+b2)*256+b3; |
| 193 |
read_tfm_word; font_bc[nf]:=((b0*256+b1)*256+b2)*256+b3; |
| 194 |
read_tfm_word; font_ec[nf]:=((b0*256+b1)*256+b2)*256+b3; |
| 195 |
end else begin |
| 196 |
lh:=b2*256+b3; |
| 197 |
read_tfm_word; font_bc[nf]:=b0*256+b1; font_ec[nf]:=b2*256+b3; |
| 198 |
end; |
| 199 |
if font_ec[nf]<font_bc[nf] then font_bc[nf]:=font_ec[nf]+1; |
| 200 |
if width_ptr+font_ec[nf]-font_bc[nf]+1>max_widths then |
| 201 |
begin print_ln('---not loaded, DVItype needs larger width table'); |
| 202 |
@.DVItype needs larger...@> |
| 203 |
goto 9998; |
| 204 |
end; |
| 205 |
@z |
| 206 |
|
| 207 |
@x |
| 208 |
read_tfm_word; nw:=b0*256+b1; |
| 209 |
if (nw=0)or(nw>256) then goto 9997; |
| 210 |
@y |
| 211 |
if fnt_ofm_p[nf] then begin |
| 212 |
read_tfm_word; nw:=((b0*256+b1)*256+b2)*256+b3; |
| 213 |
if (nw=0)or(nw>65536) then goto 9997; |
| 214 |
end |
| 215 |
else begin |
| 216 |
read_tfm_word; nw:=b0*256+b1; |
| 217 |
if (nw=0)or(nw>256) then goto 9997; |
| 218 |
end; |
| 219 |
@z |
| 220 |
|
| 221 |
@x |
| 222 |
for k:=1 to 3+lh do |
| 223 |
begin if eof(tfm_file) then goto 9997; |
| 224 |
read_tfm_word; |
| 225 |
@y |
| 226 |
if cur_ofm_lv<0 then kk:=3 else kk:=8; |
| 227 |
for k:=1 to kk do |
| 228 |
begin if eof(tfm_file) then goto 9997; |
| 229 |
read_tfm_word; |
| 230 |
end; |
| 231 |
for k:=1 to lh do { header } |
| 232 |
begin if eof(tfm_file) then goto 9997; |
| 233 |
read_tfm_word; |
| 234 |
@z |
| 235 |
|
| 236 |
@x [35] JFM by K.A. |
| 237 |
if k=4 then |
| 238 |
if b0<128 then tfm_check_sum:=((b0*256+b1)*256+b2)*256+b3 |
| 239 |
else tfm_check_sum:=(((b0-256)*256+b1)*256+b2)*256+b3 |
| 240 |
else if k=5 then |
| 241 |
if b0<128 then |
| 242 |
tfm_design_size:=round(tfm_conv*(((b0*256+b1)*256+b2)*256+b3)) |
| 243 |
else goto 9997; |
| 244 |
end; |
| 245 |
@y |
| 246 |
if k=1 then |
| 247 |
if b0<128 then tfm_check_sum:=((b0*256+b1)*256+b2)*256+b3 |
| 248 |
else tfm_check_sum:=(((b0-256)*256+b1)*256+b2)*256+b3 |
| 249 |
else if k=2 then |
| 250 |
if b0<128 then |
| 251 |
tfm_design_size:=round(tfm_conv*(((b0*256+b1)*256+b2)*256+b3)) |
| 252 |
else goto 9997; |
| 253 |
end; |
| 254 |
for k:=1 to nt do |
| 255 |
begin |
| 256 |
read_tfm_word; |
| 257 |
jfm_char_code[jfm_char_type_count]:=b0*256+b1+b2*65536; |
| 258 |
jfm_char_type[jfm_char_type_count]:=b3; |
| 259 |
jfm_char_font[jfm_char_type_count]:=nf; |
| 260 |
jfm_h:= { hash value } |
| 261 |
(jfm_char_code[jfm_char_type_count]+nf) mod jfm_hash_size; |
| 262 |
jfm_char_type_hash_link[jfm_char_type_count]:= |
| 263 |
jfm_char_type_hash_table[jfm_h]; |
| 264 |
jfm_char_type_hash_table[jfm_h]:=jfm_char_type_count; |
| 265 |
jfm_char_type_count := jfm_char_type_count + 1 |
| 266 |
end; |
| 267 |
@z |
| 268 |
|
| 269 |
@x |
| 270 |
@ @<Store character-width indices...@>= |
| 271 |
if wp>0 then for k:=width_ptr to wp-1 do |
| 272 |
begin read_tfm_word; |
| 273 |
if b0>nw then goto 9997; |
| 274 |
width[k]:=b0; |
| 275 |
end; |
| 276 |
@y |
| 277 |
@ @<Store character-width indices...@>= |
| 278 |
if wp>0 then for k:=width_ptr to wp-1 do |
| 279 |
begin read_tfm_word; |
| 280 |
if cur_ofm_lv<0 then |
| 281 |
c0:=b0 |
| 282 |
else begin |
| 283 |
c0:=(b0*256)+b1; |
| 284 |
read_tfm_word; |
| 285 |
end; |
| 286 |
if c0>nw then goto 9997; |
| 287 |
width[k]:=c0; |
| 288 |
end; |
| 289 |
@z |
| 290 |
|
| 291 |
@x |
| 292 |
@p procedure out_text(c:ASCII_code); |
| 293 |
begin if text_ptr=line_length-2 then flush_text; |
| 294 |
incr(text_ptr); text_buf[text_ptr]:=c; |
| 295 |
end; |
| 296 |
@y |
| 297 |
@p procedure out_text(c:ASCII_code); |
| 298 |
begin if text_ptr=line_length-2 then flush_text; |
| 299 |
incr(text_ptr); |
| 300 |
if c>=177 then text_buf[text_ptr]:=@'77 else text_buf[text_ptr]:=c; |
| 301 |
end; |
| 302 |
|
| 303 |
@ @p procedure out_kanji(c:integer); |
| 304 |
var @!v,@!n,@!jj: integer; |
| 305 |
begin |
| 306 |
if (isinternalUPTEX) then begin |
| 307 |
c:=fromDVI(c); |
| 308 |
n:=UVSgetcodepointlength(c); |
| 309 |
jj:=1; |
| 310 |
while jj<=n do begin |
| 311 |
v:=UVSgetcodepointinsequence(c,jj); |
| 312 |
if (v>0) then begin |
| 313 |
if text_ptr>=line_length-5 then flush_text; |
| 314 |
v:=UCStoUTF8(v); |
| 315 |
if BYTE1(v)<>0 then begin incr(text_ptr); text_buf[text_ptr]:=BYTE1(v); end; |
| 316 |
if BYTE2(v)<>0 then begin incr(text_ptr); text_buf[text_ptr]:=BYTE2(v); end; |
| 317 |
if BYTE3(v)<>0 then begin incr(text_ptr); text_buf[text_ptr]:=BYTE3(v); end; |
| 318 |
incr(text_ptr); text_buf[text_ptr]:=BYTE4(v); |
| 319 |
end; |
| 320 |
incr(jj); |
| 321 |
end |
| 322 |
end |
| 323 |
else begin |
| 324 |
if text_ptr>=line_length-5 then flush_text; |
| 325 |
c:=toBUFF(fromDVI(c)); |
| 326 |
if BYTE1(c)<>0 then begin incr(text_ptr); text_buf[text_ptr]:=BYTE1(c); end; |
| 327 |
if BYTE2(c)<>0 then begin incr(text_ptr); text_buf[text_ptr]:=BYTE2(c); end; |
| 328 |
if BYTE3(c)<>0 then begin incr(text_ptr); text_buf[text_ptr]:=BYTE3(c); end; |
| 329 |
incr(text_ptr); text_buf[text_ptr]:=BYTE4(c); |
| 330 |
end; |
| 331 |
end; |
| 332 |
|
| 333 |
@ output hexdecimal / octal character code. |
| 334 |
|
| 335 |
@d print_hex_digit(#)==if # <= 9 then print((#):1) |
| 336 |
else case # of |
| 337 |
10: print(xchr['A']); |
| 338 |
11: print(xchr['B']); |
| 339 |
12: print(xchr['C']); |
| 340 |
13: print(xchr['D']); |
| 341 |
14: print(xchr['E']); |
| 342 |
15: print(xchr['F']); { no more cases } |
| 343 |
end |
| 344 |
|
| 345 |
@p |
| 346 |
ifdef('HEX_CHAR_CODE') |
| 347 |
procedure print_hex_number(c:integer); |
| 348 |
var n:integer; |
| 349 |
b:array[1..8] of integer; |
| 350 |
begin |
| 351 |
n:=1; |
| 352 |
while (n<8) and (c<>0) do |
| 353 |
begin b[n]:=c mod 16; c:=c div 16; n:=n+1 end; |
| 354 |
print('"'); |
| 355 |
if n=1 then print(xchr['0']) |
| 356 |
else |
| 357 |
begin |
| 358 |
n:=n-1; |
| 359 |
while n>0 do |
| 360 |
begin print_hex_digit(b[n]); n:=n-1 end |
| 361 |
end |
| 362 |
end; |
| 363 |
endif('HEX_CHAR_CODE') |
| 364 |
@z |
| 365 |
|
| 366 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 367 |
% pTeX |
| 368 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 369 |
@x |
| 370 |
z0: first_par:=z; |
| 371 |
@y |
| 372 |
z0: first_par:=z; |
| 373 |
dir: first_par:=get_byte; |
| 374 |
@z |
| 375 |
|
| 376 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 377 |
% pTeX |
| 378 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 379 |
@x |
| 380 |
@!hhh:integer; {|h|, rounded to the nearest pixel} |
| 381 |
@y |
| 382 |
@!hhh,@!vvv:integer; {|h|,|v| rounded to the nearest pixel} |
| 383 |
@z |
| 384 |
|
| 385 |
@x |
| 386 |
s:=0; h:=0; v:=0; w:=0; x:=0; y:=0; z:=0; hh:=0; vv:=0; |
| 387 |
@y |
| 388 |
s:=0; h:=0; v:=0; w:=0; x:=0; y:=0; z:=0; hh:=0; vv:=0; dd:=0; |
| 389 |
@z |
| 390 |
|
| 391 |
@x |
| 392 |
move_right: @<Finish a command that sets |h:=h+q|, then |goto done|@>; |
| 393 |
@y |
| 394 |
move_right: |
| 395 |
if dd=0 then begin |
| 396 |
@<Finish a command that sets |h:=h+q|, then |goto done|@>; |
| 397 |
end else begin |
| 398 |
if dd=1 then p:=q else {if dd=3 then} p:=-q; |
| 399 |
@<Finish a command that sets |v:=v+p|, then |goto done|@>; |
| 400 |
end; |
| 401 |
@z |
| 402 |
|
| 403 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 404 |
% pTeX |
| 405 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 406 |
@x |
| 407 |
four_cases(set1): begin major('set',o-set1+1:1,' ',p:1); goto fin_set; |
| 408 |
end; |
| 409 |
four_cases(put1): begin major('put',o-put1+1:1,' ',p:1); goto fin_set; |
| 410 |
@y |
| 411 |
four_cases(set1),four_cases(put1): |
| 412 |
begin |
| 413 |
if fnt_jfm_p[cur_font]=true then |
| 414 |
begin |
| 415 |
cur_jfm_char_type:=get_jfm_char_type(cur_font,p); |
| 416 |
out_kanji(p); |
| 417 |
if o<put1 then |
| 418 |
begin |
| 419 |
minor('set',o-set1+1:1,' ',p:1); |
| 420 |
end |
| 421 |
else begin |
| 422 |
minor('put',o-put1+1:1,' ',p:1); |
| 423 |
end; |
| 424 |
ifdef('HEX_CHAR_CODE') |
| 425 |
print('('); |
| 426 |
print_hex_number(p); |
| 427 |
print(')'); |
| 428 |
endif('HEX_CHAR_CODE') |
| 429 |
print(' type=',cur_jfm_char_type); |
| 430 |
p:=cur_jfm_char_type |
| 431 |
end |
| 432 |
else if (fnt_ofm_p[cur_font]=true)and(isinternalUPTEX) then |
| 433 |
begin |
| 434 |
out_kanji(p); |
| 435 |
if o<put1 then |
| 436 |
begin |
| 437 |
minor('set',o-set1+1:1,' ',p:1); |
| 438 |
end |
| 439 |
else begin |
| 440 |
minor('put',o-put1+1:1,' ',p:1); |
| 441 |
end; |
| 442 |
ifdef('HEX_CHAR_CODE') |
| 443 |
print('('); |
| 444 |
print_hex_number(p); |
| 445 |
print(')'); |
| 446 |
endif('HEX_CHAR_CODE') |
| 447 |
end |
| 448 |
else begin |
| 449 |
if o<put1 then |
| 450 |
begin |
| 451 |
major('set',o-set1+1:1,' ',p:1); |
| 452 |
end |
| 453 |
else begin |
| 454 |
major('put',o-put1+1:1,' ',p:1); |
| 455 |
end; |
| 456 |
ifdef('HEX_CHAR_CODE') |
| 457 |
print('('); |
| 458 |
print_hex_number(p); |
| 459 |
print(')'); |
| 460 |
endif('HEX_CHAR_CODE') |
| 461 |
end; |
| 462 |
goto fin_set; |
| 463 |
@z |
| 464 |
|
| 465 |
@x |
| 466 |
@t\4@>@<Cases for commands |nop|, |bop|, \dots, |pop|@>@; |
| 467 |
@y |
| 468 |
dir: begin |
| 469 |
if not ptex_p and (out_mode=the_works) then |
| 470 |
bad_dvi('dir command within normal dvi file'); |
| 471 |
major('dir ',p:1); dd:=p; goto done; |
| 472 |
end; |
| 473 |
@t\4@>@<Cases for commands |nop|, |bop|, \dots, |pop|@>@; |
| 474 |
@z |
| 475 |
|
| 476 |
@x |
| 477 |
@!vvv:integer; {|v|, rounded to the nearest pixel} |
| 478 |
@y |
| 479 |
@!vvv,hhh:integer; {|v|,|h| rounded to the nearest pixel} |
| 480 |
@z |
| 481 |
|
| 482 |
@x |
| 483 |
move_down: @<Finish a command that sets |v:=v+p|, then |goto done|@>; |
| 484 |
@y |
| 485 |
move_down: |
| 486 |
if dd=0 then begin |
| 487 |
@<Finish a command that sets |v:=v+p|, then |goto done|@>; |
| 488 |
end else begin |
| 489 |
if dd=1 then q:=-p else {if dd=3 then} q:=p; |
| 490 |
@<Finish a command that sets |h:=h+q|, then |goto done|@>; |
| 491 |
end; |
| 492 |
@z |
| 493 |
|
| 494 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 495 |
% pTeX |
| 496 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 497 |
@x |
| 498 |
hstack[s]:=h; vstack[s]:=v; wstack[s]:=w; |
| 499 |
@y |
| 500 |
ddstack[s]:=dd; |
| 501 |
hstack[s]:=h; vstack[s]:=v; wstack[s]:=w; |
| 502 |
@z |
| 503 |
|
| 504 |
@x |
| 505 |
h:=hstack[s]; v:=vstack[s]; w:=wstack[s]; |
| 506 |
@y |
| 507 |
dd:=ddstack[s]; |
| 508 |
h:=hstack[s]; v:=vstack[s]; w:=wstack[s]; |
| 509 |
@z |
| 510 |
|
| 511 |
@x |
| 512 |
@d out_space(#)==if (p>=font_space[cur_font])or(p<=-4*font_space[cur_font]) then |
| 513 |
begin out_text(" "); hh:=pixel_round(h+p); |
| 514 |
end |
| 515 |
else hh:=hh+pixel_round(p); |
| 516 |
@y |
| 517 |
@d out_space(#)==if (p>=font_space[cur_font])or(p<=-4*font_space[cur_font]) then |
| 518 |
begin out_text(" "); |
| 519 |
if dd=0 then hh:=pixel_round(h+p) |
| 520 |
else if dd=1 then vv:=pixel_round(v+p) |
| 521 |
else {if dd=3 then} vv:=pixel_round(v-p); |
| 522 |
end |
| 523 |
else if dd=0 then hh:=hh+pixel_round(p) |
| 524 |
else if dd=1 then vv:=vv+pixel_round(p) |
| 525 |
else {if dd=3 then} vv:=vv-pixel_round(p); |
| 526 |
@z |
| 527 |
|
| 528 |
@x |
| 529 |
@d out_vmove(#)==if abs(p)>=5*font_space[cur_font] then vv:=pixel_round(v+p) |
| 530 |
else vv:=vv+pixel_round(p); |
| 531 |
@y |
| 532 |
@d out_vmove(#)==if abs(p)>=5*font_space[cur_font] then |
| 533 |
begin if dd=0 then vv:=pixel_round(v+p) |
| 534 |
else if dd=1 then hh:=pixel_round(h-p) |
| 535 |
else {if dd=3 then} hh:=pixel_round(h+p); |
| 536 |
end |
| 537 |
else if dd=0 then vv:=vv+pixel_round(p) |
| 538 |
else if dd=1 then hh:=hh-pixel_round(p) |
| 539 |
else {if dd=3 then} hh:=hh+pixel_round(p); |
| 540 |
@z |
| 541 |
|
| 542 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 543 |
% Hexadecimal code |
| 544 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 545 |
@x |
| 546 |
@ @<Translate a |set_char|...@>= |
| 547 |
begin if (o>" ")and(o<="~") then |
| 548 |
begin out_text(p); minor('setchar',p:1); |
| 549 |
end |
| 550 |
else major('setchar',p:1); |
| 551 |
@y |
| 552 |
@ @<Translate a |set_char|...@>= |
| 553 |
begin if (o>" ")and(o<="~") then |
| 554 |
begin out_text(p); minor('setchar',p:1); |
| 555 |
end |
| 556 |
else major('setchar',p:1); |
| 557 |
ifdef('HEX_CHAR_CODE') |
| 558 |
print(' ('); |
| 559 |
print_hex_number(p); |
| 560 |
print(')'); |
| 561 |
endif('HEX_CHAR_CODE') |
| 562 |
@z |
| 563 |
|
| 564 |
@x |
| 565 |
@ @<Finish a command that either sets or puts a character...@>= |
| 566 |
if p<0 then p:=255-((-1-p) mod 256) |
| 567 |
else if p>=256 then p:=p mod 256; {width computation for oriental fonts} |
| 568 |
@y |
| 569 |
@ @<Finish a command that either sets or puts a character...@>= |
| 570 |
if p<0 then p:=255-((-1-p) mod 256) |
| 571 |
else if (p>=256)and(not fnt_ofm_p[cur_font]) then p:=p mod 256; {width computation for oriental fonts} |
| 572 |
@z |
| 573 |
|
| 574 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 575 |
% pTeX |
| 576 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 577 |
@x |
| 578 |
else hh:=hh+char_pixel_width(cur_font)(p); |
| 579 |
@y |
| 580 |
else if dd=0 then hh:=hh+char_pixel_width(cur_font)(p) |
| 581 |
else if dd=1 then vv:=vv+char_pixel_width(cur_font)(p) |
| 582 |
else {if dd=3 then} vv:=vv-char_pixel_width(cur_font)(p); |
| 583 |
@z |
| 584 |
|
| 585 |
@x |
| 586 |
hh:=hh+rule_pixels(q); goto move_right |
| 587 |
@y |
| 588 |
if dd=0 then hh:=hh+rule_pixels(q) |
| 589 |
else if dd=1 then vv:=vv+rule_pixels(q) |
| 590 |
else {if dd=3 then} vv:=vv-rule_pixels(q); |
| 591 |
goto move_right |
| 592 |
@z |
| 593 |
|
| 594 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 595 |
% pTeX |
| 596 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 597 |
@x |
| 598 |
print('level ',ss:1,':(h=',h:1,',v=',v:1, |
| 599 |
',w=',w:1,',x=',x:1,',y=',y:1,',z=',z:1, |
| 600 |
',hh=',hh:1,',vv=',vv:1,')'); |
| 601 |
@y |
| 602 |
begin |
| 603 |
print('level ',ss:1,':(h=',h:1,',v=',v:1, |
| 604 |
',w=',w:1,',x=',x:1,',y=',y:1,',z=',z:1); |
| 605 |
if ptex_p then print(',d=',dd:1); |
| 606 |
print(',hh=',hh:1,',vv=',vv:1,')'); |
| 607 |
end; |
| 608 |
@z |
| 609 |
|
| 610 |
@x |
| 611 |
if k<>id_byte then bad_dvi('ID byte is ',k:1); |
| 612 |
@y |
| 613 |
ptex_p:=(k=ptex_id_byte); |
| 614 |
if (k<>id_byte) and (not ptex_p) then bad_dvi('ID byte is ',k:1); |
| 615 |
@z |
| 616 |
|
| 617 |
@x |
| 618 |
print_ln(', maxstackdepth=',max_s:1,', totalpages=',total_pages:1); |
| 619 |
@y |
| 620 |
print_ln(', maxstackdepth=',max_s:1,', totalpages=',total_pages:1); |
| 621 |
if ptex_p then print_ln('pTeX DVI (id=',ptex_id_byte:1,')'); |
| 622 |
@z |
| 623 |
|
| 624 |
@x |
| 625 |
if m<>id_byte then print_ln('identification in byte ',cur_loc-1:1, |
| 626 |
@.identification...should be n@> |
| 627 |
' should be ',id_byte:1,'!'); |
| 628 |
@y |
| 629 |
if (m<>id_byte) and (m<>ptex_id_byte) then |
| 630 |
print_ln('identification in byte ',cur_loc-1:1, |
| 631 |
@.identification...should be n@> |
| 632 |
' should be ',id_byte:1,' or ',ptex_id_byte:1,'!'); |
| 633 |
@z |
| 634 |
|
| 635 |
@x |
| 636 |
const n_options = 8; {Pascal won't count array lengths for us.} |
| 637 |
@y |
| 638 |
const n_options = 10; {Pascal won't count array lengths for us.} |
| 639 |
@z |
| 640 |
|
| 641 |
@x |
| 642 |
usage_help (DVITYPE_HELP, nil); |
| 643 |
@y |
| 644 |
usage_help (UPDVITYPE_HELP, 'issue@@texjp.org'); |
| 645 |
@z |
| 646 |
|
| 647 |
@x |
| 648 |
end; {Else it was a flag; |getopt| has already done the assignment.} |
| 649 |
@y |
| 650 |
end else if argument_is ('kanji') then begin |
| 651 |
set_prior_file_enc; |
| 652 |
if (not set_enc_string(optarg,optarg)) then begin |
| 653 |
write_ln('Bad kanji encoding "', stringcast(optarg), '".'); |
| 654 |
end; |
| 655 |
|
| 656 |
end; {Else it was a flag; |getopt| has already done the assignment.} |
| 657 |
@z |
| 658 |
|
| 659 |
@x |
| 660 |
@ An element with all zeros always ends the list. |
| 661 |
@y |
| 662 |
@ Decide kanji encode |
| 663 |
@.-kanji@> |
| 664 |
|
| 665 |
@<Define the option...@> = |
| 666 |
long_options[current_option].name := 'kanji'; |
| 667 |
long_options[current_option].has_arg := 1; |
| 668 |
long_options[current_option].flag := 0; |
| 669 |
long_options[current_option].val := 0; |
| 670 |
incr (current_option); |
| 671 |
|
| 672 |
@ An element with all zeros always ends the list. |
| 673 |
@z |