How to justify align text in html5 canvas?

Viewed 10384

How can I align text within a html5 canvas to justify"? In the code below, text can be left/right/center aligned. I need to set align="justify". Please suggest how can this be done?

HTML:

<body onload="callMe()">
    <canvas id="MyCanvas"></canvas>
</body>

JS:

function callMe() {
    var canvas = document.getElementById("MyCanvas");
    var ctx = canvas.getContext("2d");
    var txt = "Welcome to the new hello world example";
    cxt.font = "10pt Arial";
    cxt.textAlign = "left";

    /* code to text wrap*/
    cxt.fillText(txt, 10, 20);
}
1 Answers
Related