You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Rob Staveley (Tom)" <rs...@seseit.com> on 2003/03/12 08:10:46 UTC
Line-wrap in fo:leader
How can I handle line-wrap in fo:leader?
I'd like to get:
blah........................................ref,ref
blah................................ref,ref,ref
blah, blah, blah, blah, blah,.......
.........................................ref,ref,ref
However, the justification gets lost when it line wraps for me, and I
get:
blah........................................ref,ref
blah................................ref,ref,ref
blah, blah, blah, blah, blah,.......
ref,ref,ref
This looks ragged.
Here's a link to my stuff, which uses Fop 0.20.5rc2:
http://coolbox.seseit.com/~rob/mims_index_218.xml.index.6.xsl.fo.fop-0.2
0.5rc2.rtf.html
Any help would be greatly appreciated.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
RE: Line-wrap in fo:leader
Posted by "Rob Staveley (Tom)" <rs...@seseit.com>.
Again many thanks for the practical advice. I'll act on your suggestions.
-----Original Message-----
From: J.Pietschmann [mailto:j3322ptm@yahoo.de]
Sent: 14 March 2003 18:47
To: fop-user@xml.apache.org
Subject: Re: Line-wrap in fo:leader
Rob Staveley (Tom) wrote:
> To set up something robust, I need to be able to calculate the lengths
> of the strings, using the text metrics of the font,
I don't think you need that much accuracy, a crude measure should suffice to
decide whether you need one or two lines. Font-size times string-length
should be ok for most western fonts.
> Your philosophical note is very interesting. Shouldn't
> over-constraining be forbidden?
This would run counter to quite a few real world use cases...
> It sound like the FO specification leaves a lot of room for
> interpretation.
Indeed. Try to find some hints how to handle the following
<fo:block text-align-last="justify">A<fo:leader/>B<fo:leader/>C</fo:block>
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: Line-wrap in fo:leader
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Rob Staveley (Tom) wrote:
> To set up something robust, I need to be able to calculate the lengths of
> the strings, using the text metrics of the font,
I don't think you need that much accuracy, a crude measure should suffice
to decide whether you need one or two lines. Font-size times string-length
should be ok for most western fonts.
> Your philosophical note is very interesting. Shouldn't over-constraining be
> forbidden?
This would run counter to quite a few real world use cases...
> It sound like the FO specification leaves a lot of room for
> interpretation.
Indeed. Try to find some hints how to handle the following
<fo:block text-align-last="justify">A<fo:leader/>B<fo:leader/>C</fo:block>
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
RE: Line-wrap in fo:leader
Posted by "Rob Staveley (Tom)" <rs...@seseit.com>.
Thank you for pointing out that keep-together success was spurious. That's
saved me a lot of time.
To set up something robust, I need to be able to calculate the lengths of
the strings, using the text metrics of the font, and decide on the approach
to use for leaders accordingly. That's a bit hairy-chested for XSL, and it
sounds like I'm into the realm of procedural programming.
Your philosophical note is very interesting. Shouldn't over-constraining be
forbidden? It sound like the FO specification leaves a lot of room for
interpretation.
-----Original Message-----
From: J.Pietschmann [mailto:j3322ptm@yahoo.de]
Sent: 13 March 2003 20:27
To: fop-user@xml.apache.org
Subject: Re: Line-wrap in fo:leader
Rob Staveley (Tom) wrote:
> Unfortunately the two leaders wind up on the same line, if blah is
> less than 50% long and the ref,ref text goes on the following line
> (see index.13.xsl).
>
At the XSLT level, you can try to estimate the width of the blah and ref on
one entry:
string-length($stuff)*$font-size
If
width($blah)+$minimal-leader-length+width($ref) >
$allocated-width
increase leader-length.optimum to $allocated-width and insert the second
leader with default length set.
> I've tried to use keep-together with some success
Spurious success, I'd bet. Keeps don't have no effect whatsoever on line
breaking, unfortunately. I should know, I had already bad dreams featuring
the current line breaking code. In fact, the keep properties are not even
delivered anywhere near the line breaking code.
> Is this a Fop issue or am I expecting to achieve something from FO
> which is beyond its design?
Tricky question: it should be possible to get it to work with
keep-with-next.within-line, for example:
<fo:block text-align="justify" text-align-last="justify">
<fo:inline
keep-with-next.within-line="always">blah</fo:inline><fo:leader
leader-pattern="dots" leader-length.minimum="6pt"
leader-length.optimum="100%"
keep-with-next.within-line="5"/><fo:leader
leader-pattern="dots" leader-length.optimum="100%"
keep-with-next.within-line="always"/>ref</fo:block>
This is overconstrained: The processor is advised to both keep everything
within a line but expand the leaders to the full line width. OTOH the leader
length can be decreased to 6pt for the first and to 0 for the secons leader,
therefore if blah+(6pt leader)+ref fits on the line, nothing special
happens, but if not the processor can insert a break somewhere, preferably
beween the leaders, which then expand each by itself to fill all available
space. However this isn't all that well defined in the spec, some processors
could do something else, like simply overflowing the line.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: Line-wrap in fo:leader
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Rob Staveley (Tom) wrote:
> Unfortunately the two leaders wind up on the same line, if blah is less than
> 50% long and the ref,ref text goes on the following line (see index.13.xsl).
>
At the XSLT level, you can try to estimate the width of the blah and ref
on one entry:
string-length($stuff)*$font-size
If
width($blah)+$minimal-leader-length+width($ref) >
$allocated-width
increase leader-length.optimum to $allocated-width and insert the second
leader with default length set.
> I've tried to use keep-together with some success
Spurious success, I'd bet. Keeps don't have no effect whatsoever on
line breaking, unfortunately. I should know, I had already bad dreams
featuring the current line breaking code. In fact, the keep properties
are not even delivered anywhere near the line breaking code.
> Is this a Fop issue or am I expecting to achieve something from FO which is
> beyond its design?
Tricky question: it should be possible to get it to work with
keep-with-next.within-line, for example:
<fo:block text-align="justify" text-align-last="justify">
<fo:inline
keep-with-next.within-line="always">blah</fo:inline><fo:leader
leader-pattern="dots" leader-length.minimum="6pt"
leader-length.optimum="100%"
keep-with-next.within-line="5"/><fo:leader
leader-pattern="dots" leader-length.optimum="100%"
keep-with-next.within-line="always"/>ref</fo:block>
This is overconstrained: The processor is advised to both keep
everything within a line but expand the leaders to the full line
width. OTOH the leader length can be decreased to 6pt for the first
and to 0 for the secons leader, therefore if blah+(6pt leader)+ref
fits on the line, nothing special happens, but if not the processor
can insert a break somewhere, preferably beween the leaders, which
then expand each by itself to fill all available space.
However this isn't all that well defined in the spec, some processors
could do something else, like simply overflowing the line.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
RE: Line-wrap in fo:leader
Posted by "Rob Staveley (Tom)" <rs...@seseit.com>.
Many thanks for the suggestion. Your help is greatly appreciated again.
Unfortunately the two leaders wind up on the same line, if blah is less than
50% long and the ref,ref text goes on the following line (see index.13.xsl).
I've tried to use keep-together with some success (see index.14.xsl) and
this improves matters, but you can see that it appears to be ignored on the
4th page of the output, when the refs are too long, and the leader is
separated from the refs.
Is this a Fop issue or am I expecting to achieve something from FO which is
beyond its design?
Links:
http://coolbox.seseit.com/~rob/fo.index.13.html
http://coolbox.seseit.com/~rob/fo.index.14.html
-----Original Message-----
From: J.Pietschmann [mailto:j3322ptm@yahoo.de]
Sent: 12 March 2003 20:38
To: fop-user@xml.apache.org
Subject: Re: Line-wrap in fo:leader
Rob Staveley (Tom) wrote:
> blah, blah, blah, blah, blah,.......
> ref,ref,ref
Add text-align="justify".
> I'd like to get:
>
> blah........................................ref,ref
> blah................................ref,ref,ref
> blah, blah, blah, blah, blah,.......
> .........................................ref,ref,ref
Getting a second leader on the second line is definitely tricky. You could
try to add a second leader:
<fo:block>blah, blah, blah, blah, blah,<fo:leader
leader-pattern="dots"/><fo:leader leader-pattern="dots"
leader-length.optimum="50%"
leader-length.minimum="0"/>ref,ref,ref</fo:block>
This will (hopefully) break if the line is half full with
blah text.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: Line-wrap in fo:leader
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Rob Staveley (Tom) wrote:
> blah, blah, blah, blah, blah,.......
> ref,ref,ref
Add text-align="justify".
> I'd like to get:
>
> blah........................................ref,ref
> blah................................ref,ref,ref
> blah, blah, blah, blah, blah,.......
> .........................................ref,ref,ref
Getting a second leader on the second line is definitely tricky.
You could try to add a second leader:
<fo:block>blah, blah, blah, blah, blah,<fo:leader
leader-pattern="dots"/><fo:leader leader-pattern="dots"
leader-length.optimum="50%"
leader-length.minimum="0"/>ref,ref,ref</fo:block>
This will (hopefully) break if the line is half full with
blah text.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org