You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2007/11/13 13:44:32 UTC
svn commit: r594516 -
/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
Author: jeremias
Date: Tue Nov 13 04:44:29 2007
New Revision: 594516
URL: http://svn.apache.org/viewvc?rev=594516&view=rev
Log:
Filter single quotes from the filenames as this will interfere with font-family parsing.
Fixed bug: InputStream opened by URL.openConnection() wasn't closed which leads to "too many open files" when you have lots of fonts on Java 1.4.
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=594516&r1=594515&r2=594516&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java Tue Nov 13 04:44:29 2007
@@ -21,11 +21,14 @@
import java.io.IOException;
import java.net.URL;
+import java.net.URLConnection;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.regex.Pattern;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fonts.CachedFontInfo;
@@ -62,7 +65,7 @@
}
// default style and weight triplet vales (fallback)
- String strippedName = customFont.getStrippedFontName();
+ String strippedName = stripQuotes(customFont.getStrippedFontName());
String subName = customFont.getFontSubName();
String searchName = strippedName.toLowerCase();
if (subName != null) {
@@ -74,7 +77,7 @@
//Full Name usually includes style/weight info so don't use these traits
//If we still want to use these traits, we have to make FontInfo.fontLookup() smarter
- String fullName = customFont.getFullName();
+ String fullName = stripQuotes(customFont.getFullName());
triplets.add(new FontTriplet(fullName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
if (!fullName.equals(strippedName)) {
triplets.add(new FontTriplet(strippedName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
@@ -82,12 +85,18 @@
Set familyNames = customFont.getFamilyNames();
Iterator iter = familyNames.iterator();
while (iter.hasNext()) {
- String familyName = (String)iter.next();
+ String familyName = stripQuotes((String)iter.next());
if (!fullName.equals(familyName)) {
triplets.add(new FontTriplet(familyName, style, weight));
}
}
}
+
+ private final Pattern quotePattern = Pattern.compile("'");
+
+ private String stripQuotes(String name) {
+ return quotePattern.matcher(name).replaceAll("");
+ }
private String guessStyle(CustomFont customFont, String fontName) {
// style
@@ -136,7 +145,13 @@
long fileLastModified = -1;
if (fontCache != null) {
try {
- fileLastModified = fontUrl.openConnection().getLastModified();
+ URLConnection conn = fontUrl.openConnection();
+ try {
+ fileLastModified = conn.getLastModified();
+ } finally {
+ //An InputStream is created even if it's not accessed, but we need to close it.
+ IOUtils.closeQuietly(conn.getInputStream());
+ }
} catch (IOException e) {
// Should never happen, because URL must be local
log.debug("IOError: " + e.getMessage());
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org