Bug 46460 - FOP gets an error for Windows Japanese font.
Summary: FOP gets an error for Windows Japanese font.
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: fonts (show other bugs)
Version: 0.95
Hardware: PC Windows XP
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-01 00:00 UTC by Mamoru Asagami
Modified: 2012-08-24 17:17 UTC (History)
0 users



Attachments
Reproducing environment and error message (7.11 KB, application/x-zip-compressed)
2009-01-03 00:12 UTC, Mamoru Asagami
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mamoru Asagami 2009-01-01 00:00:06 UTC
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.
Comment 1 Mamoru Asagami 2009-01-03 00:12:55 UTC
Created attachment 23073 [details]
Reproducing environment and error message
Comment 2 Glenn Adams 2012-04-07 01:42:11 UTC
resetting P2 open bugs to P3 pending further review
Comment 3 Louis-Dominique Dubeau 2012-08-24 17:17:33 UTC
I've encountered the same problem with fop 0.95 but with the Chinese arphic fonts on Ubuntu.

If I take the submitter's example files, adapt them for Ubuntu and run them on Ubuntu with 0.95, I get the same error. (Note here that the "adaptation" does not change the font files used. I just had the build.xml file point to the Windows files on my Windows partition.)

However, if I upgrade to 1.0 and run the same test, then I do not get the error reported by the submitter.

I also do not get the error I experienced with the Chinese arphic fonts on Ubuntu. So it seems this error has been fixed in 1.0.