aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/documentation/content/xdocs/trunk/output.xml23
-rw-r--r--src/java/org/apache/fop/afp/AFPPaintingState.java46
-rw-r--r--src/java/org/apache/fop/render/afp/AFPCustomizable.java24
-rw-r--r--src/java/org/apache/fop/render/afp/AFPDocumentHandler.java20
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java11
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java10
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java35
-rw-r--r--status.xml3
8 files changed, 154 insertions, 18 deletions
diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml
index ea994b521..c174bf2b5 100644
--- a/src/documentation/content/xdocs/trunk/output.xml
+++ b/src/documentation/content/xdocs/trunk/output.xml
@@ -784,6 +784,29 @@ Note that the value of the encoding attribute in the example is the double-byte
<source><![CDATA[
<images mode="b+w" bits-per-pixel="1" dithering-quality="maximum"/>]]></source>
</section>
+ <section id="afp-goca-config">
+ <title>GOCA (Vector Graphics)</title>
+ <p>
+ Not all AFP implementations support GOCA. Some also have bugs related to GOCA. Therefore,
+ it is desirable to have some control over the generation of GOCA graphics.
+ </p>
+ <p>
+ GOCA is enabled by default. You can disable GOCA entirely in which case the AFP support
+ falls back to generating bitmaps for vector graphics. Example:
+ </p>
+ <source><![CDATA[
+ <goca enabled="false"/>]]></source>
+ <p>
+ Some AFP implementations have trouble rendering text in GOCA. You can instruct the AFP
+ support to render text as shapes (i.e. use vector graphics to paint text). Example:
+ </p>
+ <source><![CDATA[
+ <goca enabled="true" text="shapes"/>]]></source>
+ <p>
+ If you disable GOCA or let text render as shapes, the size of the generated AFP usually
+ increases considerably.
+ </p>
+ </section>
<section id="afp-shading-config">
<title>Shading</title>
<p>
diff --git a/src/java/org/apache/fop/afp/AFPPaintingState.java b/src/java/org/apache/fop/afp/AFPPaintingState.java
index 85d3e914b..2be3a85ac 100644
--- a/src/java/org/apache/fop/afp/AFPPaintingState.java
+++ b/src/java/org/apache/fop/afp/AFPPaintingState.java
@@ -73,6 +73,11 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
/** the output resolution */
private int resolution = 240; // 240 dpi
+ /** determines whether GOCA is enabled or disabled */
+ private boolean gocaEnabled = true;
+ /** determines whether to stroke text in GOCA mode or to use text operators where possible */
+ private boolean strokeGocaText = false;
+
/** the current page */
private transient AFPPagePaintingState pagePaintingState = new AFPPagePaintingState();
@@ -276,12 +281,46 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
return this.resolution;
}
+ /**
+ * Controls whether GOCA is enabled or disabled.
+ * @param enabled true if GOCA is enabled, false if it is disabled
+ */
+ public void setGOCAEnabled(boolean enabled) {
+ this.gocaEnabled = enabled;
+ }
+
+ /**
+ * Indicates whether GOCA is enabled or disabled.
+ * @return true if GOCA is enabled, false if GOCA is disabled
+ */
+ public boolean isGOCAEnabled() {
+ return this.gocaEnabled;
+ }
+
+ /**
+ * Controls whether to stroke text in GOCA mode or to use text operators where possible.
+ * @param stroke true to stroke, false to paint with text operators where possible
+ */
+ public void setStrokeGOCAText(boolean stroke) {
+ this.strokeGocaText = stroke;
+ }
+
+ /**
+ * Indicates whether to stroke text in GOCA mode or to use text operators where possible.
+ * @return true to stroke, false to paint with text operators where possible
+ */
+ public boolean isStrokeGOCAText() {
+ return this.strokeGocaText;
+ }
+
/** {@inheritDoc} */
+ @Override
protected AbstractData instantiateData() {
return new AFPData();
}
/** {@inheritDoc} */
+ @Override
protected AbstractPaintingState instantiate() {
return new AFPPaintingState();
}
@@ -423,6 +462,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
}
/** {@inheritDoc} */
+ @Override
public Object clone() {
AFPPaintingState paintingState = (AFPPaintingState) super.clone();
paintingState.pagePaintingState = (AFPPagePaintingState) this.pagePaintingState.clone();
@@ -436,6 +476,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return "AFPPaintingState{" + "portraitRotation=" + portraitRotation
+ ", landscapeRotation=" + landscapeRotation + ", colorImages=" + colorImages
@@ -548,6 +589,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
}
/** {@inheritDoc} */
+ @Override
public Object clone() {
AFPPagePaintingState state = new AFPPagePaintingState();
state.width = this.width;
@@ -559,6 +601,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return "AFPPagePaintingState{width=" + width + ", height=" + height + ", orientation="
+ orientation + ", fonts=" + fonts + ", fontCount=" + fontCount + "}";
@@ -577,6 +620,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
private String imageUri = null;
/** {@inheritDoc} */
+ @Override
public Object clone() {
AFPData obj = (AFPData) super.clone();
obj.filled = this.filled;
@@ -585,12 +629,14 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return "AFPData{" + super.toString() + ", filled=" + filled + ", imageUri=" + imageUri
+ "}";
}
/** {@inheritDoc} */
+ @Override
protected AbstractData instantiate() {
return new AFPData();
}
diff --git a/src/java/org/apache/fop/render/afp/AFPCustomizable.java b/src/java/org/apache/fop/render/afp/AFPCustomizable.java
index 93aaa8b1a..04f3a6eeb 100644
--- a/src/java/org/apache/fop/render/afp/AFPCustomizable.java
+++ b/src/java/org/apache/fop/render/afp/AFPCustomizable.java
@@ -87,6 +87,30 @@ public interface AFPCustomizable {
int getResolution();
/**
+ * Controls whether GOCA is enabled or disabled.
+ * @param enabled true if GOCA is enabled, false if it is disabled
+ */
+ void setGOCAEnabled(boolean enabled);
+
+ /**
+ * Indicates whether GOCA is enabled or disabled.
+ * @return true if GOCA is enabled, false if GOCA is disabled
+ */
+ boolean isGOCAEnabled();
+
+ /**
+ * Controls whether to stroke text in GOCA mode or to use text operators where possible.
+ * @param stroke true to stroke, false to paint with text operators where possible
+ */
+ void setStrokeGOCAText(boolean stroke);
+
+ /**
+ * Indicates whether to stroke text in GOCA mode or to use text operators where possible.
+ * @return true to stroke, false to paint with text operators where possible
+ */
+ boolean isStrokeGOCAText();
+
+ /**
* Sets the default resource group file path
* @param filePath the default resource group file path
*/
diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
index 87651defd..f45baaff6 100644
--- a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
@@ -415,6 +415,26 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
}
/** {@inheritDoc} */
+ public void setGOCAEnabled(boolean enabled) {
+ this.paintingState.setGOCAEnabled(enabled);
+ }
+
+ /** {@inheritDoc} */
+ public boolean isGOCAEnabled() {
+ return this.paintingState.isGOCAEnabled();
+ }
+
+ /** {@inheritDoc} */
+ public void setStrokeGOCAText(boolean stroke) {
+ this.paintingState.setStrokeGOCAText(stroke);
+ }
+
+ /** {@inheritDoc} */
+ public boolean isStrokeGOCAText() {
+ return this.paintingState.isStrokeGOCAText();
+ }
+
+ /** {@inheritDoc} */
public void setDefaultResourceGroupFilePath(String filePath) {
resourceManager.setDefaultResourceGroupFilePath(filePath);
}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
index 07b712ceb..f60e271cb 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
@@ -26,8 +26,6 @@ import java.io.IOException;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-import org.apache.xmlgraphics.util.MimeConstants;
import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPGraphics2D;
@@ -74,6 +72,7 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH
}
/** {@inheritDoc} */
+ @Override
protected AFPDataObjectInfo createDataObjectInfo() {
return new AFPGraphicsObjectInfo();
}
@@ -104,13 +103,13 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH
// Image content
ImageGraphics2D imageG2D = (ImageGraphics2D)image;
- boolean textAsShapes = false; //TODO Make configurable
+ final boolean textAsShapes = paintingState.isStrokeGOCAText();
AFPGraphics2D g2d = new AFPGraphics2D(
textAsShapes,
afpContext.getPaintingState(),
afpContext.getResourceManager(),
graphicsObjectInfo.getResourceInfo(),
- afpContext.getFontInfo());
+ (textAsShapes ? null : afpContext.getFontInfo()));
g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
graphicsObjectInfo.setGraphics2D(g2d);
@@ -127,6 +126,10 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH
boolean supported = (image == null || image instanceof ImageGraphics2D)
&& targetContext instanceof AFPRenderingContext;
if (supported) {
+ AFPRenderingContext afpContext = (AFPRenderingContext)targetContext;
+ if (!afpContext.getPaintingState().isGOCAEnabled()) {
+ return false;
+ }
String mode = (String)targetContext.getHint(ImageHandlerUtil.CONVERSION_MODE);
if (ImageHandlerUtil.isConversionModeBitmap(mode)) {
//Disabling this image handler automatically causes a bitmap to be generated
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
index 4e4e1de31..834304f6b 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
@@ -82,16 +82,16 @@ public class AFPImageHandlerSVG implements ImageHandler {
setDefaultToInlineResourceLevel(graphicsObjectInfo);
// Create a new AFPGraphics2D
- final boolean textAsShapes = false; //afpInfo.strokeText(); //TODO make configurable
+ AFPPaintingState paintingState = afpContext.getPaintingState();
+ final boolean textAsShapes = paintingState.isStrokeGOCAText();
AFPGraphics2D g2d = new AFPGraphics2D(
textAsShapes,
afpContext.getPaintingState(),
afpContext.getResourceManager(),
resourceInfo,
- afpContext.getFontInfo());
+ (textAsShapes ? null : afpContext.getFontInfo()));
g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
- AFPPaintingState paintingState = g2d.getPaintingState();
paintingState.setImageUri(image.getInfo().getOriginalURI());
// Create an AFPBridgeContext
@@ -167,6 +167,10 @@ public class AFPImageHandlerSVG implements ImageHandler {
&& image.getFlavor().isCompatible(BatikImageFlavors.SVG_DOM)))
&& targetContext instanceof AFPRenderingContext;
if (supported) {
+ AFPRenderingContext afpContext = (AFPRenderingContext)targetContext;
+ if (!afpContext.getPaintingState().isGOCAEnabled()) {
+ return false;
+ }
String mode = (String)targetContext.getHint(ImageHandlerUtil.CONVERSION_MODE);
if (ImageHandlerUtil.isConversionModeBitmap(mode)) {
//Disabling this image handler automatically causes a bitmap to be generated
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
index 8d4b3370c..8cc381c18 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
@@ -76,7 +76,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
FontManager fontManager = this.userAgent.getFactory().getFontManager();
Configuration[] triple = fontCfg.getChildren("font-triplet");
- List/*<FontTriplet>*/ tripletList = new java.util.ArrayList/*<FontTriplet>*/();
+ List<FontTriplet> tripletList = new java.util.ArrayList<FontTriplet>();
if (triple.length == 0) {
log.error("Mandatory font configuration element '<font-triplet...' is missing");
return null;
@@ -184,8 +184,8 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
if (base14 != null) {
try {
- Class clazz = Class.forName("org.apache.fop.fonts.base14."
- + base14);
+ Class<?> clazz = Class.forName(
+ "org.apache.fop.fonts.base14." + base14);
try {
Typeface tf = (Typeface)clazz.newInstance();
font.addCharacterSet(sizeMpt,
@@ -223,7 +223,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
String base14 = afpFontCfg.getAttribute("base14-font", null);
if (base14 != null) {
try {
- Class clazz = Class.forName("org.apache.fop.fonts.base14."
+ Class<?> clazz = Class.forName("org.apache.fop.fonts.base14."
+ base14);
try {
Typeface tf = (Typeface)clazz.newInstance();
@@ -291,7 +291,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
* @return List the newly created list of fonts
* @throws ConfigurationException if something's wrong with the config data
*/
- private List/*<AFPFontInfo>*/ buildFontListFromConfiguration(Configuration cfg)
+ private List<AFPFontInfo> buildFontListFromConfiguration(Configuration cfg)
throws FOPException, ConfigurationException {
Configuration fonts = cfg.getChild("fonts");
@@ -309,7 +309,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
referencedFontsCfg, this.userAgent.getFactory().validateUserConfigStrictly());
}
- List/*<AFPFontInfo>*/ fontList = new java.util.ArrayList();
+ List<AFPFontInfo> fontList = new java.util.ArrayList<AFPFontInfo>();
Configuration[] font = fonts.getChildren("font");
final String fontPath = null;
for (int i = 0; i < font.length; i++) {
@@ -352,6 +352,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
*
* @param renderer not used
*/
+ @Override
public void configure(Renderer renderer) {
throw new UnsupportedOperationException();
}
@@ -400,6 +401,16 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
shadingCfg.getValue(AFPShadingMode.COLOR.getName()));
customizable.setShadingMode(shadingMode);
+ // GOCA Support
+ Configuration gocaCfg = cfg.getChild("goca");
+ boolean gocaEnabled = gocaCfg.getAttributeAsBoolean(
+ "enabled", customizable.isGOCAEnabled());
+ customizable.setGOCAEnabled(gocaEnabled);
+ String gocaText = gocaCfg.getAttribute(
+ "text", customizable.isStrokeGOCAText() ? "stroke" : "default");
+ customizable.setStrokeGOCAText("stroke".equalsIgnoreCase(gocaText)
+ || "shapes".equalsIgnoreCase(gocaText));
+
// renderer resolution
Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false);
if (rendererResolutionCfg != null) {
@@ -415,8 +426,8 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
resourceGroupDest = resourceGroupFileCfg.getValue();
if (resourceGroupDest != null) {
File resourceGroupFile = new File(resourceGroupDest);
- resourceGroupFile.createNewFile();
- if (resourceGroupFile.canWrite()) {
+ boolean created = resourceGroupFile.createNewFile();
+ if (created && resourceGroupFile.canWrite()) {
customizable.setDefaultResourceGroupFilePath(resourceGroupDest);
} else {
log.warn("Unable to write to default external resource group file '"
@@ -454,6 +465,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
}
/** {@inheritDoc} */
+ @Override
public void configure(IFDocumentHandler documentHandler) throws FOPException {
Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
if (cfg != null) {
@@ -463,15 +475,16 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
}
/** {@inheritDoc} */
+ @Override
public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
throws FOPException {
FontManager fontManager = userAgent.getFactory().getFontManager();
- List fontCollections = new java.util.ArrayList();
+ List<FontCollection> fontCollections = new java.util.ArrayList<FontCollection>();
Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
if (cfg != null) {
try {
- List fontList = buildFontListFromConfiguration(cfg);
+ List<AFPFontInfo> fontList = buildFontListFromConfiguration(cfg);
fontCollections.add(new AFPFontCollection(
userAgent.getEventBroadcaster(), fontList));
} catch (ConfigurationException e) {
@@ -483,7 +496,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
}
fontManager.setup(fontInfo,
- (FontCollection[])fontCollections.toArray(
+ fontCollections.toArray(
new FontCollection[fontCollections.size()]));
documentHandler.setFontInfo(fontInfo);
}
diff --git a/status.xml b/status.xml
index 20f71aba0..34db1667f 100644
--- a/status.xml
+++ b/status.xml
@@ -59,6 +59,9 @@
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="JM" type="add">
+ AFP GOCA: Added option to disable GOCA and to control text painting inside GOCA graphics.
+ </action>
<action context="Renderers" dev="JM" type="fix">
AFP GOCA: Work-around for InfoPrint's AFP implementation which seems to lose
the character set state over Graphics Data (GAD) boundaries.