-
Notifications
You must be signed in to change notification settings - Fork 488
Add letterSpacing to Phaser.Text #753
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
base: master
Are you sure you want to change the base?
Conversation
Makes the docs type consistent with the tabs parameter in setStyle method
Which utilises the new Canvas2D letterSpacing property. Adds as a style parameter and instance property.
|
I can update the static doc files and typescript defs in this PR too. Just wasn't sure if there was a separate step for that. |
|
You can update the TypeScript definitions, but ignore the HTML docs, they're generated. Thanks. |
Also fixed the JSDoc type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bug: Complex Layout Ignores Letter Spacing
In the complex layout (tabs) section, the condition for using measureLine doesn't include letterSpacing check, unlike the simple layout at line 446. When tabs and letterSpacing are both used, text width calculations use context.measureText directly instead of measureLine, causing incorrect measurements that don't account for letter spacing.
src/gameobjects/Text.js#L469-L471
phaser-ce/src/gameobjects/Text.js
Lines 469 to 471 in 19c6bb4
| var tab = 0; | |
| for (var c = 0; c < line.length; c++) |
|
Thanks @samme I've added them to
|
Was missing in width calculations for other line types
|
Have added fixes to the missing bits Cursor Bot brought up. |
This PR:
Describe the changes below:
Adds support for the new Canvas2D letterSpacing property, to the
Phaser.Textobject, as a new style config.I also noticed
letterSpacingexists as a property of the BitmapText object. So I added a getter/setter for it in Phaser.Text to match.Example Usage:
JSFiddle Demo: https://jsfiddle.net/Akurn/r3zgd69x/

TODO:
Note
Adds
letterSpacingsupport toPhaser.Text, including rendering, measurement, JSDoc, and TypeScript typings.style.letterSpacing(default'0px') with getter/settertext.letterSpacing.context.letterSpacingduring render and measurement (updateText,measureLine), including tabbed layouts; width calculations now account for non-zeroletterSpacing.setStyleto documentletterSpacing.PhaserTextStyleto include optionalletterSpacing?: string.letterSpacing: stringtoPhaser.Texttypings.Written by Cursor Bugbot for commit 08eaaec. This will update automatically on new commits. Configure here.