freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] validation of TrueType fonts, particularly embedded Type 42


From: David Turner
Subject: Re: [Devel] validation of TrueType fonts, particularly embedded Type 42 fonts
Date: Fri, 12 Jul 2002 02:00:24 +0200

HI Graham,

Graham Asher a écrit :
> 
> The first twelve bytes of a TrueType font are read by TT_Load_SFNT_HeaderRec
> and placed in a SFNT_HeaderRec object. As the comment to
> TT_Load_SFNT_HeaderRec says, "'The header will be checked whether it is
> valid by looking at the values of `search_range', `entry_selector', and
> `range_shift'".
> 
> I wonder if this validation can be changed or relaxed in some way - the
> values of search_range, entry_selector and range_shift can be calculated
> from the other values, as indicated in the comment to SFNT_HeaderRec. The
> reason this might be useful is that one of the embedded Type 42 fonts I have
> tried out in the GhostScript-FreeType bridge I am writing has completely
> incorrect values for the three fields, and yet I am sure it is a valid font.
> 
> The first 4 bytes have to be the value 0x00010000 or the bytes 'true'. The
> table directory has to contain certain required table tags. Perhaps we could
> check these things and just calculate search_range, entry_selector and
> range_shift.
> 
> I shall experiment with this. In the mean time I would be grateful for
> anybody's opinion.
>
Well, I just commited a new version of the SFNT loader that checks for valid
font files in a scheme similar to the one you're describing. Here's how it
works:

 * read the format tag, check it
 * read the table count. check it (i.e. 12 + 16*count <= font_size)
 * check each table descriptor (each table must fit
   within the font file)
 * find the "head" table, and check its magic number

this completely ignores the "helper" range values which are bogus in too
many files.. Please test and report any problems !!


Regards,

- David Turner
- The FreeType Project  (www.freetype.org)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]