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.)