mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Extract font-stretch when converting pango font names to CSS.
Also wrap font-family value in quotes and lower-case the fallback generic sans-serif font-family for CSS conformance (though browsers don't seem to care).
This commit is contained in:
parent
676cc337dc
commit
4ddd28a5d9
@ -37,6 +37,7 @@
|
||||
(define (font-name-to-style-info font-name)
|
||||
(let* ((font-style "")
|
||||
(font-weight "")
|
||||
(font-stretch "")
|
||||
(idx (string-index-right font-name #\space))
|
||||
(font-size (substring font-name (1+ idx) (string-length font-name)))
|
||||
(font-name (string-take font-name idx)))
|
||||
@ -54,9 +55,18 @@
|
||||
(set! font-style "font-style: oblique; ")
|
||||
(set! font-name (string-strip font-name " oblique"))))
|
||||
|
||||
(string-append "font-family: " font-name ", Sans-Serif; "
|
||||
(cond
|
||||
((string-contains-ci font-name " expanded")
|
||||
(set! font-stretch "font-stretch: expanded; ")
|
||||
(set! font-name (string-strip font-name " expanded")))
|
||||
|
||||
((string-contains-ci font-name " condensed")
|
||||
(set! font-stretch "font-stretch: condensed; ")
|
||||
(set! font-name (string-strip font-name " condensed"))))
|
||||
|
||||
(string-append "font-family: \"" font-name "\", sans-serif; "
|
||||
"font-size: " font-size "pt; "
|
||||
font-style font-weight)))
|
||||
font-style font-weight font-stretch)))
|
||||
|
||||
;; Registers font options
|
||||
(define (register-font-options options)
|
||||
|
@ -14,23 +14,23 @@
|
||||
(test-begin "font-name-to-style-info")
|
||||
|
||||
(test-equal "basic"
|
||||
"font-family: Courier Regular, Sans-Serif; font-size: 20pt; "
|
||||
"font-family: \"Courier Regular\", sans-serif; font-size: 20pt; "
|
||||
(font-name-to-style-info "Courier Regular 20"))
|
||||
|
||||
(test-equal "basic size 50"
|
||||
"font-family: Courier Regular, Sans-Serif; font-size: 50pt; "
|
||||
"font-family: \"Courier Regular\", sans-serif; font-size: 50pt; "
|
||||
(font-name-to-style-info "Courier Regular 50"))
|
||||
|
||||
(test-equal "basic size 50 bold"
|
||||
"font-family: Courier, Sans-Serif; font-size: 50pt; font-weight: bold; "
|
||||
"font-family: \"Courier\", sans-serif; font-size: 50pt; font-weight: bold; "
|
||||
(font-name-to-style-info "Courier bold 50"))
|
||||
|
||||
(test-equal "basic size 50 italic"
|
||||
"font-family: Courier, Sans-Serif; font-size: 50pt; font-style: italic; "
|
||||
"font-family: \"Courier\", sans-serif; font-size: 50pt; font-style: italic; "
|
||||
(font-name-to-style-info "Courier italic 50"))
|
||||
|
||||
(test-equal "basic size 15 oblique"
|
||||
"font-family: Courier, Sans-Serif; font-size: 15pt; font-style: oblique; "
|
||||
"font-family: \"Courier\", sans-serif; font-size: 15pt; font-style: oblique; "
|
||||
(font-name-to-style-info "Courier oblique 15"))
|
||||
|
||||
(test-end "font-name-to-style-info"))
|
||||
|
Loading…
Reference in New Issue
Block a user