WombatTurkey Posted June 22, 2016 Share Posted June 22, 2016 I was playing around with text and kind of had a light bulb moment. This might be a future feature planned for Lazer maybe? Not really sure, but I think the ability to use bbcode inside text would be an incredible addition to either one. For example: var style = { font: "bold 12px OpenSans", fill: "#fff", align: 'center', bbcode: true}; text = game.add.text(0, 0, "Hello Phaser, I support [b]bold[/b] and [i]italic[/i] text along with [url="http://google.com"]links[/url] and other [s]goodies[/s]", style); What's everyone's thoughts on this? Yay or Nay? 3ddy 1 Link to comment Share on other sites More sharing options...
mattstyles Posted June 22, 2016 Share Posted June 22, 2016 Sounds like a userland solution rather than core, but the idea is good. I'd strongly suggest markdown over bbcode as well. scofield and WombatTurkey 2 Link to comment Share on other sites More sharing options...
in mono Posted June 22, 2016 Share Posted June 22, 2016 What I know is that in the current implementation, it's rather impossible to have multiple styles within one instance of Phaser.Text. I'd be, however, happy to see that implemented in some form. WombatTurkey 1 Link to comment Share on other sites More sharing options...
3ddy Posted June 22, 2016 Share Posted June 22, 2016 Yay! WombatTurkey 1 Link to comment Share on other sites More sharing options...
rich Posted June 22, 2016 Share Posted June 22, 2016 Easier said than done I'm afraid. Text uses Canvas.fillText, which doesn't allow you to mix styles up: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillText So you'd need to literally render a bit of text, store the coordinates, swap the text style to bold, render the next part, and continue - the problem being there's no accurate way to figure out how far the text got in the previous part (especially with kerning and special type faces). It's a huge mess really WombatTurkey 1 Link to comment Share on other sites More sharing options...
WombatTurkey Posted June 22, 2016 Author Share Posted June 22, 2016 6 hours ago, rich said: Easier said than done I'm afraid. Text uses Canvas.fillText, which doesn't allow you to mix styles up: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillText So you'd need to literally render a bit of text, store the coordinates, swap the text style to bold, render the next part, and continue - the problem being there's no accurate way to figure out how far the text got in the previous part (especially with kerning and special type faces). It's a huge mess really Bummer. But totally understandable, it does seem like a big fat mess. Oh well maybe in the future haha. in mono 1 Link to comment Share on other sites More sharing options...
Recommended Posts