pdftex bug
Nelson H. F. Beebe
beebe at math.utah.edu
Wed Sep 13 16:19:39 CEST 2023
Nobert Preining observes:
>> maybe the specification of type1 fonts requires a certain maximum precision.
I just checked p. 26 of the black-and-white covered Adobe Type 1 Font Format
book, and found that it demands that coordinates lie in [-2000, +2000].
Thus, at most 11 bits (because 2**11 = 2048) are required to represent
their precision, and David W. Matula's formula from
The Base Conversion Theorem
Proceedings of the American Mathematical Society 19(3) 716--723 June 1968
https://doi.org/10.1090/s0002-9939-1968-0234908-9
which can be written in hoc like this
func matula(p) { return ceil( p * log10(2) + 1 ) }
shows that at most 5 decimal digits are needed to recover the original
binary value of a coordinate. That of course, does not count leading
zeros, so the example of
/FontMatrix [0.000833333333333 0 0 0.000833333333333 0 0]
could have been shortened to
/FontMatrix [0.00083333 0 0 0.00083333 0 0]
Still, software should be able to correctly handle excess digits on
input values.
PostScript was defined with the IEEE 754 32-bit floating-point format
and, for integers, 32-bit two's complement values. The floating-point
value has 24 bits in the significand, for which Matula's formula
requires 9 decimal digits for exact round-trip conversion binary ->
decimal -> binary.
The PDF Reference Specification version 1.3 in Appendix C.1 shows
32-bit two's complement integers, but curiously, nonzero real
magnitudes are limited to the range [1/65536, 32767]. The book does
not mention "floating-point" in its index, and the given range
suggests that Adobe implemented PDF with 32-bit fixed-point numbers,
with a 1-bit sign, 15-bit integer value, and 16 bit fraction. That is
a 31-bit magnitude for which Matula's formula requires 11 decimal digits.
I don't have books with the TrueType and FontType specifications, so I
cannot easily check their coordinate limits. Their Wikipedia articles
do not mention numeric limits. Perhaps someone else on this list has
the necessary documents, and can report back.
----------------------------------------
For reader convenience, here is multicolumn table of bits and decimal
digits for Matula's formula, filtered with "pr -c7-f":
hoc> for (p = 1; p < 32; ++p) println p, matula(p)
1 2 6 3 11 5 16 6 20 8 24 9 28 10
2 2 7 4 12 5 17 7 21 8 25 9 29 10
3 2 8 4 13 5 18 7 22 8 26 9 30 11
4 3 9 4 14 6 19 7 23 8 27 10 31 11
5 3 10 5 15 6
-------------------------------------------------------------------------------
- Nelson H. F. Beebe Tel: +1 801 581 5254 -
- University of Utah -
- Department of Mathematics, 110 LCB Internet e-mail: beebe at math.utah.edu -
- 155 S 1400 E RM 233 beebe at acm.org beebe at computer.org -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------
More information about the tex-live
mailing list.