diff options
author | Arun Isaac | 2023-08-28 22:11:54 +0100 |
---|---|---|
committer | Arun Isaac | 2023-08-29 17:08:47 +0100 |
commit | e3db95da66da9c4c23d764e9fd3e830c3d76ab53 (patch) | |
tree | 8f472a9c7757112f68f7f3ab773eb42d36fc159a /src/guile | |
parent | 97cfd1fd18efc1945cf5fe4fd1b12311ebac6c63 (diff) | |
download | skribilo-e3db95da66da9c4c23d764e9fd3e830c3d76ab53.tar.gz skribilo-e3db95da66da9c4c23d764e9fd3e830c3d76ab53.tar.lz skribilo-e3db95da66da9c4c23d764e9fd3e830c3d76ab53.zip |
html: Implement font using CSS.
The <font> tag is deprecated in HTML5.
* src/guile/skribilo/engine/html.scm (font): Implement using CSS only.
Diffstat (limited to 'src/guile')
-rw-r--r-- | src/guile/skribilo/engine/html.scm | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/src/guile/skribilo/engine/html.scm b/src/guile/skribilo/engine/html.scm index 0425cab..5072f4a 100644 --- a/src/guile/skribilo/engine/html.scm +++ b/src/guile/skribilo/engine/html.scm @@ -1646,34 +1646,41 @@ ignored, return #f." (markup-writer 'font :options '(:size :face) :before (lambda (node engine) - (let ((size (markup-option node :size)) - (face (markup-option node :face))) - (when (and (number? size) (inexact? size)) - (let ((s (if (> size 0) 'big 'small)) - (d (if (> size 0) 1 -1))) - (do ((i (inexact->exact size) (- i d))) - ((= i 0)) - (html-open s)))) - (when (or (and (number? size) (exact? size)) face) - (html-open 'font - `((class . ,(markup-class node)) - (size . ,(and (number? size) - (exact? size) - (not (zero? size)) - size)) - (face . ,face)))))) - :after (lambda (node engine) (let ((size (markup-option node :size)) (face (markup-option node :face))) - (when (or (and (number? size) (exact? size) (not (= size 0))) - face) - (html-close 'font)) - (when (and (number? size) (inexact? size)) - (let ((s (if (> size 0) 'big 'small)) - (d (if (> size 0) 1 -1))) - (do ((i (inexact->exact size) (- i d))) - ((= i 0)) - (html-close s))))))) + ;; Set font face and size if absolute. + (html-open 'span + `((class . ,(markup-class node)) + (style . ,(style-declaration + `((font-family . ,face) + (font-size . ,(and size + (positive? size) + (exact? size) + (string-append (number->string size) + "px")))))))) + ;; If size is relative, add a number of <span> tags + ;; with larger/smaller font-size styles. + (when (and size + (or (and (positive? size) + (inexact? size)) + (negative? size))) + (for-each (lambda _ + (html-open 'span + `((style . ,(style-declaration + `((font-size . ,(if (positive? size) + "larger" + "smaller")))))))) + (iota (abs (inexact->exact size))))))) + :after (lambda (node engine) + (let ((size (markup-option node :size))) + (when (and size + (or (and (positive? size) + (inexact? size)) + (negative? size))) + (for-each (lambda _ + (html-close 'span)) + (iota (abs (inexact->exact size))))) + (html-close 'span)))) ;*---------------------------------------------------------------------*/ ;* flush ... */ |