Closed davelab6 closed 3 years ago
Ah, duplicate of https://github.com/google/woff2/issues/117
it's not possible to roundtrip because there's no place to store that bit in woff2, it's lost as soon as the glyf table is transformed. the decoder can only guess (either force it to always be set, or check for overlaps and set it accordingly but it'd be too expensive).
it's not possible to roundtrip because there's no place to store that bit in woff2, it's lost as soon as the glyf table is transformed.
I believe WOFF2 does have a place (see flagStream[]) to store that bit, it may be just the way the decoder got implemented to "optimize" for bits that are "unused.
Hm, but the flagStream (an array of u8 bytes) is for specifying the variable-length encoding of X and Y coordinates (besides the on- vs off-curve flag)
see https://www.w3.org/TR/WOFF2/#triplet_decoding
The most significant bit of a flag indicates whether the point is on- or off-curve point, the remaining seven bits of the flag determine the format of X and Y coordinate values and specify 128 possible combinations of indices that have been assigned taking into consideration typical statistical distribution of data found in TrueType fonts...
Ahh, you're right - I thought that the triplet encoding format has a provision to encode the original flags value. I just re-read the triplet encoding description and realize it redefine all the original flags beyond the on/off-curve bit.
Thanks for the clarification and pointers to the flags spec @anthrotype!
@lorp mentioned to me today he had a chat with Garret and Vlad in the ATypI hang out room that there's a bug in
woff2_decompress
when writing bit 6; the bits the spec says are reserved for 0 are forced back to 0, but they should not be, as in practice they are used.eg, bit 7 may also used for storing other curve orders (cubics).
So, if we keep the bits roundtripping, we won't need to update all the woff2 tooling if those bits do get used.