tore        01/06/06 12:56:12

  Modified:    src/org/apache/fop/layout LineArea.java
               src/org/apache/fop/render/pdf PDFRenderer.java
  Log:
  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.
  
  Revision  Changes    Path
  1.43      +39 -29    xml-fop/src/org/apache/fop/layout/LineArea.java
  
  Index: LineArea.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/LineArea.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- LineArea.java     2001/05/01 01:02:13     1.42
  +++ LineArea.java     2001/06/06 19:56:05     1.43
  @@ -1,4 +1,4 @@
  -/*-- $Id: LineArea.java,v 1.42 2001/05/01 01:02:13 arved Exp $ --
  +/*-- $Id: LineArea.java,v 1.43 2001/06/06 19:56:05 tore Exp $ --
    *
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
  @@ -185,8 +185,8 @@
               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 @@
                               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 @@
                             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 @@
           //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 @@
               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 @@
               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 @@
                     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 @@
   
       /** 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 @@
               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());
  
  
  
  1.68      +3 -3      xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java
  
  Index: PDFRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- PDFRenderer.java  2001/05/20 23:56:11     1.67
  +++ PDFRenderer.java  2001/06/06 19:56:09     1.68
  @@ -1,4 +1,4 @@
  -/* $Id: PDFRenderer.java,v 1.67 2001/05/20 23:56:11 arved Exp $
  +/* $Id: PDFRenderer.java,v 1.68 2001/06/06 19:56:09 tore Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources."
  @@ -519,7 +519,7 @@
               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 @@
   
                   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);
                   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to