move justify-overfill calculation

main
Matthew Butterick 3 years ago
parent 6ca1ca15da
commit da0fa8588b

@ -252,21 +252,23 @@
(and (pair? (quad-elems q))
(member (unsafe-car (quad-elems q)) softies)))
(define (line-wrap qs wrap-size [debug #false])
(unless (positive? wrap-size)
(raise-argument-error 'line-wrap "positive number" wrap-size))
(match qs
[(cons q _)
(define line-q (quad-copy line-quad q:line [size (pt wrap-size (quad-ref q :line-height default-line-height))]))
(define permitted-justify-overfill
(define (permitted-justify-overfill q)
(match (quad-ref q :line-align)
;; allow justified lines to go wider,
;; and then fill-wrap will tighten thes word spaces
;; this makes justified paragraphs more even, becuase
;; some lines are a little tight, as opposed to all of them being loose
;; this has to be based on a certain quad, not set globally for the line-wrap operation,
;; because different paragraphs might have different alignment settings.
["justify" 1.04]
[_ 1]))
(define (line-wrap qs wrap-size [debug #false])
(unless (positive? wrap-size)
(raise-argument-error 'line-wrap "positive number" wrap-size))
(match qs
[(cons q _)
(define line-q (quad-copy line-quad q:line [size (pt wrap-size (quad-ref q :line-height default-line-height))]))
;; group lines into sublists separated by para-breaks, but then omit the para-breaks themselves
;; because they've served their purpose (leave the others, to be expressed later)
;; however, leave line-breaks in, because they will be handled by wrap.
@ -290,9 +292,8 @@
(* (- wrap-size
(quad-ref pq :inset-left 0)
(quad-ref pq :inset-right 0))
permitted-justify-overfill)
(permitted-justify-overfill pq))
debug
;; during wrap, anchored qs are treated as having distance 0
;; so they can staty in right place, so that relative queries will work.
;; but they won't affect where lines break
@ -310,4 +311,3 @@
res]
[_ null]))
Loading…
Cancel
Save