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/20 23:36:28 UTC
svn commit: r1604282 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Author: tilman
Date: Fri Jun 20 21:36:28 2014
New Revision: 1604282
URL: http://svn.apache.org/r1604282
Log:
PDFBOX-2141: set glyph transform rather than graphics2d transform, as suggested by Petr Slaby
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1604282&r1=1604281&r2=1604282&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Fri Jun 20 21:36:28 2014
@@ -448,20 +448,20 @@ public class PageDrawer extends PDFStrea
private void writeFont(final AffineTransform at, final GlyphVector glyphs)
{
- try
- {
- // Convert from PDF, where glyphs are upright when direction is from
- // bottom to top, to AWT, where this is the other way around
- at.scale(1, -1);
- AffineTransform atInverse = at.createInverse();
- graphics.transform(at);
- graphics.drawGlyphVector(glyphs, 0, 0);
- graphics.transform(atInverse);
- }
- catch (NoninvertibleTransformException exception)
+ // Convert from PDF, where glyphs are upright when direction is from
+ // bottom to top, to AWT, where this is the other way around
+
+ // PDFBOX-2141: do not use graphics.transform(), because this prevents
+ // the correct rendering of shading patterns
+ // don't apply the translation to each glyph, only scale and shear
+ AffineTransform atRS = new AffineTransform(at.getScaleX(), at.getShearY(),
+ -at.getShearX(), -at.getScaleY(), 0, 0);
+
+ for (int i = 0; i < glyphs.getNumGlyphs(); i++)
{
- LOG.error("Can't invert the given affine transformation", exception);
+ glyphs.setGlyphTransform(i, atRS);
}
+ graphics.drawGlyphVector(glyphs, (float) at.getTranslateX(), (float) at.getTranslateY());
}
/**