From 6fb1a5c21b23630585e005336959f73a00f687e0 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 7 May 2019 09:00:15 -0700 Subject: [PATCH] next: study inset --- quad/quadwriter/core.rkt | 27 +++++++++++---------------- quad/quadwriter/param.rkt | 14 ++++++++------ quad/quadwriter/tags.rkt | 16 ++++++++++++---- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/quad/quadwriter/core.rkt b/quad/quadwriter/core.rkt index 1aef9336..0b5b56ef 100644 --- a/quad/quadwriter/core.rkt +++ b/quad/quadwriter/core.rkt @@ -97,18 +97,11 @@ (line-width doc stroke-width) (apply rect doc (append (pt+ (quad-origin q)) (size q))) (stroke doc stroke-color) - ;; draw in point & out point (both on layout box) - (define point-draw-diameter (+ stroke-width 1.5)) - (for ([which-point (list to-point from-point)] - [func (list circle circle-squared)]) - ;; if from-point is square, then its edges are still visible - ;; when to-point cricle is drawn on top - (define pt (which-point q)) - (func doc (pt-x pt) (pt-y pt) point-draw-diameter) - (fill doc fill-color)) - ;; draw inner point (adjusted by offset) - #;(rect-centered doc (pt-x (inner-point q)) (pt-y (inner-point q)) point-draw-diameter) - #;(fill doc stroke-color) + (apply rect doc (append (pt+ (quad-origin q)) (size q))) + (clip doc) + (define pt (to-point q)) + (circle doc (pt-x pt) (pt-y pt) (+ 3 stroke-width)) + (fill doc fill-color) (restore doc))) (define q:line (q #:size (pt 0 default-line-height) @@ -119,8 +112,9 @@ (struct line-spacer quad () #:transparent) (define q:line-spacer (q #:type line-spacer - #:size (pt 0 (* default-line-height 0.6)) + #:size (pt 20 (* default-line-height 0.6)) #:from 'sw + #:to 'nw #:printable (λ (q sig) (not (memq sig '(start end)))) #:draw-start (if (draw-debug-line?) draw-debug void))) @@ -388,8 +382,8 @@ (define (page-draw-start q doc) (add-page doc) - (draw-debug q doc "aliceblue" "aliceblue" 3) - (scale doc (if zoom-mode? zoom-scale 1) (if zoom-mode? zoom-scale 1))) + (scale doc (zoom-factor) (zoom-factor)) + (draw-debug q doc "aliceblue" "aliceblue" 3)) (define (draw-page-footer q doc) (match-define (list x y) (quad-origin q)) @@ -610,7 +604,8 @@ (define default-y-margin (min 72 (floor (* .10 (pdf-width pdf))))) (parameterize ([current-pdf pdf] [verbose-quad-printing? #false] - [draw-debug? #true]) + [draw-debug? #true] + [zoom-factor 3]) (let* ([qs (time-name hyphenate (handle-hyphenate qs))] [qs (map ->string-quad qs)] [qs (insert-first-line-indents qs)] diff --git a/quad/quadwriter/param.rkt b/quad/quadwriter/param.rkt index 445f84a3..a2c6f501 100644 --- a/quad/quadwriter/param.rkt +++ b/quad/quadwriter/param.rkt @@ -1,10 +1,12 @@ #lang debug racket/base (provide (all-defined-out)) -(define current-doc (make-parameter #f)) -(define current-pdf (make-parameter #f)) +(define current-doc (make-parameter #false)) +(define current-pdf (make-parameter #false)) (define current-locale (make-parameter 'us)) -(define draw-debug? (make-parameter #f)) -(define draw-debug-line? (make-parameter #t)) -(define draw-debug-block? (make-parameter #f)) -(define draw-debug-string? (make-parameter #t)) \ No newline at end of file +(define draw-debug? (make-parameter #false)) +(define draw-debug-line? (make-parameter #true)) +(define draw-debug-block? (make-parameter #false)) +(define draw-debug-string? (make-parameter #true)) + +(define zoom-factor (make-parameter 1)) \ No newline at end of file diff --git a/quad/quadwriter/tags.rkt b/quad/quadwriter/tags.rkt index f42a0814..3fefc363 100644 --- a/quad/quadwriter/tags.rkt +++ b/quad/quadwriter/tags.rkt @@ -14,9 +14,9 @@ (qexpr (append `(#;(first-line-indent "12") #;(line-align "center") #;(line-wrap "kp") - (page-margin-left "120") - (page-margin-top "80") - (page-margin-bottom "120") + #;(page-margin-left "120") + #;(page-margin-top "80") + #;(page-margin-bottom "120") (line-height "17") #;(line-align-last "center")) attrs) exprs)) @@ -57,7 +57,15 @@ (define-syntax-rule (attr-list . attrs) 'attrs) (define (heading-base font-size attrs exprs) - (qexpr (append `((font-family "fira-sans-light") (first-line-indent "0") (display "block") (font-size ,(number->string font-size))(line-height ,(number->string (* 1.2 font-size))) (border-width-top "0.5")(border-inset-top "9") (inset-bottom "-3") (inset-top "6") (keep-with-next "true")) attrs) exprs)) + (qexpr (append `((font-family "fira-sans-light") (first-line-indent "0") (display "block") (font-size ,(number->string font-size))(line-height ,(number->string (* 1.2 font-size))) + (border-width-top "1") + (border-width-bottom "1") + (border-width-left "1") + (border-width-right "1") + (inset-top "0") + (inset-left "0") + + (keep-with-next "true")) attrs) exprs)) (define-tag-function (h1 attrs exprs) (heading-base 20 (append '() attrs) exprs))