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

Built-in fonts are reporting nbsp char as having zero width.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.21
    • Fix Version/s: 2.0.22, 3.0.0 PDFBox
    • Component/s: None
    • Labels:

      Description

              PDFont font = PDType1Font.HELVETICA; // Also tested with Times.
              System.out.println("width = " + font.getStringWidth("\u00a0"));
       
      Non-breaking space is reporting as zero width (standard 14 fonts) in 2.0.21 while being encoded as a (width taking) character. As you can imagine this causes serious errors in line and justification layout.
       
      Related:
      Prior to PDFBOX-4891 non-breaking space threw an IllegalArgumentException.
       
      Originally reported at Github:
      https://github.com/danfickle/openhtmltopdf/issues/543
       
      Discovered by Github user lagar84.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tilman Tilman Hausherr
                Reporter:
                danfickle Dan Fickling
              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: