The use of typographical means

These versatile elements are used for the formatting of texts.

This example shall demonstrate how the typographical means are used in order to generate new cells, to highlight in bold and italics as well as to superscript, subscript and underline texts.

Excerpt from the DTD:

<!ELEMENT nL EMPTY><!-- New line -->
<!ELEMENT b (#PCDATA)><!-- bold -->
<!ELEMENT i (#PCDATA)><!-- italic -->
<!ELEMENT sup (#PCDATA)><!-- superscripted -->
<!ELEMENT sub (#PCDATA)><!-- subscripted -->
<!ELEMENT u (#PCDATA)><!-- underlined -->

Stylesheet:

<xsl:template match="nL">
   <fo:block/>                                           ❶
</xsl:template>
<xsl:template match="b"> 
   <fo:inline font-weight="bold">                        ❷
      <xsl:apply-templates/>
   </fo:inline>
</xsl:template>
<xsl:template match="i">
   <fo:inline font-style="italic">                       ❸
      <xsl:apply-templates/> 
   </fo:inline>
</xsl:template>
<xsl:template match="sup">
   <fo:inline baseline-shift="super" font-size="70%">    ❹
      <xsl:apply-templates/>
   </fo:inline>
</xsl:template>
<xsl:template match="sub">
   <fo:inline baseline-shift="sub" font-size="70%">      ❺      
      <xsl:apply-templates/>
   </fo:inline>
</xsl:template>
<xsl:template match="u">
   <fo:inline text-decoration="underline">               ❻
      <xsl:apply-templates/>
   </fo:inline>
</xsl:template>  
 

❶ The template for <nL> shows how a line break can be generated by using an empty block.

❷ The content of the b element shall be displayed in bold letters which is done by using the font-weight attribute and the bold value.

❸ The content of the i element shall be displayed in italics which is done by using the font-style attribute and the italic value.

❹ Texts can be superscripted by using the baseline-shift attribute and the super value. For typographical reasons the superscripted text is minimized by a certain relative measure compared to the surrounding text. Here, the font size is reduced to 70%.

❺ The same as mentioned for superscripted texts applies for subscripted texts accordingly.

❻ A text is underlined with the text-decoration attribute and the underline value. Please note: also space characters are underlined!

More typography

The example given above provides a very limited insight into the typographical possibilities of XSL-FO. Often a combination of several XSL-FO attributes is required for demanding typographical tasks. The following key words in the index refer in particular to typographical attributes:

  • spaces

  • alignment

  • lining through, underlining, overlining, text decoration

  • font, font style

  • leader lines

  • paddings

  • inline formatting

  • borders, margins

  • font family, font size, typeface

  • page break, line break, hyphenation

  • word spacing, character spacing

  • line height

<< back next >>

Copyright © dpunkt.verlag GmbH 2004
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSL-FO in der Praxis" ("XSL-FO in practice") is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo@dpunkt.de