aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2012-02-15 19:17:55 +0000
committerVincent Hennebert <vhennebert@apache.org>2012-02-15 19:17:55 +0000
commiteb81bfe45a7867000d4ce0a91aaeed00aff31f21 (patch)
tree575de2fc59fef5a645eddbf60a39f3df99a1db7c /src
parent07b46e643aa927b13a0ef86ef8b0a3ac2539ef8e (diff)
downloadxmlgraphics-fop-eb81bfe45a7867000d4ce0a91aaeed00aff31f21.tar.gz
xmlgraphics-fop-eb81bfe45a7867000d4ce0a91aaeed00aff31f21.zip
Bugzilla #52655: Fixed rendering of special glyphs when using single-byte encoding mode
Patch by Luis Bernardo git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1244656 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/render/ps/PSPainter.java13
-rw-r--r--src/java/org/apache/fop/render/ps/PSTextPainter.java11
-rw-r--r--src/java/org/apache/fop/svg/PDFTextPainter.java16
-rw-r--r--src/java/org/apache/fop/svg/PDFTextUtil.java24
4 files changed, 47 insertions, 17 deletions
diff --git a/src/java/org/apache/fop/render/ps/PSPainter.java b/src/java/org/apache/fop/render/ps/PSPainter.java
index 1b1f9437d..ef9239c2a 100644
--- a/src/java/org/apache/fop/render/ps/PSPainter.java
+++ b/src/java/org/apache/fop/render/ps/PSPainter.java
@@ -373,9 +373,9 @@ public class PSPainter extends AbstractIFPainter {
+ " " + formatMptAsPt(generator, y) + " Tm");
int textLen = text.length();
- if (singleByteFont != null && singleByteFont.hasAdditionalEncodings()) {
+ int start = 0;
+ if (singleByteFont != null) {
//Analyze string and split up in order to paint in different sub-fonts/encodings
- int start = 0;
int currentEncoding = -1;
for (int i = 0; i < textLen; i++) {
char c = text.charAt(i);
@@ -383,8 +383,8 @@ public class PSPainter extends AbstractIFPainter {
int encoding = mapped / 256;
if (currentEncoding != encoding) {
if (i > 0) {
- writeText(text, start, i - start,
- letterSpacing, wordSpacing, dx, font, tf);
+ writeText(text, start, i - start, letterSpacing, wordSpacing, dx,
+ font, tf);
}
if (encoding == 0) {
useFont(fontKey, sizeMillipoints);
@@ -395,14 +395,11 @@ public class PSPainter extends AbstractIFPainter {
start = i;
}
}
- writeText(text, start, textLen - start,
- letterSpacing, wordSpacing, dx, font, tf);
} else {
//Simple single-font painting
useFont(fontKey, sizeMillipoints);
- writeText(text, 0, textLen,
- letterSpacing, wordSpacing, dx, font, tf);
}
+ writeText(text, start, textLen - start, letterSpacing, wordSpacing, dx, font, tf);
} catch (IOException ioe) {
throw new IFException("I/O error in drawText()", ioe);
}
diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java
index 6c009607b..acc673491 100644
--- a/src/java/org/apache/fop/render/ps/PSTextPainter.java
+++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java
@@ -288,10 +288,10 @@ public class PSTextPainter extends NativeTextPainter {
public boolean isFontChanging(Font f, char mapped) {
if (f != getCurrentFont()) {
- int encoding = mapped / 256;
- if (encoding != getCurrentFontEncoding()) {
- return true; //Font is changing
- }
+ return true;
+ }
+ if (mapped / 256 != getCurrentFontEncoding()) {
+ return true;
}
return false; //Font is the same
}
@@ -432,7 +432,8 @@ public class PSTextPainter extends NativeTextPainter {
for (int i = 0, c = this.currentChars.length(); i < c; i++) {
char ch = this.currentChars.charAt(i);
mapped = f.mapChar(ch);
- PSGenerator.escapeChar(mapped, sb);
+ char codepoint = (char) (mapped % 256);
+ PSGenerator.escapeChar(codepoint, sb);
}
sb.append(')');
if (x || y) {
diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java
index 00160f091..f28020a6a 100644
--- a/src/java/org/apache/fop/svg/PDFTextPainter.java
+++ b/src/java/org/apache/fop/svg/PDFTextPainter.java
@@ -186,14 +186,24 @@ class PDFTextPainter extends NativeTextPainter {
}
}
Font f = textUtil.selectFontForChar(ch);
- if (f != textUtil.getCurrentFont()) {
+ char paintChar = (CharUtilities.isAnySpace(ch) ? ' ' : ch);
+ char mappedChar = f.mapChar(paintChar);
+ boolean encodingChanging = false; // used for single byte
+ if (!textUtil.isMultiByteFont(f.getFontName())) {
+ int encoding = mappedChar / 256;
+ mappedChar = (char) (mappedChar % 256);
+ if (textUtil.getCurrentEncoding() != encoding) {
+ textUtil.setCurrentEncoding(encoding);
+ encodingChanging = true;
+ }
+ }
+ if (f != textUtil.getCurrentFont() || encodingChanging) {
textUtil.writeTJ();
textUtil.setCurrentFont(f);
textUtil.writeTf(f);
textUtil.writeTextMatrix(localTransform);
}
- char paintChar = (CharUtilities.isAnySpace(ch) ? ' ' : ch);
- textUtil.writeTJChar(paintChar);
+ textUtil.writeTJMappedChar(mappedChar);
//Update last position
prevPos = glyphPos;
diff --git a/src/java/org/apache/fop/svg/PDFTextUtil.java b/src/java/org/apache/fop/svg/PDFTextUtil.java
index 9ba7cd049..32aed4a39 100644
--- a/src/java/org/apache/fop/svg/PDFTextUtil.java
+++ b/src/java/org/apache/fop/svg/PDFTextUtil.java
@@ -32,6 +32,7 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
private FontInfo fontInfo;
private Font[] fonts;
private Font font;
+ private int encoding;
/**
* Main constructor.
@@ -74,6 +75,14 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
}
/**
+ * Returns the current encoding.
+ * @return the current encoding
+ */
+ public int getCurrentEncoding() {
+ return this.encoding;
+ }
+
+ /**
* Sets the current font.
* @param f the new font to use
*/
@@ -82,6 +91,14 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
}
/**
+ * Sets the current encoding.
+ * @param encoding the new encoding
+ */
+ public void setCurrentEncoding(int encoding) {
+ this.encoding = encoding;
+ }
+
+ /**
* Determines whether the font with the given name is a multi-byte font.
* @param name the name of the font
* @return true if it's a multi-byte font
@@ -98,7 +115,12 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil {
public void writeTf(Font f) {
String fontName = f.getFontName();
float fontSize = (float)f.getFontSize() / 1000f;
- updateTf(fontName, fontSize, isMultiByteFont(fontName));
+ boolean isMultiByte = isMultiByteFont(fontName);
+ if (!isMultiByte && encoding != 0) {
+ updateTf(fontName + "_" + Integer.toString(encoding), fontSize, isMultiByte);
+ } else {
+ updateTf(fontName, fontSize, isMultiByte);
+ }
}
/**