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

Text new line does not work properly with word wrap #6187

Closed
robinheidrich opened this issue Aug 1, 2022 · 1 comment
Closed

Text new line does not work properly with word wrap #6187

robinheidrich opened this issue Aug 1, 2022 · 1 comment

Comments

@robinheidrich
Copy link

robinheidrich commented Aug 1, 2022

Version

  • Phaser Version: v3.60.0-beta.9
  • Operating system: Windows 11
  • Browser: Google Chrome 103.0.5060.134

Description

I have an array of messages that I want to display in a text, each in a new line. \n works fine, just not with longer texts that have been modified by word wrapping.

image

As you can see, Test 1 and Test 2 are on the same line as the longer text, despite the \n character.

Test 3 is then displayed again on a new line, as intended.

Example Test Code

The bug can be reproduced by inserting the following code in the Phaser 3 sandbox.

var config = { width: 800, height: 600, scene: { create } };
var game = new Phaser.Game(config);

function create() {
    var messages = ['Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet', 'Test 1', 'Test 2', 'Test 3'];

    var textStyle = {
        wordWrap: { width: 385, useAdvancedWrap: true }
    };

    var text = this.add.text(0, 0, '', textStyle)
    text.setText(messages.join('\n'));
}

Additional Information

This only happens with longer texts that are split into more lines by word wrapping.

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

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

No branches or pull requests

2 participants