correct operand encoding

main
Matthew Butterick 6 years ago
parent a9565a1b3d
commit fb4d1037fc

@ -130,8 +130,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js
(hash-set! ctx x:pointer-offset-key (+ (pos stream) (@size dict ctx #false)))
(for ([field (in-list @ops)])
#R (pos stream)
#R field
#;(pos stream)
#;field
(define val (dict-ref dict (list-ref field 1) #false))
(cond
[(or (not val) (equal? val (list-ref field 3)))]

@ -95,15 +95,16 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFOperand.js
(define c2 (vector-ref str (add1 i)))
(set! n2 (hash-ref FLOAT_ENCODE_LOOKUP c2 (string->number c2)))])
(encode uint8 (bitwise-ior (arithmetic-shift n1 -4) (bitwise-and n2 15)) stream))
(encode uint8 (bitwise-ior (arithmetic-shift n1 4) (bitwise-and n2 15)) stream))
(unless (= n2 FLOAT_EOF)
(encode uint8 (arithmetic-shift FLOAT_EOF 4) stream))]
[(<= -107 value 107)
(encode uint8 (+ val 139) stream)]
[(<= 108 value 1131)
(let ([val (- val 108)])
(encode uint8 (+ (arithmetic-shift val -8) 247) stream)
(encode uint8 (bitwise-and val #xff) stream)]
(encode uint8 (bitwise-and val #xff) stream))]
[(<= -1131 value -108)
(let ([val (- (- val) 108)])
(encode uint8 (+ (arithmetic-shift val -8) 251) stream)

Loading…
Cancel
Save