JAPANIZED PATCH for FOP-0.16.0

English | Japanese

download , project page




1. Introduction

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 .




2. Installation

  1. Access http://xml.apache.org/dist/fop/ , and download fop-0_16_0.zip ( or fop-0_16_0.tar.gz ) .
  2. Uncompress and extract fop-0_16_0.zip ( or .tar.gz ) .
  3. This will create a directory named fop-0_16_0 .
  4. Access http://www.sourceforge.net/projects/jpfop/ , and download jpfop_0_16_0.zip ( or jpfop_0_16_0.tar.gz ) .
  5. Uncompress and extract jpfop-0.16.0.zip ( or .tar.gz ) under fop-0_16_0 directory .
  6. This will create a directory named jpfop-0.16.0 under fop-0_16_0 directory .
  7. Access http://xml.apache.org/dist/xalan-j/ , and download xalan-j_1_2_2.zip ( or xalan-j_1_2_2.tar.gz ) .
  8. Bundle xerces.jar , xalan.jar and bsf.jar in xalan-j_1_2_2.zip ( or .tar.gz ) .
    This patch can conveniently bundle xerces.jar , xalan.jar andbsf.jar, if you copy them to fop-0_16_0/lib directory .
  9. Run following command :
    > cd fop-0_16_0
    > build-jpfop ( ./build-jpfop.sh )
  10. The JAPANIZED Fop that named fop-0.16.0-jp.jar will be created after the Ant prints out BUILD SUCCESSED .
  11. Test JAPANIZED Fop following way :
    > cd jpfop
    > makesample_jpfop ( or ./makesample_jpfop.sh )
    When no exception is thrown , following sample_jpfop.pdf file is created .

Figure. sample_jpfop.pdf

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 .




3. Sources

3.1 Updated sources

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

3.1.1 org.apache.fop.layout.LineArea

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 .

3.1.2 org.apache.fop.pdf.PDFFontDescriptor

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()));

3.1.3 org.apache.fop.pdf.PDFDocument

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 .

3.1.4 org.apache.fop.render.pdf.PDFRenderer

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 .

3.1.5 org.apache.fop.render.pdf.FontSetup

The setup() method is updated . I added the japanese font informations .



3.2 Added classes and interfaces

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

3.2.1 org.apache.fop.layout.OptionalFontDescriptor

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 .

3.2.2 org.apache.fop.pdf.PDFCIDFont

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] .

3.2.3 org.apache.fop.pdf.PDFOptionalFontDescriptor

This class is a FontDescriptor with optional attributes in a PDF file .

3.2.4 org.apache.fop.pdf.PDFFontType0

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 .

3.2.5 org.apache.fop.render.pdf.CIDFont

This abstract class represents a CIDFont .

3.2.6 org.apache.fop.render.pdf.CIDFontWidthsEntry

This class is an entry of Width in a CIDFont . In CIDFonts , following two formats is used to specify the width of glyphs:

For more details of the width of CIDFont , see PDF1.3 Reference Manual [1] 7.8.3 Character widths in CIDFonts page on 213 .

3.2.7 org.apache.fop.render.pdf.CMap

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] .

3.2.8 org.apache.fop.render.pdf.Widths

This class is Width . This class can use Type1 , TruType , etc. , too .



3.3 codegens

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



4. Known problems

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 .




5. References

  1. Portable Document Format Reference Manual Version 1.3:
    http://partners.adobe.com/asn/developer/acrosdk/DOCS/PDFRef.pdf
  2. Adobe CMap and CID Font Files Specification Version 1.0:
    http://partners.adobe.com/asn/developer/PDFS/TN/5014.CMap_CIDFont_Spec.pdf
  3. Adobe-Japan1-4 Character Collection for CID-Keyed Fonts:
    http://partners.adobe.com/asn/developer/PDFS/TN/5078.Adobe-Japan1-4.pdf
  4. Adobe Font Metrics File Format Specification Version 4.1:
    http://partners.adobe.com/asn/developer/PDFS/TN/5004.AFM_Spec.pdf