noc-book-2 icon indicating copy to clipboard operation
noc-book-2 copied to clipboard

Add script to adjust letter spacing to avoid orphans

Open jasongao97 opened this issue 1 year ago • 5 comments

This PR adds a script to avoid orphans (too short last line) of paragraphs and list items. #666

For any multi-line text with a too short last line, the script adjusts the letter spacing incrementally until it either meets a desired minimum width or the letter spacing become too extreme.

For now, I set the minimum width to 40pt and the maximum letter spacing to 0.3pt.

Here is a test build showcasing different letter spacing compare to unadjusted text: letter-spacing-test.pdf

jasongao97 avatar Feb 27 '24 08:02 jasongao97

Deploy Preview for nature-of-code-pdf ready!

Name Link
Latest commit 510f037935ae2dd936dd35f6c91c95c8c593c5ed
Latest deploy log https://app.netlify.com/sites/nature-of-code-pdf/deploys/65e11c462efb5300085c031d
Deploy Preview https://deploy-preview-873--nature-of-code-pdf.netlify.app/full/consolidated
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Feb 27 '24 08:02 netlify[bot]

Deploy Preview for nature-of-code-2nd-edition ready!

Name Link
Latest commit 510f037935ae2dd936dd35f6c91c95c8c593c5ed
Latest deploy log https://app.netlify.com/sites/nature-of-code-2nd-edition/deploys/65e11c46c8599f000858b488
Deploy Preview https://deploy-preview-873--nature-of-code-2nd-edition.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Feb 27 '24 08:02 netlify[bot]

Hi @jasongao97 thank you for this! I'm going to leave this in a separate branch for now and build two PDFs. I'll run this by the publisher and check on the idea of adjusting letter spacing. Anything beyond 0.15pt looks a little extreme to me and in the end it may ultimately be better to just add a line break for "the" for examples like this.

shiffman avatar Feb 27 '24 14:02 shiffman

@jasongao97 would it be possible to apply this letter spacing adjustement to paragraphs that I specifically mark through a callout box. Then maybe I could try it out on some of the remaining orphans.

shiffman avatar Mar 01 '24 00:03 shiffman

@jasongao97 I think this is a useful and interesting reference for the future of the magic book project and documentation of this project even though we didn't end up incorporating it into the print PDF? What's the best way to archive this? Can we close this PR and add a reference to it somewhere else?

shiffman avatar Apr 24 '24 14:04 shiffman