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

ClassCastException in PDFont.getFontWidth(int)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.6.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: