17.05.2014 Views

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

PDFlib 8 Windows COM/.NET Tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Latin core fonts. PDF viewers support a core set of 14 fonts which are assumed to be always<br />

available. Full metrics information for the core fonts is already built into <strong>PDFlib</strong> so<br />

that no additional data are required (unless the font is to be embedded). The core fonts<br />

have the following names:<br />

Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique,<br />

Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique,<br />

Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic,<br />

Symbol, ZapfDingbats<br />

If a font name is not connected to any file name via resources, <strong>PDFlib</strong> will search the<br />

font in the list of Latin core fonts. This step will be skipped if the embedding option is<br />

specified or a FontOutline resource is available for the font name. The following code<br />

fragment requests one of the core fonts without any configuration:<br />

font = p.load_font("Times-Roman", "unicode", "");<br />

Core fonts found in the internal list are never embedded. In order to embed one of these<br />

fonts you must configure a font outline file.<br />

Host fonts. If a font name is not connected to any file name via resources, <strong>PDFlib</strong> will<br />

search the font in the list of fonts installed on the <strong>Windows</strong> or Mac system. Fonts installed<br />

on the system are called host fonts. Host font names must be encoded in ASCII.<br />

On <strong>Windows</strong> Unicode can also be used. See Section 5.4.5, »Host Fonts on <strong>Windows</strong> and<br />

Mac OS X«, page 137, for more details on host fonts. Example:<br />

font = p.load_font("Verdana", "unicode", "");<br />

On <strong>Windows</strong> an optional font style can be added to the font name after a comma:<br />

font = p.load_font("Verdana,Bold", "unicode", "");<br />

In order to load a host font with the name of one of the core fonts, the font name must<br />

be connected to the desired host font name via the HostFont resource category. The following<br />

fragment makes sure that instead of using the built-in core font data, the Symbol<br />

font metrics and outline data will be taken from the host system:<br />

p.set_parameter("HostFont", "Symbol=Symbol");<br />

font = p.load_font("Symbol", "unicode", "embedding");<br />

The alias font name to the left of the equal sign can be chosen arbitrarily; we simply<br />

used the name of the host font.<br />

Extension-based search for font files. All font types except Type 3 fonts can be<br />

searched by using the specified font name as the base name (without any file suffix) of a<br />

font metrics or outline file. If <strong>PDFlib</strong> couldn’t find any font with the specified name it<br />

will loop over all entries in the SearchPath resource category, and add all known file<br />

name suffixes to the supplied font name in an attempt to locate the font metrics or outline<br />

data. The details of the extension-based search algorithm are as follows:<br />

> The following suffixes will be added to the font name, and the resulting file names<br />

tried one after the other to locate the font metrics (and outline in the case of True-<br />

Type and OpenType fonts):<br />

134 Chapter 5: Font Handling (Edition for <strong>COM</strong>, .<strong>NET</strong>, and REALbasic)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!