My page has a Canvas that i want to add some text to it.
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas"></canvas>
<script>
var txt1 = 'فارسی';
var txt2 = '۴۷';
var myText = txt1 + txt2;
//var myText = txt2 + txt1;
var c = document.getElementById('myCanvas');
var ctx = c.getContext("2d");
ctx.width = 400;
ctx.height = 400;
ctx.fillStyle = "#777";
ctx.fillRect(0,0,400,400);
ctx.font = "normal 50px tahoma";
ctx.fillStyle = "#FFF";
ctx.direction = "rtl";
ctx.fillText(myText,70,110);
</script>
</body>
</html>
i set ctx.direction = "rtl";
before ctx.fillText
!
in IE and Firefox:
Text direction is not correct, The Number is placed at the end of string anyway!
myText = txt1 + txt2;
is same as myText = txt2 + txt1;
How to resolve it?