Browse Source

Amendment to revision 755894:

The mimicking fix didn't work for all output formats.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@757681 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_0
Jeremias Maerki 15 years ago
parent
commit
c71b4374b1

+ 2
- 5
src/java/org/apache/fop/render/PrintRendererConfigurator.java View File

@@ -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(

+ 7
- 0
src/java/org/apache/fop/render/intermediate/IFUtil.java View File

@@ -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);

+ 35
- 6
test/java/org/apache/fop/intermediate/IFMimickingTestCase.java View File

@@ -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();

+ 18
- 0
test/test-no-xml-metrics.xconf View File

@@ -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>

Loading…
Cancel
Save