XML technologies / XSL-FO / Reference / Antenna House Formatter XSL Extensions / Elements / font-face

(Excerpt from "XSL-FO ― Die Referenz" by Manuel Montero Pineda & Steffen Herkert, 2016, dpunkt.verlag)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Category Appending a Font

Common Usage:

Specifies an additional font. This element does not generate area. These functions are not available with AH Formatter V6.3 Lite. [no-LT]

Areas:

None.

Constraints:

<!ELEMENT axf:font-face EMPTY> <!ATTLIST axf:font-face src CDATA #REQUIRED> <!ATTLIST axf:font-face font-family CDATA #REQUIRED> <!ATTLIST axf:font-face font-style (%font-style;) "normal"> <!ATTLIST axf:font-face font-weight (%font-weight;) "normal">

The <axf:font-face> element can be placed directly under <fo:declarations>.

Contents:

EMPTY

Examples:

<fo:declarations> <axf:font-face src="url(http://www.hixie.ch/resources/fonts/AHEM____.TTF)" font-family="AHEM"/> </fo:declarations>

A font specified by <axf:font-face> / @font-face is always embedded. A font with embedding prohibition information cannot be specified.

The following properties can be specified to <axf:font-face> / @font-face.

src

Specifies the font resource.

Value:

[ <uri> [format(<string>)]? | <font-face-name> ]#

Initial value:

N/A

Inherited:

no

Percentages:

N/A

URI can be specified to <uri> with the file name of the font, or the url() function. The type of fonts can be specified by the format() function. When omitted, it will be recognized by the extension of the font resource. Available types are as follows:

woff

WOFF (Web Open Font Format)

truetype

TrueType

opentype

OpenType

<axf:font-face> can be used as follows;

<fo:declarations> <axf:font-face src="url(woff/MyPrivate.woff) format(woff)" font-family="MyWOFF" /> </fo:declarations> ... <fo:block font-family="MyWOFF"> ...

When using the already installed font, specify the installed font name with the local() function.

<fo:declarations> <axf:font-face src="local(Arial)" ...

font-family

Specifies the font family.

Value:

<string>

Initial value:

N/A

Inherited:

no

Percentages:

N/A

font-style

Specifies the font style.

Value:

normal | italic

Initial value:

normal

Inherited:

no

Percentages:

N/A

font-weight

Specifies the font weight.

Value:

normal | bold | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

Initial value:

normal

Inherited:

no

Percentages:

N/A

XSL-FO sample:

<fo:root font-size="12pt" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:cpfo="http://www.compart.net/xmlns/cpfo" xmlns:svg="http://www.w3.org/2000/svg" xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions">
<axf:document-info name="author" value="Alex Critchfield, Antenna House"/>
<axf:document-info name="keywords" value="extensions, font-face"/>
<axf:document-info name="subject" value="font-face extension"/>
<axf:document-info name="title" value="font-face extension demonstration"/>
<fo:layout-master-set>
<fo:simple-page-master page-width="8.5in" page-height="11in" master-name="main">
<fo:region-body region-name="body" margin-top="1in" margin-bottom="1in" margin-left=".75in" margin-right=".75in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:declarations>
<axf:font-face src="url(https://dl.dropboxusercontent.com/u/221516245/Lobster-Regular.ttf)" font-family="EXTERNAL-LOBSTER"/>
</fo:declarations>
<fo:page-sequence master-reference="main">
<fo:flow flow-name="body">
<fo:block>
Formatter can reference fonts from external sources. Externally referenced fonts are always embedded.
</fo:block>
<fo:block space-after="10mm">
The text in the following block will be in the font Lobster which is referenced from a public dropbox link
</fo:block>
<fo:block font-family="EXTERNAL-LOBSTER" space-after="10mm">
This text is in the Lobster font
</fo:block>
<fo:block font-family="monospace" white-space-treatment="preserve" linefeed-treatment="preserve">
Code to include external font: <axf:font-face src="url(https://dl.dropboxusercontent.com/u/221516245/Lobster-Regular.ttf)" font-family="EXTERNAL-LOBSTER"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

Download the examples

Output:

back to top