Patch by Luis Bernardo git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1244656 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_1rc1old
@@ -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); | |||
} |
@@ -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) { |
@@ -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; |
@@ -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. | |||
@@ -73,6 +74,14 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil { | |||
return this.font; | |||
} | |||
/** | |||
* 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 | |||
@@ -81,6 +90,14 @@ public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil { | |||
this.font = f; | |||
} | |||
/** | |||
* 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 | |||
@@ -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); | |||
} | |||
} | |||
/** |
@@ -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> |