omega-pdf
Omega PDF: read and write PDF files in Omega
Brought by drakestapleton
| 1 | note Text extraction from ISO 32000-1:2008 clauses 7.3.4, 8.3, 9.3-9.4, 9.6-9.7, 9.10.3 and Annex D. |
| 2 | note Public standard: https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf |
| 3 | note SHA256 9de0ca9e8570d6209e8bd48a355be8eb6ec376acfc3fc3ae97cd8730351417ff. |
| 4 | note Independent implementation; no vendor program source. Annex D DATA is transcribed below. |
| 5 | note Bounds: page content/output 16 MiB each; token 65536 bytes; literal depth 256; |
| 6 | note operands 4096, operand bytes 1 MiB, nested containers 64, q stack 32. |
| 7 | note One active font: reload on change, at most 4096 loads and 256 MiB CMap bytes per page. |
| 8 | note ToUnicode: 65536 entries, 131072 hash slots, 4 MiB UTF16 destination pool, 512 bytes/destination. |
| 9 | note Codespaces 64; hash probe work 8388608 per font (insertion and extraction combined). |
| 10 | note CID fonts require Identity-H and ToUnicode; every other CID Encoding is refused. |
| 11 | note Numeric inputs at most 32 bytes, absolute value <= 1e9; derived geometry <= 1e12. |
| 12 | note No layout sorting, dehyphenation, ligature normalization or guessed Unicode: reading order is the |
| 13 | note order written in the file, not layout analysis. |
| 14 | text terrtxt "malformed text, font or CMap" |
| 15 | text terrsup "unsupported font, encoding, CMap or text-bearing graphics" |
| 16 | text terrlim "text engine bound exceeded" |
| 17 | text terrio "text output write failed" |
| 18 | text tkcont "Contents" |
| 19 | text tkfont "Font" |
| 20 | text tksub "Subtype" |
| 21 | text tktoun "ToUnicode" |
| 22 | text tkenc "Encoding" |
| 23 | text tkbase "BaseEncoding" |
| 24 | text tkdiff "Differences" |
| 25 | text tkfirst "FirstChar" |
| 26 | text tklast "LastChar" |
| 27 | text tkwidth "Widths" |
| 28 | text tkdesc "FontDescriptor" |
| 29 | text tkmiss "MissingWidth" |
| 30 | text tkflags "Flags" |
| 31 | text tkbf "BaseFont" |
| 32 | text tkdf "DescendantFonts" |
| 33 | text tkdw "DW" |
| 34 | text tkw "W" |
| 35 | text tkwmode "WMode" |
| 36 | text tkuse "UseCMap" |
| 37 | text tkmatrix "FontMatrix" |
| 38 | text tkxobj "XObject" |
| 39 | text tnstd "StandardEncoding" |
| 40 | text tnwin "WinAnsiEncoding" |
| 41 | text tnmac "MacRomanEncoding" |
| 42 | text tntype0 "Type0" |
| 43 | text tntype1 "Type1" |
| 44 | text tntype3 "Type3" |
| 45 | text tntrue "TrueType" |
| 46 | text tnmm "MMType1" |
| 47 | text tnidh "Identity-H" |
| 48 | text tnidv "Identity-V" |
| 49 | text tnimage "Image" |
| 50 | global tcs uchar 16777216 |
| 51 | global tobuf uchar 16777216 |
| 52 | global tstr uchar 65536 |
| 53 | global topool uchar 1048576 |
| 54 | global tokind ulong 4096 |
| 55 | global tostart ulong 4096 |
| 56 | global tolen ulong 4096 |
| 57 | global tovalue f64 4096 |
| 58 | global tlx ulong 8 |
| 59 | note tlx: source 0 tcs/1 pdbuf; position; limit; token kind; token bytes; operands; pool bytes; output bytes. |
| 60 | global tvalue f64 1 |
| 61 | global tmat f64 18 |
| 62 | note tmat: CTM, text matrix, line matrix; each a b c d e f. |
| 63 | global tstate f64 6 |
| 64 | note tstate: Tc Tw horizontal-scale TL Ts font-size. |
| 65 | global tqmat f64 384 |
| 66 | global tqfont ulong 32 |
| 67 | global tqdepth ulong 1 |
| 68 | global tfont ulong 1 |
| 69 | global tloaded ulong 1 |
| 70 | global tpage ulong 1 |
| 71 | global tinbt ulong 1 |
| 72 | global tlast f64 2 |
| 73 | note tlast: expected baseline origin x/y; survives BT/ET and q/Q. |
| 74 | global thave ulong 1 |
| 75 | global tloads ulong 1 |
| 76 | global tcbytes ulong 1 |
| 77 | global tmetrics f64 65536 |
| 78 | global tbasecp ulong 256 |
| 79 | global tfinfo ulong 7 |
| 80 | note tfinfo: composite; has ToUnicode; codespaces; entries; destination bytes; reserved; probe work. |
| 81 | global tmk ulong 131072 |
| 82 | global tmoff ulong 131072 |
| 83 | global tmlen ulong 131072 |
| 84 | global tmb uchar 4194304 |
| 85 | global tslo ulong 64 |
| 86 | global tshi ulong 64 |
| 87 | global tsbytes ulong 64 |
| 88 | global tcmaptmp uchar 512 |
| 89 | note tcv, tcp: the cm operands and the product being formed. |
| 90 | global tcv f64 6 |
| 91 | global tcp f64 6 |
| 92 | global tfontmx f64 2 |
| 93 | global tgeo f64 3 |
| 94 | |
| 95 | fn tbad to void |
| 96 | pquit 66 terrtxt |
| 97 | end |
| 98 | fn tunsup to void |
| 99 | pquit 65 terrsup |
| 100 | end |
| 101 | fn tlimit to void |
| 102 | pquit 63 terrlim |
| 103 | end |
| 104 | fn tfinite v f64 to f64 |
| 105 | if or ne v v gt fabs v 1.0e12f64 |
| 106 | tlimit |
| 107 | end |
| 108 | ret v |
| 109 | end |
| 110 | fn tnumber n ulong to f64 |
| 111 | v = pderef n |
| 112 | k = get ptype v |
| 113 | if and ne k 3 ne k 4 |
| 114 | tbad |
| 115 | end |
| 116 | ret tfinite pnumber v |
| 117 | end |
| 118 | fn tint n ulong maxv ulong to ulong |
| 119 | v = pderef n |
| 120 | if ne get ptype v 3 |
| 121 | tbad |
| 122 | end |
| 123 | z = get pnum v |
| 124 | if lt z 0 |
| 125 | tbad |
| 126 | end |
| 127 | if gt ulong z maxv |
| 128 | tlimit |
| 129 | end |
| 130 | ret ulong z |
| 131 | end |
| 132 | fn tkind n ulong k ulong to ulong |
| 133 | v = pderef n |
| 134 | if ne get ptype v k |
| 135 | tbad |
| 136 | end |
| 137 | ret v |
| 138 | end |
| 139 | fn twhite c ulong to bool |
| 140 | ret or or eq c 0 eq c 9 or or eq c 10 eq c 12 or eq c 13 eq c 32 |
| 141 | end |
| 142 | fn tdelim c ulong to bool |
| 143 | if twhite c |
| 144 | ret true |
| 145 | end |
| 146 | if or or eq c 40 eq c 41 or eq c 60 eq c 62 |
| 147 | ret true |
| 148 | end |
| 149 | ret or or eq c 91 eq c 93 or or eq c 123 eq c 125 or eq c 47 eq c 37 |
| 150 | end |
| 151 | fn tpeek to ulong |
| 152 | p = get tlx 1 |
| 153 | if ge p get tlx 2 |
| 154 | tbad |
| 155 | end |
| 156 | if eq get tlx 0 0 |
| 157 | ret ulong get tcs p |
| 158 | end |
| 159 | ret ulong get pdbuf p |
| 160 | end |
| 161 | fn ttake to ulong |
| 162 | c = tpeek |
| 163 | put tlx 1 add get tlx 1 1 |
| 164 | ret c |
| 165 | end |
| 166 | fn tsput c ulong to void |
| 167 | n = get tlx 4 |
| 168 | if ge n 65536 |
| 169 | tlimit |
| 170 | end |
| 171 | put tstr n uchar c |
| 172 | put tlx 4 add n 1 |
| 173 | end |
| 174 | fn tskip to void |
| 175 | while lt get tlx 1 get tlx 2 bound 16777217 |
| 176 | c = tpeek |
| 177 | if twhite c |
| 178 | put tlx 1 add get tlx 1 1 |
| 179 | continue |
| 180 | end |
| 181 | if ne c 37 |
| 182 | ret |
| 183 | end |
| 184 | while lt get tlx 1 get tlx 2 bound 16777217 |
| 185 | c = ttake |
| 186 | if or eq c 10 eq c 13 |
| 187 | break |
| 188 | end |
| 189 | end |
| 190 | end |
| 191 | end |
| 192 | fn tescaped to void |
| 193 | c = ttake |
| 194 | if eq c 10 |
| 195 | ret |
| 196 | end |
| 197 | if eq c 13 |
| 198 | if lt get tlx 1 get tlx 2 |
| 199 | if eq tpeek 10 |
| 200 | c = ttake |
| 201 | end |
| 202 | end |
| 203 | ret |
| 204 | end |
| 205 | if and ge c 48 le c 55 |
| 206 | v = sub c 48 |
| 207 | j = ulong 0 |
| 208 | while lt j 2 bound 3 |
| 209 | if ge get tlx 1 get tlx 2 |
| 210 | break |
| 211 | end |
| 212 | c = tpeek |
| 213 | if or lt c 48 gt c 55 |
| 214 | break |
| 215 | end |
| 216 | c = ttake |
| 217 | v = add mul v 8 sub c 48 |
| 218 | j = add j 1 |
| 219 | end |
| 220 | tsput and v 255 |
| 221 | ret |
| 222 | end |
| 223 | if eq c 110 |
| 224 | c = 10 |
| 225 | else |
| 226 | if eq c 114 |
| 227 | c = 13 |
| 228 | else |
| 229 | if eq c 116 |
| 230 | c = 9 |
| 231 | else |
| 232 | if eq c 98 |
| 233 | c = 8 |
| 234 | else |
| 235 | if eq c 102 |
| 236 | c = 12 |
| 237 | end |
| 238 | end |
| 239 | end |
| 240 | end |
| 241 | end |
| 242 | tsput c |
| 243 | end |
| 244 | fn tliteral to void |
| 245 | depth = ulong 1 |
| 246 | while ne depth 0 bound 16777217 |
| 247 | c = ttake |
| 248 | if eq c 92 |
| 249 | tescaped |
| 250 | continue |
| 251 | end |
| 252 | if eq c 40 |
| 253 | if ge depth 256 |
| 254 | tlimit |
| 255 | end |
| 256 | depth = add depth 1 |
| 257 | end |
| 258 | if eq c 41 |
| 259 | depth = sub depth 1 |
| 260 | if eq depth 0 |
| 261 | break |
| 262 | end |
| 263 | end |
| 264 | if eq c 13 |
| 265 | c = 10 |
| 266 | if lt get tlx 1 get tlx 2 |
| 267 | if eq tpeek 10 |
| 268 | q = ttake |
| 269 | end |
| 270 | end |
| 271 | end |
| 272 | tsput c |
| 273 | end |
| 274 | end |
| 275 | fn thex to void |
| 276 | hi = ulong 16 |
| 277 | while true bound 16777217 |
| 278 | c = ttake |
| 279 | if eq c 62 |
| 280 | if ne hi 16 |
| 281 | tsput mul hi 16 |
| 282 | end |
| 283 | ret |
| 284 | end |
| 285 | if twhite c |
| 286 | continue |
| 287 | end |
| 288 | v = tx_hexv uchar c |
| 289 | if eq v 16 |
| 290 | tbad |
| 291 | end |
| 292 | if eq hi 16 |
| 293 | hi = v |
| 294 | else |
| 295 | tsput add mul hi 16 v |
| 296 | hi = 16 |
| 297 | end |
| 298 | end |
| 299 | end |
| 300 | fn tparsenum to bool |
| 301 | n = get tlx 4 |
| 302 | if eq n 0 |
| 303 | ret false |
| 304 | end |
| 305 | c = ulong get tstr 0 |
| 306 | if not or and ge c 48 le c 57 or eq c 43 or eq c 45 eq c 46 |
| 307 | ret false |
| 308 | end |
| 309 | if gt n 32 |
| 310 | tlimit |
| 311 | end |
| 312 | i = ulong 0 |
| 313 | sgn = 1.0f64 |
| 314 | if or eq c 43 eq c 45 |
| 315 | i = 1 |
| 316 | if eq c 45 |
| 317 | sgn = -1.0f64 |
| 318 | end |
| 319 | end |
| 320 | v = 0.0f64 |
| 321 | scale = 1.0f64 |
| 322 | dot = false |
| 323 | digits = ulong 0 |
| 324 | while lt i n bound 33 |
| 325 | c = ulong get tstr i |
| 326 | i = add i 1 |
| 327 | if eq c 46 |
| 328 | if dot |
| 329 | tbad |
| 330 | end |
| 331 | dot = true |
| 332 | continue |
| 333 | end |
| 334 | if or lt c 48 gt c 57 |
| 335 | tbad |
| 336 | end |
| 337 | digits = add digits 1 |
| 338 | if dot |
| 339 | scale = mul scale 0.1f64 |
| 340 | v = add v mul f64 sub c 48 scale |
| 341 | else |
| 342 | v = add mul v 10.0f64 f64 sub c 48 |
| 343 | end |
| 344 | if gt v 1.0e9f64 |
| 345 | tlimit |
| 346 | end |
| 347 | end |
| 348 | if eq digits 0 |
| 349 | tbad |
| 350 | end |
| 351 | put tvalue 0 mul v sgn |
| 352 | ret true |
| 353 | end |
| 354 | note Token kinds: 0 EOF, 1 number, 2 name, 3 string, 4 word, 5 [, 6 ], 7 <<, 8 >>, 9 {, 10 }. |
| 355 | fn tlex to void |
| 356 | tskip |
| 357 | put tlx 3 0 |
| 358 | put tlx 4 0 |
| 359 | if eq get tlx 1 get tlx 2 |
| 360 | ret |
| 361 | end |
| 362 | c = ttake |
| 363 | if eq c 40 |
| 364 | put tlx 3 3 |
| 365 | tliteral |
| 366 | ret |
| 367 | end |
| 368 | if eq c 60 |
| 369 | if lt get tlx 1 get tlx 2 |
| 370 | if eq tpeek 60 |
| 371 | c = ttake |
| 372 | put tlx 3 7 |
| 373 | ret |
| 374 | end |
| 375 | end |
| 376 | put tlx 3 3 |
| 377 | thex |
| 378 | ret |
| 379 | end |
| 380 | if eq c 62 |
| 381 | if ne ttake 62 |
| 382 | tbad |
| 383 | end |
| 384 | put tlx 3 8 |
| 385 | ret |
| 386 | end |
| 387 | if or eq c 91 eq c 93 |
| 388 | put tlx 3 5 |
| 389 | if eq c 93 |
| 390 | put tlx 3 6 |
| 391 | end |
| 392 | ret |
| 393 | end |
| 394 | if or eq c 123 eq c 125 |
| 395 | put tlx 3 9 |
| 396 | if eq c 125 |
| 397 | put tlx 3 10 |
| 398 | end |
| 399 | ret |
| 400 | end |
| 401 | if eq c 41 |
| 402 | tbad |
| 403 | end |
| 404 | if eq c 47 |
| 405 | put tlx 3 2 |
| 406 | else |
| 407 | put tlx 3 4 |
| 408 | tsput c |
| 409 | end |
| 410 | while lt get tlx 1 get tlx 2 bound 16777217 |
| 411 | c = tpeek |
| 412 | if tdelim c |
| 413 | break |
| 414 | end |
| 415 | c = ttake |
| 416 | if and eq get tlx 3 2 eq c 35 |
| 417 | h = tx_hexv uchar ttake |
| 418 | l = tx_hexv uchar ttake |
| 419 | if or eq h 16 eq l 16 |
| 420 | tbad |
| 421 | end |
| 422 | c = add mul h 16 l |
| 423 | if eq c 0 |
| 424 | tbad |
| 425 | end |
| 426 | end |
| 427 | tsput c |
| 428 | end |
| 429 | if eq get tlx 3 2 |
| 430 | if gt get tlx 4 256 |
| 431 | tlimit |
| 432 | end |
| 433 | end |
| 434 | if eq get tlx 3 4 |
| 435 | if tparsenum |
| 436 | put tlx 3 1 |
| 437 | end |
| 438 | end |
| 439 | end |
| 440 | fn teq s view uchar * to bool |
| 441 | n = get tlx 4 |
| 442 | if ne n len s |
| 443 | ret false |
| 444 | end |
| 445 | i = ulong 0 |
| 446 | while lt i n bound 65537 |
| 447 | if ne get tstr i get s i |
| 448 | ret false |
| 449 | end |
| 450 | i = add i 1 |
| 451 | end |
| 452 | ret true |
| 453 | end |
| 454 | fn texpect k ulong to void |
| 455 | tlex |
| 456 | if ne get tlx 3 k |
| 457 | tbad |
| 458 | end |
| 459 | end |
| 460 | fn tendword s view uchar * to void |
| 461 | texpect 4 |
| 462 | if not teq s |
| 463 | tbad |
| 464 | end |
| 465 | end |
| 466 | fn topush to void |
| 467 | j = get tlx 5 |
| 468 | if ge j 4096 |
| 469 | tlimit |
| 470 | end |
| 471 | n = get tlx 4 |
| 472 | p = get tlx 6 |
| 473 | if gt n sub 1048576 p |
| 474 | tlimit |
| 475 | end |
| 476 | put tokind j get tlx 3 |
| 477 | put tostart j p |
| 478 | put tolen j n |
| 479 | put tovalue j get tvalue 0 |
| 480 | i = ulong 0 |
| 481 | while lt i n bound 65537 |
| 482 | put topool add p i get tstr i |
| 483 | i = add i 1 |
| 484 | end |
| 485 | put tlx 6 add p n |
| 486 | put tlx 5 add j 1 |
| 487 | end |
| 488 | fn targs n ulong to void |
| 489 | if ne get tlx 5 n |
| 490 | tbad |
| 491 | end |
| 492 | end |
| 493 | fn targnum j ulong to f64 |
| 494 | if ge j get tlx 5 |
| 495 | tbad |
| 496 | end |
| 497 | if ne get tokind j 1 |
| 498 | tbad |
| 499 | end |
| 500 | ret get tovalue j |
| 501 | end |
| 502 | fn targname j ulong d ulong to ulong |
| 503 | if ge j get tlx 5 |
| 504 | tbad |
| 505 | end |
| 506 | if ne get tokind j 2 |
| 507 | tbad |
| 508 | end |
| 509 | n = get tolen j |
| 510 | p = get tostart j |
| 511 | obj = pderef d |
| 512 | if and ne get ptype obj 8 ne get ptype obj 10 |
| 513 | tbad |
| 514 | end |
| 515 | k = get pfirst obj |
| 516 | while ne k 0 bound 262145 |
| 517 | v = get pnext k |
| 518 | if eq v 0 |
| 519 | tbad |
| 520 | end |
| 521 | if tkeyeq k p n |
| 522 | ret pderef v |
| 523 | end |
| 524 | k = get pnext v |
| 525 | end |
| 526 | ret 0 |
| 527 | end |
| 528 | note tkeyeq: name node k equals operand bytes topool[p .. p+n). |
| 529 | fn tkeyeq k ulong p ulong n ulong to bool |
| 530 | if ne get plen k n |
| 531 | ret false |
| 532 | end |
| 533 | s = get pstart k |
| 534 | for i ulong n bound 65537 |
| 535 | if ne get pbytes add s i get topool add p i |
| 536 | ret false |
| 537 | end |
| 538 | end |
| 539 | ret true |
| 540 | end |
| 541 | fn temit c ulong to void |
| 542 | n = get tlx 7 |
| 543 | if ge n 16777216 |
| 544 | tlimit |
| 545 | end |
| 546 | put tobuf n uchar c |
| 547 | put tlx 7 add n 1 |
| 548 | end |
| 549 | fn tu8 cp ulong to void |
| 550 | if or gt cp 1114111 and ge cp 55296 le cp 57343 |
| 551 | tbad |
| 552 | end |
| 553 | if lt cp 128 |
| 554 | temit cp |
| 555 | ret |
| 556 | end |
| 557 | if lt cp 2048 |
| 558 | temit add 192 shr cp 6 |
| 559 | temit add 128 and cp 63 |
| 560 | ret |
| 561 | end |
| 562 | if lt cp 65536 |
| 563 | temit add 224 shr cp 12 |
| 564 | temit add 128 and shr cp 6 63 |
| 565 | temit add 128 and cp 63 |
| 566 | ret |
| 567 | end |
| 568 | temit add 240 shr cp 18 |
| 569 | temit add 128 and shr cp 12 63 |
| 570 | temit add 128 and shr cp 6 63 |
| 571 | temit add 128 and cp 63 |
| 572 | end |
| 573 | fn tbreak c ulong to void |
| 574 | n = get tlx 7 |
| 575 | if eq n 0 |
| 576 | ret |
| 577 | end |
| 578 | v = ulong get tobuf sub n 1 |
| 579 | if eq v 10 |
| 580 | ret |
| 581 | end |
| 582 | if eq c 32 |
| 583 | if or eq v 32 eq v 9 |
| 584 | ret |
| 585 | end |
| 586 | end |
| 587 | temit c |
| 588 | end |
| 589 | fn tflush to void |
| 590 | p = ulong 0 |
| 591 | n = get tlx 7 |
| 592 | while lt p n bound 16777217 |
| 593 | r = write 1 tobuf p sub n p |
| 594 | if le r 0 |
| 595 | pquit 64 terrio |
| 596 | end |
| 597 | p = add p ulong r |
| 598 | end |
| 599 | put tlx 7 0 |
| 600 | end |
| 601 | |
| 602 | note Annex D.2 glyph names and encoding octal codes, converted to decimal; Unicode from D.3. |
| 603 | note 229 rows; STD 149, MAC 207, WIN 216 assignments. 256 denotes unencoded. |
| 604 | text tlatin "A,65,65,65,65|AE,198,225,174,198|Aacute,193,256,231,193|Acircumflex,194,256,229,194|Adieresis,196,256,128,196|Agrave,192,256,203,192|Aring,197,256,129,197|Atilde,195,256,204,195|B,66,66,66,66|C,67,67,67,67|Ccedilla,199,256,130,199|D,68,68,68,68|E,69,69,69,69|Eacute,201,256,131,201|Ecircumflex,202,256,230,202|Edieresis,203,256,232,203|Egrave,200,256,233,200|Eth,208,256,256,208|Euro,8364,256,256,128|F,70,70,70,70|G,71,71,71,71|H,72,72,72,72|I,73,73,73,73|Iacute,205,256,234,205|Icircumflex,206,256,235,206|Idieresis,207,256,236,207|Igrave,204,256,237,204|J,74,74,74,74|K,75,75,75,75|L,76,76,76,76|Lslash,321,232,256,256|M,77,77,77,77|N,78,78,78,78|Ntilde,209,256,132,209|O,79,79,79,79|OE,338,234,206,140|Oacute,211,256,238,211|Ocircumflex,212,256,239,212|Odieresis,214,256,133,214|Ograve,210,256,241,210|Oslash,216,233,175,216|Otilde,213,256,205,213|P,80,80,80,80|Q,81,81,81,81|R,82,82,82,82|S,83,83,83,83|Scaron,352,256,256,138|T,84,84,84,84|Thorn,222,256,256,222|U,85,85,85,85|Uacute,218,256,242,218|Ucircumflex,219,256,243,219|Udieresis,220,256,134,220|Ugrave,217,256,244,217|V,86,86,86,86|W,87,87,87,87|X,88,88,88,88|Y,89,89,89,89|Yacute,221,256,256,221|Ydieresis,376,256,217,159|Z,90,90,90,90|Zcaron,381,256,256,142|a,97,97,97,97|aacute,225,256,135,225|acircumflex,226,256,137,226|acute,180,194,171,180|adieresis,228,256,138,228|ae,230,241,190,230|agrave,224,256,136,224|ampersand,38,38,38,38|aring,229,256,140,229|asciicircum,94,94,94,94|asciitilde,126,126,126,126|asterisk,42,42,42,42|at,64,64,64,64|atilde,227,256,139,227|b,98,98,98,98|backslash,92,92,92,92|bar,124,124,124,124|braceleft,123,123,123,123|braceright,125,125,125,125|bracketleft,91,91,91,91|bracketright,93,93,93,93|breve,728,198,249,256|brokenbar,166,256,256,166|bullet,8226,183,165,149|c,99,99,99,99|caron,711,207,255,256|ccedilla,231,256,141,231|cedilla,184,203,252,184|cent,162,162,162,162|circumflex,710,195,246,136|colon,58,58,58,58|comma,44,44,44,44|copyright,169,256,169,169|currency,164,168,219,164|d,100,100,100,100|dagger,8224,178,160,134|daggerdbl,8225,179,224,135|degree,176,256,161,176|dieresis,168,200,172,168|divide,247,256,214,247|dollar,36,36,36,36|dotaccent,729,199,250,256|dotlessi,305,245,245,256|e,101,101,101,101|eacute,233,256,142,233|ecircumflex,234,256,144,234|edieresis,235,256,145,235|egrave,232,256,143,232|eight,56,56,56,56|ellipsis,8230,188,201,133|emdash,8212,208,209,151|endash,8211,177,208,150|equal,61,61,61,61|eth,240,256,256,240|exclam,33,33,33,33|exclamdown,161,161,193,161|f,102,102,102,102|fi,64257,174,222,256|five,53,53,53,53|fl,64258,175,223,256|florin,402,166,196,131|four,52,52,52,52|fraction,8260,164,218,256|g,103,103,103,103|germandbls,223,251,167,223|grave,96,193,96,96|greater,62,62,62,62|guillemotleft,171,171,199,171|guillemotright,187,187,200,187|guilsinglleft,8249,172,220,139|guilsinglright,8250,173,221,155|h,104,104,104,104|hungarumlaut,733,205,253,256|hyphen,45,45,45,45|i,105,105,105,105|iacute,237,256,146,237|icircumflex,238,256,148,238|idieresis,239,256,149,239|igrave,236,256,147,236|j,106,106,106,106|k,107,107,107,107|l,108,108,108,108|less,60,60,60,60|logicalnot,172,256,194,172|lslash,322,248,256,256|m,109,109,109,109|macron,175,197,248,175|minus,8722,256,256,256|mu,181,256,181,181|multiply,215,256,256,215|n,110,110,110,110|nine,57,57,57,57|ntilde,241,256,150,241|numbersign,35,35,35,35|o,111,111,111,111|oacute,243,256,151,243|ocircumflex,244,256,153,244|odieresis,246,256,154,246|oe,339,250,207,156|ogonek,731,206,254,256|ograve,242,256,152,242|one,49,49,49,49|onehalf,189,256,256,189|onequarter,188,256,256,188|onesuperior,185,256,256,185|ordfeminine,170,227,187,170|ordmasculine,186,235,188,186|oslash,248,249,191,248|otilde,245,256,155,245|p,112,112,112,112|paragraph,182,182,166,182|parenleft,40,40,40,40|parenright,41,41,41,41|percent,37,37,37,37|period,46,46,46,46|periodcentered,183,180,225,183|perthousand,8240,189,228,137|plus,43,43,43,43|plusminus,177,256,177,177|q,113,113,113,113|question,63,63,63,63|questiondown,191,191,192,191|quotedbl,34,34,34,34|quotedblbase,8222,185,227,132|quotedblleft,8220,170,210,147|quotedblright,8221,186,211,148|quoteleft,8216,96,212,145|quoteright,8217,39,213,146|quotesinglbase,8218,184,226,130|quotesingle,39,169,39,39|r,114,114,114,114|registered,174,256,168,174|ring,730,202,251,256|s,115,115,115,115|scaron,353,256,256,154|section,167,167,164,167|semicolon,59,59,59,59|seven,55,55,55,55|six,54,54,54,54|slash,47,47,47,47|space,32,32,32,32|sterling,163,163,163,163|t,116,116,116,116|thorn,254,256,256,254|three,51,51,51,51|threequarters,190,256,256,190|threesuperior,179,256,256,179|tilde,732,196,247,152|trademark,8482,256,170,153|two,50,50,50,50|twosuperior,178,256,256,178|u,117,117,117,117|uacute,250,256,156,250|ucircumflex,251,256,158,251|udieresis,252,256,159,252|ugrave,249,256,157,249|underscore,95,95,95,95|v,118,118,118,118|w,119,119,119,119|x,120,120,120,120|y,121,121,121,121|yacute,253,256,256,253|ydieresis,255,256,216,255|yen,165,165,180,165|z,122,122,122,122|zcaron,382,256,256,158|zero,48,48,48,48|" |
| 605 | |
| 606 | global tdrow ulong 5 |
| 607 | fn trow p ulong to ulong |
| 608 | i = p |
| 609 | while ne get tlatin i 44 bound 32 |
| 610 | i = add i 1 |
| 611 | end |
| 612 | put tdrow 0 sub i p |
| 613 | i = add i 1 |
| 614 | j = ulong 1 |
| 615 | while le j 4 bound 5 |
| 616 | v = ulong 0 |
| 617 | while true bound 8 |
| 618 | c = ulong get tlatin i |
| 619 | i = add i 1 |
| 620 | if or eq c 44 eq c 124 |
| 621 | break |
| 622 | end |
| 623 | v = add mul v 10 sub c 48 |
| 624 | end |
| 625 | put tdrow j v |
| 626 | j = add j 1 |
| 627 | end |
| 628 | ret i |
| 629 | end |
| 630 | fn tbase enc ulong to void |
| 631 | i = ulong 0 |
| 632 | while lt i 256 bound 257 |
| 633 | put tbasecp i 0 |
| 634 | i = add i 1 |
| 635 | end |
| 636 | if eq enc 0 |
| 637 | ret |
| 638 | end |
| 639 | p = ulong 0 |
| 640 | while lt p len tlatin bound 230 |
| 641 | p = trow p |
| 642 | c = get tdrow add enc 1 |
| 643 | if lt c 256 |
| 644 | put tbasecp c get tdrow 1 |
| 645 | end |
| 646 | end |
| 647 | note Annex D.2 notes 3,5,6: bullet holes; soft hyphen; nonbreaking space glyph duplicates. |
| 648 | if eq enc 3 |
| 649 | i = 33 |
| 650 | while lt i 256 bound 257 |
| 651 | if eq get tbasecp i 0 |
| 652 | put tbasecp i 8226 |
| 653 | end |
| 654 | i = add i 1 |
| 655 | end |
| 656 | put tbasecp 173 45 |
| 657 | put tbasecp 160 32 |
| 658 | end |
| 659 | if eq enc 2 |
| 660 | put tbasecp 202 32 |
| 661 | end |
| 662 | end |
| 663 | note Differences names outside ISO 32000-1 Annex D.2 map to U+FFFD, emitted only when shown. |
| 664 | note Difference class: the oracle may resolve more names through the Adobe Glyph List; we use Annex D only. |
| 665 | note No Annex D row has Unicode U+FFFD, so the replacement is unambiguous and costs nothing if unused. |
| 666 | fn tglyph n ulong to ulong |
| 667 | v = tkind n 5 |
| 668 | p = ulong 0 |
| 669 | while lt p len tlatin bound 230 |
| 670 | q = trow p |
| 671 | if tlateq v p get tdrow 0 |
| 672 | ret get tdrow 1 |
| 673 | end |
| 674 | p = q |
| 675 | end |
| 676 | ret 65533 |
| 677 | end |
| 678 | note tlateq: name node v equals tlatin[p .. p+n). |
| 679 | fn tlateq v ulong p ulong n ulong to bool |
| 680 | if ne get plen v n |
| 681 | ret false |
| 682 | end |
| 683 | s = get pstart v |
| 684 | for i ulong n bound 33 |
| 685 | if ne get pbytes add s i get tlatin add p i |
| 686 | ret false |
| 687 | end |
| 688 | end |
| 689 | ret true |
| 690 | end |
| 691 | fn tencoding fontn ulong to void |
| 692 | enc = pderef pget fontn tkenc |
| 693 | base = enc |
| 694 | if eq get ptype enc 8 |
| 695 | base = pderef pget enc tkbase |
| 696 | end |
| 697 | which = ulong 1 |
| 698 | if ne base 0 |
| 699 | if pne base tnwin |
| 700 | which = 3 |
| 701 | else |
| 702 | if pne base tnmac |
| 703 | which = 2 |
| 704 | else |
| 705 | if not pne base tnstd |
| 706 | tunsup |
| 707 | end |
| 708 | end |
| 709 | end |
| 710 | else |
| 711 | if pne pget fontn tksub tntype3 |
| 712 | which = 0 |
| 713 | else |
| 714 | which = timplicit fontn |
| 715 | end |
| 716 | end |
| 717 | tbase which |
| 718 | if eq get ptype enc 8 |
| 719 | diff = pderef pget enc tkdiff |
| 720 | if ne diff 0 |
| 721 | diff = tkind diff 7 |
| 722 | v = get pfirst diff |
| 723 | code = ulong 256 |
| 724 | while ne v 0 bound 262145 |
| 725 | n = pderef v |
| 726 | if eq get ptype n 3 |
| 727 | code = tint n 255 |
| 728 | else |
| 729 | if ge code 256 |
| 730 | tbad |
| 731 | end |
| 732 | put tbasecp code tglyph n |
| 733 | code = add code 1 |
| 734 | end |
| 735 | v = get pnext v |
| 736 | end |
| 737 | end |
| 738 | end |
| 739 | end |
| 740 | fn tmapkey code ulong nb ulong to ulong |
| 741 | ret add add code shl nb 32 1 |
| 742 | end |
| 743 | fn tmapfind key ulong to ulong |
| 744 | slot = rem key 131072 |
| 745 | while true bound 131073 |
| 746 | work = get tfinfo 6 |
| 747 | if ge work 8388608 |
| 748 | tlimit |
| 749 | end |
| 750 | put tfinfo 6 add work 1 |
| 751 | v = get tmk slot |
| 752 | if or eq v 0 eq v key |
| 753 | ret slot |
| 754 | end |
| 755 | slot = rem add slot 1 131072 |
| 756 | end |
| 757 | ret 0 |
| 758 | end |
| 759 | fn tmapinsert code ulong nb ulong dn ulong to void |
| 760 | if or eq dn 0 gt dn 512 |
| 761 | tbad |
| 762 | end |
| 763 | if ne rem dn 2 0 |
| 764 | tbad |
| 765 | end |
| 766 | tvaliddest dn |
| 767 | slot = tmapfind tmapkey code nb |
| 768 | if eq get tmk slot 0 |
| 769 | if ge get tfinfo 3 65536 |
| 770 | tlimit |
| 771 | end |
| 772 | put tfinfo 3 add get tfinfo 3 1 |
| 773 | end |
| 774 | p = get tfinfo 4 |
| 775 | if gt dn sub 4194304 p |
| 776 | tlimit |
| 777 | end |
| 778 | i = ulong 0 |
| 779 | while lt i dn bound 513 |
| 780 | put tmb add p i get tcmaptmp i |
| 781 | i = add i 1 |
| 782 | end |
| 783 | put tmk slot tmapkey code nb |
| 784 | put tmoff slot p |
| 785 | put tmlen slot dn |
| 786 | put tfinfo 4 add p dn |
| 787 | end |
| 788 | fn tcode to ulong |
| 789 | n = get tlx 4 |
| 790 | if or eq n 0 gt n 4 |
| 791 | tunsup |
| 792 | end |
| 793 | v = ulong 0 |
| 794 | i = ulong 0 |
| 795 | while lt i n bound 5 |
| 796 | v = add mul v 256 ulong get tstr i |
| 797 | i = add i 1 |
| 798 | end |
| 799 | ret v |
| 800 | end |
| 801 | fn tdest to ulong |
| 802 | texpect 3 |
| 803 | n = get tlx 4 |
| 804 | if gt n 512 |
| 805 | tlimit |
| 806 | end |
| 807 | if or eq n 0 ne rem n 2 0 |
| 808 | tbad |
| 809 | end |
| 810 | i = ulong 0 |
| 811 | while lt i n bound 513 |
| 812 | put tcmaptmp i get tstr i |
| 813 | i = add i 1 |
| 814 | end |
| 815 | ret n |
| 816 | end |
| 817 | text tbegcs "begincodespacerange" |
| 818 | text tendcs "endcodespacerange" |
| 819 | text tbegbf "beginbfchar" |
| 820 | text tendbf "endbfchar" |
| 821 | text tbegr "beginbfrange" |
| 822 | text tendr "endbfrange" |
| 823 | text tusecm "usecmap" |
| 824 | text twmoden "WMode" |
| 825 | fn tcspace count ulong to void |
| 826 | i = ulong 0 |
| 827 | while lt i count bound 65537 |
| 828 | j = get tfinfo 2 |
| 829 | if ge j 64 |
| 830 | tlimit |
| 831 | end |
| 832 | texpect 3 |
| 833 | lo = tcode |
| 834 | nb = get tlx 4 |
| 835 | texpect 3 |
| 836 | hi = tcode |
| 837 | if or ne nb get tlx 4 gt lo hi |
| 838 | tbad |
| 839 | end |
| 840 | tspacecheck lo hi nb |
| 841 | put tslo j lo |
| 842 | put tshi j hi |
| 843 | put tsbytes j nb |
| 844 | put tfinfo 2 add j 1 |
| 845 | i = add i 1 |
| 846 | end |
| 847 | tendword tendcs |
| 848 | end |
| 849 | fn tcbf count ulong to void |
| 850 | i = ulong 0 |
| 851 | while lt i count bound 65537 |
| 852 | texpect 3 |
| 853 | code = tcode |
| 854 | nb = get tlx 4 |
| 855 | dn = tdest |
| 856 | tmapinsert code nb dn |
| 857 | i = add i 1 |
| 858 | end |
| 859 | tendword tendbf |
| 860 | end |
| 861 | fn trarray lo ulong hi ulong nb ulong to void |
| 862 | code = lo |
| 863 | while le code hi bound 65537 |
| 864 | dn = tdest |
| 865 | tmapinsert code nb dn |
| 866 | code = add code 1 |
| 867 | end |
| 868 | texpect 6 |
| 869 | end |
| 870 | fn trstring lo ulong hi ulong nb ulong to void |
| 871 | if ne get tlx 3 3 |
| 872 | tbad |
| 873 | end |
| 874 | dn = get tlx 4 |
| 875 | if gt dn 512 |
| 876 | tlimit |
| 877 | end |
| 878 | if or eq dn 0 ne rem dn 2 0 |
| 879 | tbad |
| 880 | end |
| 881 | j = ulong 0 |
| 882 | while lt j dn bound 513 |
| 883 | put tcmaptmp j get tstr j |
| 884 | j = add j 1 |
| 885 | end |
| 886 | lastb = ulong get tcmaptmp sub dn 1 |
| 887 | if gt sub hi lo sub 255 lastb |
| 888 | tbad |
| 889 | end |
| 890 | code = lo |
| 891 | while le code hi bound 65537 |
| 892 | put tcmaptmp sub dn 1 uchar add lastb sub code lo |
| 893 | tmapinsert code nb dn |
| 894 | code = add code 1 |
| 895 | end |
| 896 | end |
| 897 | fn tcrange count ulong to void |
| 898 | i = ulong 0 |
| 899 | while lt i count bound 65537 |
| 900 | texpect 3 |
| 901 | lo = tcode |
| 902 | nb = get tlx 4 |
| 903 | texpect 3 |
| 904 | hi = tcode |
| 905 | if or ne nb get tlx 4 gt lo hi |
| 906 | tbad |
| 907 | end |
| 908 | if ge sub hi lo 65536 |
| 909 | tlimit |
| 910 | end |
| 911 | tlex |
| 912 | if eq get tlx 3 5 |
| 913 | trarray lo hi nb |
| 914 | else |
| 915 | trstring lo hi nb |
| 916 | end |
| 917 | i = add i 1 |
| 918 | end |
| 919 | tendword tendr |
| 920 | end |
| 921 | fn tcmap node ulong to void |
| 922 | if ne pderef pget node tkuse 0 |
| 923 | tunsup |
| 924 | end |
| 925 | wm = pderef pget node tkwmode |
| 926 | if ne wm 0 |
| 927 | if ne tint wm 1 0 |
| 928 | tunsup |
| 929 | end |
| 930 | end |
| 931 | pdecode node |
| 932 | n = get pdlen 0 |
| 933 | b = get tcbytes 0 |
| 934 | if gt n sub 268435456 b |
| 935 | tlimit |
| 936 | end |
| 937 | put tcbytes 0 add b n |
| 938 | put tlx 0 1 |
| 939 | put tlx 1 0 |
| 940 | put tlx 2 n |
| 941 | count = ulong 0 |
| 942 | while true bound 16777217 |
| 943 | tlex |
| 944 | k = get tlx 3 |
| 945 | if eq k 0 |
| 946 | break |
| 947 | end |
| 948 | if eq k 1 |
| 949 | v = get tvalue 0 |
| 950 | if or lt v 0.0f64 gt v 65536.0f64 |
| 951 | tlimit |
| 952 | end |
| 953 | count = ulong v |
| 954 | if ne f64 count v |
| 955 | tbad |
| 956 | end |
| 957 | continue |
| 958 | end |
| 959 | if eq k 2 |
| 960 | if teq twmoden |
| 961 | texpect 1 |
| 962 | if ne get tvalue 0 0.0f64 |
| 963 | tunsup |
| 964 | end |
| 965 | end |
| 966 | continue |
| 967 | end |
| 968 | if eq k 4 |
| 969 | if teq tusecm |
| 970 | tunsup |
| 971 | end |
| 972 | if teq tbegcs |
| 973 | tcspace count |
| 974 | end |
| 975 | if teq tbegbf |
| 976 | tcbf count |
| 977 | end |
| 978 | if teq tbegr |
| 979 | tcrange count |
| 980 | end |
| 981 | end |
| 982 | end |
| 983 | if or eq get tfinfo 2 0 eq get tfinfo 3 0 |
| 984 | tbad |
| 985 | end |
| 986 | end |
| 987 | fn tsimplewidth fontn ulong to void |
| 988 | missing = 500.0f64 |
| 989 | desc = pderef pget fontn tkdesc |
| 990 | n = pderef pget desc tkmiss |
| 991 | if ne n 0 |
| 992 | missing = tnumber n |
| 993 | end |
| 994 | i = ulong 0 |
| 995 | while lt i 65536 bound 65537 |
| 996 | put tmetrics i missing |
| 997 | i = add i 1 |
| 998 | end |
| 999 | w = pderef pget fontn tkwidth |
| 1000 | if eq w 0 |
| 1001 | ret |
| 1002 | end |
| 1003 | w = tkind w 7 |
| 1004 | first = tint pget fontn tkfirst 255 |
| 1005 | last = tint pget fontn tklast 255 |
| 1006 | if gt first last |
| 1007 | tbad |
| 1008 | end |
| 1009 | v = get pfirst w |
| 1010 | code = first |
| 1011 | while ne v 0 bound 257 |
| 1012 | if gt code last |
| 1013 | tbad |
| 1014 | end |
| 1015 | put tmetrics code tnumber v |
| 1016 | code = add code 1 |
| 1017 | v = get pnext v |
| 1018 | end |
| 1019 | if ne code add last 1 |
| 1020 | tbad |
| 1021 | end |
| 1022 | end |
| 1023 | fn tcidwidth fontn ulong to void |
| 1024 | arr = tkind pget fontn tkdf 7 |
| 1025 | v = get pfirst arr |
| 1026 | if eq v 0 |
| 1027 | tbad |
| 1028 | end |
| 1029 | if ne get pnext v 0 |
| 1030 | tbad |
| 1031 | end |
| 1032 | desc = tkind v 8 |
| 1033 | dw = 1000.0f64 |
| 1034 | v = pderef pget desc tkdw |
| 1035 | if ne v 0 |
| 1036 | dw = tnumber v |
| 1037 | end |
| 1038 | i = ulong 0 |
| 1039 | while lt i 65536 bound 65537 |
| 1040 | put tmetrics i dw |
| 1041 | i = add i 1 |
| 1042 | end |
| 1043 | arr = pderef pget desc tkw |
| 1044 | if eq arr 0 |
| 1045 | ret |
| 1046 | end |
| 1047 | arr = tkind arr 7 |
| 1048 | v = get pfirst arr |
| 1049 | while ne v 0 bound 262145 |
| 1050 | lo = tint v 65535 |
| 1051 | v = get pnext v |
| 1052 | if eq v 0 |
| 1053 | tbad |
| 1054 | end |
| 1055 | n = pderef v |
| 1056 | if eq get ptype n 7 |
| 1057 | x = get pfirst n |
| 1058 | while ne x 0 bound 65537 |
| 1059 | if ge lo 65536 |
| 1060 | tlimit |
| 1061 | end |
| 1062 | put tmetrics lo tnumber x |
| 1063 | lo = add lo 1 |
| 1064 | x = get pnext x |
| 1065 | end |
| 1066 | v = get pnext v |
| 1067 | else |
| 1068 | hi = tint n 65535 |
| 1069 | if lt hi lo |
| 1070 | tbad |
| 1071 | end |
| 1072 | v = get pnext v |
| 1073 | if eq v 0 |
| 1074 | tbad |
| 1075 | end |
| 1076 | width = tnumber v |
| 1077 | while le lo hi bound 65537 |
| 1078 | put tmetrics lo width |
| 1079 | lo = add lo 1 |
| 1080 | end |
| 1081 | v = get pnext v |
| 1082 | end |
| 1083 | end |
| 1084 | end |
| 1085 | fn tfontload fontn ulong to void |
| 1086 | nloads = get tloads 0 |
| 1087 | if ge nloads 4096 |
| 1088 | tlimit |
| 1089 | end |
| 1090 | put tloads 0 add nloads 1 |
| 1091 | put tloaded 0 fontn |
| 1092 | put tfontmx 0 0.001f64 |
| 1093 | put tfontmx 1 0.0f64 |
| 1094 | i = ulong 0 |
| 1095 | while lt i 7 bound 8 |
| 1096 | put tfinfo i 0 |
| 1097 | i = add i 1 |
| 1098 | end |
| 1099 | i = 0 |
| 1100 | while lt i 131072 bound 131073 |
| 1101 | put tmk i 0 |
| 1102 | i = add i 1 |
| 1103 | end |
| 1104 | if pne pget fontn tksub tntype0 |
| 1105 | put tfinfo 0 1 |
| 1106 | enc = pderef pget fontn tkenc |
| 1107 | if not pne enc tnidh |
| 1108 | tunsup |
| 1109 | end |
| 1110 | tcidwidth fontn |
| 1111 | else |
| 1112 | subtyp = pget fontn tksub |
| 1113 | ok = or pne subtyp tntype1 pne subtyp tntrue |
| 1114 | ok = or ok pne subtyp tnmm |
| 1115 | ok = or ok pne subtyp tntype3 |
| 1116 | if not ok |
| 1117 | tunsup |
| 1118 | end |
| 1119 | tsimplewidth fontn |
| 1120 | if pne subtyp tntype3 |
| 1121 | ttype3matrix fontn |
| 1122 | end |
| 1123 | end |
| 1124 | note With a ToUnicode CMap no base encoding is built: codes it does not map print U+FFFD (tnomap). |
| 1125 | for bi ulong 256 |
| 1126 | put tbasecp bi 0 |
| 1127 | end |
| 1128 | cmap = pderef pget fontn tktoun |
| 1129 | if ne cmap 0 |
| 1130 | put tfinfo 1 1 |
| 1131 | tcmap cmap |
| 1132 | else |
| 1133 | if ne get tfinfo 0 0 |
| 1134 | tunsup |
| 1135 | end |
| 1136 | tencoding fontn |
| 1137 | end |
| 1138 | end |
| 1139 | fn tensurefont to void |
| 1140 | f = get tfont 0 |
| 1141 | if eq f 0 |
| 1142 | tbad |
| 1143 | end |
| 1144 | if eq f get tloaded 0 |
| 1145 | ret |
| 1146 | end |
| 1147 | saved = new ulong 5 0 |
| 1148 | i = ulong 0 |
| 1149 | while lt i 5 bound 6 |
| 1150 | put saved i get tlx i |
| 1151 | i = add i 1 |
| 1152 | end |
| 1153 | tfontload f |
| 1154 | i = 0 |
| 1155 | while lt i 5 bound 6 |
| 1156 | put tlx i get saved i |
| 1157 | i = add i 1 |
| 1158 | end |
| 1159 | end |
| 1160 | |
| 1161 | note Geometry is content order only. Width fallback 500/1000 em for absent simple Widths, |
| 1162 | note overridden by descriptor MissingWidth. It affects inferred spaces only, not Unicode. |
| 1163 | note This known difference class can disagree with a standard-14 font's actual advance. |
| 1164 | note tgeo: baseline unit x/y and effective font size. |
| 1165 | fn tidentity off ulong to void |
| 1166 | i = ulong 0 |
| 1167 | while lt i 6 bound 7 |
| 1168 | v = 0.0f64 |
| 1169 | if or eq i 0 eq i 3 |
| 1170 | v = 1.0f64 |
| 1171 | end |
| 1172 | put tmat add off i v |
| 1173 | i = add i 1 |
| 1174 | end |
| 1175 | end |
| 1176 | fn ttranslate dx f64 dy f64 to void |
| 1177 | x = add mul dx get tmat 6 mul dy get tmat 8 |
| 1178 | y = add mul dx get tmat 7 mul dy get tmat 9 |
| 1179 | put tmat 10 tfinite add get tmat 10 x |
| 1180 | put tmat 11 tfinite add get tmat 11 y |
| 1181 | end |
| 1182 | fn tmove dx f64 dy f64 to void |
| 1183 | i = ulong 0 |
| 1184 | while lt i 6 bound 7 |
| 1185 | put tmat add i 6 get tmat add i 12 |
| 1186 | i = add i 1 |
| 1187 | end |
| 1188 | ttranslate dx dy |
| 1189 | i = 0 |
| 1190 | while lt i 6 bound 7 |
| 1191 | put tmat add i 12 get tmat add i 6 |
| 1192 | i = add i 1 |
| 1193 | end |
| 1194 | end |
| 1195 | fn tnextline to void |
| 1196 | tmove 0.0f64 neg get tstate 3 |
| 1197 | end |
| 1198 | fn tconcat to void |
| 1199 | targs 6 |
| 1200 | for i ulong 6 |
| 1201 | put tcv i targnum i |
| 1202 | end |
| 1203 | for i ulong 6 |
| 1204 | put tcp i tcmel i |
| 1205 | end |
| 1206 | note Separate product storage preserves all original matrix coefficients. |
| 1207 | for i ulong 6 |
| 1208 | put tmat i get tcp i |
| 1209 | end |
| 1210 | end |
| 1211 | note tcmel: element i of the product tcv x CTM (9.4.4 / 8.3.4: cm replaces CTM by M x CTM). |
| 1212 | fn tcmel i ulong to f64 |
| 1213 | j = rem i 2 |
| 1214 | k = mul div i 2 2 |
| 1215 | v = add mul get tcv k get tmat j mul get tcv add k 1 get tmat add j 2 |
| 1216 | if ge i 4 |
| 1217 | v = add v get tmat add j 4 |
| 1218 | end |
| 1219 | ret tfinite v |
| 1220 | end |
| 1221 | fn tpushq to void |
| 1222 | targs 0 |
| 1223 | d = get tqdepth 0 |
| 1224 | if ge d 32 |
| 1225 | tlimit |
| 1226 | end |
| 1227 | i = ulong 0 |
| 1228 | while lt i 6 bound 7 |
| 1229 | put tqmat add mul d 12 i get tmat i |
| 1230 | put tqmat add add mul d 12 6 i get tstate i |
| 1231 | i = add i 1 |
| 1232 | end |
| 1233 | put tqfont d get tfont 0 |
| 1234 | put tqdepth 0 add d 1 |
| 1235 | end |
| 1236 | fn tpopq to void |
| 1237 | targs 0 |
| 1238 | d = get tqdepth 0 |
| 1239 | if eq d 0 |
| 1240 | tbad |
| 1241 | end |
| 1242 | d = sub d 1 |
| 1243 | put tqdepth 0 d |
| 1244 | i = ulong 0 |
| 1245 | while lt i 6 bound 7 |
| 1246 | put tmat i get tqmat add mul d 12 i |
| 1247 | put tstate i get tqmat add add mul d 12 6 i |
| 1248 | i = add i 1 |
| 1249 | end |
| 1250 | put tfont 0 get tqfont d |
| 1251 | end |
| 1252 | fn tgeometry to void |
| 1253 | bx = add mul get tmat 6 get tmat 0 mul get tmat 7 get tmat 2 |
| 1254 | by = add mul get tmat 6 get tmat 1 mul get tmat 7 get tmat 3 |
| 1255 | mag = fsqrt add mul bx bx mul by by |
| 1256 | if eq mag 0.0f64 |
| 1257 | tbad |
| 1258 | end |
| 1259 | put tgeo 0 div bx mag |
| 1260 | put tgeo 1 div by mag |
| 1261 | sz = tfinite mul fabs get tstate 5 mag |
| 1262 | put tgeo 2 sz |
| 1263 | end |
| 1264 | fn torigin coord ulong to f64 |
| 1265 | note Rise affects painted glyphs, not the text baseline used for spacing. |
| 1266 | x = get tmat 10 |
| 1267 | y = get tmat 11 |
| 1268 | v = add mul x get tmat coord mul y get tmat add coord 2 |
| 1269 | ret tfinite add v get tmat add coord 4 |
| 1270 | end |
| 1271 | fn tseparate to void |
| 1272 | tgeometry |
| 1273 | x = torigin 0 |
| 1274 | y = torigin 1 |
| 1275 | if ne get thave 0 0 |
| 1276 | dx = sub x get tlast 0 |
| 1277 | dy = sub y get tlast 1 |
| 1278 | across = sub mul dy get tgeo 0 mul dx get tgeo 1 |
| 1279 | if gt fabs across mul get tgeo 2 0.5f64 |
| 1280 | tbreak 10 |
| 1281 | else |
| 1282 | along = add mul dx get tgeo 0 mul dy get tgeo 1 |
| 1283 | if ge along mul get tgeo 2 0.12f64 |
| 1284 | if gt along 0.0f64 |
| 1285 | tbreak 32 |
| 1286 | end |
| 1287 | end |
| 1288 | end |
| 1289 | end |
| 1290 | put thave 0 1 |
| 1291 | end |
| 1292 | fn tpen to void |
| 1293 | put tlast 0 torigin 0 |
| 1294 | put tlast 1 torigin 1 |
| 1295 | end |
| 1296 | note tmb16: the big-endian 16-bit unit at tmb[q]. |
| 1297 | fn tmb16 q ulong to ulong |
| 1298 | hi = ulong get tmb q |
| 1299 | lo = ulong get tmb add q 1 |
| 1300 | ret or shl hi 8 lo |
| 1301 | end |
| 1302 | fn tmapemit slot ulong to void |
| 1303 | p = get tmoff slot |
| 1304 | n = get tmlen slot |
| 1305 | i = ulong 0 |
| 1306 | while lt i n bound 513 |
| 1307 | cp = tmb16 add p i |
| 1308 | i = add i 2 |
| 1309 | if and ge cp 55296 le cp 56319 |
| 1310 | if ge i n |
| 1311 | tbad |
| 1312 | end |
| 1313 | lo = tmb16 add p i |
| 1314 | if or lt lo 56320 gt lo 57343 |
| 1315 | tbad |
| 1316 | end |
| 1317 | cp = add 65536 add mul sub cp 55296 1024 sub lo 56320 |
| 1318 | i = add i 2 |
| 1319 | else |
| 1320 | if and ge cp 56320 le cp 57343 |
| 1321 | tbad |
| 1322 | end |
| 1323 | end |
| 1324 | tu8 cp |
| 1325 | end |
| 1326 | end |
| 1327 | fn tmatchspace code ulong nb ulong to bool |
| 1328 | i = ulong 0 |
| 1329 | while lt i get tfinfo 2 bound 65 |
| 1330 | if eq get tsbytes i nb |
| 1331 | if and ge code get tslo i le code get tshi i |
| 1332 | ret true |
| 1333 | end |
| 1334 | end |
| 1335 | i = add i 1 |
| 1336 | end |
| 1337 | ret false |
| 1338 | end |
| 1339 | note tnomap: a code the ToUnicode CMap does not map (9.10.2) prints one U+FFFD (the base table is empty |
| 1340 | note while a ToUnicode CMap is in use, so the lookup below only guards the table index). |
| 1341 | fn tnomap code ulong to void |
| 1342 | if lt code 256 |
| 1343 | cp = get tbasecp code |
| 1344 | if ne cp 0 |
| 1345 | tu8 cp |
| 1346 | ret |
| 1347 | end |
| 1348 | end |
| 1349 | tu8 65533 |
| 1350 | end |
| 1351 | fn tshowglyph code ulong nb ulong to void |
| 1352 | tseparate |
| 1353 | if ne get tfinfo 1 0 |
| 1354 | slot = tmapfind tmapkey code nb |
| 1355 | if eq get tmk slot 0 |
| 1356 | tnomap code |
| 1357 | else |
| 1358 | tmapemit slot |
| 1359 | end |
| 1360 | else |
| 1361 | cp = get tbasecp code |
| 1362 | if eq cp 0 |
| 1363 | cp = 65533 |
| 1364 | end |
| 1365 | tu8 cp |
| 1366 | end |
| 1367 | if ge code 65536 |
| 1368 | tlimit |
| 1369 | end |
| 1370 | width = get tmetrics code |
| 1371 | size = get tstate 5 |
| 1372 | dx = mul mul width get tfontmx 0 size |
| 1373 | dy = mul mul width get tfontmx 1 size |
| 1374 | dx = add dx get tstate 0 |
| 1375 | if and eq nb 1 eq code 32 |
| 1376 | dx = add dx get tstate 1 |
| 1377 | end |
| 1378 | ttranslate mul dx get tstate 2 dy |
| 1379 | tpen |
| 1380 | end |
| 1381 | fn tshow j ulong to void |
| 1382 | if eq get tinbt 0 0 |
| 1383 | tbad |
| 1384 | end |
| 1385 | if ne get tokind j 3 |
| 1386 | tbad |
| 1387 | end |
| 1388 | tensurefont |
| 1389 | p = get tostart j |
| 1390 | n = get tolen j |
| 1391 | i = ulong 0 |
| 1392 | while lt i n bound 65537 |
| 1393 | if eq get tfinfo 1 0 |
| 1394 | tshowglyph ulong get topool add p i 1 |
| 1395 | i = add i 1 |
| 1396 | continue |
| 1397 | end |
| 1398 | code = ulong 0 |
| 1399 | nb = ulong 0 |
| 1400 | matched = false |
| 1401 | while and lt nb 4 lt i n bound 5 |
| 1402 | code = add mul code 256 ulong get topool add p i |
| 1403 | nb = add nb 1 |
| 1404 | i = add i 1 |
| 1405 | if tmatchspace code nb |
| 1406 | matched = true |
| 1407 | break |
| 1408 | end |
| 1409 | end |
| 1410 | if not matched |
| 1411 | tbad |
| 1412 | end |
| 1413 | if eq get tfinfo 0 0 |
| 1414 | if ne nb 1 |
| 1415 | tbad |
| 1416 | end |
| 1417 | end |
| 1418 | tshowglyph code nb |
| 1419 | end |
| 1420 | end |
| 1421 | fn tadjust v f64 to void |
| 1422 | if eq get tinbt 0 0 |
| 1423 | tbad |
| 1424 | end |
| 1425 | ttranslate neg mul mul div v 1000.0f64 get tstate 5 get tstate 2 0.0f64 |
| 1426 | end |
| 1427 | fn tshowarray to void |
| 1428 | n = get tlx 5 |
| 1429 | if lt n 2 |
| 1430 | tbad |
| 1431 | end |
| 1432 | if or ne get tokind 0 5 ne get tokind sub n 1 6 |
| 1433 | tbad |
| 1434 | end |
| 1435 | i = ulong 1 |
| 1436 | while lt i sub n 1 bound 4097 |
| 1437 | k = get tokind i |
| 1438 | if eq k 3 |
| 1439 | tshow i |
| 1440 | else |
| 1441 | if ne k 1 |
| 1442 | tbad |
| 1443 | end |
| 1444 | tadjust get tovalue i |
| 1445 | end |
| 1446 | i = add i 1 |
| 1447 | end |
| 1448 | end |
| 1449 | fn tsetfont to void |
| 1450 | targs 2 |
| 1451 | fontn = targname 0 pget get pres get tpage 0 tkfont |
| 1452 | if eq fontn 0 |
| 1453 | tbad |
| 1454 | end |
| 1455 | put tfont 0 fontn |
| 1456 | put tstate 5 targnum 1 |
| 1457 | end |
| 1458 | fn tsetmatrix to void |
| 1459 | targs 6 |
| 1460 | i = ulong 0 |
| 1461 | while lt i 6 bound 7 |
| 1462 | v = targnum i |
| 1463 | put tmat add i 6 v |
| 1464 | put tmat add i 12 v |
| 1465 | i = add i 1 |
| 1466 | end |
| 1467 | end |
| 1468 | text topbt "BT" |
| 1469 | text topet "ET" |
| 1470 | text toptf "Tf" |
| 1471 | text toptd "Td" |
| 1472 | text toptD "TD" |
| 1473 | text toptm "Tm" |
| 1474 | text topts "T*" |
| 1475 | text toptj "Tj" |
| 1476 | text toptJ "TJ" |
| 1477 | text topquot "'" |
| 1478 | text topdquo "\"" |
| 1479 | text toptc "Tc" |
| 1480 | text toptw "Tw" |
| 1481 | text toptz "Tz" |
| 1482 | text toptl "TL" |
| 1483 | text toprise "Ts" |
| 1484 | text toprend "Tr" |
| 1485 | text topq "q" |
| 1486 | text topQ "Q" |
| 1487 | text topcm "cm" |
| 1488 | text topdo "Do" |
| 1489 | text topbi "BI" |
| 1490 | text topbmc "BMC" |
| 1491 | text topbdc "BDC" |
| 1492 | text topemc "EMC" |
| 1493 | fn ttextstate ix ulong to void |
| 1494 | targs 1 |
| 1495 | v = targnum 0 |
| 1496 | if eq ix 2 |
| 1497 | v = div v 100.0f64 |
| 1498 | end |
| 1499 | put tstate ix v |
| 1500 | end |
| 1501 | fn toperator to void |
| 1502 | if teq topbt |
| 1503 | targs 0 |
| 1504 | if ne get tinbt 0 0 |
| 1505 | tbad |
| 1506 | end |
| 1507 | put tinbt 0 1 |
| 1508 | tidentity 6 |
| 1509 | tidentity 12 |
| 1510 | ret |
| 1511 | end |
| 1512 | if teq topet |
| 1513 | targs 0 |
| 1514 | if eq get tinbt 0 0 |
| 1515 | tbad |
| 1516 | end |
| 1517 | put tinbt 0 0 |
| 1518 | ret |
| 1519 | end |
| 1520 | if teq topq |
| 1521 | tpushq |
| 1522 | ret |
| 1523 | end |
| 1524 | if teq topQ |
| 1525 | tpopq |
| 1526 | ret |
| 1527 | end |
| 1528 | if teq topcm |
| 1529 | tconcat |
| 1530 | ret |
| 1531 | end |
| 1532 | if teq toptf |
| 1533 | tsetfont |
| 1534 | ret |
| 1535 | end |
| 1536 | if teq toptc |
| 1537 | ttextstate 0 |
| 1538 | ret |
| 1539 | end |
| 1540 | if teq toptw |
| 1541 | ttextstate 1 |
| 1542 | ret |
| 1543 | end |
| 1544 | if teq toptz |
| 1545 | ttextstate 2 |
| 1546 | ret |
| 1547 | end |
| 1548 | if teq toptl |
| 1549 | ttextstate 3 |
| 1550 | ret |
| 1551 | end |
| 1552 | if teq toprise |
| 1553 | ttextstate 4 |
| 1554 | ret |
| 1555 | end |
| 1556 | if teq toprend |
| 1557 | targs 1 |
| 1558 | v = targnum 0 |
| 1559 | if or lt v 0.0f64 gt v 7.0f64 |
| 1560 | tbad |
| 1561 | end |
| 1562 | if ne v f64 ulong v |
| 1563 | tbad |
| 1564 | end |
| 1565 | ret |
| 1566 | end |
| 1567 | if or teq toptd teq toptD |
| 1568 | if eq get tinbt 0 0 |
| 1569 | tbad |
| 1570 | end |
| 1571 | targs 2 |
| 1572 | if teq toptD |
| 1573 | put tstate 3 neg targnum 1 |
| 1574 | end |
| 1575 | tmove targnum 0 targnum 1 |
| 1576 | ret |
| 1577 | end |
| 1578 | if teq toptm |
| 1579 | if eq get tinbt 0 0 |
| 1580 | tbad |
| 1581 | end |
| 1582 | tsetmatrix |
| 1583 | ret |
| 1584 | end |
| 1585 | if teq topts |
| 1586 | if eq get tinbt 0 0 |
| 1587 | tbad |
| 1588 | end |
| 1589 | targs 0 |
| 1590 | tnextline |
| 1591 | ret |
| 1592 | end |
| 1593 | if teq toptj |
| 1594 | targs 1 |
| 1595 | tshow 0 |
| 1596 | ret |
| 1597 | end |
| 1598 | if teq toptJ |
| 1599 | tshowarray |
| 1600 | ret |
| 1601 | end |
| 1602 | if teq topquot |
| 1603 | targs 1 |
| 1604 | tnextline |
| 1605 | tshow 0 |
| 1606 | ret |
| 1607 | end |
| 1608 | if teq topdquo |
| 1609 | targs 3 |
| 1610 | put tstate 1 targnum 0 |
| 1611 | put tstate 0 targnum 1 |
| 1612 | tnextline |
| 1613 | tshow 2 |
| 1614 | ret |
| 1615 | end |
| 1616 | if teq topdo |
| 1617 | targs 1 |
| 1618 | n = targname 0 pget get pres get tpage 0 tkxobj |
| 1619 | if eq n 0 |
| 1620 | tbad |
| 1621 | end |
| 1622 | if not pne pget n tksub tnimage |
| 1623 | tunsup |
| 1624 | end |
| 1625 | ret |
| 1626 | end |
| 1627 | if teq topbi |
| 1628 | tunsup |
| 1629 | end |
| 1630 | note Other graphics operators have no effect on text state. Containers have already been bounded. |
| 1631 | end |
| 1632 | fn tinterpret to void |
| 1633 | put tlx 0 0 |
| 1634 | put tlx 1 0 |
| 1635 | put tlx 5 0 |
| 1636 | put tlx 6 0 |
| 1637 | depth = ulong 0 |
| 1638 | stack = new ulong 64 0 |
| 1639 | while true bound 16777217 |
| 1640 | tlex |
| 1641 | k = get tlx 3 |
| 1642 | if eq k 0 |
| 1643 | break |
| 1644 | end |
| 1645 | if or or eq k 5 eq k 7 eq k 9 |
| 1646 | if ge depth 64 |
| 1647 | tlimit |
| 1648 | end |
| 1649 | put stack depth k |
| 1650 | depth = add depth 1 |
| 1651 | topush |
| 1652 | continue |
| 1653 | end |
| 1654 | if or or eq k 6 eq k 8 eq k 10 |
| 1655 | if eq depth 0 |
| 1656 | tbad |
| 1657 | end |
| 1658 | depth = sub depth 1 |
| 1659 | if ne k add get stack depth 1 |
| 1660 | tbad |
| 1661 | end |
| 1662 | topush |
| 1663 | continue |
| 1664 | end |
| 1665 | if and eq k 4 eq depth 0 |
| 1666 | toperator |
| 1667 | put tlx 5 0 |
| 1668 | put tlx 6 0 |
| 1669 | else |
| 1670 | topush |
| 1671 | end |
| 1672 | end |
| 1673 | if or ne depth 0 ne get tlx 5 0 |
| 1674 | tbad |
| 1675 | end |
| 1676 | if ne get tinbt 0 0 |
| 1677 | tbad |
| 1678 | end |
| 1679 | if ne get tqdepth 0 0 |
| 1680 | tbad |
| 1681 | end |
| 1682 | end |
| 1683 | fn tappendstream n ulong to void |
| 1684 | pdecode n |
| 1685 | p = get tlx 2 |
| 1686 | nbytes = get pdlen 0 |
| 1687 | if ge nbytes sub 16777216 p |
| 1688 | tlimit |
| 1689 | end |
| 1690 | i = ulong 0 |
| 1691 | while lt i nbytes bound 16777217 |
| 1692 | put tcs add p i get pdbuf i |
| 1693 | i = add i 1 |
| 1694 | end |
| 1695 | put tcs add p nbytes 32 |
| 1696 | put tlx 2 add add p nbytes 1 |
| 1697 | end |
| 1698 | fn tpagecontent pageix ulong to void |
| 1699 | put tlx 2 0 |
| 1700 | cont = pderef pget get ppages pageix tkcont |
| 1701 | if eq cont 0 |
| 1702 | ret |
| 1703 | end |
| 1704 | if eq get ptype cont 10 |
| 1705 | tappendstream cont |
| 1706 | ret |
| 1707 | end |
| 1708 | cont = tkind cont 7 |
| 1709 | n = get pfirst cont |
| 1710 | while ne n 0 bound 262145 |
| 1711 | tappendstream n |
| 1712 | n = get pnext n |
| 1713 | end |
| 1714 | end |
| 1715 | fn tpages first ulong last ulong to void |
| 1716 | if or eq first 0 lt last first |
| 1717 | tbad |
| 1718 | end |
| 1719 | if gt last get pcount 0 |
| 1720 | tbad |
| 1721 | end |
| 1722 | ix = sub first 1 |
| 1723 | while lt ix last bound 4097 |
| 1724 | put tpage 0 ix |
| 1725 | put tfont 0 0 |
| 1726 | put tloaded 0 0 |
| 1727 | put tloads 0 0 |
| 1728 | put tcbytes 0 0 |
| 1729 | put tqdepth 0 0 |
| 1730 | put tinbt 0 0 |
| 1731 | put thave 0 0 |
| 1732 | put tlx 7 0 |
| 1733 | i = ulong 0 |
| 1734 | while lt i 6 bound 7 |
| 1735 | put tstate i 0.0f64 |
| 1736 | i = add i 1 |
| 1737 | end |
| 1738 | put tstate 2 1.0f64 |
| 1739 | tidentity 0 |
| 1740 | tpagecontent ix |
| 1741 | tinterpret |
| 1742 | note Each page ends with LF then FF (form feed), so page boundaries survive in the output. |
| 1743 | if eq get tlx 7 0 |
| 1744 | temit 10 |
| 1745 | else |
| 1746 | tbreak 10 |
| 1747 | end |
| 1748 | temit 12 |
| 1749 | tflush |
| 1750 | ix = add ix 1 |
| 1751 | end |
| 1752 | end |
| 1753 | |
| 1754 | fn ttype3matrix fontn ulong to void |
| 1755 | m = tkind pget fontn tkmatrix 7 |
| 1756 | v = get pfirst m |
| 1757 | i = ulong 0 |
| 1758 | while ne v 0 bound 7 |
| 1759 | if ge i 6 |
| 1760 | tbad |
| 1761 | end |
| 1762 | x = tnumber v |
| 1763 | if lt i 2 |
| 1764 | put tfontmx i x |
| 1765 | end |
| 1766 | i = add i 1 |
| 1767 | v = get pnext v |
| 1768 | end |
| 1769 | if ne i 6 |
| 1770 | tbad |
| 1771 | end |
| 1772 | end |
| 1773 | fn tvaliddest dn ulong to void |
| 1774 | i = ulong 0 |
| 1775 | while lt i dn bound 513 |
| 1776 | cp = add mul ulong get tcmaptmp i 256 ulong get tcmaptmp add i 1 |
| 1777 | i = add i 2 |
| 1778 | if and ge cp 55296 le cp 56319 |
| 1779 | if ge i dn |
| 1780 | tbad |
| 1781 | end |
| 1782 | lo = add mul ulong get tcmaptmp i 256 ulong get tcmaptmp add i 1 |
| 1783 | if or lt lo 56320 gt lo 57343 |
| 1784 | tbad |
| 1785 | end |
| 1786 | i = add i 2 |
| 1787 | else |
| 1788 | if and ge cp 56320 le cp 57343 |
| 1789 | tbad |
| 1790 | end |
| 1791 | end |
| 1792 | end |
| 1793 | end |
| 1794 | |
| 1795 | note Codespaces must not overlap or admit one code as a prefix of another length. |
| 1796 | fn tspacecheck lo ulong hi ulong nb ulong to void |
| 1797 | j = ulong 0 |
| 1798 | while lt j get tfinfo 2 bound 65 |
| 1799 | left = lo |
| 1800 | right = hi |
| 1801 | otherlo = get tslo j |
| 1802 | otherhi = get tshi j |
| 1803 | ob = get tsbytes j |
| 1804 | if lt nb ob |
| 1805 | bitsn = mul sub ob nb 8 |
| 1806 | otherlo = shr otherlo bitsn |
| 1807 | otherhi = shr otherhi bitsn |
| 1808 | else |
| 1809 | if gt nb ob |
| 1810 | bitsn = mul sub nb ob 8 |
| 1811 | left = shr left bitsn |
| 1812 | right = shr right bitsn |
| 1813 | end |
| 1814 | end |
| 1815 | if and le left otherhi ge right otherlo |
| 1816 | tbad |
| 1817 | end |
| 1818 | j = add j 1 |
| 1819 | end |
| 1820 | end |
| 1821 | |
| 1822 | text tnsymbol "Symbol" |
| 1823 | text tnzapf "ZapfDingbats" |
| 1824 | note timplicit: the base encoding when the font names none (9.6.6.1, Table 114): StandardEncoding (1) for a |
| 1825 | note nonsymbolic font; for a symbolic font (Flags bit 3) or Symbol/ZapfDingbats the font program's built-in |
| 1826 | note encoding, which this reader does not read: an empty base (0), so only Differences codes are mapped |
| 1827 | note and any other shown code prints U+FFFD. |
| 1828 | fn timplicit fontn ulong to ulong |
| 1829 | bf = pget fontn tkbf |
| 1830 | if or pne bf tnsymbol pne bf tnzapf |
| 1831 | ret 0 |
| 1832 | end |
| 1833 | flags = pderef pget pget fontn tkdesc tkflags |
| 1834 | if ne flags 0 |
| 1835 | f = tint flags 4294967295 |
| 1836 | if ne and f 4 0 |
| 1837 | ret 0 |
| 1838 | end |
| 1839 | end |
| 1840 | ret 1 |
| 1841 | end |
| 1842 | note Wolfram symbolic matrix product verified: a*g+b*i,a*h+b*j,c*g+d*i,c*h+d*j, |
| 1843 | note e*g+f*i+k,e*h+f*j+l. ISO example D840DC3E -> 131134 (U+2003E). |
| 1844 | note Spacing rules (stated, not layout analysis: text is printed in the order the content streams draw it): |
| 1845 | note a move across the baseline larger than 0.5 times the effective font size starts a new line; a move |
| 1846 | note along the baseline of at least 0.12 times the effective font size after the previous glyph ends |
| 1847 | note inserts one space. 0.12 em is below the narrowest justified word space seen in the corpus (pdfTeX |
| 1848 | note Times, 0.25 em less shrink) and above kerning adjustments. |