Add justified text support to text elements - #9185
Merged
Merged
Conversation
Build size reportThis PR changes the size of the minified bundles.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds justified wrapping support to text element components.
Changes:
- Adds the public
justifyproperty and layout logic. - Supports initialization, cloning, RTL layout, and tests.
- Adds an interactive justification example.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/framework/components/element/text-element.js |
Implements justified glyph positioning. |
src/framework/components/element/component.js |
Exposes the public API. |
src/framework/components/element/system.js |
Supports initialization and cloning. |
test/framework/components/element/text-element.test.mjs |
Tests justification behavior. |
examples/src/examples/user-interface/text-justify.example.mjs |
Demonstrates the feature. |
examples/src/examples/user-interface/text-justify.controls.jsx |
Adds example controls. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
added 2 commits
August 17, 2026 15:16
- gate the gap counting and the per-quad gapIndices storage on justify, so text that never justifies does not pay for the default-off feature - assert that the rtl justify test really does enable rtl layout - tidy up a comment in the example
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.
Fixes #4633.
Adds justified text to element components, fixing #4633. Wrapped lines are stretched to be flush with both edges of the element by widening the gaps between their words.
Changes:
justifyproperty on text elements, off by default. It only has an effect whenwrapLinesis true and the element has a width of its own to wrap against.alignment, which is what decides where they sit — the same split as CSStext-alignandtext-align-last.addComponentdata andclone()alongside the other text properties.API Changes:
ElementComponent#justify(boolean, defaults tofalse).Examples:
user-interface/text-justifyexample, with a toggle forjustifyand a selector foralignmentso the two can be combined, and a readout of the resulting values.Performance:
justifyis false: the per-glyph gap offset is only read for lines that are actually being stretched.