[英]Dotted underline in XSL-FO
我想使用 XSL-FO 加点下划线。
我可以使用模板在单词下划线,但不能使线条虚线。
这是我正在使用的模板:
<xsl:template match="db:link">
<fo:inline font-family="AvenirNextLTPro-It" text-decoration="underline">
<fo:basic-link internal-destination="{@idref}">
<xsl:apply-templates/>
</fo:basic-link>
</fo:inline>
</xsl:template>
这就是我将它应用到我的话上的方式:
<link idref="policy">Policy</link>
在 XSL-FO 中是否有用于制作虚线下划线的参数?
text-decoration
支持的值不包括任何虚线:
none | [ [ underline | no-underline] || [ overline | no-overline ] || [ line-through | no-line-through ] || [ blink | no-blink ] ] | inherit
您可能可以通过border-bottom-style
接近所需的效果:
<fo:inline font-family="AvenirNextLTPro-It" border-bottom-style="dotted">
旁注:确保正确考虑命名空间——您的模板与db:link
匹配,但您显示的示例是link
。 根据运行中的默认命名空间和db
命名空间前缀的定义,您可能还有一个匹配问题需要解决。
像这样:
<fo:block>
<fo:inline>I do not have anything. </fo:inline>
<fo:inline border-bottom="0.5pt dotted black">Oh look! dotted underline! </fo:inline>
<fo:inline>No extensions required.</fo:inline>
<fo:inline border-bottom="0.5pt dotted black">And should work with any formatter! </fo:inline>
</fo:block>
导致:
经过 FOP、RenderX 和 AHF 测试,没有任何扩展。
使用axf:text-line-style
,样式下划线与普通实线下划线位于同一位置,而不是移动到fo:inline
的后边缘之后(尽管您可以使用axf:text-underline-position
更改下划线的位置axf:text-underline-position
如果需要)。 axf:text-line-style
使用 AH Formatter 支持的任何扩展边框样式设置下划线(或删除线或上划线)。
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
xml:lang="en">
<fo:layout-master-set>
<fo:simple-page-master master-name="spm" size="A5">
<fo:region-body margin="10mm" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="spm">
<fo:flow flow-name="xsl-region-body">
<fo:table>
<fo:table-column column-width="50%" />
<fo:table-column column-width="50%" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding="0.5em">
<fo:block font-weight="bold" font-family="monospace">axf:text-line-style</fo:block>
</fo:table-cell>
<fo:table-cell padding="0.5em">
<fo:block font-weight="bold" font-family="monospace">border-bottom</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding="0.5em">
<fo:block>
<fo:inline text-decoration="underline">Solid underline</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="0.5em">
<fo:block>
<fo:inline border-bottom="0.5pt solid black">Solid underline</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding="0.5em">
<fo:block>
<fo:inline axf:text-line-style="dotted" text-decoration="underline">Dotted underline</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="0.5em">
<fo:block>
<fo:inline border-bottom="0.5pt dotted black">Dotted underline</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding="0.5em">
<fo:block>
<fo:inline axf:text-line-style="dotted" text-decoration="underline" background-color="yellow">Dotted underline</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="0.5em">
<fo:block>
<fo:inline border-bottom="0.5pt dotted black" background-color="yellow">Dotted underline</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.