-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 incorrect BitmapText text width calculation (#7758) #7933
base: v7.x
Are you sure you want to change the base?
Conversation
Thank you for the PR! Could you possibly add unit test for this behavior? |
Here is work in progress, for proper width/height calculations for BitmapTexts: Before: https://63hr2.csb.app PixiJS 6.2.0 (Source: https://codesandbox.io/s/boring-shadow-63hr2?file=/index.html ) I have the unit tests as well, but I'm still working on a few edge cases for "pixel perfection" but I'm unsure if it's even worth it. For me, it's "good enough" with those changes. How important is it to get this 100%? I'll tidy up the code to finish this PR as soon as I have time. |
@kjarrio Are you going to fix anything here? I would gladly use new version with your fix cause I encounter the same problem. |
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 isn't perfect, but it's good enough. If we can improve it overtime that'd be great.
🎉 |
@kjarrio I tested it more on my monospaced fonts and I noticed that this solution does not work for fonts which has xadvance<width or negative xoffset. BitmapText behaves correctly when I change digits inside but when first or last digit changes, BitmapText starts shaking. monospaced font with negative xoffset: Same font works correctly in pixi v5. |
as @kozickikarol pointed this fix does not solve the issue, There is still a clear regression made by the original #7245 fix breaking old fonts. It seems to be only occurring when anchor is set to 0.5 but that is a common use case. original recreation on #7758 using 3.6.0 https://jsfiddle.net/1zyrd4s8/ showing the issue still exist. Was this an intentional break? and if so please advice on why. Somewhat easy workaround for this is to add an invisible character to the end (as pointed out above, only seems to occur if the last digit has an xoffset). |
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 needs more work based on the feedback here with negative offsets.
Ping @kjarrio do you want to continue working on this? If not I'd like to close and maybe someone else can pick-up this work. |
I will work on this, starting today, I can't promise I'll be able to fix it, but I will try to get this perfect this week |
Description of change
Fix for BitmapText width calculation when using monospace fonts. Fixes issue #7758 - and doesn't break PR #7479 / #7245
Pre-Merge Checklist
npm run lint
)npm run test
)