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

wasn't able to create type 1 font under windows

XMLWordPrintable

    • 2d
    • x86
    • windows_2003

      FULL PRODUCT VERSION :
      jsdk 6.02

      ADDITIONAL OS VERSION INFORMATION :
      windows 2003

      A DESCRIPTION OF THE PROBLEM :
      use Font.createFont(int type, File fontFile) to create a type 1 Font.
      it couldn't generate the glyph with the give font file.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run under windows

      __________ source code ___________

      Font javaFont=Font.createFont(Font.TYPE1_FONT,new File("cour.pfa"));
                  javaFont=javaFont.deriveFont(Font.BOLD,20);
                  BufferedImage bi=new BufferedImage(600, 400, BufferedImage.TYPE_INT_RGB);
                  Graphics2D g2 = (Graphics2D) bi.getGraphics();
                  g2.setColor(Color.WHITE);
                  g2.setFont(javaFont);
                  g2.drawString("test string", 100,100);
                  ImageIO.write(bi, "png", new File("new.png"));

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      a PNG image with white text -- test string on it
      ACTUAL -
      a blank PNG image with nothing on it

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no error message

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      __________ source code ___________

      Font javaFont=Font.createFont(Font.TYPE1_FONT,new File("cour.pfa"));
                  javaFont=javaFont.deriveFont(Font.BOLD,20);
                  BufferedImage bi=new BufferedImage(600, 400, BufferedImage.TYPE_INT_RGB);
                  Graphics2D g2 = (Graphics2D) bi.getGraphics();
                  g2.setColor(Color.WHITE);
                  g2.setFont(javaFont);
                  g2.drawString("test string", 100,100);
                  ImageIO.write(bi, "png", new File("new.png"));


      the cour.pfa:


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Couldn't find a workaround. it looks like the createFont is platform dependent.

      currently, we have to try to convert Type 1 Font to true type and tolerate the information lost

            Unassigned Unassigned
            ttzhang Tao Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: