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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Justify text #2396
Comments
No it's not possible I'm afraid. It's not even possible using native Canvas Text either! It's literally not in the canvas api. I can imagine it must be quite a challenge to code robustly. |
I think I could give it a go :) |
I recommend using plain HTML/CSS if you want to have extremely granular control over the appearance of text in your game. |
Yes, you're right! 馃懐 |
I'm moving this to the Lazer wish-list for Bitmap Text objects (and for Text objects if someone fancies taking that huge challenge on!) |
I add the same issue for a project I was working on. I had to wrote my own methods to justify the text. Basically the algorithm takes advantage of the PIXI's TextMetrics to split the text in lines and measure every word. Then in each of the lines it measures the total length of the non-white characters. When you substract it to the length of the line, you obtain the remaining white space. Finally you must add : totalWhitespace / (wordCount - 1) between each words to get your text justified. Here is the implementation I used, I don't guarantee that it will work in every case but it solved my problem : `let _line = function(container,txt,x,y,width,height,font,fontSize,bold,justify,center) {
} let _text = function(container,txt,x,y,width,height,font,fontSize,bold) {
};` Hope that it can help someone ;-) |
Hi guys,
Is possible to justify text? I think that it's very useful for several games with Phaser 馃懐
Thanks in advance :)
The text was updated successfully, but these errors were encountered: