From 245c8f6ea3060264f28e8afb8ee09f009a021f20 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 14 Mar 2019 22:23:13 -0700 Subject: [PATCH] Revert "try" This reverts commit da4f8a83c1dbfcff1b03fa9b54c3ae9dc1e2a835. --- fontland/fontland/cff-glyph.rkt | 18 +++++++----------- fontland/fontland/table/cff/cff-font.rkt | 8 ++++---- fontland/fontland/table/cff/cff-index.rkt | 5 ++--- .../table/cff/cff-standard-strings.rkt | 2 +- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/fontland/fontland/cff-glyph.rkt b/fontland/fontland/cff-glyph.rkt index 523a8cf2..f6cc3107 100644 --- a/fontland/fontland/cff-glyph.rkt +++ b/fontland/fontland/cff-glyph.rkt @@ -15,8 +15,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js (define (bias this s) (cond - [(< (vector-length s) 1240) 107] - [(< (vector-length s) 33900) 1131] + [(< (length s) 1240) 107] + [(< (length s) 33900) 1131] [else 32768])) (define-syntax-rule (case= ID [(NUMS ...) . BODY] ... [else . ELSEBODY]) @@ -29,7 +29,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js ;;;(define pos (pos stream)) (define cff (get-table (glyph-font this) 'CFF_)) - (define str (vector-ref (hash-ref (hash-ref cff 'topDict) 'CharStrings) (glyph-id this))) + (define str (list-ref (hash-ref (hash-ref cff 'topDict) 'CharStrings) (glyph-id this))) (define end (+ (hash-ref str 'offset) (hash-ref str 'length))) (pos stream (hash-ref str 'offset)) @@ -73,16 +73,13 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js (define usedSubrs (make-hash)) (define open #false) - (define gsubrs (hash-ref cff 'globalSubrIndex (vector))) + (define gsubrs (hash-ref cff 'globalSubrIndex null)) (define gsubrsBias (bias this gsubrs)) (define privateDict (or (privateDictForGlyph cff (glyph-id this)) (make-hash))) - (define subrs (hash-ref privateDict 'Subrs (vector))) + (define subrs (hash-ref privateDict 'Subrs null)) (define subrsBias (bias this subrs)) - #R (vector? gsubrs) - #R (vector? subrs) - ;; skip variations shit #;(define vstore (and (hash-ref* cff 'topDict 'vstore) (hash-ref* cff 'topDict 'vstore))) @@ -108,7 +105,6 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js (let loop () (when (< (pos stream) end) (define op (read-byte stream)) - #R (list op x y) (cond [(< op 32) (case= op @@ -151,7 +147,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js [(10) ;; callsubr (define index (+ (pop stack) subrsBias)) - (define subr (vector-ref subrs index)) + (define subr (list-ref subrs index)) (when subr (hash-set! usedSubrs index #true) (define p (pos stream)) @@ -268,7 +264,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js [(29) ;; callgsubr (define index (+ (pop stack) gsubrsBias)) - (define subr (vector-ref gsubrs index)) + (define subr (list-ref gsubrs index)) (when subr (hash-set! usedGsubrs index #true) (define p (pos stream)) diff --git a/fontland/fontland/table/cff/cff-font.rkt b/fontland/fontland/table/cff/cff-font.rkt index ea3d0ac4..83689f55 100644 --- a/fontland/fontland/table/cff/cff-font.rkt +++ b/fontland/fontland/table/cff/cff-font.rkt @@ -28,7 +28,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFFont.js (when (and (hash-has-key? cff-font 'version) (< (hash-ref cff-font 'version) 2)) (match (hash-ref cff-font 'topDictIndex) - [(vector dict) (hash-set! cff-font 'topDict dict)] + [(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)) @@ -38,8 +38,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFFont.js (cond [(not sid) #false] [(>= (hash-ref this 'version) 2) #false] - [(< sid (vector-length standardStrings)) (vector-ref standardStrings sid)] - [else (vector-ref (hash-ref this 'stringIndex) (- sid (vector-length standardStrings)))])) + [(< sid (length standardStrings)) (list-ref standardStrings sid)] + [else (list-ref (hash-ref this 'stringIndex) (- sid (length standardStrings)))])) (define (CFFFont-postscriptName this) (and (< (hash-ref this 'version) 2) (car (hash-ref this 'nameIndex)))) @@ -47,7 +47,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFFont.js (define CFFFont (make-object CFFFont%)) (define (getCharString cff-font glyph-id) - (define glyph-record (vector-ref (hash-ref (hash-ref cff-font 'topDict) 'CharStrings) glyph-id)) + (define glyph-record (list-ref (hash-ref (hash-ref cff-font 'topDict) 'CharStrings) glyph-id)) (pos (hash-ref cff-font 'stream) (hash-ref glyph-record 'offset)) (read-bytes (hash-ref glyph-record 'length) (hash-ref cff-font 'stream))) diff --git a/fontland/fontland/table/cff/cff-index.rkt b/fontland/fontland/table/cff/cff-index.rkt index 5eccefe3..56eead33 100644 --- a/fontland/fontland/table/cff/cff-index.rkt +++ b/fontland/fontland/table/cff/cff-index.rkt @@ -33,7 +33,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFIndex.js (define startPos (+ (pos stream) (* (add1 count) offSize) -1)) (for/fold ([vals null] [start (send offsetType x:decode stream)] - #:result (begin0 (list->vector vals) (pos stream (+ startPos start)))) + #:result (begin0 (reverse vals) (pos stream (+ startPos start)))) ([i (in-range count)]) (define end (send offsetType x:decode stream)) (define val @@ -50,8 +50,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFIndex.js 'length (- end start))])) (values (cons val vals) end))])) - (define/augride (x:size arr-arg parent) - (define arr (if (vector? arr-arg) (vector->list arr-arg) arr-arg)) + (define/augride (x:size arr parent) (+ 2 (cond [(zero? (length arr)) 0] diff --git a/fontland/fontland/table/cff/cff-standard-strings.rkt b/fontland/fontland/table/cff/cff-standard-strings.rkt index df32dddc..5559c6b1 100644 --- a/fontland/fontland/table/cff/cff-standard-strings.rkt +++ b/fontland/fontland/table/cff/cff-standard-strings.rkt @@ -7,7 +7,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFStandardStrings.js |# (define standardStrings - '#(".notdef" "space" "exclam" "quotedbl" "numbersign" "dollar" + '(".notdef" "space" "exclam" "quotedbl" "numbersign" "dollar" "percent" "ampersand" "quoteright" "parenleft" "parenright" "asterisk" "plus" "comma" "hyphen" "period" "slash" "zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "colon"