aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/svg/PDFTextPainter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/svg/PDFTextPainter.java')
-rw-r--r--src/java/org/apache/fop/svg/PDFTextPainter.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java
index c5fa9f04e..0320438f8 100644
--- a/src/java/org/apache/fop/svg/PDFTextPainter.java
+++ b/src/java/org/apache/fop/svg/PDFTextPainter.java
@@ -25,11 +25,16 @@ import java.awt.Paint;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
+import java.io.IOException;
import org.apache.batik.gvt.text.TextPaintInfo;
+import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.svg.font.FOPGVTFont;
+import org.apache.fop.svg.font.FOPGVTGlyphVector;
/**
* Renders the attributed character iterator of a {@link org.apache.batik.gvt.TextNode}.
@@ -104,6 +109,46 @@ class PDFTextPainter extends NativeTextPainter {
pdf.writeClip(clip);
}
+ private static int[] paZero = new int[4];
+
+ protected void writeGlyphs(FOPGVTGlyphVector gv, GeneralPath debugShapes) throws IOException {
+ if (gv.getGlyphPositionAdjustments() == null) {
+ super.writeGlyphs(gv, debugShapes);
+ } else {
+ FOPGVTFont gvtFont = (FOPGVTFont) gv.getFont();
+ String fk = gvtFont.getFontKey();
+ Font f = gvtFont.getFont();
+ Point2D initialPos = gv.getGlyphPosition(0);
+ if (f.isMultiByte()) {
+ int fs = f.getFontSize();
+ float fsPoints = fs / 1000f;
+ double xc = 0f;
+ double yc = 0f;
+ double xoLast = 0f;
+ double yoLast = 0f;
+ textUtil.writeTextMatrix(new AffineTransform(1, 0, 0, -1, initialPos.getX(), initialPos.getY()));
+ textUtil.updateTf(fk, fsPoints, true);
+ int[][] dp = gv.getGlyphPositionAdjustments();
+ for (int i = 0, n = gv.getNumGlyphs(); i < n; i++) {
+ int gc = gv.getGlyphCode(i);
+ int[] pa = ((i > dp.length) || (dp[i] == null)) ? paZero : dp[i];
+ double xo = xc + pa[0];
+ double yo = yc + pa[1];
+ double xa = f.getWidth(gc);
+ double ya = 0;
+ double xd = (xo - xoLast) / 1000f;
+ double yd = (yo - yoLast) / 1000f;
+ textUtil.writeTd(xd, yd);
+ textUtil.writeTj((char) gc);
+ xc += xa + pa[2];
+ yc += ya + pa[3];
+ xoLast = xo;
+ yoLast = yo;
+ }
+ }
+ }
+ }
+
@Override
protected void beginTextObject() {
applyColorAndPaint(tpi);