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

Think I found a bad constant (TTF) value and constant use in PDFBox source

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1, 3.0.0 PDFBox
    • Component/s: PDModel
    • Labels:
      None
    • Environment:
      Found by source code inspection

      Description

      Was searching if an OBLIQUE constant was defined somewhere for fsSelection field of OS/2 TrueType table (org.apache.fontbox.ttf.OS2WindowsMetricsTable), found a private one in org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder (line 53) in v2.0.0 but it was defined with value 256 instead of 512 (as defined in official Microsoft documentation here: https://www.microsoft.com/typography/otspec/os2.htm#fss, bits are defined starting at 0 and oblique is bit 9, so OBLIQUE should have value 512 (1 << 9) instead of 256. And the constant use (line 184), is wrong too, the line should be

              fd.setItalic((fsSelection & (ITALIC | OBLIQUE)) != 0);
      

      instead of:

              fd.setItalic((fsSelection & ITALIC) == fsSelection ||
                           (fsSelection & OBLIQUE) == fsSelection);
      

      because fsSelection can contain other bits set at the same time (like BOLD = 1 << 5), so the tests can be both false while one of the bit is set.

        Attachments

          Activity

            People

            • Assignee:
              lehmi Andreas Lehmkühler
              Reporter:
              cbouc Christophe Bouchon
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: