fix handling of justified spacers

these are new quads added the line so they need to observe the same line-height logic as the rest of the line. That means we don't just look at the line height of the line-quad prototype.
main
Matthew Butterick 3 years ago
parent 1c0b091b8d
commit c5555653fe

@ -82,6 +82,12 @@
[(? string-quad?) (/ (quad-ref q :font-tracking 0) 2.0)]
[_ 0]))
(define (line-height-from-qs qs)
;; line height is the max 'line-height value or the natural height of q:line
(match (filter-map (λ (q) (or (quad-ref q :line-height) (pt-y (size q)))) qs)
[(? null?) #false]
[line-heights (apply max line-heights)]))
(define (fill-line-wrap all-qs line-prototype last-line-in-paragraph?)
;; happens during the finish of a line wrap, before consolidation of runs
(unless (pair? all-qs)
@ -134,12 +140,12 @@
;; which amounts to shrinking the word spaces till the line fits
(and line-overfull? (> nonspacess-count 1))))
(define justified-space-width (/ empty-hspace (sub1 nonspacess-count)))
(cons (make-left-edge-filler)
(apply append (add-between hung-nonspacess (list (make-quad
(define justified-spacer (make-quad
#:from 'bo
#:to 'bi
#:draw-end q:string-draw-end
#:size (pt justified-space-width line-prototype-height))))))]
#:size (pt justified-space-width (or (line-height-from-qs (append* hung-nonspacess)) line-prototype-height))))
(cons (make-left-edge-filler) (apply append (add-between hung-nonspacess (list justified-spacer))))]
[else
(define space-multiplier (match align-value
["center" 0.5]
@ -200,10 +206,7 @@
(hash-ref! h :display default-block-id)
h)]
;; line width is static
;; line height is the max 'line-height value or the natural height of q:line
[size (pt line-width (match (filter-map (λ (q) (or (quad-ref q :line-height) (pt-y (size q)))) pcs)
[(? null?) line-height]
[line-heights (apply max line-heights)]))]
[size (pt line-width (or (line-height-from-qs pcs) line-height))]
;; handle list indexes. drop new quad into line to hold list index
;; could also use this for line numbers
[elems

Loading…
Cancel
Save