main
Matthew Butterick 6 years ago
parent ca43aa9b71
commit 94695ebaf2

@ -121,8 +121,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js
(augment [@encode encode])
(define (@encode dict stream parent)
#RRR 'entering-cff-dict-encode
#R @name
#R @fields
#R @name
#R @fields
(define ctx (mhasheq
x:pointers-key null
x:start-offset-key (pos stream)
@ -150,12 +150,11 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js
(define i 0)
(let loop ()
(when (< i #R (length (hash-ref ctx x:pointers-key)))
(define ptr (list-ref (hash-ref ctx x:pointers-key) i))
#R ptr
(match (list-ref (hash-ref ctx x:pointers-key) i)
[(x:ptr type val parent) (send type encode val stream parent)])
(set! i (add1 i))
(send (hash-ref ptr 'type) encode (hash-ref ptr 'val) stream (hash-ref ptr 'parent))
(loop)))
#R 'returning-from-cff-dict-encode)))
(define (CFFDict [name 'unknown] [ops null]) (make-object CFFDict% name ops))
(define (CFFDict [name 'unknown] [ops null]) (make-object CFFDict% name ops))

@ -107,18 +107,18 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFIndex.js
(error 'cff-index-encode-bad-offset!)]))
;; write offset size
(encode uint8 (size offsetType) stream)
(send uint8 encode (size offsetType) stream)
;; write elements
(set! offset 1)
(encode offsetType offset stream)
(send offsetType encode offset stream)
(for ([size (in-list sizes)])
(set! offset (+ offset size))
(encode offsetType offset stream))
(send offsetType encode offset stream))
(for ([item (in-list arr)])
(encode type item stream #:parent parent))]))))
(send type encode item stream parent))]))))
(define (CFFIndex [type #f])
(new CFFIndex% [type type]))

@ -12,7 +12,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFOperand.js
(define FLOAT_LOOKUP (vector "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "." "E" "E-" "" "-"))
(define FLOAT_ENCODE_LOOKUP
(hasheq "." 10
(hash "." 10
"E" 11
"E-" 12
"-" 14))

Loading…
Cancel
Save