mbutterick / pollen-users

please use https://forums.matthewbutterick.com/c/typesetting/ instead
https://forums.matthewbutterick.com/c/typesetting/
52 stars 0 forks source link

Quad: inconsistent line height when `line-align` attribute is set to `justify` (probably bug) #85

Closed onvlt closed 3 years ago

onvlt commented 3 years ago

I'm playing with quadwriter and I have noticed some weird behavior considering #:line-align "justify"

With default settings, lines are rendered correctly:

#lang quadwriter/html

◊h1{What is quad?}

For instance, LaTeX is a document processor. So are web browsers. Quad borrows from both traditions — it’s an attempt to modernize the good ideas in LaTeX, and generalize the good ideas in web browsers, while bypassing some of the limitations of LaTeX (e.g., no Unicode) and of web browsers (e.g., performance and error recovery are valued above all).

Document processors sit opposite WYSIWYG tools like Microsoft Word and Adobe InDesign. There, the user controls the layout by manipulating a representation of the page on the screen. This is fine as far as it goes. But changes to the layout — for instance, a new page size — often require a new round of manual adjustments.
image

However, when I set #:line-align to "justify", line height suddently increases. Note that this only applies to justified lines. Last line is rendered correctly. It cannot be overridden with #:line-height attribute.

#lang quadwriter/html

#:line-align "justify"

◊h1{What is quad?}

For instance, LaTeX is a document processor. So are web browsers. Quad borrows from both traditions — it’s an attempt to modernize the good ideas in LaTeX, and generalize the good ideas in web browsers, while bypassing some of the limitations of LaTeX (e.g., no Unicode) and of web browsers (e.g., performance and error recovery are valued above all).

Document processors sit opposite WYSIWYG tools like Microsoft Word and Adobe InDesign. There, the user controls the layout by manipulating a representation of the page on the screen. This is fine as far as it goes. But changes to the layout — for instance, a new page size — often require a new round of manual adjustments.
image

Resulting Q-expression:

'(q
  ((output-path "my/output/path")
   (line-align "justify"))
  (q
   (para-break)
   (p
    (q
     (page-break)
     (q
      ((font-family "heading")
       (font-features "tnum 1")
       (first-line-indent "0")
       (display "block")
       (font-size "20")
       (line-height "24.0")
       (border-width-top "0.5")
       (border-inset-top "9")
       (inset-bottom "-3")
       (inset-top "6")
       (keep-with-next "true"))
      "What is quad?")))
   (para-break)
   (p
    "For instance, LaTeX is a document processor. So are web browsers. Quad borrows from both traditions — it’s an attempt to modernize the good ideas in LaTeX, and generalize the good ideas in web browsers, while bypassing some of the limitations of LaTeX (e.g., no Unicode) and of web browsers (e.g., performance and error recovery are valued above all).")
   (para-break)
   (p
    "Document processors sit opposite WYSIWYG tools like Microsoft Word and Adobe InDesign. There, the user controls the layout by manipulating a representation of the page on the screen. This is fine as far as it goes. But changes to the layout — for instance, a new page size — often require a new round of manual adjustments.")
   (para-break)))

This is how it looks with #:draw-debug "true":

image

However, when I remove the heading, line height is correct. It looks like if following paragraphs somehow inherited heading's line height. Also, when I put paragraph before that heading, line height is correct for the entire document. All in all, it doesn't look much like expected behavior.

mbutterick commented 3 years ago

Thanks! It was a bug. Fixed by https://github.com/mbutterick/quad/commit/1b38c70f98bfc37f647a5e6498a5ef2599720f42 and https://github.com/mbutterick/quad/commit/8880329d86750eb516371253fd91e2937ab52d34

onvlt commented 3 years ago

Excellent, thanks! I’m closing this issue.