You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2012/02/15 20:17:56 UTC
svn commit: r1244656 - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/render/ps/PSPainter.java
src/java/org/apache/fop/render/ps/PSTextPainter.java
src/java/org/apache/fop/svg/PDFTextPainter.java
src/java/org/apache/fop/svg/PDFTextUtil.java status.xml
Author: vhennebert
Date: Wed Feb 15 19:17:55 2012
New Revision: 1244656
URL: http://svn.apache.org/viewvc?rev=1244656&view=rev
Log:
Bugzilla #52655: Fixed rendering of special glyphs when using single-byte encoding mode
Patch by Luis Bernardo
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSPainter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextUtil.java
xmlgraphics/fop/trunk/status.xml
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSPainter.java?rev=1244656&r1=1244655&r2=1244656&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSPainter.java Wed Feb 15 19:17:55 2012
@@ -373,9 +373,9 @@ public class PSPainter extends AbstractI
+ " " + 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 AbstractI
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 AbstractI
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);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java?rev=1244656&r1=1244655&r2=1244656&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java Wed Feb 15 19:17:55 2012
@@ -288,10 +288,10 @@ public class PSTextPainter extends Nativ
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 Nativ
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) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java?rev=1244656&r1=1244655&r2=1244656&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java Wed Feb 15 19:17:55 2012
@@ -186,14 +186,24 @@ class PDFTextPainter extends NativeTextP
}
}
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;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextUtil.java?rev=1244656&r1=1244655&r2=1244656&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextUtil.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextUtil.java Wed Feb 15 19:17:55 2012
@@ -32,6 +32,7 @@ public abstract class PDFTextUtil extend
private FontInfo fontInfo;
private Font[] fonts;
private Font font;
+ private int encoding;
/**
* Main constructor.
@@ -74,6 +75,14 @@ public abstract class PDFTextUtil extend
}
/**
+ * 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 extend
}
/**
+ * 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 extend
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);
+ }
}
/**
Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1244656&r1=1244655&r2=1244656&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Wed Feb 15 19:17:55 2012
@@ -61,6 +61,9 @@
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Code" dev="VH" type="fix" fixes-bug="52655" due-to="Luis Bernardo">
+ Fixed rendering of special glyphs when using single-byte encoding mode.
+ </action>
<action context="Code" dev="PH" type="add" due-to="VH and PH">
Improvements of the Accessibility feature
</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org