diff --git a/fontland/fontland/table/cff/cff-dict.rkt b/fontland/fontland/table/cff/cff-dict.rkt index 1538b047..d54cc116 100644 --- a/fontland/fontland/table/cff/cff-dict.rkt +++ b/fontland/fontland/table/cff/cff-dict.rkt @@ -32,6 +32,9 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js (define (encodeOperands type stream ctx operands) (error 'cff-dict-encodeOperands-undefined)) + (define/override (post-decode val) + (dict->mutable-hash val)) + (augment [@decode decode]) (define (@decode stream parent) (define end (+ (pos stream) (hash-ref parent 'length))) @@ -46,6 +49,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js (for ([(key field) (in-hash @fields)]) (hash-set! ret (second field) (fourth field))) + #R ret (let loop () (when (< (pos stream) end) (define b (read-byte stream)) @@ -64,7 +68,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js (set! operands null)] [else ;; use `send` here to pass b as value arg - (set! operands (append operands (list (send CFFOperand decode stream b))))]) + (set! operands (append operands (list (decode CFFOperand stream b))))]) (loop))) ret) @@ -75,4 +79,4 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js (define/augment (encode stream dict parent) (error 'cff-dict-encode-undefined)))) -(define (CFFDict [ops null]) #R (make-object CFFDict% ops)) \ No newline at end of file +(define (CFFDict [ops null]) (make-object CFFDict% ops)) \ No newline at end of file diff --git a/fontland/fontland/table/cff/cff-font.rkt b/fontland/fontland/table/cff/cff-font.rkt index d36736f4..54e63035 100644 --- a/fontland/fontland/table/cff/cff-font.rkt +++ b/fontland/fontland/table/cff/cff-font.rkt @@ -27,11 +27,11 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFFont.js (hash-set! cff-font 'version (hash-ref cff-font 'x:version)) (when (and (hash-has-key? cff-font 'version) (< (hash-ref cff-font 'version) 2)) - (match (hash-ref cff-font 'topDictIndex) - [(list dict) (hash-set! cff-font 'topDict dict)] - [_ (error 'only-single-font-allowed-in-cff)])) + (match (hash-ref cff-font 'topDictIndex) + [(list dict) (hash-set! cff-font 'topDict dict)] + [_ (error 'only-single-font-allowed-in-cff)])) - #;(hash-set! cff-font 'isCIDFont (hash-ref (hash-ref cff-font 'topDict) 'ROS)) + (hash-set! cff-font 'isCIDFont (hash-ref (hash-ref cff-font 'topDict) 'ROS)) cff-font))) (define CFFFont (make-object CFFFont%)) @@ -52,10 +52,19 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFFont.js (check-equal? (hash-ref cff-font 'hdrSize) 4) (check-equal? (hash-ref cff-font 'offSize) 3) (check-equal? (hash-ref cff-font 'nameIndex) '("FiraSans-Book")) - (check-equal? (take-right (hash-ref cff-font 'stringIndex) 2) - (list - "Digitized data copyright \\(c\\) 2012-2015, The Mozilla Foundation and Telefonica S.A." - "Fira Sans Book")) - (hash-ref cff-font 'topDict) (check-equal? (length (hash-ref cff-font 'globalSubrIndex)) 820) - ) \ No newline at end of file + (check-equal? (length (hash-ref cff-font 'stringIndex)) 2404) + ; 'version string + (check-equal? (hash-ref (hash-ref cff-font 'topDict) 'version) 2401) + (check-equal? + (list-ref (hash-ref cff-font 'stringIndex) 2401) + "004.106") + ; 'Notice string + (check-equal? + (list-ref (hash-ref cff-font 'stringIndex) 2402) + "Digitized data copyright \\(c\\) 2012-2015, The Mozilla Foundation and Telefonica S.A.") + ; 'FullName string + (check-equal? + (list-ref (hash-ref cff-font 'stringIndex) 2403) + "Fira Sans Book") + (hash-ref (hash-ref cff-font 'topDict) 'Copyright)) \ No newline at end of file diff --git a/fontland/fontland/table/cff/cff-operand.rkt b/fontland/fontland/table/cff/cff-operand.rkt index 0fe919ce..b41abb77 100644 --- a/fontland/fontland/table/cff/cff-operand.rkt +++ b/fontland/fontland/table/cff/cff-operand.rkt @@ -22,7 +22,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFOperand.js (super-new) (augment [@decode decode]) - (define (@decode stream value) + (define (@decode stream _ value) (cond [(<= 32 value 246) (- value 139)] [(<= 247 value 250) (+ (* (- value 247) 256) (read-byte stream) 108)]