Repository navigation
Keep a hero headline word from standing alone on a line - #4
Merged
Merged
Conversation
When the largest size that fits leaves one word alone on a line, fitText now tries the sizes up to 10 percent smaller and takes the largest that leaves fewer lone words. If none does, the largest fitting size stands. A one-word paragraph (forced by a line break) does not count. PrintStream's "Every printer, every project, on every device." drew as "Every printer, / every / project, on / every device." and now draws as "Every printer, / every project, / on every device." The rule lives in fitText, so it applies to sublines too, and to Japanese and Chinese, where a lone segmenter word counts the same way. The committed examples do not change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
fitTextpicks the largest font size at which hero text fits. When that size leaves a word alone on a line, it now tries the sizes up to 10 percent smaller and takes the largest that leaves fewer lone words; if none does, the largest fitting size stands. A one-word paragraph forced by a\ndoes not count.Example: PrintStream's "Every printer, every project, on every device." drew as "Every printer, / every / project, on / every device." and now draws as "Every printer, / every project, / on every device."
Scope notes:
fitText, so sublines get it too. No current subline changes.Consumer impact
On the next pin bump,
devkit-store-hero --checkfails in these apps until their heroes are re-rendered (each reads better after):DisplaySwitchr and Little Launcher do not change. Persistent de-DE and ImmichDrive ja-JP still have one-word lines that no size in range removes (such as "Deine" and "で。"), but fewer than before. The committed examples in
docs/examples/store-hero/do not change. The next release notes should name these re-renders.Tests
Two
fitTextunit tests: the PrintStream sentence steps down to a three-line break, the step stops at 10 percent, and text with no lone word (or a forced one-word line) keeps the largest size.npm run validatepasses locally.AI disclosure: this comment and the related code were written with the assistance of AI.