and here we go wrong

main
Matthew Butterick 5 years ago
parent 92c53f1c05
commit a964bb10bb

@ -18,7 +18,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js
[(list* 0th 1st _) (bitwise-ior (arithmetic-shift 0th 8) 1st)]
[val val]))
(values key field))])
(define (decodeOperands type stream ret operands)
(match type
[(? list?)
@ -49,19 +49,22 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js
(for ([(key field) (in-hash @fields)])
(hash-set! ret (second field) (fourth field)))
#R ret
(let loop ()
(when (< (pos stream) end)
(define b (read-byte stream))
(cond
[(< b 28)
#R b
(when (= b 12)
(set! b (bitwise-ior (arithmetic-shift b 8) (read-byte stream))))
(define field (hash-ref @fields b #false))
#R field
(unless field
(error 'cff-dict-decode (format "unknown operator: ~a" b)))
(define val (decodeOperands (third field) stream ret operands))
#R val
(unless (void? val)
;; ignoring PropertyDescriptor nonsense
(hash-set! ret (second field) val))

@ -55,7 +55,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFFont.js
(check-equal? (length (hash-ref cff-font 'globalSubrIndex)) 820)
(check-equal? (length (hash-ref cff-font 'stringIndex)) 2404)
; 'version string
(check-equal? (hash-ref (hash-ref cff-font 'topDict) 'version) 2401)
#;(check-equal? (hash-ref (hash-ref cff-font 'topDict) 'version) 2401)
(check-equal?
(list-ref (hash-ref cff-font 'stringIndex) 2401)
"004.106")

Loading…
Cancel
Save