-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
SpriteFont is not aligned #2152
Labels
bug
This issue describes undesirable, incorrect, or unexpected behavior
Comments
eonarheim
added
the
bug
This issue describes undesirable, incorrect, or unexpected behavior
label
Dec 8, 2021
@lampewebdev Thanks for the excellent bug report! Definitely not working as expected. It appears that there is some internal state being shared across in the var textA = new ex.Text({
font: spriteFont.clone(),
text: "1"
});
var textAA = new ex.Actor({
anchor: ex.Vector.Zero,
x: 100,
y: 10,
z: 1,
});
textAA.graphics.add(textA);
game.add(textAA);
var textB = new ex.Text({
font: spriteFont.clone(),
text: "22"
});
var textBA = new ex.Actor({
anchor: ex.Vector.Zero,
x: 100,
y: 30,
z: 2,
});
textBA.graphics.add(textB);
game.add(textBA); |
7 tasks
eonarheim
added a commit
that referenced
this issue
Dec 18, 2021
Closes #2152 This PR fixes SpriteFont and Font alignment issues by making both of them mostly stateless. This did happen to uncover some additional bugs in SpriteFont that are fixed in this PR 1. SpriteFont rotation behaved differently than normal Fonts 2. SpriteFont's did not support multiple lines like normal Fonts <img width="455" alt="image" src="https://user-images.githubusercontent.com/612071/146626331-87610af9-8787-4890-8c4b-af1218487729.png"> ## Changes: - Added a method `measureText` on both SpriteFont and Font to return the bounds of the desired text - Small tweak to debug system to allow independent position label and position point (made debugging easier) ## TODO Before merge * [x] Tests * [x] Some code cleanup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to Reproduce
It works when both text has the same length but breaks when they do not have the same length
Expected Result
Font should be aligned on the X axis
Actual Result
Fonts are not aligned
Environment
Current Workaround
None
The text was updated successfully, but these errors were encountered: