Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5.0
-
None
-
None
-
Sun JDK 6u24.
Description
Using PDFont.getFontWidth() on a TrueType font fails with ClassCastException in PDFBox 1.5.0:
Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Float
at org.apache.pdfbox.pdmodel.font.PDFont.getFontWidth(PDFont.java:786)
at org.apache.pdfbox.pdmodel.font.PDSimpleFont.getFontWidth(PDSimpleFont.java:191)
at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:283)
at ...
This is due to PDTrueTypeFont.loadDescriptorDictionary(...) loading a non-generic List of Integer instances (lines 342-355) and then calling setWidths() with that list in line 356. But the list has been declared as List<Float>. PDFont.getFontWidth(int) then fails in line 786 with that the exception.
Attachments
Issue Links
- is duplicated by
-
PDFBOX-986 PDFont.getFontWidth(): ClassCastException: Integer cannot be cast to Float
- Closed