Underline block element with different font sizes without an interrupted line

M.E. picture M.E. · Jul 2, 2013 · Viewed 18k times · Source

I am trying to underline an block element that contains text. The block has an font-size attribute and the text within the block is surrounded by an inline element which has a different font-size attribute.

Is there any way to ensure, that the line resulting from the text-decoration="underline" of the outer block is a straight line over all the block element (without any 'gaps' - please see the attached picture) that is not changing its position with the font-size ?

My code:

<fo:block font-size="14pt" text-decoration="underline">
    Some text
    <fo:inline font-size="10pt"> text with a smaller font size </fo:inline>
    Another text
</fo:block>

My result:

Problem with undelined block with different font sizes

Thanks in advance!

Answer

G. Ken Holman picture G. Ken Holman · Jul 2, 2013

I have two versions of XSL-FO engine from one supplier, and the most up-to-date version renders a common underline without gaps, while the older version renders what you see with FOP. So it seems to be implementation dependent.

But you can mimic the appearance of what you want by selectively using the border rather than relying on the implementation:

  <block font-size="14pt">
    <inline border-after-width="1pt" border-after-style="solid">
Some text
<inline font-size="10pt"> text with a smaller font size </inline>
Another text
    </inline>
   </block>

Whether this mimic works in FOP or not, I don't know as I don't use FOP.