Re: WOFF and padding at the end of the font file

On 9 Jun 2010, at 01:07, Sergey Malkin wrote:

>> I think, based on what appears to be the common practice, that we should consider this last-table padding to be standard in sfnt files.
> 
> You are right, there is evidence in OT spec about padding after last table. But since I've seen both cases, I do not think we can easily prohibit either of them.
> 
>> It will still generate a .woff file, but gives a warning because decoding back to sfnt will not produce an exact copy of the original.
> 
> What exactly FireFox is doing? Statement above suggests that you force-padding file regardless of specified size. Is this right? 

The WOFF spec says that "Font tables whose length is not a multiple of 4 are padded with null bytes up to the next 4-byte boundary" (this is mentioned in section 4). The code used in Firefox to decode a WOFF file checks this: it computes the total size needed for the decoded data by summing all the PADDED table sizes, plus the header and directory, and verifies that this matches the totalSfntSize field in the header. If it doesn't, the WOFF file is considered invalid and will not be used. So yes, Firefox requires this padding in a WOFF-packaged font, as the WOFF spec calls for it.

In the event that an sfnt file does NOT have such padding, the process of converting to WOFF and back to sfnt will result in the padding being added; the "round-tripped" file will not be bitwise identical to the original, but will have been "regularized" by adding this final padding. I don't consider this a problem. It is analogous to what happens if you WOFF-encode a font where there was EXCESS padding between the sfnt tables. Such an sfnt is usable and does not (AFAIK) specifically conflict with the OpenType spec, but it may be thought of as "non-canonical", and the process of packaging in WOFF format implies performing a "normalization" of such a structure.

So in brief, we don't prohibit unpadded fonts at the stage of WOFF creation (at least if using my code -- I can't speak for other tools), but the encoding tool will warn about it and add the padding. We DO require the packaged font to use this standardized padding.

Hope that helps clarify,

JK

Received on Wednesday, 9 June 2010 07:36:38 UTC