word wrap, hyphenation

View: New views
8 Messages — Rating Filter:   Alert me  

word wrap, hyphenation

by Jan Driesen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear all,


While outputting PDF using FOP 0.95, I'm encountering an issue in PDF markup.

The (XSLT-generated) FO code is:

<fo:table-row>
<fo:table-cell padding-right="1mm" padding-top="9pt" text-align="justify" line-height="11pt" font-size="9pt" font-family="Times New Roman" number-columns-spanned="2"> <fo:block> <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp 146 fol. 252, 194 fol. 190v ; G 109 n° 16, G 660, 951</fo:inline> </fo:block> </fo:table-cell> </fo:table-row>


In the PDF output, this line is wrapped between "G 109 n" and "° 16, G 660, 951". Rather than choosing a white-space to wrap the line. Is there any way to avoid this? I need wrapping here to fit the content, but preferably not between the "n°" sequence...


Thanks,


Jan Driesen


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: word wrap, hyphenation

by cbowditch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jan Driesen wrote:
> Dear all,

Hi Jan,

>
>
> While outputting PDF using FOP 0.95, I'm encountering an issue in PDF markup.
>
> The (XSLT-generated) FO code is:
>
> <fo:table-row>
> <fo:table-cell padding-right="1mm" padding-top="9pt" text-align="justify" line-height="11pt" font-size="9pt" font-family="Times New Roman" number-columns-spanned="2"> <fo:block> <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp 146 fol. 252, 194 fol. 190v ; G 109 n° 16, G 660, 951</fo:inline> </fo:block> </fo:table-cell> </fo:table-row>
>
>
> In the PDF output, this line is wrapped between "G 109 n" and "° 16, G 660, 951". Rather than choosing a white-space to wrap the line. Is there any way to avoid this? I need wrapping here to fit the content, but preferably not between the "n°" sequence...


How about:

<fo:table-cell padding-right="1mm" padding-top="9pt"
text-align="justify" line-height="11pt" font-size="9pt"
font-family="Times New Roman" number-columns-spanned="2"> <fo:block>
<fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp 146
fol. 252, 194 fol. 190v ; <fo:inline keep-together.within-line="true">G
109 n° 16</fo:inline>, G 660, 951</fo:inline> </fo:block>
</fo:table-cell> </fo:table-row>

Thanks,

Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: word wrap, hyphenation

by Vincent Hennebert-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Chris Bowditch wrote:

> Jan Driesen wrote:
>> Dear all,
>
> Hi Jan,
>
>>
>>
>> While outputting PDF using FOP 0.95, I'm encountering an issue in PDF
>> markup.
>>
>> The (XSLT-generated) FO code is:
>>
>> <fo:table-row>
>> <fo:table-cell padding-right="1mm" padding-top="9pt"
>> text-align="justify" line-height="11pt" font-size="9pt"
>> font-family="Times New Roman" number-columns-spanned="2"> <fo:block>
>> <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp
>> 146 fol. 252, 194 fol. 190v ; G 109 n° 16, G 660, 951</fo:inline>
>> </fo:block> </fo:table-cell> </fo:table-row>
>>
>>
>> In the PDF output, this line is wrapped between "G 109 n" and "° 16, G
>> 660, 951". Rather than choosing a white-space to wrap the line. Is
>> there any way to avoid this? I need wrapping here to fit the content,
>> but preferably not between the "n°" sequence...
>
>
> How about:
>
> <fo:table-cell padding-right="1mm" padding-top="9pt"
> text-align="justify" line-height="11pt" font-size="9pt"
> font-family="Times New Roman" number-columns-spanned="2"> <fo:block>
> <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp 146
> fol. 252, 194 fol. 190v ; <fo:inline keep-together.within-line="true">G
> 109 n° 16</fo:inline>, G 660, 951</fo:inline> </fo:block>
> </fo:table-cell> </fo:table-row>

(Small correction: that’s keep-together.within-line="always".)

Alternatively you can use non-breaking spaces (U+00A0):
    <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp
146 fol. 252, 194 fol. 190v ; G 109 n° 16,
G 660, 951</fo:inline>

Just choose the method that is easiest to achieve for you. This may
depend on your processing chain.


HTH,
Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


RE: word wrap, hyphenation

by Jan Driesen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear all,


Thanks for the useful comments.
I went with the Chris' solution, including Vincent's correction: in my XSL-file I have now added the following templates:

  <!-- explicitly force keep-together for some strings -->
  <xsl:template match="text()">
    <xsl:call-template name="nobreak" />
  </xsl:template>
 
  <xsl:template name="nobreak">
    <xsl:param name="text" select="."/>
    <xsl:choose>
      <xsl:when test="contains($text, 'n°')">
        <xsl:value-of select="substring-before($text, 'n°')"/>
        <fo:inline keep-together.within-line="always">n°</fo:inline>
        <xsl:call-template name="nobreak">
          <xsl:with-param name="text" select="substring-after($text,'n°')"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="contains($text, 'N°')">
        <xsl:value-of select="substring-before($text, 'N°')"/>
        <fo:inline keep-together.within-line="always">N°</fo:inline>
        <xsl:call-template name="nobreak">
          <xsl:with-param name="text" select="substring-after($text,'N°')"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

The above solution does the trick, thanks for that!

Working with non-breaking spaces here would however not be a good solution, as there is no space present nor required between "n" and "°". That is exactly what I think is strange about this case. Although there are very "near" opportunities to set a line break (before "n" or after "°", the break is was put in between).

Even though my current case is solved, I'm a bit eager to know whether there is any way to influence FOP, not to split between certain characters? Would that go into hyphenation rules?



Jan Driesen


Hi,

Chris Bowditch wrote:

> Jan Driesen wrote:
>> Dear all,
>
> Hi Jan,
>
>>
>>
>> While outputting PDF using FOP 0.95, I'm encountering an issue in PDF
>> markup.
>>
>> The (XSLT-generated) FO code is:
>>
>> <fo:table-row>
>> <fo:table-cell padding-right="1mm" padding-top="9pt"
>> text-align="justify" line-height="11pt" font-size="9pt"
>> font-family="Times New Roman" number-columns-spanned="2"> <fo:block>
>> <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp
>> 146 fol. 252, 194 fol. 190v ; G 109 n° 16, G 660, 951</fo:inline>
>> </fo:block> </fo:table-cell> </fo:table-row>
>>
>>
>> In the PDF output, this line is wrapped between "G 109 n" and "° 16, G
>> 660, 951". Rather than choosing a white-space to wrap the line. Is
>> there any way to avoid this? I need wrapping here to fit the content,
>> but preferably not between the "n°" sequence...
>
>
> How about:
>
> <fo:table-cell padding-right="1mm" padding-top="9pt"
> text-align="justify" line-height="11pt" font-size="9pt"
> font-family="Times New Roman" number-columns-spanned="2"> <fo:block>
> <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp 146
> fol. 252, 194 fol. 190v ; <fo:inline keep-together.within-line="true">G
> 109 n° 16</fo:inline>, G 660, 951</fo:inline> </fo:block>
> </fo:table-cell> </fo:table-row>

(Small correction: that’s keep-together.within-line="always".)

Alternatively you can use non-breaking spaces (U+00A0):
    <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp
146 fol. 252, 194 fol. 190v ; G 109 n° 16,
G 660, 951</fo:inline>

Just choose the method that is easiest to achieve for you. This may
depend on your processing chain.


HTH,
Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...



Re: word wrap, hyphenation

by Vincent Hennebert-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jan,

Jan Driesen wrote:
> Dear all,
>
>
> Thanks for the useful comments.
> I went with the Chris' solution, including Vincent's correction: in my XSL-file I have now added the following templates:
>
<snip/>
>
> Working with non-breaking spaces here would however not be a good solution, as there is no space present nor required between "n" and "°". That is exactly what I think is strange about this case. Although there are very "near" opportunities to set a line break (before "n" or after "°", the break is was put in between).

Sorry, I didn’t read your message carefully enough. I thought the line
break was between ‘n°’ and ‘16’, in which case the non-breaking space is
a working solution.

FOP implements the Unicode line breaking algorithm (UAX#14 [1]). That
standard specifies, among other things, where it is allowed to break
a line. And it appears that it is allowed to break between a letter and
the degree character. If there were a number instead of the letter, no
break would be allowed.

[1] http://unicode.org/reports/tr14/


> Even though my current case is solved, I'm a bit eager to know whether there is any way to influence FOP, not to split between certain characters? Would that go into hyphenation rules?

Technically speaking, you can use a Word Joiner character (U+2060) to
prevent line-breaking between two characters.

In your particular case though, you should not use the degree character
as an abbreviation for number (which I guess it is). Looking on the web,
the correct abbreviation seems to be ‘no’ or ‘no.’ [2]. In which case
you wouldn’t have that line-breaking issue (you may still want to use
non-breaking spaces to prevent line breaking between ‘no.’ and ‘16’
though).

[2] http://forum.wordreference.com/showthread.php?t=264328


HTH,
Vincent


>
>
>
> Jan Driesen
>
>
> Hi,
>
> Chris Bowditch wrote:
>> Jan Driesen wrote:
>>> Dear all,
>> Hi Jan,
>>
>>>
>>> While outputting PDF using FOP 0.95, I'm encountering an issue in PDF
>>> markup.
>>>
>>> The (XSLT-generated) FO code is:
>>>
>>> <fo:table-row>
>>> <fo:table-cell padding-right="1mm" padding-top="9pt"
>>> text-align="justify" line-height="11pt" font-size="9pt"
>>> font-family="Times New Roman" number-columns-spanned="2"> <fo:block>
>>> <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp
>>> 146 fol. 252, 194 fol. 190v ; G 109 n° 16, G 660, 951</fo:inline>
>>> </fo:block> </fo:table-cell> </fo:table-row>
>>>
>>>
>>> In the PDF output, this line is wrapped between "G 109 n" and "° 16, G
>>> 660, 951". Rather than choosing a white-space to wrap the line. Is
>>> there any way to avoid this? I need wrapping here to fit the content,
>>> but preferably not between the "n°" sequence...
>>
>> How about:
>>
>> <fo:table-cell padding-right="1mm" padding-top="9pt"
>> text-align="justify" line-height="11pt" font-size="9pt"
>> font-family="Times New Roman" number-columns-spanned="2"> <fo:block>
>> <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp 146
>> fol. 252, 194 fol. 190v ; <fo:inline keep-together.within-line="true">G
>> 109 n° 16</fo:inline>, G 660, 951</fo:inline> </fo:block>
>> </fo:table-cell> </fo:table-row>
>
> (Small correction: that’s keep-together.within-line="always".)
>
> Alternatively you can use non-breaking spaces (U+00A0):
>     <fo:inline font-style="italic">XaV Latin 9598 fol. 88 ; Reg Antwerp
> 146 fol. 252, 194 fol. 190v ; G 109 n° 16,
> G 660, 951</fo:inline>
>
> Just choose the method that is easiest to achieve for you. This may
> depend on your processing chain.
>
>
> HTH,
> Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: word wrap, hyphenation

by Vincent Hennebert-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vincent Hennebert wrote:

<snip/>
> In your particular case though, you should not use the degree character
> as an abbreviation for number (which I guess it is). Looking on the web,
> the correct abbreviation seems to be ‘no’ or ‘no.’ [2].

In English, that is. Abbreviations are highly language-specific. In some
languages it’s ‘no’ with the ‘o’ put in superscript. At any rate I don’t
think degree is used in any language. It’s just abused to fake the
superscript ‘o’. Like you noticed that may have unexpected side-effects.


> In which case
> you wouldn’t have that line-breaking issue (you may still want to use
> non-breaking spaces to prevent line breaking between ‘no.’ and ‘16’
> though).
>
> [2] http://forum.wordreference.com/showthread.php?t=264328

Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


RE: word wrap, hyphenation

by Jan Driesen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Vincent,


I completely agree. The broader context of the text is French, that's why the content holds that abbreviation. However as you mention, this should in fact be superscript.

Also thanks for pointing out the Unicode standard rule base behind this, as well as the word joiner char. I agree that FOP should follow the standards and that my content should also do so. In my case it is clearly the (errors in the) content that is to blame...


Best regards,
Thanks,

Jan Driesen

-----Original Message-----
From: Vincent Hennebert [mailto:vhennebert@...]
Sent: dinsdag 3 november 2009 12:52
To: fop-users@...
Subject: Re: word wrap, hyphenation

Vincent Hennebert wrote:

<snip/>
> In your particular case though, you should not use the degree character
> as an abbreviation for number (which I guess it is). Looking on the web,
> the correct abbreviation seems to be ‘no’ or ‘no.’ [2].

In English, that is. Abbreviations are highly language-specific. In some
languages it’s ‘no’ with the ‘o’ put in superscript. At any rate I don’t
think degree is used in any language. It’s just abused to fake the
superscript ‘o’. Like you noticed that may have unexpected side-effects.


> In which case
> you wouldn’t have that line-breaking issue (you may still want to use
> non-breaking spaces to prevent line breaking between ‘no.’ and ‘16’
> though).
>
> [2] http://forum.wordreference.com/showthread.php?t=264328

Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...



Re: word wrap, hyphenation

by Christopher R. Maden :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vincent Hennebert wrote:
> In your particular case though, you should not use the degree character
> as an abbreviation for number (which I guess it is). Looking on the web,
> the correct abbreviation seems to be ‘no’ or ‘no.’ [2]. In which case
> you wouldn’t have that line-breaking issue (you may still want to use
> non-breaking spaces to prevent line breaking between ‘no.’ and ‘16’
> though).

Indeed.  It should be the masculine ordinal, U+00BA, º.  Unicode also
has the numero sign, U+2116, №, which I prefer, though it looks odd in
some typefaces and may not be present in others.

~Chris
--
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
“The State is that great fiction by which everyone tries to live at
 the expense of everyone else.” — Frédéric Bastiat, “L’État”
GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...