keiron 01/06/26 05:21:47
Modified:src/org/apache/fop/render/pdf PDFRenderer.java
src/org/apache/fop/svg PDFGraphics2D.java
Added: src/org/apache/fop/svg PDFTextPainter.java
Log:
added initial impl of text painter that uses pdf fonts
rather than stroking
Revision ChangesPath
1.71 +10 -6 xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java
Index: PDFRenderer.java
===
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- PDFRenderer.java 2001/06/25 14:15:45 1.70
+++ PDFRenderer.java 2001/06/26 12:21:34 1.71
@@ -1,4 +1,4 @@
-/* $Id: PDFRenderer.java,v 1.70 2001/06/25 14:15:45 keiron Exp $
+/* $Id: PDFRenderer.java,v 1.71 2001/06/26 12:21:34 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources."
@@ -371,7 +371,7 @@
UserAgent userAgent = new MUserAgent(new AffineTransform());
GVTBuilder builder = new GVTBuilder();
-GraphicsNodeRenderContext rc = getRenderContext();
+GraphicsNodeRenderContext rc = getRenderContext(fs);
BridgeContext ctx = new BridgeContext(userAgent, rc);
GraphicsNode root;
PDFGraphics2D graphics =
@@ -392,7 +392,7 @@
currentStream.add("Q\n");
}
-public GraphicsNodeRenderContext getRenderContext() {
+public GraphicsNodeRenderContext getRenderContext(FontState fs) {
GraphicsNodeRenderContext nodeRenderContext = null;
if (nodeRenderContext == null) {
RenderingHints hints = new RenderingHints(null);
@@ -406,9 +406,13 @@
new FontRenderContext(new AffineTransform(), true,
true);
-TextPainter textPainter = new StrokingTextPainter();
-//TextPainter textPainter = new PDFTextPainter();
-
+TextPainter textPainter = null;
+Boolean bl =
org.apache.fop.configuration.Configuration.getBooleanValue("strokeSVGText");
+if(bl == null || bl.booleanValue()) {
+textPainter = new StrokingTextPainter();
+} else {
+textPainter = new PDFTextPainter(fs);
+}
GraphicsNodeRableFactory gnrFactory =
new ConcreteGraphicsNodeRableFactory();
1.8 +42 -7 xml-fop/src/org/apache/fop/svg/PDFGraphics2D.java
Index: PDFGraphics2D.java
===
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/PDFGraphics2D.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PDFGraphics2D.java2001/06/18 08:19:20 1.7
+++ PDFGraphics2D.java2001/06/26 12:21:43 1.8
@@ -1,4 +1,4 @@
-/* $Id: PDFGraphics2D.java,v 1.7 2001/06/18 08:19:20 keiron Exp $
+/* $Id: PDFGraphics2D.java,v 1.8 2001/06/26 12:21:43 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources."
@@ -38,7 +38,7 @@
* implementing a Graphic2D piece-meal.
*
* @author mailto:[EMAIL PROTECTED]";>Keiron Liddle
- * @version $Id: PDFGraphics2D.java,v 1.7 2001/06/18 08:19:20 keiron Exp $
+ * @version $Id: PDFGraphics2D.java,v 1.8 2001/06/26 12:21:43 keiron Exp $
* @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D
*/
public class PDFGraphics2D extends AbstractGraphics2D {
@@ -688,6 +688,7 @@
public void drawString(String s, float x, float y) {
System.out.println("drawString(String)");
currentStream.write("BT\n");
+
Shape imclip = getClip();
writeClip(imclip);
Color c = getColor();
@@ -697,15 +698,40 @@
PDFColor col = new PDFColor(c.getRed(), c.getGreen(), c.getBlue());
currentStream.write(col.getColorSpaceOut(false));
+Font gFont = getFont();
+String name = gFont.getName();
+if(name.equals("sanserif")) {
+name = "sans-serif";
+}
+int size = gFont.getSize();
+String style = gFont.isItalic() ? "italic" : "normal";
+String weight = gFont.isBold() ? "bold" : "normal";
+try {
+fontState = new FontState(fontState.getFontInfo(), name,
+ style, weight, size * 1000, 0);
+} catch(org.apache.fop.apps.FOPException fope) {
+fope.printStackTrace();
+}
+name = fontState.getFontName();
+size = fontState.getFontSize() / 1000;