[Webkit-unassigned] [Bug 169922] New: fillText ignores canvas RTL unless canvas is member of the DOM

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Mar 21 14:04:57 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=169922

            Bug ID: 169922
           Summary: fillText ignores canvas RTL unless canvas is member of
                    the DOM
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Canvas
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: rdavey at gmail.com
                CC: dino at apple.com

Demo: http://codepen.io/photonstorm/pen/peLyyX?editors=1010

Issue:

The canvas fillText function ignores the canvas dir and canvas.style.direction properties unless the canvas itself has been added to the DOM.

For example this works fine:

```
var str1 = "این یک آزمایش است.";

var canvas = document.createElement('canvas');
canvas.dir = 'rtl';

document.body.appendChild(canvas);

var ctx = canvas.getContext('2d');
ctx.font = '48px serif';
ctx.fillStyle = '#ff00ff';
ctx.fillText(str1, 500, 100);
```

The Arabic text will respect the canvas dir attribute and render correctly. However if you do not add the canvas to the document body, it will ignore the dir property entirely, making this fail:

```
//  However if the canvas is NOT added to the document.body then it's clear that
//  fillText ignores the RTL setting entirely, as seen below:

var canvas3 = document.createElement('canvas');
var ctx3 = canvas3.getContext('2d');

//  Both of the following are ignored, because the canvas isn't in the DOM
canvas3.dir = 'rtl';
canvas3.style.direction = 'rtl';

canvas3.width = 600;
canvas3.height = 600;

ctx3.font = '48px serif';
ctx3.fillStyle = '#00ff00';

ctx3.textAlign = 'end';
ctx3.fillText(str1, 500, 300);

ctx.drawImage(canvas3, 0, 0);
```

You can see all of this, plus more examples here: http://codepen.io/photonstorm/pen/peLyyX?editors=1010

I don't know if this behaviour matches the spec or not as I couldn't find anything specific to this issue in it, but it doesn't really make sense (on a logical level, maybe on a technical one it does).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170321/92254b02/attachment-0001.html>


More information about the webkit-unassigned mailing list