灰狼的雕虫小技

灰狼和小红帽的现代版

Home Contact Syndicate this Site (RSS 2.0) Syndicate this Site (Atom) Login
  139 Posts :: 0 Stories :: 65 Comments :: 0 Trackbacks

文章 分类

存档

日记 分类

C/C++

Databases

Java

JavaScripts

Linux

友情连接


Fonts from jars (and font packs):
CID fonts are Postscript-based fonts which can support a large number of characters (65,536 max). The format is often used for CJK fonts (CJK = Chinese Japanese Korean). CID format makes it possible to change the character order (encoding) of a font through the use of character-to-glyph tables (CMaps) which are external to the font.
If you want to use CJK fonts in iText, you need an extra jar: iTextAsian.jar. If you want to be able to read the text you generated with iText using CJK fonts, you will also need to download and install a special font pack for Acrobat Reader (or maybe your Reader will ask you to install such a font pack upon opening a PDF file with CJK fonts). For the rest, creating a CJK font supported by the iTextAsian.jar is as easy as using any other font:
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font FontChinese = new Font(bfChinese, 12, Font.NORMAL);
Paragraph p = new Paragraph(chinese, FontChinese);
document.add(p);
Skip to the direction-section if you want to know how to write vertical text!
Example: java com.lowagie.examples.fonts.getting.ChineseJapaneseKorean
Using CJK Fonts: see cjk.pdf
Extra jars needed in your CLASSPATH: iTextAsian.jar
This is the list of fonts supported in the iTextAsian.jar:
  • Chinese Simplified:
    STSong-Light and STSongStd-Light with the encodings UniGB-UCS2-H and UniGB-UCS2-V
  • Chinese Traditional:
    MHei-Medium, MSung-Light and MSungStd-Light with the encodings UniCNS-UCS2-H and UniCNS-UCS2-V
  • Japanese:
    HeiseiMin-W3, HeiseiKakuGo-W5 and KozMinPro-Regular with the encodings UniJIS-UCS2-H, UniJIS-UCS2-V, UniJIS-UCS2-HW-H and UniJIS-UCS2-HW-V
  • Korean:
    HYGoThic-Medium, HYSMyeongJo-Medium and HYSMyeongJoStd with the encodings UniKS-UCS2-H and UniKS-UCS2-V
利用TTF(true type fonts)
Fonts from files:
TTF Files (True Type Fonts)
The True Type font format was developed by Apple Computer, Inc., and has been adopted as a standard font format for the MicroSoft Windows operating system. You will find lots of TTF files in the directory 'C:/WINDOWS/FONTS'. These font files can be read by iText. It doesn't matter on which operating system you are working: you can use a ttf-file on LINUX as well as on Apple computers as long as you don't violate any copyrights that may rest on the font (in which case iText will throw an exception). Example: java com.lowagie.examples.fonts.getting.TrueType
Using a True Type font: see truetype.pdf
posted on Wednesday, April 25, 2007 11:34 AM #程序人生