local option for font-face

master
Matthew Butterick 7 years ago
parent 6a33aed790
commit cd43e1ee33

@ -97,16 +97,18 @@
(define/contract (font-face-declaration font-family (define/contract (font-face-declaration font-family
src-url src-url
#:local [local-name #f]
#:font-style [font-style "normal"] #:font-style [font-style "normal"]
#:font-weight [font-weight "normal"] #:font-weight [font-weight "normal"]
#:font-stretch [font-stretch "normal"] #:font-stretch [font-stretch "normal"]
#:base64 [base64? #f]) #:base64 [base64? #f])
((string? (or/c urlish? base64-font-string?)) ((string? (or/c urlish? base64-font-string?))
(#:font-style valid-font-style? #:font-weight valid-font-weight? #:font-stretch valid-font-stretch? #:base64 boolean?) (#:font-style valid-font-style? #:font-weight valid-font-weight? #:font-stretch valid-font-stretch? #:base64 boolean? #:local (or/c #f string?))
. ->* . string?) . ->* . string?)
(let* [(url (->url src-url)) (let* ([url (->url src-url)]
(url-value (if base64? (path->base64-font-string src-url) (->path 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 (format "url('~a') format('~a')" url-value (font-format src-url))]
[src (string-append (if local-name (format "local(~v), " local-name) "") src)])
(string-append "@font-face {\n" (string-append "@font-face {\n"
(join-css-strings (map make-css-string (join-css-strings (map make-css-string
'(font-family font-style font-weight font-stretch src) '(font-family font-style font-weight font-stretch src)

Loading…
Cancel
Save