diff --git a/fontland/fontland/cff-glyph.rkt b/fontland/fontland/cff-glyph.rkt index 98bf475b..2134dd06 100644 --- a/fontland/fontland/cff-glyph.rkt +++ b/fontland/fontland/cff-glyph.rkt @@ -25,11 +25,13 @@ https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js [else . ELSEBODY])) (define (getPath this) - (define stream (ttf-font-port (glyph-font this))) - + (define cff (get-table (glyph-font this) 'CFF_)) (define str (vector-ref (hash-ref* cff 'topDict 'CharStrings) (glyph-id this))) (define end (+ (index-item-offset str) (index-item-length str))) + (define stream (if (woff-font? (glyph-font this)) + (get-table-stream (glyph-font this) 'CFF_) + (ttf-font-port (glyph-font this)))) (pos stream (index-item-offset str)) (define path (Path)) diff --git a/fontland/fontland/font.rkt b/fontland/fontland/font.rkt index 9603c996..c44add5f 100644 --- a/fontland/fontland/font.rkt +++ b/fontland/fontland/font.rkt @@ -31,7 +31,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js (define (+ttf-font port #:directory [directory-class directory] - #:probe [probe-vals (list #"true" #"OTTO" (bytes 0 1 0 0))]) + #:probe [probe-vals (list #"true" #"OTTO" (bytes 0 1 0 0))] + #:constructor [structor ttf-font]) (unless (input-port? port) (raise-argument-error '+ttf-font "input port" port)) @@ -48,7 +49,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js (define get-head-table-proc #f) (define font - (ttf-font port decoded-tables src directory ft-face hb-font hb-buf crc get-head-table-proc)) + (structor port decoded-tables src directory ft-face hb-font hb-buf crc get-head-table-proc)) ;; needed for `loca` table decoding cross-reference (set-ttf-font-get-head-table-proc! font (delay (get-head-table font))) font) @@ -86,7 +87,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/WOFFFont.js (define (+woff-font port) (+ttf-font port #:directory woff-directory - #:probe (list #"wOFF"))) + #:probe (list #"wOFF") + #:constructor woff-font)) ;; 181228: disk-based caching (either with sqlite or `with-cache`) is a loser ;; reads & writes aren't worth it vs. recomputing diff --git a/fontland/fontland/struct.rkt b/fontland/fontland/struct.rkt index b9670baa..722ee3dd 100644 --- a/fontland/fontland/struct.rkt +++ b/fontland/fontland/struct.rkt @@ -11,6 +11,8 @@ (let-values ([(dir name _) (split-path (ttf-font-src f))]) name)) p))) +(struct woff-font ttf-font ()) + (define (ft-face this) (or (force (ttf-font-ft-face this)) (error 'ft-face-not-available)))