expose shaping args

main
Matthew Butterick 6 years ago
parent 5e825deca8
commit 3fb90cae5a

@ -73,14 +73,19 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js
;; (though this is good news, as it avoids massive disk caches hanging around)
;; ram cache in pitfall suffices
;; todo: preserve semantics of user-features argument from pitfall, which is
;; #f = no features, null = default features, list = explicit features
(define (layout font str [features #f] [script #f] [language #f])
(define (layout font str
[features null]
[script 'HB_SCRIPT_LATIN]
[lang #"en"]
[direction 'HB_DIRECTION_LTR])
(define buf (hb-buf font))
(hb_buffer_reset buf)
(hb_buffer_set_script buf script)
(hb_buffer_set_language buf (hb_language_from_string lang))
(hb_buffer_set_direction buf direction)
(define codepoints (for/list ([c (in-string str)]) (char->integer c)))
(hb_buffer_add_codepoints buf codepoints)
(hb_shape (hb-font font) buf (map tag->hb-feature (or features null)))
(hb_shape (hb-font font) buf (map tag->hb-feature features))
(define gis (hb_buffer_get_glyph_infos buf))
(define hb-gids (map hb_glyph_info_t-codepoint gis))
(define hb-clusters (break-at codepoints (map hb_glyph_info_t-cluster gis)))

Loading…
Cancel
Save