You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2014/06/21 00:43:16 UTC

svn commit: r1604297 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java

Author: tilman
Date: Fri Jun 20 22:43:15 2014
New Revision: 1604297

URL: http://svn.apache.org/r1604297
Log:
PDFBOX-2141: set glyph transform rather than graphics2d transform, as suggested by Petr Slaby

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java?rev=1604297&r1=1604296&r2=1604297&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java Fri Jun 20 22:43:15 2014
@@ -23,8 +23,6 @@ import java.awt.RenderingHints;
 import java.awt.font.FontRenderContext;
 import java.awt.font.GlyphVector;
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-import java.awt.geom.NoninvertibleTransformException;
 import java.io.IOException;
 
 import java.io.InputStream;
@@ -337,30 +335,12 @@ public abstract class PDSimpleFont exten
         // check if we have a rotation
         if (!at.isIdentity()) 
         {
-            try 
-            {
-                AffineTransform atInv = at.createInverse();
-                // do only apply the size of the transform, rotation will be realized by rotating the graphics,
-                // otherwise the hp printers will not render the font
-                // apply the transformation to the graphics, which should be the same as applying the
-                // transformation itself to the text
-                g2d.transform(at);
-                // translate the coordinates
-                Point2D.Float newXy = new  Point2D.Float(x,y);
-                atInv.transform(new Point2D.Float( x, y), newXy);
-                g2d.drawGlyphVector(glyphs, (float)newXy.getX(), (float)newXy.getY() );
-                // restore the original transformation
-                g2d.transform(atInv);
-            }
-            catch (NoninvertibleTransformException e) 
+            for (int i = 0; i < glyphs.getNumGlyphs(); i++)
             {
-                LOG.error("Error in "+getClass().getName()+".writeFont",e);
+                glyphs.setGlyphTransform(i, at);
             }
         }
-        else 
-        {
-            g2d.drawGlyphVector(glyphs, x, y);
-        }
+        g2d.drawGlyphVector(glyphs, x, y);
     }
 
     /**