finish woffing

main
Matthew Butterick 5 years ago
parent e7fe04d85b
commit 06bb817002

@ -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))

@ -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

@ -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)))

Loading…
Cancel
Save