aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/svg/PDFTextElementBridge.java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2007-11-03 10:59:09 +0000
committerJeremias Maerki <jeremias@apache.org>2007-11-03 10:59:09 +0000
commitb4539a24234a1a79e64dcf8e360f67b6109283b9 (patch)
tree6fc40f119ae8a4b2f8c72a6b65b2d1324c405696 /src/java/org/apache/fop/svg/PDFTextElementBridge.java
parentd3568be8f920c9c4b9170626ba05a9c348439f38 (diff)
downloadxmlgraphics-fop-b4539a24234a1a79e64dcf8e360f67b6109283b9.tar.gz
xmlgraphics-fop-b4539a24234a1a79e64dcf8e360f67b6109283b9.zip
Completely reimplemented the PDFTextPainter. All SVG text (including flow text, but excluding special cases with filters) is now painted in PDF text primitives.
The whole thing compiles against and runs with Batik 1.6 but was developed against Batik Trunk (1.7). The TextBridge for SVG 1.2 text is omitted because we're still on Batik 1.6 and FOP wouldn't compile with it. The full feature set is only available with Batik 1.7, of course. With Batik 1.6, font selection may not work as expected. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@591587 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/svg/PDFTextElementBridge.java')
-rw-r--r--src/java/org/apache/fop/svg/PDFTextElementBridge.java76
1 files changed, 12 insertions, 64 deletions
diff --git a/src/java/org/apache/fop/svg/PDFTextElementBridge.java b/src/java/org/apache/fop/svg/PDFTextElementBridge.java
index 100711eb9..47e794dda 100644
--- a/src/java/org/apache/fop/svg/PDFTextElementBridge.java
+++ b/src/java/org/apache/fop/svg/PDFTextElementBridge.java
@@ -19,15 +19,13 @@
package org.apache.fop.svg;
-import org.apache.batik.gvt.TextNode;
-import org.apache.batik.bridge.SVGTextElementBridge;
import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.SVGTextElementBridge;
import org.apache.batik.gvt.GraphicsNode;
-
+import org.apache.batik.gvt.TextNode;
+import org.apache.batik.gvt.TextPainter;
import org.apache.fop.fonts.FontInfo;
-
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
/**
* Bridge class for the &lt;text> element.
@@ -37,11 +35,12 @@ import org.w3c.dom.Node;
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
*/
public class PDFTextElementBridge extends SVGTextElementBridge {
+
private PDFTextPainter pdfTextPainter;
/**
* Constructs a new bridge for the &lt;text> element.
- * @param fi the font infomration
+ * @param fi the font information
*/
public PDFTextElementBridge(FontInfo fi) {
pdfTextPainter = new PDFTextPainter(fi);
@@ -56,71 +55,20 @@ public class PDFTextElementBridge extends SVGTextElementBridge {
*/
public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
GraphicsNode node = super.createGraphicsNode(ctx, e);
- if (node != null && isSimple(ctx, e, node)) {
+ if (node != null) {
+ //Set our own text painter
((TextNode)node).setTextPainter(getTextPainter());
}
return node;
}
- private PDFTextPainter getTextPainter() {
- return pdfTextPainter;
- }
-
/**
- * Check if text element contains simple text.
- * This checks the children of the text element to determine
- * if the text is simple. The text is simple if it can be rendered
- * with basic text drawing algorithms. This means there are no
- * alternate characters, the font is known and there are no effects
- * applied to the text.
- *
- * @param ctx the bridge context
- * @param element the svg text element
- * @param node the graphics node
- * @return true if this text is simple of false if it cannot be
- * easily rendered using normal drawString on the PDFGraphics2D
+ * Returns the TextPainter instance used by this bridge.
+ * @return the text painter
*/
- private boolean isSimple(BridgeContext ctx, Element element, GraphicsNode node) {
- /* I cannot find any reference that 36pt is the maximum font size in PDF. Tests show
- * no such restriction (jeremias, 28.5.2007)
- *
- // Font size, in user space units.
- float fs = TextUtilities.convertFontSize(element).floatValue();
- // PDF cannot display fonts over 36pt
- if (fs > 36) {
- return false;
- }
- */
-
- Element nodeElement;
- for (Node n = element.getFirstChild();
- n != null;
- n = n.getNextSibling()) {
-
- switch (n.getNodeType()) {
- case Node.ELEMENT_NODE:
-
- nodeElement = (Element)n;
-
- if (n.getLocalName().equals(SVG_TSPAN_TAG)
- || n.getLocalName().equals(SVG_ALT_GLYPH_TAG)) {
- return false;
- } else if (n.getLocalName().equals(SVG_TEXT_PATH_TAG)) {
- return false;
- } else if (n.getLocalName().equals(SVG_TREF_TAG)) {
- return false;
- }
- break;
- case Node.TEXT_NODE:
- case Node.CDATA_SECTION_NODE:
- }
- }
-
- /*if (CSSUtilities.convertFilter(element, node, ctx) != null) {
- return false;
- }*/
-
- return true;
+ public TextPainter getTextPainter() {
+ return pdfTextPainter;
}
+
}