From 461ea0bd5301f3d747b8c07bfd187c74414d4b4e Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 13 Jun 2017 12:30:53 -0700 Subject: [PATCH] fix --- pitfall/fontkit/directory.rkt | 6 +++--- pitfall/fontkit/hmtx.rkt | 11 +++++++---- pitfall/fontkit/subset.rkt | 2 +- pitfall/restructure/array.rkt | 19 ++++++++++++++----- pitfall/restructure/utils.rkt | 1 - 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/pitfall/fontkit/directory.rkt b/pitfall/fontkit/directory.rkt index 88c2e87d..072b304c 100644 --- a/pitfall/fontkit/directory.rkt +++ b/pitfall/fontkit/directory.rkt @@ -22,7 +22,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js (hash-set! this-res 'tables new-tables-val)) (define/override (preEncode this-val stream) - (report 'start-directory-preEncode) + (define tables empty) (for ([(tag table) (in-hash (· this-val tables))]) (when table @@ -32,7 +32,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js 'checkSum 0 'offset #xdeadbeef ; todo 'length (let ([tag (hash-ref table-decoders tag (λ () (raise-argument-error 'directory:preEncode "valid table tag" tag)))]) - (report* tag table (send tag size table))))))) + (send tag size table)))))) (define numTables (length tables)) (define searchRange (* (floor (log (/ numTables (log 2)))) 16)) (define entrySelector (floor (/ searchRange (log 2)))) @@ -45,7 +45,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js 'searchRange searchRange 'entrySelector rangeShift 'rangeShift rangeShift) - (report 'end-directory-preEncode))) + )) (define Directory (make-object RDirectory diff --git a/pitfall/fontkit/hmtx.rkt b/pitfall/fontkit/hmtx.rkt index f0e2ff29..5bee0616 100644 --- a/pitfall/fontkit/hmtx.rkt +++ b/pitfall/fontkit/hmtx.rkt @@ -15,9 +15,9 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/hmtx.js (define hmtx (+Rhmtx (dictify - 'metrics (+LazyArray HmtxEntry (λ (t) (· (send (· t parent) _getTable 'hhea) numberOfMetrics))) - 'bearing (+LazyArray int16be (λ (t) (- (· (send (· t parent) _getTable 'maxp) numGlyphs) - (· (send (· t parent) _getTable 'hhea) numberOfMetrics))))))) + 'metrics (+LazyArray HmtxEntry (λ (this-array) (· (send (· this-array parent) _getTable 'hhea) numberOfMetrics))) + 'bearings (+LazyArray int16be (λ (this-array) (- (· (send (· this-array parent) _getTable 'maxp) numGlyphs) + (· (send (· this-array parent) _getTable 'hhea) numberOfMetrics))))))) @@ -38,4 +38,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/hmtx.js (check-equal? (send hmtx-test size) (* 229 (send HmtxEntry size))) (define H-gid 41) (define OE-gid 142) (check-equal? (send (· hmtx-data metrics) get H-gid) (mhasheq 'advance 738 'bearing 33)) - (check-equal? (send (· hmtx-data metrics) get OE-gid) (mhasheq 'advance 993 'bearing 43))) \ No newline at end of file + (check-equal? (send (· hmtx-data metrics) get OE-gid) (mhasheq 'advance 993 'bearing 43)) + + + ) \ No newline at end of file diff --git a/pitfall/fontkit/subset.rkt b/pitfall/fontkit/subset.rkt index 3f5d6bd5..359c4d0e 100644 --- a/pitfall/fontkit/subset.rkt +++ b/pitfall/fontkit/subset.rkt @@ -93,7 +93,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/subset/TTFSubset.js ;; todo: cvt 'prep (send (· this font) _getTable 'prep) ;; 'glyf (· this glyf) - ;; 'hmtx (· this hmtx) + 'hmtx (· this hmtx) 'fpgm (send (· this font) _getTable 'fpgm) ))) diff --git a/pitfall/restructure/array.rkt b/pitfall/restructure/array.rkt index 6234a11d..5c2a474c 100644 --- a/pitfall/restructure/array.rkt +++ b/pitfall/restructure/array.rkt @@ -25,7 +25,6 @@ https://github.com/mbutterick/restructure/blob/master/src/Array.coffee (send type decode stream this))]))) (define/override (size [array #f]) - (report* _length array) (when (and array (not (list? array))) (raise-argument-error 'Array:size "list" array)) (cond @@ -88,9 +87,9 @@ https://github.com/mbutterick/restructure/blob/master/src/LazyArray.coffee val))) (define/override (encode stream val) - (super encode (if (InnerLazyArray? val) - (send val toArray) - val)))) + (super encode stream (if (InnerLazyArray? val) + (send val toArray) + val)))) (test-module (define bstr #"ABCD1234") @@ -101,4 +100,14 @@ https://github.com/mbutterick/restructure/blob/master/src/LazyArray.coffee (check-equal? (send ila get 1) 66) (check-equal? (send ila get 3) 68) (check-equal? (send ds pos) 4) - (check-equal? (send ila toArray) '(65 66 67 68))) + (check-equal? (send ila toArray) '(65 66 67 68)) + + (define la2 (+LazyArray int16be (λ (t) 4))) + (define es (+EncodeStream)) + (send la2 encode es '(1 2 3 4)) + (check-equal? (send es dump) #"\0\1\0\2\0\3\0\4") + (check-equal? (send (send la2 decode (+DecodeStream #"\0\1\0\2\0\3\0\4")) toArray) '(1 2 3 4)) + + ) + + diff --git a/pitfall/restructure/utils.rkt b/pitfall/restructure/utils.rkt index 53c915e0..01a59ddb 100644 --- a/pitfall/restructure/utils.rkt +++ b/pitfall/restructure/utils.rkt @@ -3,7 +3,6 @@ (require "number.rkt") (define (resolveLength len stream parent) - (report* len stream parent) (cond [(number? len) len] [(procedure? len) (len parent)]