Jump to content

Text styling


Greenmoonbase
 Share

Recommended Posts

 

https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Text.html

https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Text.html#lineSpacing__anchor

Not sure about the letter spacing, but here's a short demo

 

    var tconfig = {
      x: 200,
      y: 50,
      text: 'Some text to play with on my canvas',
      style: {
        fontSize: '24px',
        fontFamily: 'Arial',
        color: '#ffffff',
        align: 'center',
        lineSpacing: 44,
      }
    };
    var text = this.make.text(tconfig);
    text.setWordWrapWidth(100, false);

 

Link to comment
Share on other sites

  • 2 weeks later...

Looks like there's no letter spacing for text in Phaser 3

So here's a little solution if someone will need it

textline = 'qwerty';
letterSpacing = 10;
letter = null;
startPositionX = 400;

for(var i = 0; i < textline.length; i++){
    if(!letter){
        letter = this.add.text(startPositionX, 1020, textline[i]).setStyle({
            fontSize: '60px'
        });                
    } else {
        letter = this.add.text(nextLetterX, 1020, textline[i]).setStyle({
            fontSize: '60px'
        });
    }
    nextLetterX = letter.x + letter.width + letterSpacing;
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...