English | Japanese
This patch supports the Type0 fonts for FOP-0.16.0 that is provided http://xml.apache.org/fop . When you have patched , you can use following family font name:
This patch is tested for compile and create PDF file following environments :
NOTE: It is not possible that this patch works fine for other than Internationalized ( or Localized ) JDK . And if your machine does not support the japanese fonts , this patch can't create the PDF File that written in japanese .
Note: This patch only provides Japanese Font , but it is easy to support Chinese or Korea . If you want to use the other CJKFont that does not include in this patch , you can use them to create font information in fop-0_16_0/src/codegen/cidfont and fop-0_16_0/src/codegen/cmp and to added it to FontSetup.java and build-jpfop.xml .
This patch have updated following classes .
- org.apache.fop.layout.LineArea
- org.apache.fop.pdf.PDFFontDescriptor
- org.apache.fop.pdf.PDFDocument
- org.apache.fop.render.pdf.PDFRenderer
- org.apache.fop.render.pdf.FontSetup
The addText() method is updated . A Type0 composit font uses single-byte or multi-byte character codes that range is from 0 to 65535 . In FOP-0.16.0 , the character code is automatically transrated to "#" , if it is higher than 127 . I commented out that codes .
And I added new line code . In japanese , the words is not separated by whitespace , but currently fop only supports the new line algorithm that judges at every words . In this patch , when a line contains japanese , it breaks if overrun .
The toPDF() method is updated . A type of return value for Rectangle.toPDF() was byte[] , so A PDF Rectangle format was not exactly . I think that this is FOP's BUG .
- previous codes:
p.append("\n/FontBBox "); p.append(fontBBox.toPDF());
- updated codes:
p.append("\n/FontBBox "); p.append(new String(fontBBox.toPDF()));
The makeFont() and makeFontDescriptor() methods is updated .
makeFont() method: When the implemented Font object does not have FontDescriptor object and that Font object is the instance of CIDFont , create Type0 font object .
makeFontDescriptor() method: I added the algorithm of OptionalFontDescriptor instance creation . And , in the original code of PDFFontDescriptor instance creation , the position of ItalicAngle and StemV was swapped . I think that this is FOP's BUG .
The renderInlineArea() method is updated . The code of Type0 font ( CIDFont ) is added . The UTF-8 strings is encoded to by specified file encoding in CIDFont . If the CIDType in CIDFont is CIDFontType2 , encoded string is written because it's code poing is TrueType .
If the CIDType in CIDFont is CIDFontType0 , that cocoded strings is mapped to Adobe Type1 by CMap . When the font-style attribute in FO is specified Italic , Tm is written in PDF File . And/or if the font-weigth attribute is BOLD , TD is used .
The setup() method is updated . I added the japanese font informations .
This patch have updated following classes or interfaces .
- org.apache.fop.layout.OptionalFontDescriptor
- org.apache.fop.pdf.PDFCIDFont
- org.apache.fop.pdf.PDFOptionalFontDescriptor
- org.apache.fop.pdf.PDFFontType0
- org.apache.fop.render.pdf.CIDFont
- org.apache.fop.render.pdf.CMap
This interface is a FontDescriptor with optional attributes . For more details of FontDescriptor , see PDF1.3 Reference Manual [1] 7.11 Font descriptors page on 222 .
This class is a CIDFont in a PDF file . For more details of CIDFont , see PDF1.3 Reference Manual [1] 7.8 CIDFonts page on 210 and Adobe CMap and CID Font Files Specification Version 1.0 [2] .
This class is a FontDescriptor with optional attributes in a PDF file .
This class is a Type0 Font in a PDF file . For more details of Type0 Font , see PDF1.3 Reference Manual [1] 7.7.7 Type0 Fonts page on 207 .
This abstract class represents a CIDFont .
This class is an entry of Width in a CIDFont . In CIDFonts , following two formats is used to specify the width of glyphs:
- C [ W1 W2 ... Wn ]
- Cfirst Clast W
For more details of the width of CIDFont , see PDF1.3 Reference Manual [1] 7.8.3 Character widths in CIDFonts page on 213 .
The CMap classes must implement this interface . The mapping() methods in the implemtend classes maps code points to a font number . For more details of Japanese CMaps , see Adobe CMap and CID Font Files Specification Version 1.0 [2] and Adobe-Japan1-4 Character Collection for CID-Keyed Fonts [3] .
This class is Width . This class can use Type1 , TruType , etc. , too .
This patch automatically generates the following codes .
- org.apache.fop.render.pdf.cmap._90ms_RKSJ_H
- org.apache.fop.render.pdf.fonts.jp.GothicBBBMedium
- org.apache.fop.render.pdf.fonts.jp.MSGothic
- org.apache.fop.render.pdf.fonts.jp.MSGothicAlias
- org.apache.fop.render.pdf.fonts.jp.MSGothicBold
- org.apache.fop.render.pdf.fonts.jp.MSGothicBoldAlias
- org.apache.fop.render.pdf.fonts.jp.MSGothicBoldItalic
- org.apache.fop.render.pdf.fonts.jp.MSGothicBoldItalicAlias
- org.apache.fop.render.pdf.fonts.jp.MSGothicItalic
- org.apache.fop.render.pdf.fonts.jp.MSGothicItalicAlias
- org.apache.fop.render.pdf.fonts.jp.MSMincho
- org.apache.fop.render.pdf.fonts.jp.MSMinchoAlias
- org.apache.fop.render.pdf.fonts.jp.MSMinchoBold
- org.apache.fop.render.pdf.fonts.jp.MSMinchoBoldAlias
- org.apache.fop.render.pdf.fonts.jp.MSMinchoBoldItalic
- org.apache.fop.render.pdf.fonts.jp.MSMinchoBoldItalicAlias
- org.apache.fop.render.pdf.fonts.jp.MSMinchoItalic
- org.apache.fop.render.pdf.fonts.jp.MSMinchoItalicAlias
- org.apache.fop.render.pdf.fonts.jp.Osaka
- org.apache.fop.render.pdf.fonts.jp.RyuminLight
In this section , I write the known problems for this pathc . If you want to know about FOP's problems , see fop-dev@xml.apache.org and fop-cvs@xml.apache.org .
In svg namespace tags , Japanese can currently not use .
The mixed line that contains Japanese and other words can't do hyphenations , if the last words in a line terminates a non-Japanese word . This is because there is no customs of hypenation in Japanese .
The Type0 fonts can use ToUnicde to embedding Unicode code points in the PDF file ( see , PDF1.3 Reference Manual [1] Section 7.7 Fonts page on 199 and Section 7.10.1 ToUnicode CMaps page on 219 ) . This patch does not support this feature . I think that this is the problem for FOP other then this patch .
The CMap informations can embed in PDF file ( see , PDF1.3 Reference Manual [1] Section 7.10 CMaps page on 117 ) . This patch does not support this feature .
It is possible to embed font files in PDF file by specifing FontDescriptor ( see , PDF1.3 Reference Manual [1] Section 7.11 Font descriptors page on 223 ) . This patch does not support this feature . I think that this is the problem for FOP other then this patch .
The value of the font's BaseFont key and the font descriptor's FontName key use the pseudoUniqueTag+PostScriptName format ( see , PDF1.3 Reference Manual [1] Section 7.7.4 Font Subsets page on 204 ) . This patch does not add six uppercase alphabetic characters to before PostScriptName .