fix searchRange computation

main
Matthew Butterick 5 years ago
parent 94943055c3
commit dbf16bb9f5

@ -42,13 +42,15 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js
'offset (x:void-pointer table-codec table)
'length (size table-codec table))))
(define numTables (length tables))
(define searchRange (* (floor (log numTables 2)) 16))
;; patch from https://github.com/foliojs/fontkit/pull/178
(define max-exponent-for-2 (floor (log numTables 2)))
(define searchRange (* (expt 2 max-exponent-for-2) 16))
(hash-set*! this-val
'tag 'true
'numTables numTables
'tables tables
'searchRange searchRange
'entrySelector (floor (/ searchRange (log 2)))
'entrySelector max-exponent-for-2
'rangeShift (- (* numTables 16) searchRange))
this-val)

Loading…
Cancel
Save