pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Thomas-Cramer <thomascram...@dnastar.com>
Subject NPE during PDTrueTypeFont.loadTTF() on Mac TrueType font lacking Windows-platformID CMAPEncodingEntry
Date Wed, 27 Nov 2013 19:15:59 GMT

I'm attempting to embed a TrueType font using PDFBox, on the Mac, using PDTrueType.loadTTF(
PDDocument, InputStream, Encoding ).

For TrueType fonts originating from Windows (e.g., Tahoma) this works.

For TrueType fonts originating from the Mac (e.g., Apple Chancery), a NullPointerException
is thrown.

                at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:409)
                at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:201)
                at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:177)

I stepped through the code in a debugger. The method PDTrueTypeFont.loadDescriptorDictionary()
loops through the cmap table for the font, looking for a cmap with platform ID 3 (Windows),
and sets the variable unimap only if one is found. After that loop, the variable unimap is
dereferenced without checking for null.

Some Mac TrueType fonts have platform IDs 0 (Unicode) and 1 (Mac), but not 3 (Windows).

At the least, a null check seems required. But more desirable would be support for Mac TrueType

Am I missing something, or should I enter a bug?

* PDFBox version: 1.8.2
* Platform: Mac
* Java 6
* Font platform IDs: 0, 1

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message