From e93341557e552c26822163fd1ebacf72cb39ec7f Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 25 May 2019 10:54:36 -0700 Subject: [PATCH] hang hyphens --- quad/quadwriter/core.rkt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/quad/quadwriter/core.rkt b/quad/quadwriter/core.rkt index 444737a0..648d367c 100644 --- a/quad/quadwriter/core.rkt +++ b/quad/quadwriter/core.rkt @@ -156,11 +156,14 @@ ;; for instance, kerning between last letter and hyphen. (match (and ending-q (equal? (quad-elems ending-q) '("\u00AD")) qs) [(list head ... last-q) - (define str+hyphen (string-append (car (quad-elems last-q)) "-")) + (define str (car (quad-elems last-q))) + (define str+hyphen (string-append str "-")) + (define hang-hyphens? #true) + (define size-basis (if hang-hyphens? str str+hyphen)) (append head (list (struct-copy quad last-q [elems (list str+hyphen)] - [size (make-size-promise last-q str+hyphen)])))] + [size (make-size-promise last-q size-basis)])))] [_ qs])) (define-quad q:line-break quad ()) @@ -202,7 +205,7 @@ [_ (for*/list ([str (in-list (quad-elems q))] [hyphen-char (in-value #\u00AD)] [hstr (in-value (hyphenate str hyphen-char - #:min-left-length 4 + #:min-left-length 3 #:min-right-length 3))] [substr (in-list (regexp-match* (regexp (string hyphen-char)) hstr #:gap-select? #t))]) (struct-copy quad q [elems (list substr)]))]))))