Jump to content

[Suggestion] - BBCode Text


WombatTurkey
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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