bgcolor for text (eh)

main
Matthew Butterick 6 years ago
parent 0e3512205e
commit 0ddddd771b

@ -8,6 +8,12 @@ And now, for something __altogether__ the same.
At the command line:
`raco pkg install hyphenate`
We said `raco pkg install hyphenate` dude
What?!
What?!
Hyphenate `xexpr` by calculating hyphenation points and inserting
`joiner` at those points. By default, `joiner` is the soft hyphen
\(Unicode 00AD = decimal 173\). Words shorter than
`#:min-length` `length` will not be hyphenated. To hyphenate words of
any length, use `#:min-length` `#f`.

@ -9,7 +9,7 @@
(list 'q 'attrs . exprs))
(define-syntax-rule (code attrs . exprs)
(list 'q (list* '(font "fira-mono") '(bg "gray") 'attrs) . exprs))
(list 'q (list* '(font "fira-mono") '(fontsize "11") '(bg "lightgray") 'attrs) . exprs))
(define-syntax-rule (strong attrs . exprs)
(list 'q (cons '(font "charter-bold") 'attrs) . exprs))
@ -26,9 +26,10 @@
;; draw with pdf text routine
#:draw (λ (q doc)
(font doc (path->string (hash-ref (quad-attrs q) 'font)))
(font-size doc (string->number (hash-ref (quad-attrs q) 'fontsize "12")))
(match-define (list str) (quad-elems q))
(match-define (list x y) (quad-origin q))
(text doc str x y))))
(text doc str x y #:bg (hash-ref (quad-attrs q) 'bg #f)))))
(define-runtime-path charter "fonts/charter.ttf")
(define-runtime-path charter-bold "fonts/charter-bold.ttf")
@ -97,10 +98,10 @@
#:hard-break (λ (q) (equal? "" (car (quad-elems q))))
#:soft-break soft-break-for-line?
#:finish-wrap (λ (pcs q idx)
(append
(if (= idx 1) (list q:line-spacer) null)
(list (struct-copy quad q:line
[elems (consolidate-runs pcs)]))))))
(append
(if (= idx 1) (list q:line-spacer) null)
(list (struct-copy quad q:line
[elems (consolidate-runs pcs)]))))))
(define q:page (q #:offset '(36 36)
#:pre-draw (λ (q doc) (add-page doc))))
@ -118,8 +119,8 @@
(define pdf (time-name make-pdf (make-pdf #:compress #t
#:auto-first-page #f
#:output-path path)))
(define line-width 200)
(define vertical-height 400)
(define line-width 400)
(define vertical-height 600)
(let* ([x (time-name runify (runify (qexpr->quad xs)))]
[x (time-name ->string-quad (map (λ (x) (->string-quad pdf x)) x))]
[x (time-name line-wrap (line-wrap x line-width))]

Loading…
Cancel
Save