W3C home > Mailing lists > Public > www-xsl-fo@w3.org > December 2010

Re: keeping word together (not breaking words onto next line)

From: Jeremias Maerki <dev@jeremias-maerki.ch>
Date: Tue, 21 Dec 2010 09:02:02 +0100
To: www-xsl-fo@w3.org
Message-Id: <20101221084619.19F6.60BA733C@jeremias-maerki.ch>
Have you had the "TIP-IN/FIXED" enclosed in an fo:inline? That should
really work. Otherwise, it's a bug (or missing functionality). Using
that on fo:block, it prevents the whole block text from being broken.

As an alternative, you can try to use word joiners (&#x2060;) to keep
the formatter from breaking a word apart at a particular place.

I've verified both approaches with Apache FOP 1.0:

      <fo:block-container width="11.3cm" background-color="lightgray">
        <fo:block>FLUSH WINDOW ASSEMBLY, NON-EMERGENCY TIP-IN/FIXED</fo:block>
        <fo:block keep-together.within-line="always">FLUSH WINDOW ASSEMBLY, NON-EMERGENCY TIP-IN/FIXED</fo:block>
        <fo:block>FLUSH WINDOW ASSEMBLY, NON-EMERGENCY <fo:inline keep-together.within-line="always">TIP-IN/FIXED</fo:inline></fo:block>
        <fo:block>FLUSH WINDOW ASSEMBLY, NON-EMERGENCY TIP-&#x2060;IN/&#x2060;FIXED</fo:block>
      </fo:block-container>

Some FO formatters implement Unicode UAX #14 for line breaking:
http://unicode.org/reports/tr14/
That document may give you additional ideas on how to control
line-breaking behaviour.

On 20.12.2010 17:16:02 Mario Madunic wrote:
> After doing some investigation by playing with the string "FLUSH WINDOW
> ASSEMBLY, NON-EMERGENCY TIP-IN/FIXED", I found that the culprit is the
> "-". When I remove it from the string I get the behaviour I'm looking
> for without using @keep-together.within-line. Is there a way to modify
> this behaviour?
> 
> Marijan (Mario) Madunic
> Publishing Specialist
> New Flyer Industries
> 
> -----Original Message-----
> From: www-xsl-fo-request@w3.org [mailto:www-xsl-fo-request@w3.org] On Behalf Of Mario Madunic
> Sent: Monday, December 20, 2010 9:47 AM
> To: www-xsl-fo@w3.org
> Subject: RE: keeping word together (not breaking words onto next line)
> 
> Thanks Jeremias, but it is keeping the entire string on one line instead of forcing an entire word to the next line. I'm looking at keeping words together when they would span two lines. Is there a group of attributes that I should be looking at?
> 
> Example:
> FLUSH WINDOW ASSEMBLY, NON-EMERGENCY TIP-IN/FIXED
> 
> Should become
> FLUSH WINDOW ASSEMBLY, NON-EMERGENCY
> TIP-IN/FIXED
> 
> Not
> FLUSH WINDOW ASSEMBLY, NON-EMERGENCY TIP-IN/
> FIXED
> 
> Marijan (Mario) Madunic
> Publishing Specialist
> New Flyer Industries
> 
> -----Original Message-----
> From: www-xsl-fo-request@w3.org [mailto:www-xsl-fo-request@w3.org] On Behalf Of Jeremias Maerki
> Sent: Monday, December 20, 2010 8:31 AM
> To: www-xsl-fo@w3.org
> Subject: Re: keeping word together (not breaking words onto next line)
> 
> <fo:block keep-together.within-line="always">My Title</fo:block>
> 
> ...or the same with fo:inline.
> 
> HTH
> 
> On 20.12.2010 14:52:13 Mario Madunic wrote:
> > I’m trying to keep words in titles together when they would break onto
> > two lines. An example would be when a title has the following
> > text“TIP-IN/FIXED”. Currently it is breaking the string at the “/
> > ” and placing “FIXED” on the next line. What is required is the
> > whole string on the next line. How can this be accomplished.
> > 
> > Marijan (Mario) Madunic
> > Publishing Specialist
> > New Flyer Industries


Jeremias Maerki
Received on Tuesday, 21 December 2010 08:02:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 21 December 2010 08:02:28 GMT