[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetype-devel
Subject:    Re: [Devel] Bug of freetype2 2.1.3. [patch attached]
From:       Anthony Fok <anthony () thizlinux ! com>
Date:       2002-12-29 20:22:41
[Download RAW message or body]

Hello all,

On Tue, Dec 24, 2002 at 10:53:01AM +0800, James Su wrote:
> Hi,
> I recently updated my freetype2 to 2.1.3, and I found that some of my
> font cannot be loaded by freetype2 anymore. ftdump just tell me "can not
> load face" and gave me a errno = 0x0002. Freetype 2.1.2 is OK. [...]

Out of curiosity, I downloaded Yzdws1.ttf and tested it, and had the same
results James had, that FreeType 2.1.2 recognized it, but not 2.1.3.
It turns out that Just (fonttools/TTX's author) has the right idea:

> From: Just van Rossum <just@letterror.com>
> Subject: Re: [FontTools] Bug of fonttools 2.0 beta1?
> To: James Su <suzhe@turbolinux.com.cn>
> cc: fonttools-discussion@lists.sourceforge.net
> Date: Tue, 24 Dec 2002 14:59:22 +0100
>
> James Su wrote:
>
> > Recently, I tried fonttools 2.0 beta1 with one of my CJK fonts, but it
> > failed at OS/2 table:
>
> Your OS/2 table has the wrong size: for format 1 it should be 86 bytes
> long, yours is 88. It seems like the tools that created it padded it to
> be a multiple of 4 bytes, but the data length in the header should still
> be 86. I'll change TTX to be more lenient, though.

ttload.c would goto Bad_Format if table.Length != 0x36.  After padding this
number to a multiple of 4 bytes, i.e. 0x38, FreeType 2.1.3 accepts
Yzdws1.ttf.  I don't know if this is the same OS/2 table that Just talked
about, but hey, it does the trick!  :-)

Attached is a suggested fix to make FreeType 2.1.3 more lenient by accepting
both 0x36 and 0x38.  :-)

Cheers,

Anthony

-- 
Anthony Fok Tung-Ling
ThizLinux Laboratory   <anthony@thizlinux.com> http://www.thizlinux.com/
Debian Chinese Project <foka@debian.org>       http://www.debian.org/intl/zh/
Come visit Our Lady of Victory Camp!           http://www.olvc.ab.ca/

["007-freetype-2.1.3-ttload-table-length.patch" (text/plain)]

diff -Naur freetype-2.1.3~/src/sfnt/ttload.c freetype-2.1.3/src/sfnt/ttload.c
--- freetype-2.1.3~/src/sfnt/ttload.c	2002-09-29 00:40:57.000000000 +0800
+++ freetype-2.1.3/src/sfnt/ttload.c	2002-12-30 03:55:48.000000000 +0800
@@ -213,10 +213,12 @@
 
         has_head = 1;
 
-        if ( table.Length != 0x36                ||
-             FT_STREAM_SEEK( table.Offset + 12 ) ||
-             FT_READ_ULONG( magic )              ||
-             magic != 0x5F0F3CF5UL               )
+        /* The correct table.Length is 0x36, but some tools may */
+        /* erroneously pad it to a multiple of 4 bytes (0x38)   */
+        if ( table.Length != 0x36 && table.Length != 0x38 ||
+             FT_STREAM_SEEK( table.Offset + 12 )          ||
+             FT_READ_ULONG( magic )                       ||
+             magic != 0x5F0F3CF5UL                        )
           goto Bad_Format;
 
         if ( FT_STREAM_SEEK( offset + 28 + 16*nn ) )

_______________________________________________
Devel mailing list
Devel@freetype.org
http://www.freetype.org/mailman/listinfo/devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic