diff --git a/fontland/fontland/unsafe/harfbuzz-helper.rkt b/fontland/fontland/unsafe/harfbuzz-helper.rkt index 00f980ae..5eb49704 100644 --- a/fontland/fontland/unsafe/harfbuzz-helper.rkt +++ b/fontland/fontland/unsafe/harfbuzz-helper.rkt @@ -13,9 +13,7 @@ HB_DIRECTION_BTT = 7)) (define (->tag bstr) - (define bs (bytes->list bstr)) - (for/sum ([(b i) (in-indexed (reverse bs))]) - (* b (expt 2 (* i 8))))) + (integer-bytes->integer bstr #f #;(= unsigned) 'big-endian)) (define hb-script-values `(HB_SCRIPT_COMMON = ,(->tag #"Zyyy") diff --git a/fontland/fontland/unsafe/harfbuzz.rkt b/fontland/fontland/unsafe/harfbuzz.rkt index 5e8ccea6..244c7d96 100644 --- a/fontland/fontland/unsafe/harfbuzz.rkt +++ b/fontland/fontland/unsafe/harfbuzz.rkt @@ -182,18 +182,16 @@ (define HB_FEATURE_GLOBAL_START 0) (define HB_FEATURE_GLOBAL_END 4294967295) -(define (tag->hb-feature tag) - (define str (symbol->string tag)) - (define bs (string->bytes/utf-8 str)) - (unless (= (bytes-length bs) (string-length str)) - (error 'invalid-tag-char)) +(define (tag->hb-feature bs) + (unless (and (bytes? bs) (= (bytes-length bs) 4)) + (raise-argument-error 'tag->hb-feature "4 bytes" bs)) (hb_feature_from_string bs)) -(define liga_on (tag->hb-feature 'liga)) +(define liga_on (tag->hb-feature #"liga")) (define liga_off (make-hb_feature_t (->tag #"liga") 0 0 4294967295)) -(define kern_on (tag->hb-feature 'kern)) +(define kern_on (tag->hb-feature #"kern")) (define kern_off (make-hb_feature_t (->tag #"kern") 0 0 4294967295)) -(define onum_on (tag->hb-feature 'onum)) +(define onum_on (tag->hb-feature #"onum")) (define onum_off (make-hb_feature_t (->tag #"onum") 0 0 4294967295)) (define (shape font text [feats null])