ClassCastException in PDFont.getFontWidth(int)
----------------------------------------------

                 Key: PDFBOX-976
                 URL: https://issues.apache.org/jira/browse/PDFBOX-976
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 1.5.0
         Environment: Sun JDK 6u24.
            Reporter: Jan Normann Nielsen


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.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to