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

feat: add text-wrap: "pretty" #663

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RostiMelk
Copy link

@RostiMelk RostiMelk commented Feb 26, 2025

Hey! I've been doing some work on trying to add text-wrap: "pretty" into Satori. I must admit, this is a very naive implementation, but I still wanted to post it here to gain some traction and comments before proceeding with adding some tests.

I initially tried to follow Google’s full spec, but fell face first before abandoning the approach.

The current solution checks if the last line of a paragraph is shorter than 30% of the paragraph’s width. If it is, the paragraph width is adjusted to 90%, before the content is passed back into flow() for a 2nd pass. This method works quite well in many cases, but of course it doesn’t cover all the edge cases the full spec would handle, such as advanced hyphen handling.

Demo:

77c4a6d6b591fd95bd0963ac677f0574.mp4

Some other sources:

@RostiMelk RostiMelk requested a review from shuding as a code owner February 26, 2025 15:43
Copy link

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
satori-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 3:44pm

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

1 participant