-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
BitmapText not wrapping lines in some cases #6860
Comments
Hi @bagyoni. Thanks for submitting this issue. We have fixed this and pushed it to the |
Thanks for the quick response @zekeatchan. The change appears to cause the first two lines to overlap. (The one in the example I sent begins with a newline, so it won't show this). It also doesn't seem to solve the line wrapping issue on my end. |
Noticed the first 2 lines overlapping as well. Another push has been made to Could you kindly test it out and provide examples if you encounter other issues? Thanks! |
I'm still seeing the same issues. const text = `first line overlaps with itself
second line ends with a space
third line not wrapped as it should be`;
class Example extends Phaser.Scene {
preload() {
this.load.bitmapFont(
"atari",
"assets/fonts/bitmap/atari-smooth.png",
"assets/fonts/bitmap/atari-smooth.xml"
);
}
create() {
this.add.bitmapText(50, 50, "atari", text, 20).setMaxWidth(300);
}
}
const config = {
type: Phaser.AUTO,
parent: "phaser-example",
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config); Note that I used the "Dev Build" version in Labs, not sure if that's always up to date with master. |
Ok, I know why you're not seeing the update... I only pushed to Here's the url you can try out: |
Yeah, my bad, I didn't know which version it was using (also tried building from source, but the first version must have got stuck in a cache because that didn't work either). |
More concerningly, character indexes are now also off. If you update the previous code with create() {
let bt = this.add
.bitmapText(50, 50, "atari", text, 20)
.setMaxWidth(300);
let characters = bt.getTextBounds().characters;
console.log("last idx: " + characters[characters.length - 1].idx); // prints 105
console.log("text length: " + text.length); // prints 101
} it will report that the index of the last |
https://github.com/phaserjs/phaser/compare/944c6be993adb4a1a334ecb76622703a720d7cfc..6fd076991507075b293b4df7f90a73f1f2d58a6b#diff-2f451878b483f7a17db65a497c5b42d9072ac80ac6bfc3555779f5e2b0a83692
|
Thanks @rgk. Appreciate you sharing more examples so I can further fine tune. |
For internal use onlyThe issue with BitmapText not wrapping lines correctly when a line ends with a space can be addressed by modifying the word wrapping logic in the BitmapText class. Specifically, check the References/changelog/3.21/CHANGELOG-v3.21.md
|
The issue: BitmapText setMaxWidth() bug #6807 was solved in Beta 3.85.0-1 but its not working in Beta 3.85.0-2 again could be because of this changes? |
Hi @bagyoni @rgk @AlvaroNeuronup. A fix has been pushed to the |
This has been reintroduced: Look at the how you handle wrappedLine. |
The problem I mentioned in #6860 (comment) still persists. const text = `first line first line first line
second line second line second line
third line third line third line`;
class Example extends Phaser.Scene {
preload() {
this.load.bitmapFont(
"atari",
"assets/fonts/bitmap/atari-smooth.png",
"assets/fonts/bitmap/atari-smooth.xml"
);
}
create() {
let bt = this.add.bitmapText(50, 50, "atari", text, 20).setMaxWidth(300);
let characters = bt.getTextBounds().characters;
console.log("last idx: " + characters[characters.length - 1].idx);
console.log("text length: " + bt.text.length);
}
}
const config = {
type: Phaser.AUTO,
parent: "phaser-example",
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config); Console output:
According to docs the |
Version
Description
If a line of
BitmapText.text
is (1) long enough to get wrapped, and (2) it ends with a space, then the next non-empty line will never be wrapped, no matter how long it is.In the example, the first and last lines are wrapped correctly, but the middle one is not.
Example Test Code
Additional Information
Might be related to #6717.
The text was updated successfully, but these errors were encountered: