Revert "try"

This reverts commit da4f8a83c1.
main
Matthew Butterick 5 years ago
parent da4f8a83c1
commit 245c8f6ea3

@ -15,8 +15,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js
(define (bias this s) (define (bias this s)
(cond (cond
[(< (vector-length s) 1240) 107] [(< (length s) 1240) 107]
[(< (vector-length s) 33900) 1131] [(< (length s) 33900) 1131]
[else 32768])) [else 32768]))
(define-syntax-rule (case= ID [(NUMS ...) . BODY] ... [else . ELSEBODY]) (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 pos (pos stream))
(define cff (get-table (glyph-font this) 'CFF_)) (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))) (define end (+ (hash-ref str 'offset) (hash-ref str 'length)))
(pos stream (hash-ref str 'offset)) (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 usedSubrs (make-hash))
(define open #false) (define open #false)
(define gsubrs (hash-ref cff 'globalSubrIndex (vector))) (define gsubrs (hash-ref cff 'globalSubrIndex null))
(define gsubrsBias (bias this gsubrs)) (define gsubrsBias (bias this gsubrs))
(define privateDict (or (privateDictForGlyph cff (glyph-id this)) (make-hash))) (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)) (define subrsBias (bias this subrs))
#R (vector? gsubrs)
#R (vector? subrs)
;; skip variations shit ;; skip variations shit
#;(define vstore (and (hash-ref* cff 'topDict 'vstore) #;(define vstore (and (hash-ref* cff 'topDict 'vstore)
(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 () (let loop ()
(when (< (pos stream) end) (when (< (pos stream) end)
(define op (read-byte stream)) (define op (read-byte stream))
#R (list op x y)
(cond (cond
[(< op 32) [(< op 32)
(case= op (case= op
@ -151,7 +147,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js
[(10) ;; callsubr [(10) ;; callsubr
(define index (+ (pop stack) subrsBias)) (define index (+ (pop stack) subrsBias))
(define subr (vector-ref subrs index)) (define subr (list-ref subrs index))
(when subr (when subr
(hash-set! usedSubrs index #true) (hash-set! usedSubrs index #true)
(define p (pos stream)) (define p (pos stream))
@ -268,7 +264,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js
[(29) ;; callgsubr [(29) ;; callgsubr
(define index (+ (pop stack) gsubrsBias)) (define index (+ (pop stack) gsubrsBias))
(define subr (vector-ref gsubrs index)) (define subr (list-ref gsubrs index))
(when subr (when subr
(hash-set! usedGsubrs index #true) (hash-set! usedGsubrs index #true)
(define p (pos stream)) (define p (pos stream))

@ -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)) (when (and (hash-has-key? cff-font 'version) (< (hash-ref cff-font 'version) 2))
(match (hash-ref cff-font 'topDictIndex) (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)])) [_ (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))
@ -38,8 +38,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFFont.js
(cond (cond
[(not sid) #false] [(not sid) #false]
[(>= (hash-ref this 'version) 2) #false] [(>= (hash-ref this 'version) 2) #false]
[(< sid (vector-length standardStrings)) (vector-ref standardStrings sid)] [(< sid (length standardStrings)) (list-ref standardStrings sid)]
[else (vector-ref (hash-ref this 'stringIndex) (- sid (vector-length standardStrings)))])) [else (list-ref (hash-ref this 'stringIndex) (- sid (length standardStrings)))]))
(define (CFFFont-postscriptName this) (define (CFFFont-postscriptName this)
(and (< (hash-ref this 'version) 2) (car (hash-ref this 'nameIndex)))) (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 CFFFont (make-object CFFFont%))
(define (getCharString cff-font glyph-id) (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)) (pos (hash-ref cff-font 'stream) (hash-ref glyph-record 'offset))
(read-bytes (hash-ref glyph-record 'length) (hash-ref cff-font 'stream))) (read-bytes (hash-ref glyph-record 'length) (hash-ref cff-font 'stream)))

@ -33,7 +33,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFIndex.js
(define startPos (+ (pos stream) (* (add1 count) offSize) -1)) (define startPos (+ (pos stream) (* (add1 count) offSize) -1))
(for/fold ([vals null] (for/fold ([vals null]
[start (send offsetType x:decode stream)] [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)]) ([i (in-range count)])
(define end (send offsetType x:decode stream)) (define end (send offsetType x:decode stream))
(define val (define val
@ -50,8 +50,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFIndex.js
'length (- end start))])) 'length (- end start))]))
(values (cons val vals) end))])) (values (cons val vals) end))]))
(define/augride (x:size arr-arg parent) (define/augride (x:size arr parent)
(define arr (if (vector? arr-arg) (vector->list arr-arg) arr-arg))
(+ 2 (+ 2
(cond (cond
[(zero? (length arr)) 0] [(zero? (length arr)) 0]

@ -7,7 +7,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFStandardStrings.js
|# |#
(define standardStrings (define standardStrings
'#(".notdef" "space" "exclam" "quotedbl" "numbersign" "dollar" '(".notdef" "space" "exclam" "quotedbl" "numbersign" "dollar"
"percent" "ampersand" "quoteright" "parenleft" "parenright" "percent" "ampersand" "quoteright" "parenleft" "parenright"
"asterisk" "plus" "comma" "hyphen" "period" "slash" "zero" "one" "asterisk" "plus" "comma" "hyphen" "period" "slash" "zero" "one"
"two" "three" "four" "five" "six" "seven" "eight" "nine" "colon" "two" "three" "four" "five" "six" "seven" "eight" "nine" "colon"

Loading…
Cancel
Save