JDK-4113796 : 2D font rendering doesn't work with standard font format in Far East
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: x86
  • Submitted: 1998-02-20
  • Updated: 1999-01-14
  • Resolved: 1999-01-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2beta4Fixed
Related Reports
Relates :  
Description
[this is information that was improperly added to 4100565 after that bug was improperly marked verified]
On the Far East version of Win32, kanji font files are almost always in TTC (TrueTypeCollection) format. The current implementation, which only searches ttf format for truetype font on win32 platform will probably fail to find o an appropriate font file for Japanese/Chinese strings from System font directory.


xueming.shen@Japan 1998-02-23
While investigating this bug I found another "swap" bug in MapString.c, and I 
think this bug is also as serious as the 4113795, so please put it into the
the beta3 if possible, otherwise even if you implement the TTC format, Japanese
will still be unavailable on Win32 platform. (even I have not done any test yet,
but I believe this one will also effect some char points in Japanese/Chinese
TTF font foramt). I attach the suggested fix here.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.2beta4 FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

SUGGESTED FIX From sherman@japan, 2/20/98: *** /tmp/geta5049 Fri Feb 20 20:26:37 1998 --- fontObject.cpp Fri Feb 20 18:15:26 1998 *************** *** 38,43 **** --- 38,44 ---- #define kFullName 4 #define kFamilyName 1 + typedef struct { char *fontName; char *fullName; *************** *** 655,664 **** return true; } UInt32 sfntFileFontObject::FindTableSize(UInt32 tableTag, UInt32* offset) { sfntDirectory dir; ! (void)this->ReadChunk(0, sizeof_sfntDirectory, &dir); int numTables = SWAPW(dir.numOffsets); --- 656,685 ---- return true; } + struct ttcHeadEntry { + UInt32 ttcTag; + UInt32 version; + UInt32 numTables; + UInt32 offsets[1]; + }; + typedef struct ttcHeadEntry ttcHead; + #define ttcFontTableTag 0x74746366 // 'ttcf' + UInt32 sfntFileFontObject::FindTableSize(UInt32 tableTag, UInt32* offset) { + ttcHead ttc; + (void)this->ReadChunk(0, sizeof(ttcHead), &ttc); + printf("fontObject: ttcTag=%x, numTalbe=%x, offset=%x\n", + SWAPL(ttc.ttcTag), + SWAPL(ttc.numTables), + SWAPL(ttc.offsets[0])); + int off = SWAPL(ttc.offsets[0]); + if (SWAPL(ttc.ttcTag) != ttcFontTableTag) + off = 0; + sfntDirectory dir; ! // (void)this->ReadChunk(0, sizeof_sfntDirectory, &dir); ! (void)this->ReadChunk(off, sizeof_sfntDirectory, &dir); int numTables = SWAPW(dir.numOffsets); *************** *** 667,673 **** if (numTables > 0) { const sfntDirectoryEntry* dirEntry = ! (sfntDirectoryEntry*)this->ReadChunk(sizeof_sfntDirectory, (UInt32)sizeof(sfntDirectoryEntry) * numTables); --- 688,694 ---- if (numTables > 0) { const sfntDirectoryEntry* dirEntry = ! (sfntDirectoryEntry*)this->ReadChunk(sizeof_sfntDirectory + off, (UInt32)sizeof(sfntDirectoryEntry) * numTables); ------------------------------------------------------- *** /tmp/geta5056 Fri Feb 20 20:28:54 1998 --- truetype.c Fri Feb 20 18:48:35 1998 *************** *** 200,206 **** cmapClass *t = (cmapClass *) tsi_AllocMem( mem, sizeof( cmapClass ) ); t->mem = mem; /* t->version = ReadInt32( in ); */ ! t->version = ReadInt16(in); t->numEncodingTables = ReadInt16(in); --- 200,206 ---- cmapClass *t = (cmapClass *) tsi_AllocMem( mem, sizeof( cmapClass ) ); t->mem = mem; /* t->version = ReadInt32( in ); */ ! t->version = ReadInt16(in); t->numEncodingTables = ReadInt16(in); *************** *** 698,704 **** /***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/ /***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/ ! /* * --- 698,704 ---- /***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/ /***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/ ! #define ttcFontTableTag 0x74746366 // 'ttcf' /* * *************** *** 707,712 **** --- 707,729 ---- { long i; sfnt_OffsetTable *t = (sfnt_OffsetTable *) tsi_AllocMem( mem, sizeof( sfnt_OffsetTable ) ); + + { + uint32 ttcTag = 0; + uint32 version = 0; + uint32 numTables = 0; + uint32 offset = 0; + + if ((ttcTag = ReadInt32(in)) == ttcFontTableTag){ + version = ReadInt32(in); + numTables = ReadInt32(in); + offset = ReadInt32(in); + printf("truetype: ttcTag=%x, version=%x, numTalbe=%x, offset=%x\n", + ttcTag, version, numTables, offset); + } + Seek_InputStream(in, offset); + } + t->mem = mem; t->version = ReadInt32(in); t->numOffsets = ReadInt16(in); *************** *** 1994,2000 **** } return stream; /*****/ } - static void CacheKeyTables_sfntClass( sfntClass *t, InputStream *in ) { --- 2011,2016 ---- xueming.shen@Japan 1998-02-23 *** /tmp/geta18178 Mon Feb 23 13:32:58 1998 --- MapString.c Mon Feb 23 13:30:11 1998 *************** *** 115,121 **** #define maxLinearX2 16 #define BinaryIteration newP = (unsigned short *) ((char *)tableP + (range >>= 1)); ! if ( charCode > *newP ) tableP = newP; /* * Segment gxMapping to delta values, Yack.. ! --- 115,121 ---- #define maxLinearX2 16 #define BinaryIteration newP = (unsigned short *) ((char *)tableP + (range >>= 1)); ! if ( charCode > SWAPW(*newP)) tableP = newP; /* * Segment gxMapping to delta values, Yack.. ! *************** *** 148,154 **** shift = SWAPWINC(tableP); /* == 2*segCount-range */ /* tableP points at endCount[] */ ! if ( charCode >= *((unsigned short *)((char *)tableP + range))) tableP = (unsigned short *) ((char *)tableP + shift); /* range to low shift it up */ switch ( selector ) { --- 148,154 ---- shift = SWAPWINC(tableP); /* == 2*segCount-range */ /* tableP points at endCount[] */ ! if ( charCode >= SWAPW(*((unsigned short *)((char *)tableP + range)))) tableP = (unsigned short *) ((char *)tableP + shift); /* range to low shift it up */ switch ( selector ) {
11-06-2004

PUBLIC COMMENTS support for TTC files added
10-06-2004

EVALUATION [gelf 2/23/98] TTC files contain several TrueType fonts. Fixing this bug will require deriving ttcFileFontObject from sfntFileFontObject and overriding several virtual functions. [xueming.shen@Japan 1998-03-05] The SWAP problem in MapString.c makes the new ttc support failed on Japanese Win32 platform, PLESE try my suggested fix dated 1998-02-23 in "X Suggested Fix" field. Both the beta3 workspace and 2D team's workspace have the same problem, I have tested my suggested fix both on these two workspaces, the Japanese is being displayed correctly. You can use the following sample to test on a Japanese version to see the problem. import java.awt.*; import java.awt.font.*; import java.awt.geom.*; public class Draw2D { TestCanvas tc; public Draw2D(){ Frame frame = new Frame("Test"); frame.setLayout(new BorderLayout()); tc = new TestCanvas(); frame.add("Center", tc); frame.pack(); frame.setVisible(true); } void setText(String ss){ tc.setText(ss); } public static void main( String[] args ) { Draw2D draw2d = new Draw2D(); draw2d.setText(args[0]); } class TestCanvas extends Canvas { String text = null; Font font = null; int w = 600; int h = 200; void setText(String ss){ text = ss; } public TestCanvas() { super(); setSize(w, h); //font =new Font("serif", Font.PLAIN, w/6); //font =new Font("HG-GothicB", Font.PLAIN, w/6); font =new Font("HG-MinchoL", Font.PLAIN, w/6); } public void paint(Graphics g) { Graphics2D g2 = (Graphics2D)g; GlyphSet gs = font.getGlyphSet(text); Shape sha = font.getOutline(gs,null,w/6, h/2); ((GeneralPath)sha).closePath(); g2.setColor(Color.red); g2.draw(sha); System.out.println("Painting:" + text); } } } ============ There is some font architectural changes that must happen for TTC files to be properly handled. These changes will happen in beta4. jeannette.hung@Eng 1998-03-10
10-03-1998