You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/08/22 16:05:10 UTC
svn commit: r688085 - in /xmlgraphics/fop/branches/fop-0_95:
src/java/org/apache/fop/svg/PDFTextPainter.java status.xml
Author: jeremias
Date: Fri Aug 22 07:05:09 2008
New Revision: 688085
URL: http://svn.apache.org/viewvc?rev=688085&view=rev
Log:
Fixed text stroking in SVG when the stroke-width is zero.
Modified:
xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/svg/PDFTextPainter.java
xmlgraphics/fop/branches/fop-0_95/status.xml
Modified: xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/svg/PDFTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/svg/PDFTextPainter.java?rev=688085&r1=688084&r2=688085&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/svg/PDFTextPainter.java (original)
+++ xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/svg/PDFTextPainter.java Fri Aug 22 07:05:09 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,6 +43,7 @@
import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
import org.apache.batik.gvt.text.TextPaintInfo;
import org.apache.batik.gvt.text.TextSpanLayout;
+
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
@@ -61,7 +62,7 @@
public class PDFTextPainter extends StrokingTextPainter {
private static final boolean DEBUG = false;
-
+
private boolean strokeText = false;
private FontInfo fontInfo;
@@ -97,7 +98,7 @@
if ((tpi != null) && (tpi.composite != null)) {
g2d.setComposite(tpi.composite);
}
-
+
//------------------------------------
TextSpanLayout layout = textRun.getLayout();
if (DEBUG) {
@@ -105,7 +106,7 @@
System.out.println("================================================");
System.out.println("New text run:");
System.out.println("char count: " + charCount);
- System.out.println("range: "
+ System.out.println("range: "
+ runaci.getBeginIndex() + " - " + runaci.getEndIndex());
System.out.println("glyph count: " + layout.getGlyphCount()); //=getNumGlyphs()
}
@@ -120,29 +121,31 @@
System.out.println("Text: " + chars);
pdf.currentStream.write("%Text: " + chars + "\n");
}
-
+
GeneralPath debugShapes = null;
if (DEBUG) {
debugShapes = new GeneralPath();
}
-
+
Font[] fonts = findFonts(runaci);
if (fonts == null || fonts.length == 0) {
//Draw using Java2D
textRun.getLayout().draw(g2d);
continue;
}
-
+
textUtil.saveGraphicsState();
textUtil.concatMatrixCurrentTransform();
Shape imclip = g2d.getClip();
pdf.writeClip(imclip);
-
+
applyColorAndPaint(tpi, pdf);
-
+
textUtil.beginTextObject();
textUtil.setFonts(fonts);
- textUtil.setTextRenderingMode(tpi.fillPaint != null, tpi.strokePaint != null, false);
+ boolean stroke = (tpi.strokePaint != null)
+ && (tpi.strokeStroke != null);
+ textUtil.setTextRenderingMode(tpi.fillPaint != null, stroke, false);
AffineTransform localTransform = new AffineTransform();
Point2D prevPos = null;
@@ -153,7 +156,7 @@
boolean visibleChar = gv.isGlyphVisible(index)
|| (CharUtilities.isAnySpace(ch) && !CharUtilities.isZeroWidthSpace(ch));
if (DEBUG) {
- System.out.println("glyph " + index
+ System.out.println("glyph " + index
+ " -> " + layout.getGlyphIndex(index) + " => " + ch);
if (CharUtilities.isAnySpace(ch) && ch != 32) {
System.out.println("Space found: " + Integer.toHexString(ch));
@@ -193,9 +196,9 @@
localTransform.concatenate(glyphTransform);
}
localTransform.scale(1, -1);
-
- boolean yPosChanged = (prevPos == null
- || prevPos.getY() != p.getY()
+
+ boolean yPosChanged = (prevPos == null
+ || prevPos.getY() != p.getY()
|| glyphTransform != null);
if (yPosChanged) {
if (index > 0) {
@@ -213,7 +216,7 @@
textUtil.adjustGlyphTJ(adjust * 1000);
}
if (DEBUG) {
- System.out.println("==> x diff: " + xdiff + ", " + effxdiff
+ System.out.println("==> x diff: " + xdiff + ", " + effxdiff
+ ", charWidth: " + cw);
}
}
@@ -226,7 +229,7 @@
}
char paintChar = (CharUtilities.isAnySpace(ch) ? ' ' : ch);
textUtil.writeTJChar(paintChar);
-
+
//Update last position
prevPos = p;
prevVisibleCharWidth = textUtil.getCurrentFont().getCharWidth(chars.charAt(index));
@@ -263,7 +266,7 @@
}
pdf.applyAlpha(fillAlpha, PDFGraphics2D.OPAQUE);
}
-
+
private Font[] findFonts(AttributedCharacterIterator aci) {
List fonts = new java.util.ArrayList();
List gvtFonts = (List) aci.getAttribute(
@@ -338,5 +341,5 @@
}
return (Font[])fonts.toArray(new Font[fonts.size()]);
}
-
+
}
\ No newline at end of file
Modified: xmlgraphics/fop/branches/fop-0_95/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_95/status.xml?rev=688085&r1=688084&r2=688085&view=diff
==============================================================================
--- xmlgraphics/fop/branches/fop-0_95/status.xml (original)
+++ xmlgraphics/fop/branches/fop-0_95/status.xml Fri Aug 22 07:05:09 2008
@@ -53,6 +53,9 @@
<changes>
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="JM" type="fix">
+ Fixed text stroking in SVG when the stroke-width is zero.
+ </action>
<action context="Layout" dev="JM" type="fix">
Fixed ID resolution for nested bookmarks with duplicated IDs.
</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org