<?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>19128</bug_id>
          
          <creation_ts>2008-05-19 13:16:44 -0700</creation_ts>
          <short_desc>SVG fonts don&apos;t work with medial Arabic characters</short_desc>
          <delta_ts>2008-06-08 11:40:45 -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>SVG</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jonathan Haas">myrdred</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>myrdred</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>80913</commentid>
    <comment_count>0</comment_count>
    <who name="Jonathan Haas">myrdred</who>
    <bug_when>2008-05-19 13:16:44 -0700</bug_when>
    <thetext>To repro, go to LayoutTests/svg/W3C-SVG-1.1/fonts-glyphs-02-t.svg. Note big ugly blank rectangles where none should exist.

Simplified repro case is:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; &gt;
    &lt;defs&gt;
      &lt;font horiz-adv-x=&quot;500&quot;&gt;
        &lt;font-face font-family=&quot;SVGFont&quot; /&gt;
        &lt;missing-glyph d=&quot;M0 500L250 750L500 500&quot;/&gt;
        &lt;glyph unicode=&quot;&amp;#x069A;&quot; arabic-form=&quot;initial&quot; d=&quot;M0 500L250 0L500 500&quot;/&gt;
        &lt;glyph unicode=&quot;&amp;#x069A;&quot; arabic-form=&quot;medial&quot; d=&quot;M0 500L250 0L500 500&quot;/&gt;
        &lt;glyph unicode=&quot;&amp;#x069A;&quot; arabic-form=&quot;terminal&quot; d=&quot;M0 500L250 0L500 500&quot;/&gt;
      &lt;/font&gt;
    &lt;/defs&gt;
    &lt;g font-family=&quot;SVGFont&quot; font-size=&quot;80&quot;&gt;
      &lt;text font-face=&quot;SVGFont&quot; font-size=&quot;80&quot; x=&quot;100&quot; y=&quot;100&quot;&gt;&amp;#x069A;&amp;#x069A;&amp;#x069A;&lt;/text&gt;
    &lt;/g&gt;
&lt;/svg&gt;

This should output three downward-pointing triangles (one for each character in the &lt;text&gt; element) but it outputs two downward triangles with an upward triangle between them. Glyphs with arabic-form &quot;medial&quot; don&apos;t work. Here&apos;s the problem.

SVGGlyphElement.h:

    struct SVGGlyphIdentifier {
...
        // SVG Font depends on exactly this order.
        enum ArabicForm {
            None = 0,
            Isolated,
            Terminal,
            Initial,
            Medial
        };
...
        ArabicForm arabicForm : 3;

ArabicForm has values 0 to 4 inclusive, so it looks like a 3-bit bitfield should be more than sufficient. But enumerations are signed types, so the bitfield is also signed, so rather than ranging from 0..7, it ranges from -4..3. You can verify this:



void main() {
  enum foo { ZERO, ONE, TWO, THREE, FOUR };
  struct bar { foo f : 3; } b;

  b.f = FOUR;
  cout &lt;&lt; &quot;FOUR = &quot; &lt;&lt; FOUR &lt;&lt; endl;
  cout &lt;&lt; &quot;b.f = &quot; &lt;&lt; b.f &lt;&lt; endl;
  cout &lt;&lt; &quot;FOUR == b.f = &quot; &lt;&lt; (FOUR==b.f) &lt;&lt; endl;
}

...which outputs:

FOUR = 4
b.f = -4
FOUR == b.f = 0

The simplest solution is to bump the size of the bitfield up by one. This should have zero impact on performance, since the next data member should be byte-aligned (at least) anyway.

Sure would be nice if the compiler warned of the potential integer overflow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80915</commentid>
    <comment_count>1</comment_count>
      <attachid>21233</attachid>
    <who name="Jonathan Haas">myrdred</who>
    <bug_when>2008-05-19 13:23:37 -0700</bug_when>
    <thetext>Created attachment 21233
Dirt-simple patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80916</commentid>
    <comment_count>2</comment_count>
      <attachid>21233</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-05-19 13:27:32 -0700</bug_when>
    <thetext>Comment on attachment 21233
Dirt-simple patch

Needs a test case.  Otherwise this looks great!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80917</commentid>
    <comment_count>3</comment_count>
      <attachid>21233</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-05-19 13:29:22 -0700</bug_when>
    <thetext>Comment on attachment 21233
Dirt-simple patch

Oh, and actually, this is the wrong fix.  There is a way to force unsigned enums.  We have to do that for windows compilers.  there is an rtl flag on RenderStyle which we had to do this for iirc.  (Random Trivia: When the very very first versions of WebKit ran on windows the first time all the text was RTL due to this bug.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80918</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan Haas">myrdred</who>
    <bug_when>2008-05-19 13:40:56 -0700</bug_when>
    <thetext>Huh... learn something new every day. There is a way to force an enum to be unsigned, and the syntax is:

enum foo : unsigned
{
  one,
  two, 
  three
};

I had no idea. Will update patch. Will also start thinking of a test case, but the current SVG tree dumper doesn&apos;t dump anything wrong with the way things are, so it&apos;ll require changes (and hence changes to a lot of expected output.)
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80927</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Haas">myrdred</who>
    <bug_when>2008-05-19 16:06:53 -0700</bug_when>
    <thetext>Alas, while enum something : unsigned { } is kind of neat, it appears to be a nonstandard language extension. Other places in the code just use unsigned as the bitfield type, guess that&apos;s what I&apos;ll do here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80937</commentid>
    <comment_count>6</comment_count>
      <attachid>21243</attachid>
    <who name="Jonathan Haas">myrdred</who>
    <bug_when>2008-05-19 18:27:46 -0700</bug_when>
    <thetext>Created attachment 21243
Updated patch

Rather than increasing the size of the bitfield, declared it as unsigned instead of ArabicForm. This matches how other enumerations in WebKit are placed in bitfields.

As for a testcase, well, you can verify the bug&apos;s existence and fix manually by visiting LayoutTests/svg/W3C-SVG-1.1/fonts-glyph-03-t.svg. A testcase that fails automated tests without the patch would be a lot tougher... the SVG render tree dumper doesn&apos;t dump nearly enough information to cause a test case to fail, and would need to be changed substantially to make it do so.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82423</commentid>
    <comment_count>7</comment_count>
      <attachid>21243</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-06-06 08:21:31 -0700</bug_when>
    <thetext>Comment on attachment 21243
Updated patch

Ok.  r=me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82622</commentid>
    <comment_count>8</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-06-08 11:34:25 -0700</bug_when>
    <thetext>Patch fails to compile as-is with a warning about signed/unsigned comparison. I&apos;ll fix it as I check it in.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82623</commentid>
    <comment_count>9</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-06-08 11:40:45 -0700</bug_when>
    <thetext>Committed revision 34445.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>21233</attachid>
            <date>2008-05-19 13:23:37 -0700</date>
            <delta_ts>2008-05-19 18:28:19 -0700</delta_ts>
            <desc>Dirt-simple patch</desc>
            <filename>patch</filename>
            <type>text/plain</type>
            <size>1029</size>
            <attacher name="Jonathan Haas">myrdred</attacher>
            
              <data encoding="base64">SW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lzVmFsaWQgOiAxOwogCiAgICAgICAgIE9yaWVu
dGF0aW9uIG9yaWVudGF0aW9uIDogMjsKLSAgICAgICAgQXJhYmljRm9ybSBhcmFiaWNGb3JtIDog
MzsKKyAgICAgICAgQXJhYmljRm9ybSBhcmFiaWNGb3JtIDogNDsKICAgICAgICAgaW50IHByaW9y
aXR5OwogICAgICAgICBzaXplX3QgbmFtZUxlbmd0aDsKICAgICAgICAgU3RyaW5nIGdseXBoTmFt
ZTsK
</data>
<flag name="review"
          id="9277"
          type_id="1"
          status="-"
          setter="eric"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>21243</attachid>
            <date>2008-05-19 18:27:46 -0700</date>
            <delta_ts>2008-06-06 08:21:31 -0700</delta_ts>
            <desc>Updated patch</desc>
            <filename>patch</filename>
            <type>text/plain</type>
            <size>1102</size>
            <attacher name="Jonathan Haas">myrdred</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiAzMzU4MCkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTIgQEAKKzIwMDgtMDUtMTkgIEpvbmF0aGFuIEhhYXMgPG15cmRyZWRAZ21haWwu
Y29tPgorCisgICAgICAgIFJldmlld2VkIGJ5IChUQlIpLgorCisgICAgICAgIGh0dHA6Ly9idWdz
LndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE5MTI4CisgICAgICAgIE1hZGUgYXJhYmljRm9y
bSB1bnNpZ25lZCBzbyBpdCBmaXRzIGludG8gaXRzIDMtYml0IGJpdGZpZWxkCisKKyAgICAgICAg
KiBzdmcvU1ZHR2x5cGhFbGVtZW50Lmg6CisKIDIwMDgtMDUtMTkgIEFkYSBDaGFuICA8YWRhY2hh
bkBhcHBsZS5jb20+CiAKICAgICAgICAgQWRkZWQgQ29va2llU3RvcmFnZVdpbi5oL2NwcCwgaW50
cm9kdWNpbmcgbWV0aG9kcyB0byBnZXQvc2V0IHRoZSBjdXJyZW50IENGSFRUUENvb2tpZVN0b3Jh
Z2VSZWYuCkluZGV4OiBXZWJDb3JlL3N2Zy9TVkdHbHlwaEVsZW1lbnQuaAo9PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0t
LSBXZWJDb3JlL3N2Zy9TVkdHbHlwaEVsZW1lbnQuaAkocmV2aXNpb24gMzM1ODApCisrKyBXZWJD
b3JlL3N2Zy9TVkdHbHlwaEVsZW1lbnQuaAkod29ya2luZyBjb3B5KQpAQCAtODUsOCArODUsOCBA
QCBuYW1lc3BhY2UgV2ViQ29yZSB7CiAKICAgICAgICAgYm9vbCBpc1ZhbGlkIDogMTsKIAotICAg
ICAgICBPcmllbnRhdGlvbiBvcmllbnRhdGlvbiA6IDI7Ci0gICAgICAgIEFyYWJpY0Zvcm0gYXJh
YmljRm9ybSA6IDM7CisgICAgICAgIHVuc2lnbmVkIG9yaWVudGF0aW9uIDogMjsgLy8gT3JpZW50
YXRpb24KKyAgICAgICAgdW5zaWduZWQgYXJhYmljRm9ybSA6IDM7ICAvLyBBcmFiaWNGb3JtCiAg
ICAgICAgIGludCBwcmlvcml0eTsKICAgICAgICAgc2l6ZV90IG5hbWVMZW5ndGg7CiAgICAgICAg
IFN0cmluZyBnbHlwaE5hbWU7Cg==
</data>
<flag name="review"
          id="9289"
          type_id="1"
          status="+"
          setter="eric"
    />
          </attachment>
      

    </bug>

</bugzilla>