diff --git a/pitfall/fontkit/charter-directory.rktd b/pitfall/fontkit/charter-directory.rktd index 53394959..26c96b55 100644 --- a/pitfall/fontkit/charter-directory.rktd +++ b/pitfall/fontkit/charter-directory.rktd @@ -9,7 +9,6 @@ () (tag u . "\u0000\u0001\u0000\u0000") (rangeShift . 96) - (data) (searchRange . 128) (numTables . 14) (tables diff --git a/pitfall/fontkit/charter-italic-directory.rktd b/pitfall/fontkit/charter-italic-directory.rktd index 8e6bce46..0562958f 100644 --- a/pitfall/fontkit/charter-italic-directory.rktd +++ b/pitfall/fontkit/charter-italic-directory.rktd @@ -9,7 +9,6 @@ () (tag u . "\u0000\u0001\u0000\u0000") (rangeShift . 96) - (data) (searchRange . 128) (numTables . 14) (tables diff --git a/pitfall/fontkit/directory.rkt b/pitfall/fontkit/directory.rkt index ef7f6985..812cdad5 100644 --- a/pitfall/fontkit/directory.rkt +++ b/pitfall/fontkit/directory.rkt @@ -61,20 +61,20 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js 'entrySelector (floor (/ searchRange (log 2))) 'rangeShift (- (* numTables 16) searchRange) 'data table-datas))) - - -(define Directory (+RDirectory - (dictify 'tag (+String 4) - 'numTables uint16be - 'searchRange uint16be - 'entrySelector uint16be - 'rangeShift uint16be - 'tables (+Array TableEntry 'numTables) + +(define directory-common-dict (dictify 'tag (+String 4) + 'numTables uint16be + 'searchRange uint16be + 'entrySelector uint16be + 'rangeShift uint16be + 'tables (+Array TableEntry 'numTables))) + +(define Directory (+RDirectory directory-common-dict)) - ;; we don't know what tables we might get - ;; so we represent as generic Buffer type, - ;; and convert the tables to bytes manually in preEncode - 'data (+Array (+Buffer))))) +;; we don't know what tables we might get +;; so we represent as generic Buffer type, +;; and convert the tables to bytes manually in preEncode +(define EncodableDirectory (+RDirectory (append directory-common-dict (list (cons 'data (+Array (+Buffer))))))) (define (directory-decode ip [options (mhash)]) (send Directory decode (+DecodeStream (port->bytes ip)))) @@ -85,6 +85,4 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js (test-module (define ip (open-input-file charter-path)) (define decoded-dir (deserialize (read (open-input-file charter-directory-path)))) - (check-equal? (directory-decode ip) decoded-dir) - - ) \ No newline at end of file + (check-equal? (directory-decode ip) decoded-dir)) \ No newline at end of file diff --git a/pitfall/fontkit/subset.rkt b/pitfall/fontkit/subset.rkt index 3da6f330..2c374de3 100644 --- a/pitfall/fontkit/subset.rkt +++ b/pitfall/fontkit/subset.rkt @@ -124,7 +124,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/subset/TTFSubset.js (define hhea (cloneDeep (· this font hhea))) (hash-set! hhea 'numberOfMetrics (length (· this hmtx metrics))) - (send Directory encode stream + (send EncodableDirectory encode stream (mhash 'tables (mhash 'head head