Docbook - Adding special characters using different fonts

By xngo on March 4, 2019

To add a special character using a specific font, you have to do the followings. For example, if you want to add a check symbol, you have to add the following in your docbook file.

<!-- Insert the check symbol -->
<symbol role="ZapfDingbats">&check;</symbol><!-- in named entity -->
<symbol role="ZapfDingbats">&#x2713;</symbol><!-- in hexadecimal  -->
<symbol role="ZapfDingbats">&#8658;</symbol><!-- in decimal -->

In your customization layer, you tell docbook to use ZapfDingbats font-family for symbol element with ZapfDingbats role as follows:

<xsl:template match="symbol[@role = 'ZapfDingbats']">
  <fo:inline font-family="ZapfDingbats">
    <xsl:apply-templates/>
  </fo:inline>
</xsl:template>

With this process, you can add as many fonts as you want by simply using different role attributes.

References

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.