|
|
@ -160,25 +160,20 @@
|
|
|
|
#:post (list-of quad?)
|
|
|
|
#:post (list-of quad?)
|
|
|
|
|
|
|
|
|
|
|
|
(define (resolve-font-size-once attrs parent-attrs)
|
|
|
|
(define (resolve-font-size-once attrs parent-attrs)
|
|
|
|
|
|
|
|
(define previous-font-size
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
|
|
|
[(and parent-attrs (hash-ref parent-attrs :font-size #false))]
|
|
|
|
|
|
|
|
[else default-font-size]))
|
|
|
|
(define base-size-adjusted
|
|
|
|
(define base-size-adjusted
|
|
|
|
(match (hash-ref attrs :font-size 'missing)
|
|
|
|
(match (hash-ref attrs :font-size #false)
|
|
|
|
|
|
|
|
[(? procedure? proc)
|
|
|
|
;; if our value represents an adjustment,
|
|
|
|
;; if our value represents an adjustment,
|
|
|
|
;; we apply the adjustment to the previous value
|
|
|
|
;; we apply the adjustment to the previous value
|
|
|
|
[(? procedure? proc)
|
|
|
|
|
|
|
|
(define previous-font-size (cond
|
|
|
|
|
|
|
|
[(and parent-attrs (hash-ref parent-attrs :font-size-previous #false))]
|
|
|
|
|
|
|
|
[else default-font-size]))
|
|
|
|
|
|
|
|
(proc previous-font-size)]
|
|
|
|
(proc previous-font-size)]
|
|
|
|
;; otherwise we use our value directly
|
|
|
|
;; otherwise we use our value directly
|
|
|
|
[(? number? num) num]
|
|
|
|
[(? number? num) num]
|
|
|
|
[other (raise-user-error 'resolve-font-sizes "procedure or number" other)]))
|
|
|
|
[other #false]))
|
|
|
|
;; we write our new value into both font-size and font-size-previous
|
|
|
|
(hash-set! attrs :font-size (or base-size-adjusted previous-font-size)))
|
|
|
|
;; because as we cascade down, we're likely to come across superseding values
|
|
|
|
|
|
|
|
;; of font-size
|
|
|
|
|
|
|
|
;; but the font-size-previous will persist
|
|
|
|
|
|
|
|
;; because on the next recursion, the current `attrs` will be `parent-attrs`
|
|
|
|
|
|
|
|
(hash-set*! attrs :font-size base-size-adjusted
|
|
|
|
|
|
|
|
:font-size-previous base-size-adjusted))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(for-each-attrs qs resolve-font-size-once))
|
|
|
|
(for-each-attrs qs resolve-font-size-once))
|
|
|
|
|
|
|
|
|
|
|
|