main
Matthew Butterick 6 years ago
parent 165241cbc4
commit 309756456b

@ -54,13 +54,13 @@
(define str (car (quad-elems q)))
(font-size doc fontsize)
(font doc (path->string charter))
(list
(pt
(string-width doc str)
(current-line-height doc)))]))
(define line-height 16)
(define $line (q #:attrs (hasheq 'type "line")
#:size (list +inf.0 line-height)
#:size (pt +inf.0 line-height)
#:out 'sw
#:printable #true))
(define $page (q #:attrs (hasheq 'type "page")
@ -95,7 +95,7 @@
[attrs (quad-attrs (car pcs))]
[elems (merge-adjacent-strings (apply append (for/list ([pc (in-list run-pcs)])
(quad-elems pc))))]
[size (delay (list (for/sum ([pc (in-list run-pcs)])
[size (delay (pt (for/sum ([pc (in-list run-pcs)])
(pt-x (size pc)))
(pt-y (size (car pcs)))))]))
(values (cons new-run runs) rest)))

@ -104,13 +104,13 @@
(define (runify qx)
;; runify a quad by reducing it to a series of "runs",
;; which are multi-character quads with the same formatting.
(define first-key (eq-hash-code (current-default-attrs)))
(define first-run-idx (eq-hash-code (current-default-attrs)))
(define first-attrs (hash-copy (current-default-attrs)))
(hash-set! first-attrs 'idx first-key)
(hash-set! first-attrs run-key first-run-idx)
(dropf
(let loop ([x (if (string? qx) (make-quad #f (list qx)) qx)]
[attrs first-attrs]
[key first-key])
[key first-run-idx])
(match x
[(? quad?) ;; qexprs with attributes are recursed
(define this-attrs (quad-attrs x))

Loading…
Cancel
Save