Does Tw work with TrueType fonts?
- January 23, 2023
- 5 replies
- 3761 views
I own and maintain the Perl library PDF::Builder, used for generating PDF files. I have encountered a possible problem with Adobe Acrobat Reader (64-bit) on Windows 10. The resulting PDF behaves as expected for "Tw" operators in the stream for core fonts and T1 fonts. However, it seems to be ignored for all the TrueType (.ttf) fonts I tried. Attached is a sample PDF, giving results for Times-Roman core font, English Towne Medium TrueType font, and URW Palladio-L Type 1 font. Each has a line with -5 Tw, 0 Tw, 3 Tw; and then a line with 10 Tc. The TrueType example also has a closed-up line where I individually place each word, emulating a 40% wide space. As far as I can see, the PDF is created with the expected Tw (or Tc) operators. Am I doing something wrong, or are TrueType fonts really a problem? The sample Perl program (as .pl.txt) is also attached, if you can read Perl.
In the documentation for Tw, it mentions that it looks specifically for x20 ASCII spaces. For TrueType font outputs, PDF::Builder is using glyph IDs (4 hex digits each). I'm wondering if the renderer is being fooled by those hex digits (no x20 in there). Perhaps the renderer could look for any glyph that has no ink, and treat it as a space, but that might be a problem with different-width spaces.
More discussion on this: https://github.com/PhilterPaper/Perl-PDF-Builder/issues/193
