<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>27993</bug_id>
          
          <creation_ts>2015-02-10 07:28:38 +0000</creation_ts>
          <short_desc>&lt;canvas&gt;: influence of computed style or bidi text direction on CanvasRenderingContext2D text rendering</short_desc>
          <delta_ts>2017-07-21 10:47:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vivek Galatage">vivekg</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>eae</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>117787</commentid>
    <comment_count>0</comment_count>
    <who name="Vivek Galatage">vivekg</who>
    <bug_when>2015-02-10 07:28:38 +0000</bug_when>
    <thetext>There is a concern on how the directionality should be determined when the &apos;direction&apos; attribute is not specified on a &lt;canvas&gt; element explicitly. 

The blink implementation determines the direction as:
* If the target object&apos;s direction attribute has the value &quot;ltr&quot; 
    Let direction be &apos;ltr&apos;
* If the target object&apos;s direction attribute has the value &quot;rtl&quot; 
    Let direction be &apos;rtl&apos;
* Update the computed style of the document 
* Run bidi directionality detection algorithm on the given text to compute the direction value

As per the specification [1], neither CSS nor the text being rendered should have any influence on directionality.

In blink, currently this feature is available behind --enable-experimental-canvas-features (can be activated in chrome://flags).
In order to ship the support for &apos;direction&apos; attribute on a CanvasRenderingContext2D, there is an ongoing discussion [1], for the above concern. 

Which is the correct approach to sync the implementation and the specification?

[1] https://html.spec.whatwg.org/multipage/scripting.html#text-preparation-algorithm
[2] https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/h7hfD3yOCfA</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117788</commentid>
    <comment_count>1</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-02-10 07:48:12 +0000</bug_when>
    <thetext>Vivek, do you think what is implemented in Blink is better than what the spec says? The spec seems simpler to me, but I don&apos;t know why the Blink code ended up this way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117794</commentid>
    <comment_count>2</comment_count>
    <who name="Vivek Galatage">vivekg</who>
    <bug_when>2015-02-10 09:07:26 +0000</bug_when>
    <thetext>(In reply to Philip Jägenstedt from comment #1)
&gt; Vivek, do you think what is implemented in Blink is better than what the
&gt; spec says? The spec seems simpler to me, but I don&apos;t know why the Blink code
&gt; ended up this way.

IMHO utilizing the bidi directionality based on the input text seems a better approach when the default direction is inherit. If its explicitly mentioned we do override it anyways. This was added here [1] for fixing the measureText on RTL text.

[1] https://code.google.com/p/chromium/issues/detail?id=439850</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117796</commentid>
    <comment_count>3</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-02-10 09:39:14 +0000</bug_when>
    <thetext>Was the problem with measureText that it didn&apos;t match the bounds of what would actually be rendered, or that what was actually rendered looked bad? From http://jsfiddle.net/behdad/cjy5jhby/1/ it looks like it&apos;s a mismatch problem, but if the rendering isn&apos;t a problem I&apos;m not sure why we need to take CSS into account here.

Using the BiDi algorithm seems sensible, since that&apos;s simply a property of the input.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118298</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2015-03-04 19:37:26 +0000</bug_when>
    <thetext>As far as I can tell the spec is very precise about this. I don&apos;t understand the issue with what the spec says. Can you elaborate?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118339</commentid>
    <comment_count>5</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-03-05 05:09:56 +0000</bug_when>
    <thetext>The spec is clear, I think the problem is that it looks only at the direction attribute. How about falling back to the bidi algorithm?

CC Emil from the Chromium bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119082</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2015-03-30 20:44:04 +0000</bug_when>
    <thetext>(In reply to Vivek Galatage from comment #2)
&gt; 
&gt; IMHO utilizing the bidi directionality based on the input text seems a
&gt; better approach when the default direction is inherit. 

Why?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128748</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2017-07-21 10:47:37 +0000</bug_when>
    <thetext>Please file a new issue at https://github.com/whatwg/html/issues/new if you still think this needs changing.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>