|
|
|
@ -35,7 +35,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js
|
|
|
|
|
(define (+ttf-font port
|
|
|
|
|
[decoded-tables (mhash)]
|
|
|
|
|
[src (path->string (object-name port))]
|
|
|
|
|
[directory (delay (decode Directory port #:parent (mhash '_startOffset 0)))]
|
|
|
|
|
[directory (delay (parameterize ([current-parent (mhash '_startOffset 0)])
|
|
|
|
|
(xdecode Directory port)))]
|
|
|
|
|
[ft-face (delay (and src (FT_New_Face (force ft-library) src)))]
|
|
|
|
|
[hb-font (delay (and src (hb_ft_font_create (force ft-face))))]
|
|
|
|
|
[hb-buf (delay (hb_buffer_create))]
|
|
|
|
@ -48,7 +49,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js
|
|
|
|
|
(define font
|
|
|
|
|
(ttf-font 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 (dump (get-head-table font))))
|
|
|
|
|
(set-ttf-font-get-head-table-proc! font (delay (get-head-table font)))
|
|
|
|
|
font)
|
|
|
|
|
|
|
|
|
|
(define (font-postscript-name font) (FT_Get_Postscript_Name (ft-face font)))
|
|
|
|
@ -146,7 +147,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js
|
|
|
|
|
(λ ()
|
|
|
|
|
#;(encode hb-output (apply harfbuzz-layout font args) #f)
|
|
|
|
|
(match (get-layout-from-db key)
|
|
|
|
|
[(? bytes? res) (dump (decode hb-output res))]
|
|
|
|
|
[(? bytes? res) (decode hb-output res)]
|
|
|
|
|
[_ (define new-layout (apply harfbuzz-layout font args))
|
|
|
|
|
(add-record! (cons key (encode hb-output new-layout #f)))
|
|
|
|
|
(make-hasheq new-layout)])))) ;; `dump` converts to hash
|
|
|
|
|