10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

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.

Horizontal and vertical writing mode. PDFlib supports both horizontal and verticalwriting modes. For standard CJK fonts and CMaps the writing mode is selected alongwith the encoding by choosing the appropriate CMap name. CMaps with names endingin -H select horizontal writing mode, while the -V suffix selects vertical writing mode.Fonts with encodings other than a CMap can be used for vertical writing mode by supplyingthe vertical option to PDF_load_font( ). Font names starting with an @ characterwill always be processed in vertical mode.Note Some PDFlib functions change their semantics according to the writing mode. For example,PDF_continue_text( ) should not be used in vertical writing mode, and the character spacingmust be negative in order to spread characters apart in vertical writing mode.Standard CJK font example. Standard CJK fonts can be selected with the PDF_load_font( ) interface, supplying the CMap name as the encoding parameter. However, youmust take into account that a given CJK font supports only a certain set of CMaps (seeTable 5.2), and that Unicode-aware language bindings support only UCS2-compatibleCMaps. The KozMinPro-Regular-Acro sample in Table 5.2 can been generated with the followingcode:font = p.load_font("KozMinPro-Regular-Acro", "UniJIS-UCS2-H", "");if (font == -1) { ... }p.setfont(font, 24);p.set_text_pos(50, 500);p.show("\u65E5\u672C\u8A9E");These statements locate one of the Japanese standard fonts, choosing a Shift-JIS-compatibleCMap (Ext-RKSJ) and horizontal writing mode (H). The fontname parameter mustbe the exact name of the font without any encoding or writing mode suffixes. Theencoding parameter is the name of one of the supported CMaps (the choice depends onthe font) and will also indicate the writing mode (see above). PDFlib supports all of Acrobat’sdefault CMaps, and will complain when it detects a mismatch between the requestedfont and the CMap. For example, PDFlib will reject a request to use a Koreanfont with a Japanese encoding.Forcing monospaced fonts. Some applications are not prepared to deal with proportionalCJK fonts, and calculate the extent of text based on a constant glyph width andthe number of glyphs. PDFlib can be instructed to force monospaced glyphs even forfonts that usually have glyphs with varying widths. Use the monospace option of PDF_load_font( ) to specify the desired width for all glyphs. For standard CJK fonts the value1000 will result in pleasing results:font = p.load_font("KozMinPro-Regular-Acro", "UniJIS-UCS2-H", "monospace=1000");The monospace option is only recommended for standard CJK fonts.5.6.2 Custom CJK FontsIn addition to Acrobat’s standard CJK fonts PDFlib supports custom CJK fonts (fonts outsidethe list in Table 5.2) in the TrueType (including TrueType Collections, TTC) andOpenType formats. Custom CJK fonts will be processed as follows:> If the embedding option is true, the font will be converted to a CID font and embeddedin the PDF output.5.6 Chinese, Japanese, and Korean Fonts 117

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

Saved successfully!

Ooh no, something went wrong!