From 90c8f8f1068e5d03e0c4793712a5cb48af9aef48 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 25 Mar 2022 18:15:09 -0700 Subject: [PATCH] allow number for font-weight argument --- font-face.rkt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/font-face.rkt b/font-face.rkt index b8d5ce6..b02e509 100644 --- a/font-face.rkt +++ b/font-face.rkt @@ -72,13 +72,17 @@ (check-false (valid-font-style? "foobar"))) (define (valid-font-weight? x) - (and (string? x) (member x `("normal" "bold" ,@(map ~a (range 100 1000 100)))) #t)) + (define str (format "~a" x)) + (and (string? str) (member str `("normal" "bold" ,@(map ~a (range 100 1000 100)))) #t)) (module+ test (check-true (valid-font-weight? "normal")) (check-true (valid-font-weight? "100")) (check-true (valid-font-weight? "300")) (check-true (valid-font-weight? "900")) + (check-true (valid-font-weight? 100)) + (check-true (valid-font-weight? 300)) + (check-true (valid-font-weight? 900)) (check-false (valid-font-weight? "italic")) (check-false (valid-font-weight? "1000"))) @@ -120,7 +124,8 @@ (let* ([url (->url src-url)] [url-value (if base64? (path->base64-font-string src-url) (->path url))] [src (format "url('~a') format('~a')" url-value (font-format src-url))] - [src (string-append (if local-name (format "local(~v), " local-name) "") src)]) + [src (string-append (if local-name (format "local(~v), " local-name) "") src)] + [font-weight (format "~a" font-weight)]) (string-append "@font-face {\n" (join-css-strings (append (map make-css-string