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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The keepnative option is false by default. In order to avoid subtle problems in Acrobat<br />

we recommend to set keepnative=false if no font embedding is desired, and to set<br />

embedding=true if keepnative=true is desired.<br />

Custom CJK font example with Chinese Unicode text. The following example uses the<br />

ArialUnicodeMS font to display some Chinese text. The font must either be installed on<br />

the system or must be configured according to Section 5.4.4, »Searching for Fonts«, page<br />

132):<br />

font = p.load_font("Arial Unicode MS", "unicode", "");<br />

p.setfont(font, 24);<br />

p.set_text_pos(50, 500);<br />

p.show("\u4e00\u500b\u4eba");<br />

Accessing individual fonts in a TrueType Collection (TTC). TTC files contain<br />

multiple separate fonts. You can access each font by supplying its proper<br />

name. However, if you don’t know which fonts are contained in a TTC file you<br />

can numerically address each font by appending a colon character and the<br />

number of the font within the TTC file (starting with 0). If the index is 0 it can<br />

be omitted. For example, the TTC file msgothic.ttc contains multiple fonts which can be<br />

addressed as follows in load_font( ) (each line contains equivalent font names):<br />

msgothic:0 MS Gothic msgothic:<br />

msgothic:1 MS PGothic<br />

msgothic:2 MS UI Gothic<br />

Note that msgothic (without any suffix) will not work as a font name since it does not<br />

uniquely identify a font. Font name aliases (see »Sources of Font Data«, page 132) can be<br />

used in combination with TTC indexing. If a font with the specified index cannot be<br />

found, the function call will fail.<br />

It is only required to configure the TTC font file once; all indexed fonts in the TTC file<br />

will be found automatically. The following code is sufficient to configure all indexed<br />

fonts in msgothic.ttc (see Section 5.4.4, »Searching for Fonts«, page 132):<br />

p.set_parameter("FontOutline", "msgothic=msgothic.ttc");<br />

6.5.3 EUDC and SING Fonts for Gaiji Characters<br />

<strong>PDFlib</strong> supports <strong>Windows</strong> EUDC (end-user defined characters, *.tte) and SING fonts<br />

(*.gai) which can be used to access custom Gaiji characters for CJK text. Most conveniently<br />

fonts with custom characters are integrated into other fonts with the fallback font<br />

mechanism. Gaiji characters will commonly be provided in EUDC or SING fonts. Alternatively,<br />

Gaiji characters can also be supplied as Type 3 fonts, but this requires more<br />

programming effort.<br />

Using fallback fonts for Gaiji characters. Typically, Gaiji characters will be pulled from<br />

<strong>Windows</strong> EUDC fonts or SING glyphlets, but the fallbackfonts option accepts any kind of<br />

font. Therefore this approach is not limited to Gaiji characters, but can be used for any<br />

kind of symbol (e.g. a company logo in a separate font). You can use the following font<br />

6.5 Chinese, Japanese, and Korean Text Output 173

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

Saved successfully!

Ooh no, something went wrong!