Author: spepping
Date: Sat Dec 4 08:30:47 2010
New Revision: 1042115
URL: http://svn.apache.org/viewvc?rev=1042115&view=rev
Log:
Allow for words consisting of only soft hyphens; fixes bug 49837
Added:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/word_lonely_shy.xml
(with props)
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java?rev=1042115&r1=1042114&r2=1042115&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java Sat Dec
4 08:30:47 2010
@@ -398,7 +398,9 @@ public class FOTreeBuilder extends Defau
FOValidationEventProducer eventProducer
= FOValidationEventProducer.Provider.get(
userAgent.getEventBroadcaster());
- eventProducer.unknownFormattingObject(this,
currentFObj.getName(),
+ String name = (currentFObj != null ? currentFObj.getName()
+ : "{" + namespaceURI + "}"
+ localName);
+ eventProducer.unknownFormattingObject(this, name,
new QName(namespaceURI, localName),
getEffectiveLocator());
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=1042115&r1=1042114&r2=1042115&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
Sat Dec 4 08:30:47 2010
@@ -770,11 +770,8 @@ public class TextLayoutManager extends L
while (lastIndex > 0 && foText.charAt(lastIndex - 1) ==
CharUtilities.SOFT_HYPHEN) {
lastIndex--;
}
- final boolean endsWithHyphen = checkEndsWithHyphen
- && foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN;
Font font = FontSelector
.selectFontForCharactersInText(foText, thisStart, lastIndex,
foText, this);
- int wordLength = lastIndex - thisStart;
boolean kerning = font.hasKerning();
MinOptMax wordIPD = MinOptMax.ZERO;
for (int i = thisStart; i < lastIndex; i++) {
@@ -801,23 +798,31 @@ public class TextLayoutManager extends L
}
}
}
+ boolean endsWithHyphen = checkEndsWithHyphen
+ && foText.charAt(lastIndex) ==
CharUtilities.SOFT_HYPHEN;
if (kerning
&& breakOpportunity
&& !TextLayoutManager.isSpace(ch)
&& lastIndex > 0
&& endsWithHyphen) {
- final int kern = font.getKernValue(foText.charAt(lastIndex - 1),
ch);
+ int kern = font.getKernValue(foText.charAt(lastIndex - 1), ch);
if (kern != 0) {
addToLetterAdjust(lastIndex, kern);
//TODO: add kern to wordIPD?
}
}
- int letterSpaces = wordLength - 1;
- // if there is a break opportunity and the next one
- // is not a space, it could be used as a line end;
- // add one more letter space, in case other text follows
- if (breakOpportunity && !TextLayoutManager.isSpace(ch)) {
- letterSpaces++;
+ // shy+chars at start of word: wordLength == 0 && breakOpportunity
+ // shy only characters in word: wordLength == 0 && !breakOpportunity
+ int wordLength = lastIndex - thisStart;
+ int letterSpaces = 0;
+ if (wordLength != 0) {
+ letterSpaces = wordLength - 1;
+ // if there is a break opportunity and the next one
+ // is not a space, it could be used as a line end;
+ // add one more letter space, in case other text follows
+ if (breakOpportunity && !TextLayoutManager.isSpace(ch)) {
+ letterSpaces++;
+ }
}
assert letterSpaces >= 0;
wordIPD = wordIPD.plus(letterSpaceIPD.mult(letterSpaces));
Added:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/word_lonely_shy.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/word_lonely_shy.xml?rev=1042115&view=auto
==============================================================================
---
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/word_lonely_shy.xml
(added)
+++
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/word_lonely_shy.xml
Sat Dec 4 08:30:47 2010
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks that a word consisting of one or more Soft Hyphens is
rendered as an empty word.
+ </p>
+ </info>
+ <fo>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<fo:layout-master-set>
+ <fo:simple-page-master page-width="297mm" page-height="210mm"
master-name="a4"><fo:region-body/></fo:simple-page-master>
+</fo:layout-master-set>
+
+ <fo:page-sequence initial-page-number="auto" master-reference="a4">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>Name: hy (hyphen), Unicode: U+002D (45)</fo:block>
+ <fo:block>-</fo:block>
+ <fo:block>Name: shy (soft hyphen = discretionary hyphen), Unicode:
U+00AD (173)</fo:block>
+ <fo:block>  Â Â Â a  b  c  d
ÂÂÂÂ</fo:block>
+ </fo:flow>
+</fo:page-sequence>
+
+</fo:root>
+ </fo>
+ <checks>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[1]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[2]"/>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[3]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[4]"/>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[5]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[6]"/>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[7]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[8]"/>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[9]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[10]"/>
+ <eval expected="a" xpath="//flow/block[4]/lineArea/text/*[11]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[12]"/>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[13]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[14]"/>
+ <eval expected="b" xpath="//flow/block[4]/lineArea/text/*[15]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[16]"/>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[17]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[18]"/>
+ <eval expected="c" xpath="//flow/block[4]/lineArea/text/*[19]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[20]"/>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[21]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[22]"/>
+ <eval expected="d" xpath="//flow/block[4]/lineArea/text/*[23]"/>
+ <eval expected=" " xpath="//flow/block[4]/lineArea/text/*[24]"/>
+ <eval expected="" xpath="//flow/block[4]/lineArea/text/*[25]"/>
+<!--
+ <word offset="0"/>
+ <space offset="0"> </space>
+ <word offset="0"/>
+ <space offset="0"> </space>
+ <word offset="0"/>
+ <space offset="0"> </space>
+ <word offset="0"/>
+ <space offset="0"> </space>
+ <word offset="0"/>
+ <space offset="0"> </space>
+ <word offset="0">a</word>
+ <space offset="0"> </space>
+ <word offset="0"/>
+ <space offset="0"> </space>
+ <word offset="0">b</word>
+ <space offset="0"> </space>
+ <word offset="0"/>
+ <space offset="0"> </space>
+ <word offset="0">c</word>
+ <space offset="0"> </space>
+ <word offset="0"/>
+ <space offset="0"> </space>
+ <word offset="0">d</word>
+ <space offset="0"> </space>
+ <word offset="0"/>
+-->
+ </checks>
+</testcase>
+
Propchange:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/word_lonely_shy.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/word_lonely_shy.xml
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]