XSL-FO Tutorials - Herong's Tutorial Examples - v2.25, by Herong Yang
Adobe PDF Base-14 Fonts
This section describes Adobe PDF Base-14 fonts in 5 font families: Helvetica, Times, Courier, Symbol, and ZapfDingbats.
In the last tutorial, we learned that XSL-FO defines 5 generic font families: "serif", "sans-serif", "cursive", "fantasy", and "monospace". All XSL processors should support all of them. If your XSL-FO documents uses only these font families, you should not have any issues formatting them to any output devices.
But if you want to use a specific font family, you need to read your XSL processor document to see that font families are supported for each output device type. For example, both Apache FOP and RenderX XEP support Adobe Base-14 Fonts on PDF output files:
Here is my tutorial example, Adobe-PDF-Base-14-Fonts.fo, that uses Adobe PDF Base-14 fonts to format some characters, symbols and dingbats:
<?xml version="1.0" encoding="utf-8"?> <!-- Adobe-PDF-Base-14-Fonts.fo - Copyright (c) 2006 HerongYang.com. All Rights Reserved. --> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="page" margin="0.1in" page-height="4.4in" page-width="3.4in"> <fo:region-body region-name="body"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="page"> <fo:flow flow-name="body"> <fo:block margin-top="6pt">Generic font "Helvetica": <fo:inline background-color="#ffddff" font-family="Helvetica" font-size="12pt" font-weight="bold"> The tangram is a dissection puzzle. </fo:inline> </fo:block> <fo:block margin-top="6pt">Generic font "Times": <fo:inline background-color="#ffddff" font-family="Times" font-size="12pt" font-style="italic"> The tangram is a dissection puzzle. </fo:inline> </fo:block> <fo:block margin-top="6pt">Generic font "Courier": <fo:inline background-color="#ffddff" font-family="Courier" font-size="12pt"> The tangram is a dissection puzzle. </fo:inline> </fo:block> <fo:block margin-top="6pt">Generic font "Symbol": <fo:inline background-color="#ffddff" font-family="Symbol" font-size="12pt"> ! ∀ # ∃ Α Β Χ Δ Ε Φ Γ Η Ι ϑ Κ Λ Μ Ν Ο Π Θ Ρ Σ Τ Υ ς Ω Ξ Ψ Ζ ∴ ⊥ α β χ δ ε φ γ η ι ϕ κ λ μ ν ο π θ ρ σ τ υ ϖ ω ξ ψ ζ </fo:inline> </fo:block> <fo:block margin-top="6pt">Generic font "ZapfDingbats": <fo:inline background-color="#ffddff" font-family="ZapfDingbats" font-size="12pt"> ✁ ✂ ✃ ✄ ☎ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ ✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ </fo:inline> </fo:block> </fo:flow> </fo:page-sequence> </fo:root>
If you process this example XSL-FO document with Apache FOP tool to generate a PDF file, you will get some warnings:
herong> fop -fo XSL-FO-Generic-Font-Families.fo -awt herong> fop -fo Adobe-PDF-Base-14-Fonts.fo \ -pdf Adobe-PDF-Base-14-Fonts_fop.pdf ... org.apache.fop.events.LoggingEventListener processEvent WARNING: Glyph "?" (0x263a, smileface) not available in font "ZapfDingbats". ... org.apache.fop.events.LoggingEventListener processEvent WARNING: Glyph "?" (0x263b, blacksmilingface) not available in font "ZapfDingbats". WARNING: Glyph "ò" (0x2022, bullet) not available in font "ZapfDingbats". WARNING: Glyph "?" (0x25d8, bulletinverse) not available in font "ZapfDingbats". WARNING: Glyph "?" (0x25cb, circle) not available in font "ZapfDingbats". ... org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #1.
Those warnings tell us that the Adobe ZapfDingbats font family does not support all dingbats listed in my XSL-FO document.
The picture below shows you how the Apache FOP PDF output looks like:
Notice that Apache FOP replaced those 5 glyphs that are not supported in ZapfDingbats with "✃" near the bottom of the last block.
Table of Contents
Apache™ FOP (Formatting Objects Processor)
XSL-FO Document Basics and Examples
Block-Level Formatting Objects
Inline-Level Formatting Objects
Including Graphics in XSL-FO document
Floating Blocks - "float" and "footnote"
Hyperlinks, Table of Contents and Indexes
Headers and Footers using "static-content"
►Font Attributes and Font Families
Font Attributes and Generic Fonts
Generic Font for Chinese Characters
Apache FOP Font Configurations