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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>86071</bug_id>
          
          <creation_ts>2012-05-10 01:59:24 -0700</creation_ts>
          <short_desc>Incorrect behavior of upright text in vertical writing modes</short_desc>
          <delta_ts>2017-07-11 18:47:00 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Text</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>http://people.mozilla.org/~jdaggett/tests/text-orientation-with-ligatures.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>93304</blocked>
          <everconfirmed>0</everconfirmed>
          <reporter name="Theresa O&apos;Connor">eoconnor</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>itshustletime</cc>
    
    <cc>jdaggett</cc>
    
    <cc>kojii</cc>
    
    <cc>phiw2</cc>
    
    <cc>siqinbilige</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>620385</commentid>
    <comment_count>0</comment_count>
    <who name="Theresa O&apos;Connor">eoconnor</who>
    <bug_when>2012-05-10 01:59:24 -0700</bug_when>
    <thetext>See the test at the linked URL.

In vertical writing modes, upright text should be centered [the text in (2) is incorrectly aligned to the left].

In vertical writing modes, upright text should remain upright, even when the author has enabled ligatures with text-rendering: optimizeLegibility or with font-feature-settings [(4) and (5) exhibit the incorrect behavior].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>620387</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2012-05-10 02:00:19 -0700</bug_when>
    <thetext>&lt;rdar://problem/11422958&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>624092</commentid>
    <comment_count>2</comment_count>
    <who name="Koji Ishii">kojii</who>
    <bug_when>2012-05-15 08:02:03 -0700</bug_when>
    <thetext>This is a tough one. I can&apos;t see the file at URL right now due to 500 error, I can come back to check later, but here&apos;re some quick info.

text-rendering: optimizeLegibility lets WebKit use complex code path, and a test[1] indicates that it requires a fix in Core Text:
&gt; The complex text code path mis-renders because of API deficiency.
&gt; There is no way to tell CoreText to use upright horizontal glyphs
&gt; when rendering a vertical line.

One possible fix is not to use complex code path if vertical flow and upright even if text-rendering is set to optimizeLegibility, but I haven&apos;t look into its other implications yet.

If this fix has some undesirable side-effect and therefore is not applicable, we have to find a way to fix upright in complex code path, but this is really a tough one. OS X needs Core Text to fix as mentioned above. Complex code path is likely to fail on Windows too, because Uniscribe, the shaping engine we use in complex code path, has the same limitation as Core Text, but I don&apos;t think MS is going to fix this because Uniscribe is already deprecated. Probably we have to move on to DirectWrite, the successor of Uniscribe, or other open source shaping engine. If we go this way, I guess it&apos;ll be a long way.

For font-feature-settings, I can&apos;t see which value the test file is using, but from what I heard from John before, I suspect it&apos;s about ligatures. This is also a tough one in regards to figuring out the correct behavior.

1.3.4 of Adobe Technical Notes #5901[2] says:
&gt; Although the conventional ordering of these features is ‘liga’
&gt; followed by ‘vert’ and ‘vrt2’, this font’s vertical-only hiragana
&gt; ligatures necessitates a different ordering, specifically ‘vert’
&gt; and ‘vrt2’ followed by ‘liga’.
so the order of &apos;liga&apos; and &apos;vert&apos; are font-dependent, at least in some fonts. I asked this to a guy who created this font before, but didn&apos;t get back yet. I&apos;ll check with him again.


[1] http://svn.webkit.org/repository/webkit/trunk/LayoutTests/fast/writing-mode/text-orientation-basic.html
[2] http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5901.Kazuraki_Tutorial.pdf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>624823</commentid>
    <comment_count>3</comment_count>
      <attachid>142117</attachid>
    <who name="John Daggett">jdaggett</who>
    <bug_when>2012-05-15 18:31:51 -0700</bug_when>
    <thetext>Created attachment 142117
testcase, test text orientation with various other property settings</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>624841</commentid>
    <comment_count>4</comment_count>
    <who name="John Daggett">jdaggett</who>
    <bug_when>2012-05-15 18:48:01 -0700</bug_when>
    <thetext>Koji, the bug here is the inconsistency between the different modes and fonts, the orientation changes based on whether features that enable &quot;complex&quot; rendering mode are enabled or not and whether the font is judged to be &quot;Japanese&quot; or not.  Whether the &apos;fi&apos; ligature shows in the upright case isn&apos;t really the issue here.

I think you&apos;re jumping to conclusions that this is necessarily a bug in CoreText/Uniscribe.  My guess is that it has to do with the Webkit code that is calling those API&apos;s.

In general, font features are executed in the order given in the font.  But that&apos;s not the issue here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625105</commentid>
    <comment_count>5</comment_count>
    <who name="Koji Ishii">kojii</who>
    <bug_when>2012-05-16 01:02:09 -0700</bug_when>
    <thetext>Got the file, thank you for attaching.

(In reply to comment #4)
&gt; Koji, the bug here is the inconsistency between the different modes and fonts, the orientation changes based on whether features that enable &quot;complex&quot; rendering mode are enabled or not and whether the font is judged to be &quot;Japanese&quot; or not.  Whether the &apos;fi&apos; ligature shows in the upright case isn&apos;t really the issue here.

Maybe I still don&apos;t get what issue you want to discuss in this bug, since there are several problems mixed in the test file. Which one are you talking about? Since I&apos;m not sure if I understand the above sentence (sorry, due to my English skill,) please allow me to go through:

#1 is ok, right?
#2 is left aligned on Mac, look fine on Windows + bug 48459. I guess this is a bug in Mac port.
#3 is ok, right? It uses complex code path, but still ok because it doesn&apos;t apply upright.
#4 behaves differently between Mac and Win. Both are broken in different ways, but this is the one I mentioned. Not using complex code path when vertical + upright + optimizeLegibility is a possible fix but I&apos;m not sure if that&apos;s the right fix as written above. Otherwise we need CT/Uniscribe support to fix this.
#5 is broken differently on Mac and Win. I didn&apos;t know WebKit supports font-feature-settings already, this could be the same bug as #2 or different bug, I&apos;m not sure at this point. It renders the same as #2 on Mac but differently on Win.

So, it looks to me that #2 and #5 are probably easy fix at platform level code, and probably fixes are different and therefore they&apos;re separate bugs. #4 is yet another bug, the tough one I mentioned below.

For #2, calculating glyph position offset in upright orientation relies on CT on Mac port, and Win port reads OpenType tables directly because of the lack of such API, so this could possibly a bug in CT. I guess #5 will be ok on Mac if #2 was fixed, but we need another fix for #5 on Win.

I can&apos;t make a good connection between what you wrote above and the view I looked as above. What did I miss?

WebKit categorizes each font to one of two categories by if the font has vertical metrics or not. And if it tries to draw CJK code points using fonts without vertical metrics, it does a little hack so that it can render good on some Chinese fonts. But it doesn&apos;t do things differently by whether a font is Japanese or not. Is this the question you&apos;re asking?

&gt; In general, font features are executed in the order given in the font.  But that&apos;s not the issue here.

Oh, I didn&apos;t know that. I looked for OT specs without luck to find the ordering. Thank you for telling me about this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625116</commentid>
    <comment_count>6</comment_count>
    <who name="John Daggett">jdaggett</who>
    <bug_when>2012-05-16 01:27:01 -0700</bug_when>
    <thetext>As noted in the testcase text, the bugs shown in the testcase are:

1. The text orientation of the letters &quot;ABC&quot; are different in (4), (5) compared to (2)

2. In (4) and (5), the orientation of &quot;Tow&quot; varies based on the font (with Hiragino Mincho, sideways, with Times, upright)

3. The glyphs for &quot;final&quot; in (2) should be centered</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625203</commentid>
    <comment_count>7</comment_count>
    <who name="Koji Ishii">kojii</who>
    <bug_when>2012-05-16 02:57:32 -0700</bug_when>
    <thetext>Thanks for the clarifications. I looked into further.

#2 turned out to be a bug in CTFontGetVerticalTranslationsForGlyphs. This API supposed to return vertical origins, but its X component of return value is incorrect for some glyphs (probably proportional glyphs?) if the font has vertical metrics. We could either wait OS X to fix this bug, or disregard X position of the returned value and calculate by ourselves.

Note that the API returns values for font-size of 1 on Snow Leopard and we have a workaround for the bug, but this bug reproduces on both Snow Leopard and Lion. Also note that this looks good on iOS Safari, maybe iOS doesn&apos;t use the API, or the API on iOS doesn&apos;t have the bug.

#4 is complex code path + upright combination. The current implementation really doesn&apos;t support this combination well.

#5 shows different results by builds. A patch was landed to switch to the complex code path by setting any font feature settings on last August, so it used to behave the same as #2 but it&apos;s now the same issue as #4.

On OS X, complex code path + upright hits CT bug. On Windows, it hits Uniscribe limitations. This is a separate issue from #2. We could either workaround not to use these APIs on such cases, or wait for these APIs to fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625256</commentid>
    <comment_count>8</comment_count>
    <who name="Koji Ishii">kojii</who>
    <bug_when>2012-05-16 04:22:35 -0700</bug_when>
    <thetext>I hope it&apos;s already clear but I guess I should add a note that, orientation is inconsistent in #4/#5 because we really can&apos;t render it correctly, and Mac is currently falling back to sideways in that case. Win doesn&apos;t do the fallback and results in glyph overlaps. It&apos;s a side effect of the root problem, and is not intentional.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>142117</attachid>
            <date>2012-05-15 18:31:51 -0700</date>
            <delta_ts>2012-05-15 18:31:51 -0700</delta_ts>
            <desc>testcase, test text orientation with various other property settings</desc>
            <filename>text-orientation-with-ligatures.html</filename>
            <type>text/html</type>
            <size>2655</size>
            <attacher name="John Daggett">jdaggett</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIEhUTUw+CjxodG1sPgo8aGVhZD4KPHRpdGxlPnRleHQtb3JpZW50YXRpb24gdGVz
dDwvdGl0bGU+CjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0idGV4dC9o
dG1sOyBjaGFy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