Skip to content

Fix visual_bounding_rect for rotated text#7050

Merged
emilk merged 1 commit intoemilk:mainfrom
pmarks:pmarks/text-bb-rotation
May 18, 2025
Merged

Fix visual_bounding_rect for rotated text#7050
emilk merged 1 commit intoemilk:mainfrom
pmarks:pmarks/text-bb-rotation

Conversation

@pmarks
Copy link
Contributor

@pmarks pmarks commented May 15, 2025

TextShape.visual_bounding_rect was not taking the text rotation into account. I manually tested drawing the new bounding box on top of the text for various rotations & anchor settings. For example:
image

The unit test I added will fail without this patch, but perhaps doesn't add much value.

  • I have followed the instructions in the PR template

@lucasmerlin lucasmerlin added bug Something is broken egui epaint and removed egui labels May 16, 2025
Copy link
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

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

Nice, thanks for adding a test!

@github-actions
Copy link

Preview available at https://egui-pr-preview.github.io/pr/7050-pmarkstext-bb-rotation
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@emilk emilk changed the title fix visual_bounding_rect for rotated text Fix visual_bounding_rect for rotated text May 18, 2025
@emilk emilk merged commit a15040c into emilk:main May 18, 2025
46 of 49 checks passed
darkwater pushed a commit to darkwater/egui that referenced this pull request Aug 24, 2025
TextShape.visual_bounding_rect was not taking the text rotation into
account. I manually tested drawing the new bounding box on top of the
text for various rotations & anchor settings. For example:
<img width="191" alt="image"
src="https://github.com/user-attachments/assets/56528fc7-7e7d-45af-b92a-c1cd307ff205"
/>

The unit test I added will fail without this patch, but perhaps doesn't
add much value.

* [x] I have followed the instructions in the PR template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is broken epaint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants