retouch Directory

main
Matthew Butterick 8 years ago
parent 7b5a04ba10
commit 53e1ab3334

@ -9,7 +9,6 @@
()
(tag u . "\u0000\u0001\u0000\u0000")
(rangeShift . 96)
(data)
(searchRange . 128)
(numTables . 14)
(tables

@ -9,7 +9,6 @@
()
(tag u . "\u0000\u0001\u0000\u0000")
(rangeShift . 96)
(data)
(searchRange . 128)
(numTables . 14)
(tables

@ -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)
)
(check-equal? (directory-decode ip) decoded-dir))

@ -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

Loading…
Cancel
Save