main
Matthew Butterick 6 years ago
parent 7718968e47
commit e494ceeac0

@ -1,5 +1,5 @@
#lang debug racket/base
(require racket/class xenomorph sugar/unstable/dict)
(require racket/class xenomorph sugar/unstable/dict)
(provide CFFDict)
#|

@ -0,0 +1,45 @@
#lang debug racket/base
(require racket/class racket/match xenomorph sugar/unstable/dict
"cff-dict.rkt"
"cff-index.rkt"
"cff-pointer.rkt")
(provide CFFPrivateDict)
#|
approximates
https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFPrivateDict.js
|#
(define CFFBlendOp
(class xenobase%
(define/augment (:decode stream parent operands)
(match (reverse operands)
[(cons numBlends operands)
;; TODO: actually blend. For now just consume the deltas
;; since we don't use any of the values anyway.
(let loop ([operands operands])
(when (> (length operands) numBlends)
(loop (cdr operands))))]))))
(define CFFPrivateDict
;; key name type default
`((6 BlueValues delta #false)
(7 OtherBlues delta #false)
(8 FamilyBlues delta #false)
(9 FamilyOtherBlues delta #false)
((12 9) BlueScale number 0.039625)
((12 10) BlueShift number 7)
((12 11) BlueFuzz number 1)
(10 StdHW number #false)
(11 StdVW number #false)
((12 12) StemSnapH delta #false)
((12 13) StemSnapV delta #false)
((12 14) ForceBold boolean #false)
((12 17) LanguageGroup number 0)
((12 18) ExpansionFactor number 0.06)
((12 19) initialRandomSeed number 0)
(20 defaultWidthX number 0)
(21 nominalWidthX number 0)
(22 vsindex number 0)
(23 blend ,CFFBlendOp #false)
(19 Subrs ,(CFFPointer CFFIndex #:type 'local) #false)))

@ -3,7 +3,8 @@
"cff-index.rkt"
"cff-dict.rkt"
"cff-charsets.rkt"
"cff-pointer.rkt")
"cff-pointer.rkt"
"cff-encodings.rkt")
(provide CFFTop)
#|
@ -27,6 +28,23 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFTop.js
'first uint16be
'nLeft uint16be))
(define CFFEncodingVersion
(x:int #:size 1
#:signed #false
#:post-decode (λ (res) (bitwise-and res #x7f))))
(define CFFCustomEncoding
(x:versioned-struct
CFFEncodingVersion
(dictify
0 (dictify 'nCodes uint8
'codes (x:array uint8 'nCodes))
1 (dictify 'nRanges uint8
'ranges (x:array Range1 'nRanges)))))
(define CFFEncoding (PredefinedOp (list StandardEncoding ExpertEncoding)
(CFFPointer CFFCustomEncoding #:lazy #true)))
;; Decodes an array of ranges until the total
;; length is equal to the provided length.
@ -43,7 +61,6 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFTop.js
(define range (decode @type stream parent))
(hash-set! range 'offset count)
(values (cons range res) (+ count (hash-ref range 'nLeft) 1))))))
(define CFFCustomCharset
(let ([tproc (λ (t) (sub1 (length (hash-ref (hash-ref t 'parent) 'CharStrings))))])
@ -58,6 +75,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFTop.js
(list ISOAdobeCharset ExpertCharset ExpertSubsetCharset)
(CFFPointer CFFCustomCharset #:lazy #true)))
(define ptr (CFFPointer CFFPrivateDict))
(define CFFTopDict
(CFFDict
;; key name type(s) default

Loading…
Cancel
Save