xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Driesen <Jan.Drie...@brepols.net>
Subject RE: word wrap, hyphenation
Date Tue, 03 Nov 2009 10:35:35 GMT
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.&#x00A0;88 ; Reg Antwerp
146 fol.&#x00A0;252, 194 fol.&#x00A0;190v ; G&#x00A0;109 n°&#x00A0;16,
G&#x00A0;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@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message