Luca (and maybe Finn), I think I found a problem with TextLayoutManager where NEWLINEs are not properly handled. Consider the following block (extracted from list.fo):
<fo:block line-height="10pt" space-before.optimum="5cm" white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve" wrap-option="no-wrap"> <![CDATA[<!-- list level 1 --> <fo:list-block provisional-distance-between-starts="0.4cm" provisional-label-separation="0.15cm"> <!-- list item --> ]]> </fo:block> If the FO file is parsed directly the SAX events happen to always start with a NEWLINE and then adding exactly one line of text. In this case the current algorithm finds the NEWLINE characters and adds the necessary KnuthPenalty. However, if you do an XSLT transform (as happens with my layout engine test cases) the SAX characters() call can contain more than one line at once. In this case the algorithm ignores the NEWLINEs (see comment). I wonder why this was done like this. I think the whole linefeed handling is done beforehand and all NEWLINEs still coming through this algorithm are preserved linefeeds. Is there some reason why my patch below would make anything worse? It seems to fix my problem here and all my test cases still pass (at least the ones that passed before). Thanks for any feedback! Index: TextLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java,v retrieving revision 1.29 diff -u -r1.29 TextLayoutManager.java --- TextLayoutManager.java 25 Jan 2005 10:55:47 -0000 1.29 +++ TextLayoutManager.java 1 Feb 2005 21:33:07 -0000 @@ -788,16 +788,13 @@ iThisStart = iNextStart; iTempStart = iNextStart; MinOptMax wordIPD = new MinOptMax(0); - for (; - iTempStart < textArray.length - && textArray[iTempStart] != SPACE - && textArray[iTempStart] != NBSPACE; - iTempStart ++) { - // ignore newline characters - if (textArray[iTempStart] != NEWLINE) { - wordIPD.add - (new MinOptMax(fs.getCharWidth(textArray[iTempStart]))); - } + for (; iTempStart < textArray.length + && textArray[iTempStart] != SPACE + && textArray[iTempStart] != NBSPACE + && textArray[iTempStart] != NEWLINE; + iTempStart++) { + wordIPD.add( + new MinOptMax(fs.getCharWidth(textArray[iTempStart]))); } wordIPD.add(MinOptMax.multiply(letterSpaceIPD, (iTempStart - iThisStart - 1))); vecAreaInfo.add Jeremias Maerki