< prev index next >

src/java.desktop/share/classes/sun/font/TrueTypeFont.java

Print this page
rev 60042 : 8248802: Add log helper methods to FontUtilities.java

@@ -241,13 +241,11 @@
      * which means nested locks may be in effect.
      */
     private synchronized FileChannel open(boolean usePool)
                                      throws FontFormatException {
         if (disposerRecord.channel == null) {
-            if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().info("open TTF: " + platName);
-            }
+            FontUtilities.logInfo("open TTF: " + platName);
             try {
                 RandomAccessFile raf = AccessController.doPrivileged(
                     new PrivilegedExceptionAction<RandomAccessFile>() {
                         public RandomAccessFile run() throws FileNotFoundException {
                             return new RandomAccessFile(platName, "r");

@@ -306,16 +304,14 @@
                          * Also fileSize is updated every time we
                          * open() the file here, but in native the value
                          * isn't updated. If the file has changed whilst we
                          * are executing we want to bail, not spin.
                          */
-                        if (FontUtilities.isLogging()) {
                             String msg = "Read offset is " + offset +
                                 " file size is " + fileSize+
                                 " file is " + platName;
-                            FontUtilities.getLogger().severe(msg);
-                        }
+                        FontUtilities.logSevere(msg);
                         return -1;
                     } else {
                         length = fileSize - offset;
                     }
                 }

@@ -328,13 +324,11 @@
                         int currSize = (int)disposerRecord.channel.size();
                         if (currSize != fileSize) {
                             msg += " File size was " + fileSize +
                                 " and now is " + currSize;
                         }
-                        if (FontUtilities.isLogging()) {
-                            FontUtilities.getLogger().severe(msg);
-                        }
+                        FontUtilities.logSevere(msg);
                         // We could still flip() the buffer here because
                         // it's possible that we did read some data in
                         // an earlier loop, and we probably should
                         // return that to the caller. Although if
                         // the caller expected 8K of data and we return

@@ -343,15 +337,12 @@
                         // The following is therefore using arbitrary values
                         // but is meant to allow cases where enough
                         // data was read to probably continue.
                         if (bread > length/2 || bread > 16384) {
                             buffer.flip();
-                            if (FontUtilities.isLogging()) {
-                                msg = "Returning " + bread +
-                                    " bytes instead of " + length;
-                                FontUtilities.getLogger().severe(msg);
-                            }
+                            msg = "Returning " + bread + " bytes instead of " + length;
+                            FontUtilities.logSevere(msg);
                         } else {
                             bread = -1;
                         }
                         throw new IOException(msg);
                     }

@@ -520,13 +511,11 @@
                     && getDirectoryEntry(hheaTag) == null) {
                 throw new FontFormatException("missing hhea table");
             }
             initNames();
         } catch (Exception e) {
-            if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().severe(e.toString());
-            }
+            FontUtilities.logSevere(e.toString());
             if (e instanceof FontFormatException) {
                 throw (FontFormatException)e;
             } else {
                 throw new FontFormatException(e.toString());
             }

@@ -1070,13 +1059,11 @@
         }
 
         try {
             return new String(bytes, 0, len, charset);
         } catch (UnsupportedEncodingException e) {
-            if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().warning(e + " EncodingID=" + encoding);
-            }
+            FontUtilities.logWarning(e + " EncodingID=" + encoding);
             return new String(bytes, 0, len);
         } catch (Throwable t) {
             return null;
         }
     }
< prev index next >