Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5092191

RFE: CFF/Type2 embedded fonts not supported with Font.createFont()

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • Understanding:
      Fix Understood
    • CPU:
      x86
    • OS:
      windows_xp

      Description



      Name: gm110360 Date: 08/25/2004


      FULL PRODUCT VERSION :
      jdk 1.5 beta 2

      ADDITIONAL OS VERSION INFORMATION :
      windows XP

      A DESCRIPTION OF THE PROBLEM :
      According to the description in bug #4390880, type1c fonts are supported in 1.5.

      This is incorrect. Type1 fonts work fine, but Type1C fonts do not.

      Type 1C fonts are very common in document processing as they are used extensively with PDF files.

      It should be possible to use the TYPE1_FONT constant, but maybe a TYPE1C_FONT constant would be better?

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      use provided test case with Type1C font

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the font should be created
      ACTUAL -
      an exception is thrown

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.awt.FontFormatException: bad pfa font
      at sun.font.Type1Font.verifyPFA(Type1Font.java:258)
      at sun.font.Type1Font.verify(Type1Font.java:236)
      at sun.font.Type1Font.<init>(Type1Font.java:120)
      at sun.font.FontManager.createFont2D(FontManager.java:1460)
      at java.awt.Font.<init>(Font.java:437)
      at java.awt.Font.createFont(Font.java:744)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.io.*;

      public class TestFont {
         public static void main(String[] args) throws FileNotFoundException, FontFormatException, IOException {
              Font awtFont = Font.createFont(Font.TYPE1_FONT, new FileInputStream ("testfont.pfa"));
         }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 300788)
      ======================================================================

        Activity

        Hide
        prr Philip Race added a comment -
        BT2:EVALUATION

        The original submitted synopsis of this report was
        "type1c fonts not supported with Font.createFont()"

        But "Type1C" isn't a font format name, its the name of a subkey in PDF
        to indicate that an embedded font is CFF/Type 2 (CFF=Compact Font Format).
        Type 2 refers to the encoding of the glyph procedures. This is a source
        of confusion and the tenuous justification for this name is presumably
        that "C" indicates "compact" and these fonts can be converted into
        equivalent Type1 fonts.

        This is from the Adobe font types Q&A document referenced below :-
        Q. Is the CFF format fairly similar to the Type 1 format?
        A. Yes, it is based on all of the same concepts for drawing paths and hinting, but allows a more compact encoding of the font data and procedures. A Type 1 font can be converted into CFF/Type2 format, and back to Type 1 again, without any loss of quality.

        The fix for 4390880 applied to Type1 fonts. It was not intended to
        support CFF/Type2 fonts, and whether or not it would be more appropriate
        to augment createFont's TYPE1_FONT key to accept these, or to create a
        new key for these fonts is open to question, but what is also open to
        question is whether the JDK should implement this support for this
        explicit purpose : embedded fonts in PDF documents. The only use case for
        this is creating a PDF viewer and there is a workaround (See the workaround
        section of the bug report)

        CFF is also used in OpenType fonts, but that does more than is supported
        in PDF.

        For a full spec on CFF/Type 2 see Adobe Technical Notes, 5176 and 5177.

        For a quicker overview see :-
        http://partners.adobe.com/asn/tech/type/cfft2.jsp

        and for a list of font format types and Q&A see
        http://partners.adobe.com/asn/tech/type/ftypes.jsp

        ###@###.### 2004-08-26
        ============================
        Show
        prr Philip Race added a comment - BT2:EVALUATION The original submitted synopsis of this report was "type1c fonts not supported with Font.createFont()" But "Type1C" isn't a font format name, its the name of a subkey in PDF to indicate that an embedded font is CFF/Type 2 (CFF=Compact Font Format). Type 2 refers to the encoding of the glyph procedures. This is a source of confusion and the tenuous justification for this name is presumably that "C" indicates "compact" and these fonts can be converted into equivalent Type1 fonts. This is from the Adobe font types Q&A document referenced below :- Q. Is the CFF format fairly similar to the Type 1 format? A. Yes, it is based on all of the same concepts for drawing paths and hinting, but allows a more compact encoding of the font data and procedures. A Type 1 font can be converted into CFF/Type2 format, and back to Type 1 again, without any loss of quality. The fix for 4390880 applied to Type1 fonts. It was not intended to support CFF/Type2 fonts, and whether or not it would be more appropriate to augment createFont's TYPE1_FONT key to accept these, or to create a new key for these fonts is open to question, but what is also open to question is whether the JDK should implement this support for this explicit purpose : embedded fonts in PDF documents. The only use case for this is creating a PDF viewer and there is a workaround (See the workaround section of the bug report) CFF is also used in OpenType fonts, but that does more than is supported in PDF. For a full spec on CFF/Type 2 see Adobe Technical Notes, 5176 and 5177. For a quicker overview see :- http://partners.adobe.com/asn/tech/type/cfft2.jsp and for a list of font format types and Q&A see http://partners.adobe.com/asn/tech/type/ftypes.jsp ###@###.### 2004-08-26 ============================
        Hide
        defectconv Defect Conversion BT2 (Inactive) added a comment -
        BT2:WORK AROUND

        The application that is providing the font stream to the JDK presumably
        must be embedded font aware to obtain such a stream and can therefore
        transform the font to provide the font stream in the Type 1 font.
        Show
        defectconv Defect Conversion BT2 (Inactive) added a comment - BT2:WORK AROUND The application that is providing the font stream to the JDK presumably must be embedded font aware to obtain such a stream and can therefore transform the font to provide the font stream in the Type 1 font.

          People

          • Assignee:
            prr Philip Race
            Reporter:
            gmanwanisunw Girish Manwani (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Imported:
              Indexed: