import java.io.IOException;
import java.io.OutputStream;
+import org.w3c.dom.Document;
+import org.w3c.dom.svg.SVGLength;
+
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UnitProcessor;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.ImageTranscoder;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontSetup;
-import org.apache.fop.svg.AbstractFOPTranscoder;
+
import org.apache.xmlgraphics.java2d.TextHandler;
import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D;
import org.apache.xmlgraphics.ps.PSGenerator;
-import org.w3c.dom.Document;
-import org.w3c.dom.svg.SVGLength;
+
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.svg.AbstractFOPTranscoder;
/**
* This class enables to transcode an input to a PostScript document.
//TODO Do custom font configuration here somewhere/somehow
FontSetup.setup(fontInfo);
PSGenerator generator = graphics.getPSGenerator();
- graphics.setCustomTextHandler(new NativeTextHandler(generator, fontInfo));
+ graphics.setCustomTextHandler(new NativeTextHandler(graphics, fontInfo));
}
super.transcode(document, uri, output);
import java.awt.geom.AffineTransform;
import java.io.IOException;
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.java2d.ps.PSTextHandler;
+import org.apache.xmlgraphics.ps.PSGenerator;
+
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontSetup;
import org.apache.fop.fonts.FontTriplet;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.java2d.ps.PSTextHandler;
-import org.apache.xmlgraphics.ps.PSGenerator;
/**
* Specialized TextHandler implementation that the PSGraphics2D class delegates to to paint text
*/
public class NativeTextHandler implements PSTextHandler {
- private final PSGenerator gen;
+ private PSGraphics2D rootG2D;
/** FontInfo containing all available fonts */
protected FontInfo fontInfo;
* @param g2d the PSGraphics2D instance this instances is used by
* @param fontInfo the FontInfo object with all available fonts
*/
- public NativeTextHandler(PSGenerator gen, FontInfo fontInfo) {
- this.gen = gen;
+ public NativeTextHandler(PSGraphics2D g2d, FontInfo fontInfo) {
+ this.rootG2D = g2d;
if (fontInfo != null) {
this.fontInfo = fontInfo;
} else {
}
private PSGenerator getPSGenerator() {
- return this.gen;
+ return this.rootG2D.getPSGenerator();
}
/** {@inheritDoc} */
import java.io.IOException;
import java.util.Map;
+import org.w3c.dom.Document;
+
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.ps.PSGenerator;
+
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContextConstants;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.w3c.dom.Document;
/**
* PostScript XML handler for SVG. Uses Apache Batik for SVG processing.
NativeTextHandler nativeTextHandler = null;
BridgeContext ctx = new BridgeContext(ua);
if (!strokeText) {
- PSGenerator generator = graphics.getPSGenerator();
FontInfo fontInfo = psInfo.getFontInfo();
- nativeTextHandler = new NativeTextHandler(generator, fontInfo);
+ nativeTextHandler = new NativeTextHandler(graphics, fontInfo);
graphics.setCustomTextHandler(nativeTextHandler);
PSTextPainter textPainter = new PSTextPainter(nativeTextHandler);
ctx.setTextPainter(textPainter);