https://issues.apache.org/bugzilla/show_bug.cgi?id=46460

           Summary: FOP gets an error for Windows Japanese font.
           Product: Fop
           Version: 0.95
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: fonts
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: lovelylovelyfl...@ab.auone-net.jp


Problem:

You get:  
   [Fatal Error] msmincho.xml:1:171: Character reference "&#0" is an invalid
XML character

if you make font metrics files from msmincho.ttc and msgothic.ttc of Windows
and use them.

To reproduce it, set up the attached file: fopdoc.zip as c:\fopdoc,
fop.xconf.xml(one of the zip)  as ${fop.home}/conf/fop.xconf.xml, and run ant
as follows:

c:\fopdoc>ant


For your convenience, I included ant's error message as err.txt in the attached
file: fopdoc.zip.

Solution:

I found something in "public final String readTTFString(int len)" of 
org.apache.fop.fonts.truetype.FontFileReader.

When I replaced the character encoding discerning heuristic:

        final String encoding;
        if ((tmp.length > 0) && (tmp[0] == 0)) {
            encoding = "UTF-16BE";
        } else {
            encoding = "ISO-8859-1";
        }

with the following:

        String encoding = "ISO-8859-1";
        for(int c: tmp) {
            c &= 0xff;
            if(c==0 || c >= 0x80) {
                encoding = "UTF-16BE";
                break;
            }
        }

everything went fine.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to