Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to adjust letter spacing to avoid orphans #873

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jasongao97
Copy link
Contributor

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

Copy link

netlify bot commented Feb 27, 2024

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

Name Link
🔨 Latest commit 510f037
🔍 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.

Copy link

netlify bot commented Feb 27, 2024

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

Name Link
🔨 Latest commit 510f037
🔍 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.

@shiffman
Copy link
Member

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
Copy link
Member

shiffman commented Mar 1, 2024

@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 shiffman mentioned this pull request Mar 5, 2024
@shiffman
Copy link
Member

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants