why isn't ptr-offset set

main
Matthew Butterick 5 years ago
parent 3d1ed8d280
commit f25c3a2aee

@ -78,16 +78,23 @@ https://github.com/mbutterick/fontkit/blob/master/src/subset/CFFSubset.js
(subset-add-glyph! ss 0)
ss)
(require racket/format racket/string)
(define (bytes->hexes bs)
(string-join
(for/list ([b (in-bytes bs)])
(~r #:base 16 b #:min-width 2 #:pad-string "0"))  " "))
(define (subsetCharstrings this)
(set-cff-subset-charstrings! this null)
(define gsubrs (make-hash))
(for ([gid (in-list (subset-glyphs this))])
#R gid
(set-cff-subset-charstrings!
this
(append (cff-subset-charstrings this)
(list (getCharString (cff-subset-cff this) gid))))
#R gid
(define glyph (get-glyph (subset-font this) gid))
;; apparently path parsing is not necessary?
#;(define path (hash-ref glyph 'path)) ;; this causes the glyph to be parsed
@ -190,7 +197,6 @@ https://github.com/mbutterick/fontkit/blob/master/src/subset/CFFSubset.js
'stringIndex (cff-subset-strings this)
'globalSubrIndex (cff-subset-gsubrs this)))
#R top
(encode CFFTop top stream)
(error 'boom))

@ -30,7 +30,15 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js
[_ operands]))
(define (encodeOperands type stream ctx operands)
(error 'cff-dict-encodeOperands-undefined))
(cond
[(list? type)
(for/list ([(op i) (in-indexed operands)])
(car (encodeOperands (list-ref type i) stream ctx op)))]
[(xenomorphic? type) (encode type operands stream #:parent ctx)]
[(number? operands) (list operands)]
[(boolean? operands) (list (if operands 1 0))]
[(list? operands) operands]
[else (list operands)]))
(define/override (post-decode val)
(dict->mutable-hash val))
@ -72,7 +80,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js
ret)
(define/augment (size dict parent [includePointers #true])
(augment [@size size])
(define (@size dict parent [includePointers #true])
(define ctx
(mhasheq x:parent-key parent
x:val-key dict
@ -99,7 +108,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFDict.js
len)
(define/augment (encode stream dict parent)
(error 'cff-dict-encode-undefined))))
(augment [@encode encode])
(define (@encode stream dict parent)
(error 'cff-dict-encode-undefined))))
(define (CFFDict [ops null]) (make-object CFFDict% ops))

@ -50,10 +50,12 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFOperand.js
(let ([strs (cons (vector-ref FLOAT_LOOKUP n2) strs)])
(values strs #false))]))]))]))
(define/augment (size value-arg)
(define/augment (size value-arg _)
;; if the value needs to be forced to the largest size (32 bit)
;; e.g. for unknown pointers, set to 32768
(define value (if (hash-ref value-arg 'forceLarge #f) 32768 value-arg))
(define value (if (and (hash? value-arg) (hash-ref value-arg 'forceLarge #f))
32768
value-arg))
(cond
[(not (integer? value)) ; floating point

@ -29,8 +29,11 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFTop.js
(define/augment (size value ctx)
(error 'predefined-op-size-not-finished))
(define/augment (encode stream value ctx)
(error 'predefined-op-encode-not-finished))))
(augment [@encode encode])
(define (@encode stream value ctx)
#R (get-field pointer-relative-to @type)
(or (index-of @predefinedOps value)
(encode @type value stream #:parent ctx)))))
(define (PredefinedOp predefinedOps type) (make-object PredefinedOp% predefinedOps type))
@ -176,8 +179,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/cff/CFFTop.js
(x:versioned-struct
#:pre-encode
(λ (val)
;; because fontkit depends on overloading 'version key, and we don't
(hash-set! val 'x:version (hash-ref val 'version))
;; because fontkit depends on overloading 'version key, and we don't
(hash-set! val 'x:version (hash-ref val 'version))
val)
fixed16be
(dictify

Loading…
Cancel
Save