Re: WOFF2 bug

Thank you Vlad and team, what a great find.  Having another pair of eyes
reviewing the specification and reference implementation together is
fantastic.  In this particular case, it would be great if we could update
the specification to reflect the reference implementation.


On Tue, Sep 2, 2014 at 10:51 AM, Levantovsky, Vladimir <
Vladimir.Levantovsky@monotype.com> wrote:

>  Hello WG,
>
>
>
> One of my colleagues brought up a question about the discrepancy between
> the draft WOFF2 spec vs. the reference implementation - I believe he is on
> to something real that was overlooked all along.
>
>
>
> The spec description of the TransformedGlyfHeader says that:
>
> "The transformed table consists of a header with the size of each of the
> substreams, followed by the substreams in sequence."
>
>
>
> The very last field of the header (according to the spec) is bboxBitmap
> array, which [as one would guess] is to be followed by nContourStream,
> nPointsStream, flagStream, glyphStream, compositeStream, bboxStream and
> instructionStream.
>
> (Note to editors: the spec is very light on the stream descriptions
> leaving developers to guess what they and their sequence are, some
> additional language needs to be added to address this).
>
>
>
> However, looking at the reference implementation (
> https://code.google.com/p/font-compression-reference/source/browse/woff2/transform.cc):
>
>
>   void GetTransformedGlyfBytes(std::vector<uint8_t>* result) {
>
>     WriteLong(result, 0);  // version
>
>     WriteUShort(result, n_glyphs_);
>
>     WriteUShort(result, 0);  // index_format, will be set later
>
>     WriteLong(result, n_contour_stream_.size());
>
>     WriteLong(result, n_points_stream_.size());
>
>     WriteLong(result, flag_byte_stream_.size());
>
>     WriteLong(result, glyph_stream_.size());
>
>     WriteLong(result, composite_stream_.size());
>
>     WriteLong(result, bbox_bitmap_.size() + bbox_stream_.size());
>
>     WriteLong(result, instruction_stream_.size());
>
>     WriteBytes(result, n_contour_stream_);
>
>     WriteBytes(result, n_points_stream_);
>
>     WriteBytes(result, flag_byte_stream_);
>
>     WriteBytes(result, glyph_stream_);
>
>     WriteBytes(result, composite_stream_);
>
>     WriteBytes(result, bbox_bitmap_);
>
>     WriteBytes(result, bbox_stream_);
>
>     WriteBytes(result, instruction_stream_);
>
>   }
>
>
>
> where the bbox_bitmap is written out much later in the process - in
> between compositeStream and bboxStream.
>
>
>
> This definitely breaks compatibility between the code and the spec, but
> considering that the code has now been widely adopted by two publicly
> released browser version (Chrome and Opera) and that large number of fonts
> served over the web in WOFF2 format implemented the same stream sequence as
> reference implementation - I think it would be much less of a pain to
> simply edit the spec to reflect the current implementation status.
>
>
>
> Let's discuss it during the telcon tomorrow.
>
>
>
> Thank you,
>
> Vlad
>
>
>
>
>

Received on Wednesday, 3 September 2014 15:02:58 UTC