From 0ddddd771be618f50e3181f04472f9d1ff6bdd49 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 10 Jan 2019 10:12:52 -0800 Subject: [PATCH] bgcolor for text (eh) --- quad/qtest/hyphenate.rkt | 10 ++++++++-- quad/qtest/markdown.rkt | 17 +++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/quad/qtest/hyphenate.rkt b/quad/qtest/hyphenate.rkt index e136297e..c3b7df5a 100644 --- a/quad/qtest/hyphenate.rkt +++ b/quad/qtest/hyphenate.rkt @@ -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?! \ No newline at end of file +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`. \ No newline at end of file diff --git a/quad/qtest/markdown.rkt b/quad/qtest/markdown.rkt index 618d275f..e2864185 100644 --- a/quad/qtest/markdown.rkt +++ b/quad/qtest/markdown.rkt @@ -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))]