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

java.awt.Font.createFont(int, File fontFile) can delete fontFile

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 5.0
    • 5.0
    • client-libs
    • 2d
    • tiger
    • sparc
    • solaris_8
    • Verified



      Name: dsR10051 Date: 07/04/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b09"
      Platform[s] : Solaris

      Problem description
      ===================
      Method
      public static Font createFont(int fontFormat, File fontFile)
      deletes fontFile if fontFile does not represent true type font.

      Minimized test:
      ===============
      ------- FontTest.java -------
      import java.awt.Font;
      import java.io.*;

      public class FontTest {

          public static void main(String[] args) {
              File file = new File("file.ttf");
              try {
                  Font font = Font.createFont(Font.TRUETYPE_FONT, file);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }

      ------- end-of-FontTest.java -------

      Minimized test output:
      ======================
      % cat file.ttf
      % java FontTest
      java.awt.FontFormatException: java.nio.BufferUnderflowException
              at sun.font.TrueTypeFont.init(TrueTypeFont.java:398)
              at sun.font.TrueTypeFont.<init>(TrueTypeFont.java:152)
              at sun.font.FontManager.createFont2D(FontManager.java:1255)
              at java.awt.Font.<init>(Font.java:378)
              at java.awt.Font.createFont(Font.java:700)
              at FontTest.main(FontTest.java:9)
      % cat file.ttf
      cat: cannot open file.ttf

      ======================================================================

            prr Philip Race
            sdasunw Sda Sda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: