From: Tore Engvig Date: Wed, 6 Jun 2001 19:56:09 +0000 (+0000) Subject: PR: 1681 X-Git-Tag: PRE_CODEFORMATTING~104 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=503416560bf299e1ca4d210bb2b34fcf1d6122b5;p=xmlgraphics-fop.git PR: 1681 Moved mapping from character to cid from LineArea to PDFRenderer. This fixes bug no 1681 and other issues with wrong characters being displayed when using CID fonts. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194275 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java index bbad26e06..18fc27208 100644 --- a/src/org/apache/fop/layout/LineArea.java +++ b/src/org/apache/fop/layout/LineArea.java @@ -185,8 +185,8 @@ public class LineArea extends Area { char c = data[i]; if (!((c == ' ') || (c == '\n') || (c == '\r') || (c == '\t'))) { - c = data[i] = currentFontState.mapChar(c); - charWidth = currentFontState.width(c); + //c = data[i] = currentFontState.mapChar(c); + charWidth = currentFontState.width(currentFontState.mapChar(c)); isText = true; if (charWidth <= 0) charWidth = whitespaceWidth; @@ -373,7 +373,7 @@ public class LineArea extends Area { return wordStart; } } else if (this.wrapOption == WrapOption.WRAP) { - if (this.hyphProps.hyphenate == Hyphenate.TRUE) { + if (hyphProps.hyphenate == Hyphenate.TRUE) { return this.doHyphenation(dataCopy,i,wordStart,this.getContentWidth() - (finalWidth + spaceWidth + pendingWidth)); } else { return wordStart; @@ -445,10 +445,12 @@ public class LineArea extends Area { int leaderAlignment) { WordArea leaderPatternArea; int leaderLength = 0; - char dotIndex = currentFontState.mapChar('.'); - int dotWidth = currentFontState.width(dotIndex); - char whitespaceIndex = currentFontState.mapChar(' '); - int whitespaceWidth = currentFontState.width(whitespaceIndex); + char dotIndex = '.'; // currentFontState.mapChar('.'); + int dotWidth = + currentFontState.width(currentFontState.mapChar(dotIndex)); + char whitespaceIndex = ' ';//currentFontState.mapChar(' '); + int whitespaceWidth = + currentFontState.width(currentFontState.mapChar(whitespaceIndex)); int remainingWidth = this.getContentWidth() - this.getCurrentXPosition(); @@ -888,7 +890,8 @@ public class LineArea extends Area { //no hyphenation points, but a inword non-letter character } else if (hyph == null && preString != null){ remainingString.append(preString); - this.addMapWord(startChar,remainingString); + //is.addMapWord(startChar,remainingString); + this.addWord(startChar,remainingString); return wordStart + remainingString.length(); //hyphenation points and no inword non-letter character } else if (hyph != null && preString == null) { @@ -896,7 +899,8 @@ public class LineArea extends Area { if (index != -1) { remainingString.append(hyph.getPreHyphenText(index)); remainingString.append(this.hyphProps.hyphenationChar); - this.addMapWord(startChar,remainingString); + //is.addMapWord(startChar,remainingString); + this.addWord(startChar,remainingString); return wordStart + remainingString.length()-1; } //hyphenation points and a inword non letter character @@ -905,11 +909,13 @@ public class LineArea extends Area { if (index != -1) { remainingString.append(preString.append(hyph.getPreHyphenText(index))); remainingString.append(this.hyphProps.hyphenationChar); - this.addMapWord(startChar,remainingString); + //is.addMapWord(startChar,remainingString); + this.addWord(startChar,remainingString); return wordStart + remainingString.length()-1; } else { remainingString.append(preString) ; - this.addMapWord(startChar,remainingString); + //is.addMapWord(startChar,remainingString); + this.addWord(startChar,remainingString); return wordStart + remainingString.length(); } } @@ -930,20 +936,22 @@ public class LineArea extends Area { assume that it's already done. */ private int getWordWidth (String word, boolean doMap) { - int wordLength = word.length(); - int width = 0; - char [] characters = new char [wordLength]; - word.getChars(0,wordLength,characters,0); - char currentChar; - for (int i = 0; i < wordLength; i++) { - if (doMap) - currentChar = currentFontState.mapChar(characters[i]); - else - currentChar=characters[i]; - - width += this.currentFontState.width(currentChar); - } - return width; + if (word == null) + return 0; + int wordLength = word.length(); + int width = 0; + char [] characters = new char [wordLength]; + word.getChars(0,wordLength,characters,0); + char currentChar; + for (int i = 0; i < wordLength; i++) { + if (doMap) + currentChar = currentFontState.mapChar(characters[i]); + else + currentChar=characters[i]; + + width += this.currentFontState.width(currentChar); + } + return width; } public int getRemainingWidth() @@ -1018,9 +1026,11 @@ public class LineArea extends Area { /** adds a InlineArea containing the String startChar+wordBuf to the line area children. */ private void addWord (char startChar, StringBuffer wordBuf) { - String word = wordBuf.toString(); + String word = (wordBuf != null) ? wordBuf.toString() : ""; WordArea hia; - int startCharWidth = this.currentFontState.width(currentFontState.mapChar(startChar)); + int startCharWidth = + this.currentFontState.width(currentFontState.mapChar(startChar)); + if (startChar == ' ') { this.addChild(new InlineSpace(startCharWidth)); } else { @@ -1030,7 +1040,7 @@ public class LineArea extends Area { hia.setYOffset(placementOffset); this.addChild(hia); } - int wordWidth = this.getWordWidth(word, false); + int wordWidth = this.getWordWidth(word); hia = new WordArea(currentFontState, this.red, this.green, this.blue, word,word.length()); diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index cf808b8e4..fb4a84ed3 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -519,7 +519,7 @@ public class PDFRenderer extends PrintRenderer { int l = s.length(); for (int i = 0; i < l; i++) { - char ch = s.charAt(i); + char ch = area.getFontState().mapChar(s.charAt(i)); if (!useMultiByte) { if (ch > 127) { @@ -542,7 +542,7 @@ public class PDFRenderer extends PrintRenderer { if (kerningAvailable && (i + 1) < l) { addKerning(pdf, (new Integer((int) ch)), - (new Integer((int) s.charAt(i + 1))), + (new Integer((int) area.getFontState().mapChar(s.charAt(i + 1)))), kerning, startText, endText); }