summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/fop/render/PrintRendererConfigurator.java7
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFUtil.java7
-rw-r--r--test/java/org/apache/fop/intermediate/IFMimickingTestCase.java41
-rw-r--r--test/test-no-xml-metrics.xconf18
4 files changed, 62 insertions, 11 deletions
diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java
index 67dda0354..66618b093 100644
--- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java
@@ -29,7 +29,6 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.fonts.CustomFontCollection;
-import org.apache.fop.fonts.FontCache;
import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontEventAdapter;
import org.apache.fop.fonts.FontEventListener;
@@ -40,8 +39,6 @@ import org.apache.fop.fonts.FontResolver;
import org.apache.fop.fonts.base14.Base14FontCollection;
import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
-import org.apache.fop.render.intermediate.IFUtil;
-import org.apache.fop.util.LogUtil;
/**
* Base Print renderer configurator (mostly handles font configuration)
@@ -108,7 +105,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator
fontInfoConfigurator.configure(fontInfoList);
return fontInfoList;
}
-
+
// ---=== IFDocumentHandler configuration ===---
/** {@inheritDoc} */
@@ -123,7 +120,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator
List fontCollections = new java.util.ArrayList();
fontCollections.add(new Base14FontCollection(fontManager.isBase14KerningEnabled()));
- Configuration cfg = super.getRendererConfig(IFUtil.getEffectiveMIMEType(documentHandler));
+ Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
if (cfg != null) {
FontResolver fontResolver = new DefaultFontResolver(userAgent);
FontEventListener listener = new FontEventAdapter(
diff --git a/src/java/org/apache/fop/render/intermediate/IFUtil.java b/src/java/org/apache/fop/render/intermediate/IFUtil.java
index 58399f3ac..437648bcc 100644
--- a/src/java/org/apache/fop/render/intermediate/IFUtil.java
+++ b/src/java/org/apache/fop/render/intermediate/IFUtil.java
@@ -153,6 +153,13 @@ public class IFUtil {
if (fontInfo == null) {
fontInfo = new FontInfo();
}
+ if (documentHandler instanceof IFSerializer) {
+ IFSerializer serializer = (IFSerializer)documentHandler;
+ if (serializer.getMimickedDocumentHandler() != null) {
+ //Use the mimicked document handler's configurator to set up fonts
+ documentHandler = serializer.getMimickedDocumentHandler();
+ }
+ }
IFDocumentHandlerConfigurator configurator = documentHandler.getConfigurator();
if (configurator != null) {
configurator.setupFontInfo(documentHandler, fontInfo);
diff --git a/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java b/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java
index b6b6aebd6..610bc600b 100644
--- a/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java
+++ b/test/java/org/apache/fop/intermediate/IFMimickingTestCase.java
@@ -31,6 +31,7 @@ import javax.xml.transform.stream.StreamSource;
import junit.framework.TestCase;
+import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
@@ -40,6 +41,7 @@ import org.apache.fop.events.EventFormatter;
import org.apache.fop.events.EventListener;
import org.apache.fop.render.intermediate.IFContext;
import org.apache.fop.render.intermediate.IFDocumentHandler;
+import org.apache.fop.render.intermediate.IFException;
import org.apache.fop.render.intermediate.IFSerializer;
/**
@@ -47,15 +49,42 @@ import org.apache.fop.render.intermediate.IFSerializer;
*/
public class IFMimickingTestCase extends TestCase {
+ private FopFactory fopFactory;
+
+ /** {@inheritDoc} */
+ protected void setUp() throws Exception {
+ super.setUp();
+ fopFactory = FopFactory.newInstance();
+ File configFile = new File("test/test-no-xml-metrics.xconf");
+ fopFactory.setUserConfig(configFile);
+ }
+
/**
- * Tests IF document handler mimicking.
+ * Tests IF document handler mimicking with PDF output.
* @throws Exception if an error occurs
*/
- public void testMimicking() throws Exception {
- FopFactory fopFactory = FopFactory.newInstance();
- File configFile = new File("test/test-no-xml-metrics.xconf");
- fopFactory.setUserConfig(configFile);
+ public void testMimickingPDF() throws Exception {
+ doTestMimicking(MimeConstants.MIME_PDF);
+ }
+
+ /**
+ * Tests IF document handler mimicking with PostScript output.
+ * @throws Exception if an error occurs
+ */
+ public void testMimickingPS() throws Exception {
+ doTestMimicking(MimeConstants.MIME_POSTSCRIPT);
+ }
+
+ /**
+ * Tests IF document handler mimicking with TIFF output.
+ * @throws Exception if an error occurs
+ */
+ public void testMimickingTIFF() throws Exception {
+ doTestMimicking(MimeConstants.MIME_TIFF);
+ }
+ private void doTestMimicking(String mime) throws FOPException, IFException,
+ TransformerException {
//Set up XMLRenderer to render to a DOM
DOMResult domResult = new DOMResult();
@@ -73,7 +102,7 @@ public class IFMimickingTestCase extends TestCase {
//Create an instance of the target renderer so the XMLRenderer can use its font setup
IFDocumentHandler targetHandler = userAgent.getRendererFactory().createDocumentHandler(
- userAgent, MimeConstants.MIME_PDF);
+ userAgent, mime);
//Setup painter
IFSerializer serializer = new IFSerializer();
diff --git a/test/test-no-xml-metrics.xconf b/test/test-no-xml-metrics.xconf
index d47e0ec8f..beb24c0ef 100644
--- a/test/test-no-xml-metrics.xconf
+++ b/test/test-no-xml-metrics.xconf
@@ -22,5 +22,23 @@
</font>
</fonts>
</renderer>
+ <renderer mime="application/postscript">
+ <fonts>
+ <font embed-url="glb12.ttf" kerning="yes">
+ <font-triplet name="Gladiator Bold" style="normal" weight="normal"/>
+ <font-triplet name="Gladiator" style="normal" weight="bold"/>
+ <font-triplet name="Gladiator" style="normal" weight="normal"/>
+ </font>
+ </fonts>
+ </renderer>
+ <renderer mime="image/tiff">
+ <fonts>
+ <font embed-url="glb12.ttf" kerning="yes">
+ <font-triplet name="Gladiator Bold" style="normal" weight="normal"/>
+ <font-triplet name="Gladiator" style="normal" weight="bold"/>
+ <font-triplet name="Gladiator" style="normal" weight="normal"/>
+ </font>
+ </fonts>
+ </renderer>
</renderers>
</fop>