diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-05-21 07:32:46 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-05-21 07:32:46 +0000 |
commit | 2b5c710ccf7e9e32900b8dc5914339fcdba5a978 (patch) | |
tree | 654b120216f51a1027f785494441b665fdd53532 /src/java/org/apache/fop | |
parent | c432f41561bb6dc966b7e918b127a412a2da8acc (diff) | |
download | xmlgraphics-fop-2b5c710ccf7e9e32900b8dc5914339fcdba5a978.tar.gz xmlgraphics-fop-2b5c710ccf7e9e32900b8dc5914339fcdba5a978.zip |
Bugzilla #42109:
Fixed the rendering of zero-width spaces for certain fonts by not generating them into the area tree.
Submitted by: Paul Vinkenoog <paul.at.vinkenoog.nl>
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@540049 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
3 files changed, 26 insertions, 12 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java index 26dc8c3b4..3d1291480 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java @@ -75,11 +75,14 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { } private org.apache.fop.area.inline.TextArea getCharacterInlineArea(Character node) { - org.apache.fop.area.inline.TextArea text + org.apache.fop.area.inline.TextArea text = new org.apache.fop.area.inline.TextArea(); char ch = node.getCharacter(); if (CharUtilities.isAnySpace(ch)) { - text.addSpace(ch, 0, CharUtilities.isAdjustableSpace(ch)); + // add space unless it's zero-width: + if (!CharUtilities.isZeroWidthSpace(ch)) { + text.addSpace(ch, 0, CharUtilities.isAdjustableSpace(ch)); + } } else { text.addWord(String.valueOf(ch), 0); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index 7e14f49da..8d6c13670 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; import java.util.LinkedList; import java.util.ListIterator; -import java.util.NoSuchElementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -378,7 +377,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { iTotalAdjust += (iWordSpaceDim - wordSpaceIPD.opt) * iWScount; if (iTotalAdjust != iDifference) { // the applied adjustment is greater or smaller than the needed one - log.trace("TextLM.addAreas: error in word / letter space adjustment = " + log.trace("TextLM.addAreas: error in word / letter space adjustment = " + (iTotalAdjust - iDifference)); // set iTotalAdjust = iDifference, so that the width of the TextArea // will counterbalance the error and the other inline areas will be @@ -458,11 +457,13 @@ public class TextLayoutManager extends LeafNodeLayoutManager { areaInfo = (AreaInfo) vecAreaInfo.get(i); if (areaInfo.isSpace) { // areaInfo stores information about spaces - // add the spaces to the TextArea + // add the spaces - except zero-width spaces - to the TextArea for (int j = areaInfo.iStartIndex; j < areaInfo.iBreakIndex; j++) { char spaceChar = textArray[j]; - textArea.addSpace(spaceChar, 0, - CharUtilities.isAdjustableSpace(spaceChar)); + if (!CharUtilities.isZeroWidthSpace(spaceChar)) { + textArea.addSpace(spaceChar, 0, + CharUtilities.isAdjustableSpace(spaceChar)); + } } } else { // areaInfo stores information about a word fragment diff --git a/src/java/org/apache/fop/util/CharUtilities.java b/src/java/org/apache/fop/util/CharUtilities.java index dc2d987f3..1aad75ad7 100644 --- a/src/java/org/apache/fop/util/CharUtilities.java +++ b/src/java/org/apache/fop/util/CharUtilities.java @@ -64,8 +64,8 @@ public class CharUtilities { public static final char ZERO_WIDTH_NOBREAK_SPACE = '\uFEFF'; /** soft hyphen */ public static final char SOFT_HYPHEN = '\u00AD'; - - + + /** * Utility class: Constructor prevents instantiating when subclassed. */ @@ -98,7 +98,17 @@ public class CharUtilities { public static boolean isBreakableSpace(char c) { return (c == SPACE || isFixedWidthSpace(c)); } - + + /** + * Method to determine if the character is a zero-width space. + * @param c the character to check + * @return true if the character is a zero-width space + */ + public static boolean isZeroWidthSpace(char c) { + return c == ZERO_WIDTH_SPACE // 200Bh + || c == ZERO_WIDTH_NOBREAK_SPACE; // FEFFh (also used as BOM) + } + /** * Method to determine if the character is a (breakable) fixed-width space. * @param c the character to check @@ -111,7 +121,7 @@ public class CharUtilities { // c == '\u2002' // en space // c == '\u2003' // em space // c == '\u2004' // three-per-em space -// c == '\u2005' // four--per-em space +// c == '\u2005' // four-per-em space // c == '\u2006' // six-per-em space // c == '\u2007' // figure space // c == '\u2008' // punctuation space @@ -120,7 +130,7 @@ public class CharUtilities { // c == '\u200B' // zero width space // c == '\u3000' // ideographic space } - + /** * Method to determine if the character is a nonbreaking * space. |