Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-976

ClassCastException in PDFont.getFontWidth(int)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.0
    • 1.6.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

          Activity

            People

              lehmi Andreas Lehmkühler
              normann Jan Normann Nielsen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: