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

Support for Adobe CFF/Type2 fonts

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.8.0-incubator
    • 1.0.0
    • FontBox, PDModel
    • None

    Description

      PDFBox should support embedded font types, most prominently the Adobe CFF/Type2 (aka Type1C) font type. The desired functionality includes both glyph metrics (for PDF text extraction using org.apache.pdfbox.util.PDFTextStripper) and glyph painting (for PDF rendering using org.apache.pdfbox.pdfviewer.PageDrawer).

      I have implemented the basics of Adobe CFF/Type2 font specification. If the other project members find my work substantial, I would like to see it incorporated into FontBox/PDFBox projects. Please see the attached patch files.

      Design considerations. A PDF FontFile3 stream can be parsed into CFFFont objects by class CFFParser. CFFFont contains a map of glyph names to Type2 charstrings, which can be converted to Type1 charstrings by class CharStringConverter and rendered by class CharStringRenderer. Glyph metrics is attained by formatting the result as AFM by class AFMFormatter, which plugs nicely with existing PDFBox infrastructure. Glyph painting is attained by formatting the result as PostScript Type1 font by class Type1FontFormatter, which can be loaded via java.awt.Font#createFont(int, InputStream).

      The current implementation does not support synthetic CFF fonts nor CID-keyed CFF fonts. Also, the conversion of certain Type2 features (stemming, hinting, flex) is missing.

      Attachments

        1. without-cff.png
          140 kB
          Villu Ruusmann
        2. with-cff.png
          163 kB
          Villu Ruusmann
        3. pdfbox-r823839.patch
          19 kB
          Villu Ruusmann
        4. fontbox-r818793.patch
          123 kB
          Villu Ruusmann

        Issue Links

          Activity

            People

              lehmi Andreas Lehmkühler
              vfed Villu Ruusmann
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: