aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2011-11-07 18:18:29 +0000
committerVincent Hennebert <vhennebert@apache.org>2011-11-07 18:18:29 +0000
commit02303acdd92bbdd79dfe9b8866617209b183ae26 (patch)
tree6e728bdafd520fd1ee911a76a42ad46aad181df4 /src/java/org/apache/fop
parentfd263a114c84c3756ead9c16b8b088531c5cab2c (diff)
downloadxmlgraphics-fop-02303acdd92bbdd79dfe9b8866617209b183ae26.tar.gz
xmlgraphics-fop-02303acdd92bbdd79dfe9b8866617209b183ae26.zip
Bugzilla 52136: Added to build file JUnit target that uses a regex to run all of the test cases.
Patch by Mehdi Houshmand, applied with minor modifications git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1198853 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/fonts/FontDetector.java12
-rw-r--r--src/java/org/apache/fop/fonts/FontEventAdapter.java5
-rw-r--r--src/java/org/apache/fop/fonts/FontEventListener.java6
-rw-r--r--src/java/org/apache/fop/fonts/FontEventProducer.java8
-rw-r--r--src/java/org/apache/fop/fonts/FontEventProducer.xml1
-rw-r--r--src/java/org/apache/fop/fonts/FontInfoConfigurator.java6
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java18
-rw-r--r--src/java/org/apache/fop/tools/fontlist/FontListMain.java4
8 files changed, 52 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/fonts/FontDetector.java b/src/java/org/apache/fop/fonts/FontDetector.java
index 88e4c6e69..8cfb0da12 100644
--- a/src/java/org/apache/fop/fonts/FontDetector.java
+++ b/src/java/org/apache/fop/fonts/FontDetector.java
@@ -27,10 +27,12 @@ import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.util.ClasspathResource;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fonts.autodetect.FontFileFinder;
import org.apache.fop.util.LogUtil;
-import org.apache.xmlgraphics.util.ClasspathResource;
/**
* Detector of operating system and classpath fonts
@@ -45,17 +47,21 @@ public class FontDetector {
private final FontManager fontManager;
private final FontAdder fontAdder;
private final boolean strict;
+ private final FontEventListener eventListener;
/**
* Main constructor
* @param manager the font manager
* @param adder the font adder
* @param strict true if an Exception should be thrown if an error is found.
+ * @param listener for throwing font related events
*/
- public FontDetector(FontManager manager, FontAdder adder, boolean strict) {
+ public FontDetector(FontManager manager, FontAdder adder, boolean strict,
+ FontEventListener listener) {
this.fontManager = manager;
this.fontAdder = adder;
this.strict = strict;
+ this.eventListener = listener;
}
/**
@@ -66,7 +72,7 @@ public class FontDetector {
public void detect(List<EmbedFontInfo> fontInfoList) throws FOPException {
// search in font base if it is defined and
// is a directory but don't recurse
- FontFileFinder fontFileFinder = new FontFileFinder();
+ FontFileFinder fontFileFinder = new FontFileFinder(eventListener);
String fontBaseURL = fontManager.getFontBaseURL();
if (fontBaseURL != null) {
try {
diff --git a/src/java/org/apache/fop/fonts/FontEventAdapter.java b/src/java/org/apache/fop/fonts/FontEventAdapter.java
index 77846ee77..85a43393e 100644
--- a/src/java/org/apache/fop/fonts/FontEventAdapter.java
+++ b/src/java/org/apache/fop/fonts/FontEventAdapter.java
@@ -61,4 +61,9 @@ public class FontEventAdapter implements FontEventListener {
getEventProducer().glyphNotAvailable(source, ch, fontName);
}
+ /** {@inheritDoc} */
+ public void fontDirectoryNotFound(Object source, String dir) {
+ getEventProducer().fontDirectoryNotFound(source, dir);
+ }
+
}
diff --git a/src/java/org/apache/fop/fonts/FontEventListener.java b/src/java/org/apache/fop/fonts/FontEventListener.java
index 740a05fdc..5f9e7b6c6 100644
--- a/src/java/org/apache/fop/fonts/FontEventListener.java
+++ b/src/java/org/apache/fop/fonts/FontEventListener.java
@@ -48,4 +48,10 @@ public interface FontEventListener {
*/
void glyphNotAvailable(Object source, char ch, String fontName);
+ /**
+ * An error occurred trying to find the font directory specified in the config file.
+ * @param source the event source
+ * @param dir the directory in the config file
+ */
+ void fontDirectoryNotFound(Object source, String dir);
}
diff --git a/src/java/org/apache/fop/fonts/FontEventProducer.java b/src/java/org/apache/fop/fonts/FontEventProducer.java
index ae4294318..702d3efb6 100644
--- a/src/java/org/apache/fop/fonts/FontEventProducer.java
+++ b/src/java/org/apache/fop/fonts/FontEventProducer.java
@@ -71,4 +71,12 @@ public interface FontEventProducer extends EventProducer {
*/
void glyphNotAvailable(Object source, char ch, String fontName);
+ /**
+ * An error occurred trying to find the font directory specified in the config file.
+ * @param source the event sourece
+ * @param dir the directory in the config file
+ * @event.severity WARN
+ */
+ void fontDirectoryNotFound(Object source, String dir);
+
}
diff --git a/src/java/org/apache/fop/fonts/FontEventProducer.xml b/src/java/org/apache/fop/fonts/FontEventProducer.xml
index 6ea587036..27fd587b1 100644
--- a/src/java/org/apache/fop/fonts/FontEventProducer.xml
+++ b/src/java/org/apache/fop/fonts/FontEventProducer.xml
@@ -20,4 +20,5 @@
<message key="fontSubstituted">Font "{requested}" not found. Substituting with "{effective}".</message>
<message key="fontLoadingErrorAtAutoDetection">Unable to load font file: {fontURL}.[ Reason: {e}]</message>
<message key="glyphNotAvailable">Glyph "{ch}" (0x{ch,hex}[, {ch,glyph-name}]) not available in font "{fontName}".</message>
+ <message key="fontDirectoryNotFound">'{dir}' does not exist or is not a directory.</message>
</catalogue>
diff --git a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
index 67bb2e295..1f1116990 100644
--- a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
+++ b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
@@ -33,6 +33,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.fonts.autodetect.FontFileFinder;
import org.apache.fop.fonts.autodetect.FontInfoFinder;
@@ -88,7 +89,8 @@ public class FontInfoConfigurator {
// native o/s search (autodetect) configuration
boolean autodetectFonts = (fontsCfg.getChild("auto-detect", false) != null);
if (autodetectFonts) {
- FontDetector fontDetector = new FontDetector(fontManager, fontAdder, strict);
+ FontDetector fontDetector = new FontDetector(fontManager, fontAdder, strict,
+ listener);
fontDetector.detect(fontInfoList);
}
@@ -139,7 +141,7 @@ public class FontInfoConfigurator {
}
// add fonts found in directory
- FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
+ FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1, listener);
List<URL> fontURLList;
try {
fontURLList = fontFileFinder.find(directory);
diff --git a/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
index 9a0a73e2f..3c1a94f63 100644
--- a/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
@@ -34,6 +34,8 @@ import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fonts.FontEventListener;
+
/**
* Helps to autodetect/locate available operating system fonts.
*/
@@ -44,20 +46,24 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder {
/** default depth limit of recursion when searching for font files **/
public static final int DEFAULT_DEPTH_LIMIT = -1;
+ private final FontEventListener eventListener;
/**
* Default constructor
+ * @param listener for throwing font related events
*/
- public FontFileFinder() {
- super(getDirectoryFilter(), getFileFilter(), DEFAULT_DEPTH_LIMIT);
+ public FontFileFinder(FontEventListener listener) {
+ this(DEFAULT_DEPTH_LIMIT, listener);
}
/**
* Constructor
* @param depthLimit recursion depth limit
+ * @param listener for throwing font related events
*/
- public FontFileFinder(int depthLimit) {
+ public FontFileFinder(int depthLimit, FontEventListener listener) {
super(getDirectoryFilter(), getFileFilter(), depthLimit);
+ eventListener = listener;
}
/**
@@ -163,6 +169,12 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder {
public List<URL> find(String dir) throws IOException {
List<URL> results = new java.util.ArrayList<URL>();
super.walk(new File(dir), results);
+ File directory = new File(dir);
+ if (!directory.isDirectory()) {
+ eventListener.fontDirectoryNotFound(this, dir);
+ } else {
+ super.walk(directory, results);
+ }
return results;
}
}
diff --git a/src/java/org/apache/fop/tools/fontlist/FontListMain.java b/src/java/org/apache/fop/tools/fontlist/FontListMain.java
index d31da92c2..92c2acffd 100644
--- a/src/java/org/apache/fop/tools/fontlist/FontListMain.java
+++ b/src/java/org/apache/fop/tools/fontlist/FontListMain.java
@@ -143,6 +143,10 @@ public final class FontListMain {
//ignore
}
+ public void fontDirectoryNotFound(Object source, String msg) {
+ //ignore
+ }
+
};
FontListGenerator listGenerator = new FontListGenerator();