Return-Path: Delivered-To: apmail-xmlgraphics-fop-dev-archive@www.apache.org Received: (qmail 26180 invoked from network); 7 Apr 2006 08:07:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Apr 2006 08:07:34 -0000 Received: (qmail 82897 invoked by uid 500); 7 Apr 2006 08:07:31 -0000 Delivered-To: apmail-xmlgraphics-fop-dev-archive@xmlgraphics.apache.org Received: (qmail 82872 invoked by uid 500); 7 Apr 2006 08:07:31 -0000 Mailing-List: contact fop-dev-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: fop-dev@xmlgraphics.apache.org Delivered-To: mailing list fop-dev@xmlgraphics.apache.org Received: (qmail 82861 invoked by uid 99); 7 Apr 2006 08:07:31 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Apr 2006 01:07:30 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [213.239.215.103] (HELO tux17.hoststar.ch) (213.239.215.103) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Apr 2006 01:07:30 -0700 Received: from [127.0.0.1] (zux221-078-210.adsl.green.ch [81.221.78.210]) (authenticated bits=0) by tux17.hoststar.ch (8.12.11/8.12.11) with ESMTP id k3787Alq032124 for ; Fri, 7 Apr 2006 10:07:12 +0200 Date: Fri, 07 Apr 2006 10:06:45 +0200 From: Jeremias Maerki To: fop-dev@xmlgraphics.apache.org Subject: Fixing leading whitespace on a line (was: How about a release?) In-Reply-To: <032401c659aa$f32cf500$d825010a@nb.mindspeed.com> References: <20060406170125.7662.DEV@jeremias-maerki.ch> <032401c659aa$f32cf500$d825010a@nb.mindspeed.com> Message-Id: <20060407093225.B831.DEV@jeremias-maerki.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.12.01 [en] X-Antivirus: avast! (VPS 0614-2, 04/06/2006), Outbound message X-Antivirus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On 06.04.2006 20:50:18 Peter S. Housel wrote: > > WDYT? > > >From my perspective as a user, I think it's essential to fix the problem > with preserving whitespace after a newline (for
-style output) before 
> doing another release.
> 
> -Peter-

Yeah, that's an annoying problem. A quick fix may not be possible,
however. The following patch is simple and does its job for most cases.
It simply makes sure that leading spaces are not ignored anymore by the
line breaker. However, this has a side-effect which breaks a few test
cases, namely:
- inline_block_nested_4
- inline_border_padding_block_nested_1
- inline_border_padding_block_nested_2

These test are about blocks nested in inlines. Here, a linefeed is
converted to a space (by the XMLWhiteSpaceHandler) which ends up as a
leading space on the line right after the nested block. Up to date, this
leading space was suppressed by the Knuth algorithm (leading glues and
penalties are ignored). I think the behaviour after applying the patch
below could actually be correct but may be unexpected from a user
perspective. But linefeed-treatment is on the default ("treat-as-space")
in these test cases.

However, if I set linefeed-treatment to "ignore", the leading space
still remains. Only if I set it to "treat-as-zero-width-space" does the
leading space vanish.

Any insight from the whitespace specialists? I'm not sure about it and
don't want to apply that "quick fix" without a second opinion.

Index: TextLayoutManager.java
===================================================================
--- TextLayoutManager.java      (Revision 391740)
+++ TextLayoutManager.java      (Arbeitskopie)
@@ -539,6 +539,10 @@
                 vecAreaInfo.add(ai);

                 // create the elements
+                if (sequence.size() == 0) {
+                    sequence.add(new KnuthInlineBox(0, null,
+                            notifyPos(new LeafPosition(this, -1)), true));
+                }
                 sequence.addAll
                     (createElementsForASpace(alignment, ai, vecAreaInfo.size() - 1));

Jeremias Maerki