[英]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.