Jump to content

text direction rtl


Recommended Posts


I need to add text in hebrew but it seems like the align prop changes only the position, how can i use "rtl"?

this is my css:



canvas {






this looks ok (but obviously not useful with phaser) :



      var c = this.game.canvas

      var test = c.getContext("2d");

      test.font="25px Arial";

      var str1 = "טקסט עברית ואנגלית text שאלה?";

      test.fillText(str1, 0, 0);




This is not (the words order changes):


var style = {

            "font": "25px Arial"        


        this.game.add.text(0, 0, str1,style);





What's the diff? and how can i fix it? :\

Link to comment
Share on other sites

There's no built-in way to handle this. Text objects have their own internal canvas element, which the text is rendered to. so changing the main canvas won't do anything. You can add the direction property to the Text texture canvases, but because they are unattached to the dom most browsers seem to ignore it. If you manage to get it working, let me know.

Link to comment
Share on other sites

I know, it's a bit ridiculous really. You'd think once you set rlt that was it, fillText would just use it, regardless if the canvas is in the page or not. But that really doesn't seem to be the case. For now I'd suggest you either use graphics, BitmapText (because then you control the order directly), or DOM element overlays.

Link to comment
Share on other sites

  • 2 years later...
On 2/19/2019 at 10:27 PM, eriwine said:

Greetings from 3 years in the future! I'm currently trying to get RTL order working with Arabic text in Phaser 2. @sharon would you please elaborate on how you got BitmapText to render RTL? 

even I am trying to use arabic, as far as I can see that it goes beserk when we have line breaks either via \n or wordWrap, so I temporary got it working by doing like this:

"اجمعوا الطرود لتحصلوا" + "\n" + "على خصم حتى" + "\n" + "50 NIS"

if you keep english and arabic and \n text separate and connect them using + it works fine.

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.

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.


  • Recently Browsing   0 members

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