]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed cursor advancement for fixed width spaces.
authorJeremias Maerki <jeremias@apache.org>
Tue, 26 Aug 2008 08:14:11 +0000 (08:14 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 26 Aug 2008 08:14:11 +0000 (08:14 +0000)
Set color before "BT" (beginText) to match the old PDFRenderer.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@688990 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/pdf/PDFPainter.java

index e4418bb99d0da719e7e5dbace6790b30d4cb2623..6501ea64866e3dd4f49f1b721a7d19377ba846a8 100644 (file)
@@ -393,6 +393,7 @@ public class PDFPainter extends AbstractBinaryWritingIFPainter {
     /** {@inheritDoc} */
     public void drawText(int x, int y, int[] dx, int[] dy, String text) throws IFException {
         //Note: dy is currently ignored
+        generator.updateColor(state.getTextColor(), true, null);
         generator.beginTextObject();
         FontTriplet triplet = new FontTriplet(
                 state.getFontFamily(), state.getFontStyle(), state.getFontWeight());
@@ -401,7 +402,6 @@ public class PDFPainter extends AbstractBinaryWritingIFPainter {
         String fontKey = fontInfo.getInternalFontKey(triplet);
         int sizeMillipoints = state.getFontSize();
         float fontSize = sizeMillipoints / 1000f;
-        generator.updateColor(state.getTextColor(), true, null);
 
         // This assumes that *all* CIDFonts use a /ToUnicode mapping
         Typeface tf = getTypeface(fontKey);
@@ -442,7 +442,8 @@ public class PDFPainter extends AbstractBinaryWritingIFPainter {
                 if (CharUtilities.isFixedWidthSpace(orgChar)) {
                     //Fixed width space are rendered as spaces so copy/paste works in a reader
                     ch = font.mapChar(CharUtilities.SPACE);
-                    glyphAdjust = -(font.getCharWidth(ch) - font.getCharWidth(orgChar));
+                    int spaceDiff = font.getCharWidth(ch) - font.getCharWidth(orgChar);
+                    glyphAdjust = -(10 * spaceDiff / fontSize);
                 } else {
                     ch = font.mapChar(orgChar);
                 }