< 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

@@ -242,11 +242,11 @@
      */
     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 {

@@ -310,11 +310,11 @@
                          */
                         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;
                     }

@@ -329,11 +329,11 @@
                         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

@@ -344,13 +344,12 @@
                         // 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);

@@ -362,12 +361,11 @@
                     bread = length;
                 }
             }
         } catch (FontFormatException e) {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().severe(
-                                       "While reading " + platName, e);
+                FontUtilities.getLogger().severe("While reading " + platName, e);
             }
             bread = -1; // signal EOF
             deregisterFontAndClearStrikeCache();
         } catch (ClosedChannelException e) {
             /* NIO I/O is interruptible, recurse to retry operation.

@@ -383,12 +381,11 @@
              * Other than an attempt to read past the end of the file it
              * seems unlikely this would occur as problems opening the
              * file are handled as a FontFormatException.
              */
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().severe(
-                                       "While reading " + platName, e);
+                FontUtilities.getLogger().severe("While reading " + platName, e);
             }
             if (bread == 0) {
                 bread = -1; // signal EOF
                 deregisterFontAndClearStrikeCache();
             }

@@ -521,11 +518,11 @@
                 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());

@@ -1071,11 +1068,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 >