Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You don't need to set the direction for each individual string. See the following example which also shows the proper use of implicit bidi control marks for proper display order:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;/head&gt; &lt;body&gt; &lt;canvas id="myCanvas" width="700" dir="rtl" height="250" style="border:1px solid #d3d3d3;"&gt; Your browser does not support the HTML5 canvas tag. &lt;/canvas&gt; &lt;script type="text/javascript" charset="utf-8"&gt; var c = document.getElementById("myCanvas"); var cArabic = c.getContext("2d"); cArabic.font="25px Arial"; // Simple Sentence with punctuation. var str1 = "این یک آزمایش است."; // Few sentences with punctuation and numerals. var str2 = "۱ آزمایش. 2 آزمایش، سه آزمایش &amp; Foo آزمایش!"; // Needs implicit bidi marks to display correctly. var str3 = "آزمایش برای Foo Ltd. و Bar Inc. باشد که آزموده شود."; // Implicit bidi marks added; "Foo Ltd.&amp;lrm; و Bar Inc.&amp;lrm;" var str4 = "آزمایش برای Foo Ltd.‎ و Bar Inc.‎ باشد که آزموده شود."; cArabic.fillText(str1, 600, 60); cArabic.fillText(str2, 600, 100); cArabic.fillText(str3, 600, 140); cArabic.fillText(str4, 600, 180); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And here is the output: <img src="https://i.stack.imgur.com/Inh0l.png" alt="as rendered by Chrome &lt;code&gt;26.0.1410.64 m&lt;/code&gt; on MS Windows XP SP3"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload