fix table-stream to support global ptrs

main
Matthew Butterick 5 years ago
parent e02eb36fce
commit 48f9d1b9b4

@ -39,11 +39,15 @@
(define (decode-table this table-tag)
(unless (hash-has-key? table-codecs table-tag)
(raise-argument-error 'decode-table "decodable table" table-tag))
(define last-pos (pos (ttf-font-port this)))
(define stream (get-table-stream this table-tag))
(define table-decoder (hash-ref table-codecs table-tag))
(define directory (force (ttf-font-directory this)))
(define table (hash-ref (hash-ref directory 'tables) table-tag))
;; todo: possible to avoid copying the bytes here?
(pos (ttf-font-port this) (hash-ref table 'offset))
(define table-bytes (open-input-bytes (peek-bytes (hash-ref table 'length) 0 (ttf-font-port this))))
(define table-decoder (hash-ref table-codecs table-tag))
(decode table-decoder table-bytes #:parent this))
(begin0
(decode table-decoder stream #:parent this (hash-ref table 'length))
(pos (ttf-font-port this) last-pos)))

Loading…
Cancel
Save