W3C home > Mailing lists > Public > www-font@w3.org > July to September 2009

Re: WebOTF Proposal: updated description and sample code

From: Jonathan Kew <jonathan@jfkew.plus.com>
Date: Fri, 14 Aug 2009 00:53:59 +0100
Cc: www-font <www-font@w3.org>
Message-Id: <9707F2DE-264E-4761-A2CA-1E441DCD3839@jfkew.plus.com>
To: Laurence Penney <lorp@lorp.org>
On 13 Aug 2009, at 23:26, Laurence Penney wrote:

> Thanks a lot for this code and spec, Jonathan!
> I have a question about the compLength field. The definition in the  
> draft spec is rather convoluted. If compression did not make the  
> table smaller, then does it *always* record the padded length of the  
> uncompressed table? If so, it's got two purposes which need to be  
> more clearly explained: 1) length of zlib-compressed data, 2) padded  
> length of uncompressed data.
> I do wonder about the utility of the padding bytes. Having any  
> padding allowed in the WebOTF file - in other words, allowing  
> anything other than a fully packed file to be valid - seems like an  
> opportunity for nasty things to hide, and makes validation &  
> calculation of the various length fields trickier (there are up to 6  
> zero bytes to track per table).
> Fixing compLength simply to record the zlib-compressed length (or  
> any number larger than the origLength to force interpretation as  
> uncompressed), and to enforce data packing would handily remove 99  
> words from the spec.

Packing successive unpadded, uncompressed tables is not a good idea,  
because this means that if a client wants to use the uncompressed data  
directly from the WebOTF rather than copying each table to a new  
buffer, it may find itself reading two- or four-byte values from  
unaligned memory addresses. This is expensive on some architectures,  
and is even be a crashing bug on some systems. The OpenType spec calls  
for tables to start on 4-byte-aligned addresses, and if WebOTF doesn't  
offer the same guarantee when storing uncompressed tables, it will  
force clients to do an extra copy operation before they can safely  
access the data with their usual code.

(The current Firefox test build wouldn't actually crash on such  
tables, because in practice it always memcpy()s the data into a  
complete new font buffer. But I don't want to assume that every WebOTF- 
reading client will always work that way.)

Received on Thursday, 13 August 2009 23:54:49 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:01:41 UTC