Matthew Butterick 7 years ago
parent 461ea0bd53
commit ec675b61fa

@ -21,7 +21,7 @@
(OS/2 h ! () (tag u . "OS/2") (offset . 360) (checkSum . 2351070438) (length . 96))
(hhea h ! () (tag u . "hhea") (offset . 292) (checkSum . 132056097) (length . 36))
(post h ! () (tag u . "post") (offset . 41520) (checkSum . 1670855689) (length . 514))
(|cvt | h ! () (tag u . "cvt ") (offset . 4592) (checkSum . 10290865) (length . 26))
(cvt h ! () (tag u . "cvt ") (offset . 4592) (checkSum . 10290865) (length . 26))
(VDMX h ! () (tag u . "VDMX") (offset . 1372) (checkSum . 1887795202) (length . 1504))
(prep h ! () (tag u . "prep") (offset . 4512) (checkSum . 490862356) (length . 78))
(maxp h ! () (tag u . "maxp") (offset . 328) (checkSum . 50135594) (length . 32))

@ -21,7 +21,7 @@
(OS/2 h ! () (tag u . "OS/2") (offset . 360) (checkSum . 2367847603) (length . 96))
(hhea h ! () (tag u . "hhea") (offset . 292) (checkSum . 113838023) (length . 36))
(post h ! () (tag u . "post") (offset . 40280) (checkSum . 1671576585) (length . 514))
(|cvt | h ! () (tag u . "cvt ") (offset . 4592) (checkSum . 9307818) (length . 26))
(cvt h ! () (tag u . "cvt ") (offset . 4592) (checkSum . 9307818) (length . 26))
(VDMX h ! () (tag u . "VDMX") (offset . 1372) (checkSum . 1905948947) (length . 1504))
(prep h ! () (tag u . "prep") (offset . 4512) (checkSum . 776081685) (length . 78))
(maxp h ! () (tag u . "maxp") (offset . 328) (checkSum . 50135583) (length . 32))

@ -0,0 +1,32 @@
#lang fontkit/racket
(require restructure)
(provide (all-defined-out))
#|
approximates
https://github.com/mbutterick/fontkit/blob/master/src/tables/cvt.js
|#
(define-subclass Struct (Rcvt))
(define cvt (make-object Rcvt
(dictify
'controlValues (+Array int16be))))
(test-module
(define ip (open-input-file charter-path))
(define dir (deserialize (read (open-input-file charter-directory-path))))
(define offset (· dir tables cvt offset))
(define len (· dir tables cvt length))
(check-equal? offset 4592)
(check-equal? len 26)
(set-port-position! ip 0)
(define table-bytes #"\0\24\0+\0S\0\0\0\20\377&\0\0\1\341\0\v\2\237\0\22\2\340\0\b")
(check-equal? table-bytes (peek-bytes len offset ip))
(define ds (+DecodeStream (peek-bytes len offset ip)))
(define cvt-array '(20 43 83 0 16 -218 0 481 11 671 18 736 8))
(check-equal? (hash-ref (send cvt decode ds) 'controlValues) cvt-array)
(define es (+EncodeStream))
(send cvt encode es (mhash 'controlValues cvt-array))
(check-equal? (send es dump) table-bytes)
)

@ -18,7 +18,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js
;; in `restructure` `process` method, `res` is aliased as `this`
(define new-tables-val (mhash))
(for ([table (in-list (· this-res tables))])
(hash-set! new-tables-val (string->symbol (· table tag)) table))
(hash-set! new-tables-val (string->symbol (string-trim (· table tag))) table))
(hash-set! this-res 'tables new-tables-val))
(define/override (preEncode this-val stream)

@ -90,6 +90,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/subset/TTFSubset.js
'hhea hhea
'loca (· this loca)
'maxp maxp
'cvt (send (· this font) _getTable 'cvt)
;; todo: cvt
'prep (send (· this font) _getTable 'prep)
;; 'glyf (· this glyf)

@ -9,4 +9,4 @@
(test-module (require (submod TABLE-ID-STRING test) ...))
(define ID (make-hasheq (map cons (list 'TABLE-ID ...) (list TABLE-ID ...)))))))
(define-table-decoders table-decoders maxp hhea head loca prep fpgm hmtx)
(define-table-decoders table-decoders maxp hhea head loca prep fpgm hmtx cvt)
Loading…
Cancel
Save