< 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,253 ****
* 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);
! }
try {
RandomAccessFile raf = AccessController.doPrivileged(
new PrivilegedExceptionAction<RandomAccessFile>() {
public RandomAccessFile run() throws FileNotFoundException {
return new RandomAccessFile(platName, "r");
--- 241,251 ----
* which means nested locks may be in effect.
*/
private synchronized FileChannel open(boolean usePool)
throws FontFormatException {
if (disposerRecord.channel == null) {
! FontUtilities.logInfo("open TTF: " + platName);
try {
RandomAccessFile raf = AccessController.doPrivileged(
new PrivilegedExceptionAction<RandomAccessFile>() {
public RandomAccessFile run() throws FileNotFoundException {
return new RandomAccessFile(platName, "r");
*** 306,321 ****
* 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);
! }
return -1;
} else {
length = fileSize - offset;
}
}
--- 304,317 ----
* 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.
*/
String msg = "Read offset is " + offset +
" file size is " + fileSize+
" file is " + platName;
! FontUtilities.logSevere(msg);
return -1;
} else {
length = fileSize - offset;
}
}
*** 328,340 ****
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);
! }
// 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
--- 324,334 ----
int currSize = (int)disposerRecord.channel.size();
if (currSize != fileSize) {
msg += " File size was " + fileSize +
" and now is " + currSize;
}
! 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,357 ****
// 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);
! }
} else {
bread = -1;
}
throw new IOException(msg);
}
--- 337,348 ----
// 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();
! msg = "Returning " + bread + " bytes instead of " + length;
! FontUtilities.logSevere(msg);
} else {
bread = -1;
}
throw new IOException(msg);
}
*** 520,532 ****
&& getDirectoryEntry(hheaTag) == null) {
throw new FontFormatException("missing hhea table");
}
initNames();
} catch (Exception e) {
! if (FontUtilities.isLogging()) {
! FontUtilities.getLogger().severe(e.toString());
! }
if (e instanceof FontFormatException) {
throw (FontFormatException)e;
} else {
throw new FontFormatException(e.toString());
}
--- 511,521 ----
&& getDirectoryEntry(hheaTag) == null) {
throw new FontFormatException("missing hhea table");
}
initNames();
} catch (Exception e) {
! FontUtilities.logSevere(e.toString());
if (e instanceof FontFormatException) {
throw (FontFormatException)e;
} else {
throw new FontFormatException(e.toString());
}
*** 1070,1082 ****
}
try {
return new String(bytes, 0, len, charset);
} catch (UnsupportedEncodingException e) {
! if (FontUtilities.isLogging()) {
! FontUtilities.getLogger().warning(e + " EncodingID=" + encoding);
! }
return new String(bytes, 0, len);
} catch (Throwable t) {
return null;
}
}
--- 1059,1069 ----
}
try {
return new String(bytes, 0, len, charset);
} catch (UnsupportedEncodingException e) {
! FontUtilities.logWarning(e + " EncodingID=" + encoding);
return new String(bytes, 0, len);
} catch (Throwable t) {
return null;
}
}
< prev index next >