PDFlib 8 Windows COM/.NET Tutorial
PDFlib 8 Windows COM/.NET Tutorial
PDFlib 8 Windows COM/.NET Tutorial
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
5.4.5 Host Fonts on <strong>Windows</strong> and Mac OS X<br />
On Mac and <strong>Windows</strong> systems <strong>PDFlib</strong> can access TrueType, OpenType, and PostScript<br />
fonts which have been installed in the operating system. We refer to such fonts as host<br />
fonts. Instead of manually configuring font files simply install the font in the system<br />
(usually by dropping it into the appropriate directory), and <strong>PDFlib</strong> will happily use it.<br />
When working with host fonts it is important to use the exact (case-sensitive) font<br />
name. Since font names are crucial we mention some platform-specific methods for determining<br />
font names below. More information on font names can be found in Section<br />
5.1.3, »PostScript Type 1 Fonts«, page 118, and Section 5.1.1, »TrueType Fonts«, page 117.<br />
Finding host font names on <strong>Windows</strong>. You can find the name of an installed font by<br />
double-clicking the font file and taking note of the full font name which is displayed in<br />
the window title (on <strong>Windows</strong> Vista/7/8) or the first line of the resulting window (on<br />
<strong>Windows</strong> XP). Some fonts may have parts of their name localized according to the respective<br />
<strong>Windows</strong> version in use. For example, the common font name portion Bold<br />
may appear as the translated word Fett on a German system. In order to retrieve the<br />
host font data from the <strong>Windows</strong> system you must use the translated form of the font<br />
name in <strong>PDFlib</strong> (e.g. Arial Fett), or use font style names (see below). However, in order to<br />
retrieve the font data directly from file you must use the generic (non-localized) form of<br />
the font name (e.g. Arial Bold).<br />
Note You can avoid this internationalization problem by appending font style names (e.g. »,Bold«,<br />
see below) to the font name instead of using localized font name variants.<br />
If you want to examine TrueType fonts in more detail take a look at Microsoft’s free<br />
»font properties extension« 1 which will display many entries of the font’s TrueType tables<br />
in human-readable form.<br />
<strong>Windows</strong> font style names. When loading host fonts from the <strong>Windows</strong> operating<br />
system <strong>PDFlib</strong> users have access to a feature provided by the <strong>Windows</strong> font selection<br />
machinery: style names can be provided for the weight and slant, for example<br />
font = p.load_font("Verdana,Bold", "unicode", "");<br />
This will instruct <strong>Windows</strong> to search for a particular bold, italic, or other variation of the<br />
base font. Depending on the available fonts <strong>Windows</strong> will select a font which most<br />
closely resembles the requested style (it will not create a new font variation). The font<br />
found by <strong>Windows</strong> may be different from the requested font, and the font name in the<br />
generated PDF may be different from the requested name; <strong>PDFlib</strong> does not have any<br />
control over <strong>Windows</strong>’ font selection. Font style names only work with host fonts, but<br />
not for fonts configured via a font file.<br />
The following keywords (separated from the font name with a comma) can be attached<br />
to the base font name to specify the font weight:<br />
none, thin, extralight, ultralight, light, normal, regular, medium,<br />
semibold, demibold, bold, extrabold, ultrabold, heavy, black<br />
1. See www.microsoft.com/typography/TrueTypeProperty21.mspx<br />
136 Chapter 5: Font Handling (Edition for <strong>COM</strong>, .<strong>NET</strong>, and REALbasic)