diff --git a/pitfall/pitfall/bbox.rkt b/pitfall/pitfall/bbox.rkt index 6a398521..2f040183 100644 --- a/pitfall/pitfall/bbox.rkt +++ b/pitfall/pitfall/bbox.rkt @@ -10,7 +10,6 @@ [maxX -inf.0] ; The maxmimum Y position in the bounding box [maxY -inf.0]) - (super-new) (as-methods width diff --git a/pitfall/pitfall/directory.rkt b/pitfall/pitfall/directory.rkt index 339f1f5f..f9212938 100644 --- a/pitfall/pitfall/directory.rkt +++ b/pitfall/pitfall/directory.rkt @@ -14,8 +14,11 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js 'length uint32be))) (define-subclass RStruct (RDirectory) - (define/public (process) - 'boom)) + (define/override (process res stream) + (define new-tables-val (mhash)) + (for ([table (in-list (· res tables))]) + (hash-set! new-tables-val (· table tag) table)) + (hash-set! res 'tables new-tables-val))) (define Directory (make-object RDirectory (dictify 'tag (make-object RString 4) @@ -30,28 +33,52 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/directory.js (send Directory decode is)) (module+ test - (require rackunit) + (require rackunit racket/serialize) (define ip (open-input-file "test/assets/Charter.ttf")) (check-equal? (directory-decode ip) - (make-hasheq - (list (cons 'tables - (list (make-hasheq '((length . 96) (checkSum . 2351070438) (offset . 360) (tag . "OS/2"))) - (make-hasheq '((length . 1504) (checkSum . 1887795202) (offset . 1372) (tag . "VDMX"))) - (make-hasheq '((length . 1262) (checkSum . 1723761408) (offset . 2876) (tag . "cmap"))) - (make-hasheq '((length . 26) (checkSum . 10290865) (offset . 4592) (tag . "cvt "))) - (make-hasheq '((length . 371) (checkSum . 106535991) (offset . 4140) (tag . "fpgm"))) - (make-hasheq '((length . 34072) (checkSum . 1143629849) (offset . 4620) (tag . "glyf"))) - (make-hasheq '((length . 54) (checkSum . 4281190895) (offset . 236) (tag . "head"))) - (make-hasheq '((length . 36) (checkSum . 132056097) (offset . 292) (tag . "hhea"))) - (make-hasheq '((length . 916) (checkSum . 3982043058) (offset . 456) (tag . "hmtx"))) - (make-hasheq '((length . 460) (checkSum . 2795817194) (offset . 38692) (tag . "loca"))) - (make-hasheq '((length . 32) (checkSum . 50135594) (offset . 328) (tag . "maxp"))) - (make-hasheq '((length . 2367) (checkSum . 2629707307) (offset . 39152) (tag . "name"))) - (make-hasheq '((length . 514) (checkSum . 1670855689) (offset . 41520) (tag . "post"))) - (make-hasheq '((length . 78) (checkSum . 490862356) (offset . 4512) (tag . "prep"))))) - (cons 'entrySelector 3) - (cons 'numTables 14) - (cons 'searchRange 128) - (cons 'rangeShift 96) - (cons 'tag "\u0000\u0001\u0000\u0000"))))) \ No newline at end of file + (deserialize '((3) + 0 + () + 14 + ((u . "head") + (u . "prep") + (u . "fpgm") + (u . "hmtx") + (u . "hhea") + (u . "maxp") + (u . "VDMX") + (u . "loca") + (u . "name") + (u . "cvt ") + (u . "OS/2") + (u . "post") + (u . "glyf") + (u . "cmap")) + () + (h + ! + () + (tag u . "\u0000\u0001\u0000\u0000") + (rangeShift . 96) + (searchRange . 128) + (numTables . 14) + (entrySelector . 3) + (tables + h + ! + (equal) + ((? . 0) h ! () (tag ? . 0) (offset . 236) (checkSum . 4281190895) (length . 54)) + ((? . 1) h ! () (tag ? . 1) (offset . 4512) (checkSum . 490862356) (length . 78)) + ((? . 2) h ! () (tag ? . 2) (offset . 4140) (checkSum . 106535991) (length . 371)) + ((? . 3) h ! () (tag ? . 3) (offset . 456) (checkSum . 3982043058) (length . 916)) + ((? . 4) h ! () (tag ? . 4) (offset . 292) (checkSum . 132056097) (length . 36)) + ((? . 5) h ! () (tag ? . 5) (offset . 328) (checkSum . 50135594) (length . 32)) + ((? . 6) h ! () (tag ? . 6) (offset . 1372) (checkSum . 1887795202) (length . 1504)) + ((? . 7) h ! () (tag ? . 7) (offset . 38692) (checkSum . 2795817194) (length . 460)) + ((? . 8) h ! () (tag ? . 8) (offset . 39152) (checkSum . 2629707307) (length . 2367)) + ((? . 9) h ! () (tag ? . 9) (offset . 4592) (checkSum . 10290865) (length . 26)) + ((? . 10) h ! () (tag ? . 10) (offset . 360) (checkSum . 2351070438) (length . 96)) + ((? . 11) h ! () (tag ? . 11) (offset . 41520) (checkSum . 1670855689) (length . 514)) + ((? . 12) h ! () (tag ? . 12) (offset . 4620) (checkSum . 1143629849) (length . 34072)) + ((? . 13) h ! () (tag ? . 13) (offset . 2876) (checkSum . 1723761408) (length . 1262)))))))) \ No newline at end of file diff --git a/pitfall/pitfall/embedded.rkt b/pitfall/pitfall/embedded.rkt index f2c9c265..399e9daa 100644 --- a/pitfall/pitfall/embedded.rkt +++ b/pitfall/pitfall/embedded.rkt @@ -3,7 +3,6 @@ (provide EmbeddedFont) (define-subclass PDFFont (EmbeddedFont document font id) - (super-new) (field [subset (· this font createSubset)] ;; we make `unicode` and `width` fields integer-keyed hashes not lists ;; because they offer better random access and growability diff --git a/pitfall/pitfall/glyph.rkt b/pitfall/pitfall/glyph.rkt index 88bf0434..659bf331 100644 --- a/pitfall/pitfall/glyph.rkt +++ b/pitfall/pitfall/glyph.rkt @@ -27,7 +27,6 @@ (check-false (and (is-mark? #x2ee) #t))) (define-subclass object% (Glyph id codePoints font) - (super-new) (field [_font font] [isMark (andmap is-mark? codePoints)] [isLigature (> (length codePoints) 1)] @@ -58,11 +57,9 @@ (define-subclass Glyph (CFFGlyph) - (super-new) (error 'cff-glyph-unimplemented)) (define-subclass Glyph (TTFGlyph) - (super-new) ) \ No newline at end of file diff --git a/pitfall/pitfall/glyphrun.rkt b/pitfall/pitfall/glyphrun.rkt index da1a1467..050adfbc 100644 --- a/pitfall/pitfall/glyphrun.rkt +++ b/pitfall/pitfall/glyphrun.rkt @@ -10,7 +10,6 @@ script ; The script that was requested for shaping. This was either passed in or detected automatically. language) ; The language requested for shaping, as passed in. If `null`, the default language for the script was used. - (super-new) ;; An array of GlyphPosition objects for each glyph in the run (field [positions #f]) diff --git a/pitfall/pitfall/layout-engine.rkt b/pitfall/pitfall/layout-engine.rkt index 9fc56479..bd4540cb 100644 --- a/pitfall/pitfall/layout-engine.rkt +++ b/pitfall/pitfall/layout-engine.rkt @@ -3,7 +3,6 @@ (provide LayoutEngine) (define-subclass object% (LayoutEngine font) - (super-new) (field [unicodeLayoutEngine #f] [kernProcessor #f] [engine diff --git a/pitfall/pitfall/subset.rkt b/pitfall/pitfall/subset.rkt index 6b566f7d..3d7a6ed2 100644 --- a/pitfall/pitfall/subset.rkt +++ b/pitfall/pitfall/subset.rkt @@ -6,7 +6,6 @@ ;; https://github.com/devongovett/fontkit/blob/master/src/subset/Subset.js (define-subclass object% (Subset font) - (super-new) (field [glyphs empty] ; list of glyph ids in the subset [mapping (mhash)] ; mapping of glyph ids to indexes in `glyphs` ) @@ -28,7 +27,6 @@ (define-subclass Subset (CFFSubset) - (super-new) (error 'cff-subset-unimplemented)) @@ -36,7 +34,6 @@ ;; https://github.com/devongovett/fontkit/blob/master/src/subset/TTFSubset.js (define-subclass Subset (TTFSubset) - (super-new) (field [glyphEncoder (make-object TTFGlyphEncoder)]) (field [glyf #f] [offset #f] @@ -68,7 +65,7 @@ (for ([gid (in-list (· this glyphs))]) (send this _addGlyph gid)) - (define maxp (cloneDeep (· this font maxp))) + #;(define maxp (cloneDeep (· this font maxp))) (unfinished) ) diff --git a/pitfall/pitfall/test/test12rkt.pdf b/pitfall/pitfall/test/test12rkt.pdf index d43571b4..e69de29b 100644 Binary files a/pitfall/pitfall/test/test12rkt.pdf and b/pitfall/pitfall/test/test12rkt.pdf differ diff --git a/pitfall/pitfall/ttfglyphencoder.rkt b/pitfall/pitfall/ttfglyphencoder.rkt index 72dd7525..284da511 100644 --- a/pitfall/pitfall/ttfglyphencoder.rkt +++ b/pitfall/pitfall/ttfglyphencoder.rkt @@ -2,8 +2,6 @@ (provide TTFGlyphEncoder) (define-subclass object% (TTFGlyphEncoder) - (super-new) - (as-methods encodeSimple _encodePoint)) diff --git a/pitfall/restructure/helper.rkt b/pitfall/restructure/helper.rkt index dfab4357..99098b58 100644 --- a/pitfall/restructure/helper.rkt +++ b/pitfall/restructure/helper.rkt @@ -7,6 +7,8 @@ (super-new) (abstract decode) (abstract encode) + (define/public (process . args) + (void)) #;(abstract size))) diff --git a/pitfall/restructure/struct.rkt b/pitfall/restructure/struct.rkt index f5deb00d..08e44123 100644 --- a/pitfall/restructure/struct.rkt +++ b/pitfall/restructure/struct.rkt @@ -13,10 +13,11 @@ https://github.com/mbutterick/restructure/blob/master/src/Struct.coffee (for ([(k v) (in-dict assocs)]) (hash-set! fields k v)) - (define/override (decode stream [parent #f] [length 0]) + (define/overment (decode stream [parent #f] [length 0]) (define res (_setup stream parent length)) (_parseFields stream res fields) #;(hash-set! (hash-ref res '_props) '_currentOffset (· stream pos)) + (send this process res stream) res) (define/override (encode stream val [parent #f])