jdk/src/share/classes/sun/font/FontManager.java
changeset 2627 c66fa5c0e626
parent 2373 b12af7661027
parent 2624 1ae5a9028dd4
child 3928 be186a33df9b
equal deleted inserted replaced
2541:824a5ff07bcb 2627:c66fa5c0e626
  2355 
  2355 
  2356     private static Thread fileCloser = null;
  2356     private static Thread fileCloser = null;
  2357     static Vector<File> tmpFontFiles = null;
  2357     static Vector<File> tmpFontFiles = null;
  2358 
  2358 
  2359     public static Font2D createFont2D(File fontFile, int fontFormat,
  2359     public static Font2D createFont2D(File fontFile, int fontFormat,
  2360                                       boolean isCopy)
  2360                                       boolean isCopy,
       
  2361                                       CreatedFontTracker tracker)
  2361         throws FontFormatException {
  2362         throws FontFormatException {
  2362 
  2363 
  2363         String fontFilePath = fontFile.getPath();
  2364         String fontFilePath = fontFile.getPath();
  2364         FileFont font2D = null;
  2365         FileFont font2D = null;
  2365         final File fFile = fontFile;
  2366         final File fFile = fontFile;
       
  2367         final CreatedFontTracker _tracker = tracker;
  2366         try {
  2368         try {
  2367             switch (fontFormat) {
  2369             switch (fontFormat) {
  2368             case Font.TRUETYPE_FONT:
  2370             case Font.TRUETYPE_FONT:
  2369                 font2D = new TrueTypeFont(fontFilePath, null, 0, true);
  2371                 font2D = new TrueTypeFont(fontFilePath, null, 0, true);
  2370                 break;
  2372                 break;
  2371             case Font.TYPE1_FONT:
  2373             case Font.TYPE1_FONT:
  2372                 font2D = new Type1Font(fontFilePath, null);
  2374                 font2D = new Type1Font(fontFilePath, null, isCopy);
  2373                 break;
  2375                 break;
  2374             default:
  2376             default:
  2375                 throw new FontFormatException("Unrecognised Font Format");
  2377                 throw new FontFormatException("Unrecognised Font Format");
  2376             }
  2378             }
  2377         } catch (FontFormatException e) {
  2379         } catch (FontFormatException e) {
  2378             if (isCopy) {
  2380             if (isCopy) {
  2379                 java.security.AccessController.doPrivileged(
  2381                 java.security.AccessController.doPrivileged(
  2380                      new java.security.PrivilegedAction() {
  2382                      new java.security.PrivilegedAction() {
  2381                           public Object run() {
  2383                           public Object run() {
       
  2384                               if (_tracker != null) {
       
  2385                                   _tracker.subBytes((int)fFile.length());
       
  2386                               }
  2382                               fFile.delete();
  2387                               fFile.delete();
  2383                               return null;
  2388                               return null;
  2384                           }
  2389                           }
  2385                 });
  2390                 });
  2386             }
  2391             }
  2387             throw(e);
  2392             throw(e);
  2388         }
  2393         }
  2389         if (isCopy) {
  2394         if (isCopy) {
  2390             font2D.setFileToRemove(fontFile);
  2395             font2D.setFileToRemove(fontFile, tracker);
  2391             synchronized (FontManager.class) {
  2396             synchronized (FontManager.class) {
  2392 
  2397 
  2393                 if (tmpFontFiles == null) {
  2398                 if (tmpFontFiles == null) {
  2394                     tmpFontFiles = new Vector<File>();
  2399                     tmpFontFiles = new Vector<File>();
  2395                 }
  2400                 }