diff options
author | Jeremias Maerki <jeremias@apache.org> | 2011-07-02 10:20:33 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2011-07-02 10:20:33 +0000 |
commit | e3ac5256c74c3a7a54a04c7b12deb37a3256b042 (patch) | |
tree | 0a09cc38f9392e64779b37035b23a32a1b20acc8 /src/java | |
parent | fa9fc6d171686e319bf56a844c78a8c2f5afe723 (diff) | |
download | xmlgraphics-fop-e3ac5256c74c3a7a54a04c7b12deb37a3256b042.tar.gz xmlgraphics-fop-e3ac5256c74c3a7a54a04c7b12deb37a3256b042.zip |
Bugfix: select the right font to paint replacement glyphs. This used to paint some characters on top of each others when a font with an auxiliary encoding was active.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1142190 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/org/apache/fop/render/pdf/PDFPainter.java | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFPainter.java b/src/java/org/apache/fop/render/pdf/PDFPainter.java index 161b46617..11af216a2 100644 --- a/src/java/org/apache/fop/render/pdf/PDFPainter.java +++ b/src/java/org/apache/fop/render/pdf/PDFPainter.java @@ -84,6 +84,7 @@ public class PDFPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override protected IFContext getContext() { return this.documentHandler.getContext(); } @@ -153,6 +154,7 @@ public class PDFPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override protected RenderingContext createRenderingContext() { PDFRenderingContext pdfContext = new PDFRenderingContext( getUserAgent(), generator, this.documentHandler.currentPage, getFontInfo()); @@ -255,6 +257,7 @@ public class PDFPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override public void drawBorderRect(Rectangle rect, BorderProps before, BorderProps after, BorderProps start, BorderProps end) throws IFException { if (before != null || after != null || start != null || end != null) { @@ -268,6 +271,7 @@ public class PDFPainter extends AbstractIFPainter { } /** {@inheritDoc} */ + @Override public void drawLine(Point start, Point end, int width, Color color, RuleStyle style) throws IFException { generator.endTextObject(); @@ -278,7 +282,7 @@ public class PDFPainter extends AbstractIFPainter { if (fontName == null) { throw new NullPointerException("fontName must not be null"); } - Typeface tf = (Typeface)getFontInfo().getFonts().get(fontName); + Typeface tf = getFontInfo().getFonts().get(fontName); if (tf instanceof LazyFont) { tf = ((LazyFont)tf).getRealFont(); } @@ -337,16 +341,7 @@ public class PDFPainter extends AbstractIFPainter { float glyphAdjust = 0; if (font.hasChar(orgChar)) { ch = font.mapChar(orgChar); - if (singleByteFont != null && singleByteFont.hasAdditionalEncodings()) { - int encoding = ch / 256; - if (encoding == 0) { - textutil.updateTf(fontName, fontSize, tf.isMultiByte()); - } else { - textutil.updateTf(fontName + "_" + Integer.toString(encoding), - fontSize, tf.isMultiByte()); - ch = (char)(ch % 256); - } - } + ch = selectAndMapSingleByteFont(singleByteFont, fontName, fontSize, textutil, ch); if ((wordSpacing != 0) && CharUtilities.isAdjustableSpace(orgChar)) { glyphAdjust += wordSpacing; } @@ -362,6 +357,8 @@ public class PDFPainter extends AbstractIFPainter { glyphAdjust += wordSpacing; } } + ch = selectAndMapSingleByteFont(singleByteFont, fontName, fontSize, + textutil, ch); } textutil.writeTJMappedChar(ch); @@ -377,4 +374,19 @@ public class PDFPainter extends AbstractIFPainter { textutil.writeTJ(); } + private char selectAndMapSingleByteFont(SingleByteFont singleByteFont, String fontName, + float fontSize, PDFTextUtil textutil, char ch) { + if (singleByteFont != null && singleByteFont.hasAdditionalEncodings()) { + int encoding = ch / 256; + if (encoding == 0) { + textutil.updateTf(fontName, fontSize, singleByteFont.isMultiByte()); + } else { + textutil.updateTf(fontName + "_" + Integer.toString(encoding), + fontSize, singleByteFont.isMultiByte()); + ch = (char)(ch % 256); + } + } + return ch; + } + } |