From 2569a6d829991a2aebad001df2447483d44e1d9b Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 10 Apr 2006 07:39:01 +0000 Subject: List NBSP under adjustable spaces in CharUtilities. Generate space elements in the area tree from spaces in fo:character. Clearly mark test cases which test for NBSP. Document failure to generate adjustable spaces from fo:character in a disabled test case. Adjust checks to the fact the fo:character can now also generate spaces. Enable block_white-space-collapse_2.xml again git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@392901 13f79535-47bb-0310-9956-ffa450edef68 --- .../layoutmgr/inline/CharacterLayoutManager.java | 16 +++- src/java/org/apache/fop/util/CharUtilities.java | 4 +- test/layoutengine/disabled-testcases.xml | 9 +- .../block_white-space-collapse_1.xml | 3 +- .../standard-testcases/block_white-space_2.xml | 48 ---------- .../standard-testcases/block_white-space_4.xml | 24 ++--- .../block_white-space_nbsp_1.xml | 105 +++++++++++++++++++++ .../block_white-space_nbsp_2.xml | 52 ++++++++++ 8 files changed, 188 insertions(+), 73 deletions(-) delete mode 100644 test/layoutengine/standard-testcases/block_white-space_2.xml create mode 100644 test/layoutengine/standard-testcases/block_white-space_nbsp_1.xml create mode 100644 test/layoutengine/standard-testcases/block_white-space_nbsp_2.xml diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java index 4bc66adfb..9067c575c 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java @@ -32,6 +32,7 @@ import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.area.Trait; import org.apache.fop.traits.MinOptMax; import org.apache.fop.traits.SpaceVal; +import org.apache.fop.util.CharUtilities; import java.util.List; import java.util.LinkedList; @@ -73,12 +74,17 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { } private org.apache.fop.area.inline.TextArea getCharacterInlineArea(Character node) { - org.apache.fop.area.inline.TextArea ch + org.apache.fop.area.inline.TextArea text = new org.apache.fop.area.inline.TextArea(); - ch.addWord(String.valueOf(node.getCharacter()), 0); - TraitSetter.setProducerID(ch, node.getId()); - TraitSetter.addTextDecoration(ch, fobj.getTextDecoration()); - return ch; + char ch = node.getCharacter(); + if (CharUtilities.isAnySpace(ch)) { + text.addSpace(ch, 0, CharUtilities.isAdjustableSpace(ch)); + } else { + text.addWord(String.valueOf(ch), 0); + } + TraitSetter.setProducerID(text, node.getId()); + TraitSetter.addTextDecoration(text, fobj.getTextDecoration()); + return text; } /** @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int) */ diff --git a/src/java/org/apache/fop/util/CharUtilities.java b/src/java/org/apache/fop/util/CharUtilities.java index f200c3e2f..985c25df7 100644 --- a/src/java/org/apache/fop/util/CharUtilities.java +++ b/src/java/org/apache/fop/util/CharUtilities.java @@ -61,6 +61,8 @@ public class CharUtilities { public static final char ZERO_WIDTH_SPACE = '\u200B'; /** zero-width no-break space (= byte order mark) */ public static final char ZERO_WIDTH_NOBREAK_SPACE = '\uFEFF'; + /** soft hyphen */ + public static final char SOFT_HYPHEN = '\u00AD'; /** @@ -142,7 +144,7 @@ public class CharUtilities { //TODO: are there other kinds of adjustable spaces? return (c == '\u0020' // normal space - /*|| c == ''*/); + || c == NBSPACE); // no-break space } /** diff --git a/test/layoutengine/disabled-testcases.xml b/test/layoutengine/disabled-testcases.xml index cd9b71f86..366550224 100644 --- a/test/layoutengine/disabled-testcases.xml +++ b/test/layoutengine/disabled-testcases.xml @@ -57,11 +57,10 @@ stacking constraints which it shouldn't. - block white-space-collapse 2 - block_white-space-collapse_2.xml - First line-break occurs after the fifth space following the - word 'each'. Trailing spaces not removed in layout. Note: the test passes - in case of text-align="justify". + block white-space nbsp 2 + block_white-space_nbsp_2.xml + The nbsp given as an fo:character is not adjustable and therefore + the justification does not work in this case. block word-spacing diff --git a/test/layoutengine/standard-testcases/block_white-space-collapse_1.xml b/test/layoutengine/standard-testcases/block_white-space-collapse_1.xml index f0383be8c..b12666096 100644 --- a/test/layoutengine/standard-testcases/block_white-space-collapse_1.xml +++ b/test/layoutengine/standard-testcases/block_white-space-collapse_1.xml @@ -103,8 +103,7 @@ - - + diff --git a/test/layoutengine/standard-testcases/block_white-space_2.xml b/test/layoutengine/standard-testcases/block_white-space_2.xml deleted file mode 100644 index bf6c570c0..000000000 --- a/test/layoutengine/standard-testcases/block_white-space_2.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - -

- This test checks non breaking white space. -

-
- - - - - - - - - -  single nbsp around  -   -   after  empty  line   - - - - - - - - - - - - -
diff --git a/test/layoutengine/standard-testcases/block_white-space_4.xml b/test/layoutengine/standard-testcases/block_white-space_4.xml index 29f724490..c19c6f529 100644 --- a/test/layoutengine/standard-testcases/block_white-space_4.xml +++ b/test/layoutengine/standard-testcases/block_white-space_4.xml @@ -88,7 +88,7 @@ - 11 + 12 @@ -125,7 +125,7 @@ - 15 + 16 @@ -162,7 +162,7 @@ - 15 + 16 @@ -192,7 +192,7 @@ - 19 + 20 @@ -207,7 +207,7 @@ - 11 + 12 @@ -246,7 +246,7 @@ - 23 + 24 @@ -277,7 +277,7 @@ - 5 + 6 @@ -300,7 +300,7 @@ - 7 + 8 @@ -325,7 +325,7 @@ - 9 + 10 @@ -350,7 +350,7 @@ - 5 + 6 @@ -374,7 +374,7 @@ - 7 + 8 @@ -400,7 +400,7 @@ - 9 + 10 diff --git a/test/layoutengine/standard-testcases/block_white-space_nbsp_1.xml b/test/layoutengine/standard-testcases/block_white-space_nbsp_1.xml new file mode 100644 index 000000000..9ef8ba78e --- /dev/null +++ b/test/layoutengine/standard-testcases/block_white-space_nbsp_1.xml @@ -0,0 +1,105 @@ + + + + + +

+ This test checks non breaking white space (nbsp). +

+
+ + + + + + + + + +  single nbsp around  +   +   after  empty  line   +  single nbsp around  + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + 3 + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + + + + + 3 + + + +
diff --git a/test/layoutengine/standard-testcases/block_white-space_nbsp_2.xml b/test/layoutengine/standard-testcases/block_white-space_nbsp_2.xml new file mode 100644 index 000000000..ac8d1d76c --- /dev/null +++ b/test/layoutengine/standard-testcases/block_white-space_nbsp_2.xml @@ -0,0 +1,52 @@ + + + + + +

+ This test checks non breaking white space (nbsp) specified as fo:character. + This is to check if a nbsb as fo:character is processed the same way as a normal nbsb. +

+
+ + + + + + + + + +  singlenbsp around  + +  single nbsp around  +  singlenbsp around  + + + + + + + + + + + + + + +
-- cgit v1.2.3