-
Notifications
You must be signed in to change notification settings - Fork 160
Wrong encoding in EOT's 255SHORT for large negative numbers #101
Comments
The correct code should do something like this:
|
There are some values which can be encoded in multiple ways. For Ex: Is there a preference for one or the other? Or are we just concerned about minimizing the number of bytes taken to encode, so either one works. |
Yeah I see the overlaps. No idea. @taylorb-monotype can you advise, which way does Monotype encode / recommend encoding these? Thanks. |
Our code to write 255Shorts is the same as what Behdad has indicated above. value encoding |
Thanks for confirming.
There is ambiguity in the spec, but yeah sticking to the above scheme works.
|
Thank you for clarifying :) My concern with the above approach was that, 750-755 take up 3 bytes whereas they could be encoded in 2 bytes as FE FA - FE FF. But I guess that can be sacrificed for a simpler and consistent solution. |
Code here:
https://github.com/googlei18n/sfntly/blob/master/java/src/com/google/typography/font/tools/conversion/eot/GlyfEncoder.java#L185
The "spec" is here:
https://www.w3.org/Submission/MTX/#id_255SHORT
Note how in the spec, a wordCode-encoded short does NOT get a flipSignCode before it. The short is encoded as is in two's-complement.
Eg. to encode the number -984, currently we encode: FA FD 03 D8
FA – flipsignCode (250 decimal)
FD – WordCode (253 decimal)
03 D8 – Value (984 decimal)
Correct encoding is FD FC 28
FD – WordCode (253 decimal)
FC 28 – Value (-984 decimal)
(Reported to me by Microsoft.)
The text was updated successfully, but these errors were encountered: