Skip to content

feat(layers): add clipping to TextLayer#10118

Merged
Pessimistress merged 6 commits intomasterfrom
x/clipping-text
Mar 22, 2026
Merged

feat(layers): add clipping to TextLayer#10118
Pessimistress merged 6 commits intomasterfrom
x/clipping-text

Conversation

@Pessimistress
Copy link
Collaborator

This extension lets any TextLayer to provide a per-object "clipping rectangle" that defines the context box that contains the text. Text overflowing this box will be hidden. If the layer has background enabled, the background rectangle will fill the clipping rectangle instead of fit around the text. Optionally, text can be automatically aligned to the visible region of the content box.

Screen.Recording.2026-03-19.at.2.15.23.PM.mov

Change List

  • ClippingTextExtension
  • Example
  • Documentation

@coveralls
Copy link

coveralls commented Mar 19, 2026

Coverage Status

coverage: 91.064% (+0.03%) from 91.038%
when pulling 57b8634 on x/clipping-text
into 023afee on master.

@ibgreen
Copy link
Collaborator

ibgreen commented Mar 20, 2026

  • One concern with extensions is that we currently have no idea for how to implement these in WebGPU.
  • Another is that extensions make more sense when there are multiple layers that benefit from it.
  • If this is mainly a concern about adding overhead when there is no clipping we do have some other ways to deal with that the ability to control it with defines and #ifdefs

@Pessimistress Pessimistress changed the title feat(extensions): add ClippingTextExtension feat(layers): add clipping to TextLayer Mar 21, 2026
Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for considering and making the change!

Nit: Any new test cases that could be added for the text layer?

@Pessimistress Pessimistress merged commit 04bd220 into master Mar 22, 2026
5 checks passed
@Pessimistress Pessimistress deleted the x/clipping-text branch March 22, 2026 01:13
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.

3 participants