Font Properties

One of the properties that will have the most visible impact on the appearance of your documents is the font face used to display the text. Manipulating the font style, size, and other aspects will bring dramatically different results to the final rendered document.

Here are some of the more common font properties you can use with XSL-FO:

  • font-family— The font-family property allows you to choose the generic family of font to be used, such as serif or sans-serif fonts. Although you can specify specific typefaces, specifying a family ensures that the general appearance of your font will be acceptable, as not all font faces will be available to all XSL processors.

  • font-size— This property allows you to set the size of the font the text should be rendered in. Typically, font sizes are specified using points (pt).

  • font-style— The font style property accepts values such as italic, oblique, or backslant. These are common styles that can be applied to a variety of typefaces.

  • font-weight— The font weight allows you to control the weight of the font, such as bold, or specify a numeric value, such as 100, 200, 300, and so on. The value of 700 is equivalent to bold.

Let's take a look at a stylesheet that shows off some of the changes the font properties can have on the text within a block object:

<?xml version="1.0"?> 
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <fo:layout-master-set>
  <fo:simple-page-master master-name="title_page">
   <fo:region-body/>
  </fo:simple-page-master>
 </fo:layout-master-set>

 <fo:page-sequence master-name="title_page">
  <fo:flow flow-name="xsl-region-body">
   <fo:block font-size="10pt" font-family="serif">10 point type</fo:block>
   <fo:block font-size="24pt" font-family="serif">24 point type</fo:block>
   <fo:block font-size="36pt" font-family="serif">36 point type</fo:block>
   <fo:block font-size="48pt" font-family="serif">A Serif Family Type</fo:block>
   <fo:block font-size="48pt" font-family="sans-serif">A Sans-Serif Family</fo:block>
   <fo:block font-size="48pt" font-family="sans-serif" font-style="italic">Italics</fo:block>
   <fo:block font-size="48pt" font-family="sans-serif" color="red">RED type</fo:block>
  </fo:flow>
 </fo:page-sequence>

</fo:root>

The rendered results of the file can be seen in Figure 10.10.

Figure 10.10. Manipulating type appearance with the font properties.


As you can see, manipulating the font properties of an object can have profound changes. Font manipulation is a very common way to alter the appearance of your documents.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.171.125