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:
Thanks in advance!
Underlining can be added to inline text using the XSL-FO property text-decoration="underline" . Likewise, text with a horizontal line through it can be generated using text-decoration="line-through" .
In the horizontal text we use text-underline-position: under; to put the underline below all the descenders. In the text with a vertical writing-mode set, we can then use values of left or right to make the underline appear on the left or right of the text as required.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With