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

Fix WebGL text alignment + add tests #7481

Merged
merged 1 commit into from
Jan 18, 2025
Merged

Conversation

davepagurek
Copy link
Contributor

Resolves #7480

Changes:

  • WebGL's _renderText always draws text left-aligned, unlike 2D mode, which has native canvas text alignment to fall back on, so it has a custom implementation of text alignment. This wasn't correctly accounting for all combinations of alignments / provided bounding boxes, so this has since been updated.
  • WebGL's textBounds were broken previously because they assume 2D mode alignment, but were calling internal text alignment methods that are overridden in WebGL mode. They now explicitly call the 2D mode methods, although this should probably be refactored more in the future.
  • There were no text alignment tests for WebGL previously, so I adapted the existing tests to run for both 2D and WebGL mode. The screenshots for 2D mode were updated too because I had to pick a font that WebGL mode can also use rather than relying on the canvas default font.

Screenshots of the change:

WebGL text, correctly centered in a box:
004

PR Checklist

@davepagurek davepagurek merged commit 92da914 into dev-2.0 Jan 18, 2025
2 checks passed
@davepagurek davepagurek deleted the fix/webgl-text-align branch January 18, 2025 19:23
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.

1 participant