Title: [107211] trunk
Revision
107211
Author
[email protected]
Date
2012-02-09 03:40:53 -0800 (Thu, 09 Feb 2012)

Log Message

2012-02-09  Philip Rogers  <[email protected]>

        Fix mirroring with SVG fonts
        https://bugs.webkit.org/show_bug.cgi?id=77067

        Reviewed by Nikolas Zimmermann.

        SVG fonts were incorrectly handling mirrored characters in bidi text.
        In this change I added the function createStringWithMirroredCharacters
        which handles mirroring the characters when selecting glyphs for SVG
        fonts. I also made a small cosmetic change in the function
        charactersWithArabicForm, changing the bool parameter "mirror" to "rtl"
        which better reflects what it actually does.

        Several new tests were added to test mirroring with SVG fonts in the
        presence of Arabic forms and non-BMP characters.

        * platform/gtk/test_expectations.txt:
        * platform/win/test_expectations.txt:
        * svg/custom/glyph-selection-arabic-forms-expected.txt: Added.
        * svg/custom/glyph-selection-arabic-forms.svg: Added.
        * svg/custom/glyph-selection-bidi-mirror-expected.txt: Added.
        * svg/custom/glyph-selection-bidi-mirror.svg: Added.
        * svg/custom/glyph-selection-non-bmp-expected.png: Added.
        * svg/custom/glyph-selection-non-bmp-expected.txt: Added.
        * svg/custom/glyph-selection-non-bmp.svg: Added.

2012-02-09  Philip Rogers  <[email protected]>

        Fix mirroring with SVG fonts
        https://bugs.webkit.org/show_bug.cgi?id=77067

        Reviewed by Nikolas Zimmermann.

        SVG fonts were incorrectly handling mirrored characters in bidi text.
        In this change I added the function createStringWithMirroredCharacters
        which handles mirroring the characters when selecting glyphs for SVG
        fonts. I also made a small cosmetic change in the function
        charactersWithArabicForm, changing the bool parameter "mirror" to "rtl"
        which better reflects what it actually does.

        Several new tests were added to test mirroring with SVG fonts in the
        presence of Arabic forms and non-BMP characters.

        Tests: svg/custom/glyph-selection-arabic-forms.svg
               svg/custom/glyph-selection-bidi-mirror.svg
               svg/custom/glyph-selection-non-bmp.svg

        * platform/graphics/SVGGlyph.cpp:
        (WebCore::charactersWithArabicForm):
        * svg/SVGFontData.cpp:
        (WebCore::SVGFontData::applySVGGlyphSelection):
        (WebCore::SVGFontData::createStringWithMirroredCharacters):
        * svg/SVGFontData.h:
        (SVGFontData):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107210 => 107211)


--- trunk/LayoutTests/ChangeLog	2012-02-09 11:37:16 UTC (rev 107210)
+++ trunk/LayoutTests/ChangeLog	2012-02-09 11:40:53 UTC (rev 107211)
@@ -1,3 +1,30 @@
+2012-02-09  Philip Rogers  <[email protected]>
+
+        Fix mirroring with SVG fonts
+        https://bugs.webkit.org/show_bug.cgi?id=77067
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG fonts were incorrectly handling mirrored characters in bidi text.
+        In this change I added the function createStringWithMirroredCharacters
+        which handles mirroring the characters when selecting glyphs for SVG
+        fonts. I also made a small cosmetic change in the function
+        charactersWithArabicForm, changing the bool parameter "mirror" to "rtl"
+        which better reflects what it actually does.
+
+        Several new tests were added to test mirroring with SVG fonts in the
+        presence of Arabic forms and non-BMP characters.
+
+        * platform/gtk/test_expectations.txt:
+        * platform/win/test_expectations.txt:
+        * svg/custom/glyph-selection-arabic-forms-expected.txt: Added.
+        * svg/custom/glyph-selection-arabic-forms.svg: Added.
+        * svg/custom/glyph-selection-bidi-mirror-expected.txt: Added.
+        * svg/custom/glyph-selection-bidi-mirror.svg: Added.
+        * svg/custom/glyph-selection-non-bmp-expected.png: Added.
+        * svg/custom/glyph-selection-non-bmp-expected.txt: Added.
+        * svg/custom/glyph-selection-non-bmp.svg: Added.
+
 2012-02-09  Philippe Normand  <[email protected]>
 
         Unreviewed, GTK rebaseline after r107207.

Modified: trunk/LayoutTests/platform/gtk/test_expectations.txt (107210 => 107211)


--- trunk/LayoutTests/platform/gtk/test_expectations.txt	2012-02-09 11:37:16 UTC (rev 107210)
+++ trunk/LayoutTests/platform/gtk/test_expectations.txt	2012-02-09 11:40:53 UTC (rev 107211)
@@ -98,3 +98,8 @@
 BUGWK74270 : fast/forms/basic-selects.html = FAIL
 
 BUGWK76639 : fast/table/multiple-captions-crash3.html = IMAGE FAIL
+
+// These tests need to be rebaselined after 77067
+BUGWK77067 : svg/custom/glyph-selection-arabic-forms.svg = TEXT
+BUGWK77067 : svg/custom/glyph-selection-bidi-mirror.svg = TEXT
+BUGWK77067 : svg/custom/glyph-selection-non-bmp.svg = TEXT

Modified: trunk/LayoutTests/platform/win/test_expectations.txt (107210 => 107211)


--- trunk/LayoutTests/platform/win/test_expectations.txt	2012-02-09 11:37:16 UTC (rev 107210)
+++ trunk/LayoutTests/platform/win/test_expectations.txt	2012-02-09 11:40:53 UTC (rev 107211)
@@ -132,3 +132,8 @@
 // Rebaseline required after bug 74874
 BUGWK74874 : fast/table/027.html = IMAGE+TEXT
 BUGWK74874 : fast/table/027-vertical.html = IMAGE+TEXT
+
+// These tests need to be rebaselined after 77067
+BUGWK77067 : svg/custom/glyph-selection-arabic-forms.svg = IMAGE
+BUGWK77067 : svg/custom/glyph-selection-bidi-mirror.svg = IMAGE
+BUGWK77067 : svg/custom/glyph-selection-non-bmp.svg = IMAGE

Added: trunk/LayoutTests/svg/custom/glyph-selection-arabic-forms-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/svg/custom/glyph-selection-arabic-forms-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/svg/custom/glyph-selection-arabic-forms-expected.txt (0 => 107211)


--- trunk/LayoutTests/svg/custom/glyph-selection-arabic-forms-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/glyph-selection-arabic-forms-expected.txt	2012-02-09 11:40:53 UTC (rev 107211)
@@ -0,0 +1,10 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 400x50
+  RenderSVGRoot {svg} at (10,7) size 347x18
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+    RenderSVGContainer {g} at (10,7) size 347x18
+      RenderSVGText {text} at (10,7) size 347x18 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 347x18
+          chunk 1 text run 1 at (10.00,20.00) startOffset 0 endOffset 56 width 339.18 RTL: "\x{62E}] [\x{62E}][\x{62E}][\x{62E}] | [\x{62E}] [\x{62E}\x{62E}][\x{62E}] | [\x{62E}] [\x{62E}\x{62E}\x{62E}] | [\x{62E} \x{62E}\x{62E}\x{62E}] | \x{62E} \x{62E}\x{62E}\x{62E}"
+          chunk 1 text run 1 at (349.18,20.00) startOffset 0 endOffset 1 width 6.88: "]"

Added: trunk/LayoutTests/svg/custom/glyph-selection-arabic-forms.svg (0 => 107211)


--- trunk/LayoutTests/svg/custom/glyph-selection-arabic-forms.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/glyph-selection-arabic-forms.svg	2012-02-09 11:40:53 UTC (rev 107211)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="400px" height="50px">
+<!-- Test that SVG fonts in RTL correctly render Arabic forms and mirrored characters together -->
+<defs>
+  <font horiz-adv-x="573">
+    <font-face font-family="SVGAr" units-per-em="1000" panose-1="5 1 1 1 1 1 1 1 1 1" ascent="1025" descent="-399" alphabetic="0"/>
+    <missing-glyph horiz-adv-x="500" d="M31 0V800H469V0H31ZM438 31V769H62V31H438Z"/>
+    <glyph unicode=" " glyph-name="space" horiz-adv-x="370"/>
+    <glyph unicode="خ" glyph-name="khah-isolated" arabic-form="isolated" horiz-adv-x="562" d="M309 360Q309 353 297 335T271 317Q260 317 227 337T194 370Q194 380 205 397T232 415Q246 415 277 395T309 360ZM518 -265Q516 -269 509 -275Q507 -277 502 -281Q447 -319 424 -330Q356 -363 281 -363Q228 -363 186 -347T110 -294Q69 -249 54 -199Q44 -167 44 -127Q44 -96 50 -65T76 12Q88 39 110 70Q152 127 152 137Q152 151 148 156T121 161Q95 161 85 156Q72 146 62 140Q44 128 35 130Q35 138 35 146Q37 151 43 162Q77 208 98 219T159 231Q170 231 234 221Q255 218 298 210H340Q347 210 382 218T425 230T435 235Q446 239 449 234Q454 226 444 189T426 152Q418 152 393 154T360 156Q327 156 297 149T228 120Q180 93 142 36Q96 -33 96 -110Q96 -209 168 -257Q223 -294 300 -294Q343 -294 371 -291Q429 -285 489 -267Q506 -260 511 -260Q514 -262 518 -265Z"/>
+    <glyph unicode="خ" glyph-name="khah-initial" arabic-form="initial" horiz-adv-x="728" d="M297 372Q297 365 285 347T259 329Q248 329 215 349T182 382Q182 392 193 409T220 427Q234 427 265 407T297 372ZM600 0H0V68H373Q396 68 396 86Q396 89 394 95Q377 137 347 159Q308 188 243 188Q210 188 183 171Q165 160 157 158T145 156Q138 156 138 164L140 174Q145 196 191 220Q228 240 269 240Q313 240 355 221T447 160Q488 120 530 81Q543 73 563 71T609 68Q619 68 620 68T625 68Q645 68 645 46Q645 30 633 15T600 0Z"/>
+    <glyph unicode="خ" glyph-name="khah-medial" arabic-form="medial" horiz-adv-x="625" d="M296 376Q296 369 284 351T258 333Q247 333 214 353T181 386Q181 396 192 413T219 431Q233 431 264 411T296 376ZM625 0H0V68H373Q396 68 396 86Q396 89 394 95Q377 137 347 159Q308 188 243 188Q210 188 183 171Q165 160 157 158T145 156Q138 156 138 164L140 174Q145 196 191 220Q228 240 269 240Q313 240 355 221T447 160Q488 120 530 81Q543 73 563 71T609 68Q619 68 620 68T625 68V0Z"/>
+    <glyph unicode="خ" glyph-name="khah-terminal" arabic-form="terminal" horiz-adv-x="514" d="M296 352Q296 345 284 327T258 309Q247 309 214 329T181 362Q181 372 192 389T219 407Q233 407 264 387T296 352ZM514 0H375Q313 0 298 64T261 128Q209 128 153 62Q91 -12 91 -101Q91 -199 162 -243Q220 -279 319 -279Q367 -279 390 -276T463 -259Q466 -258 475 -255T488 -252Q490 -252 491 -254T489 -263Q484 -272 466 -286T433 -307Q408 -320 401 -323Q349 -344 277 -344Q169 -344 104 -274Q44 -210 44 -118Q44 -88 51 -53T73 14Q80 31 97 56Q132 108 132 118Q132 127 126 134T110 141Q92 141 85 137Q72 127 59 117Q49 112 44 112Q38 112 38 119Q38 122 40 128Q49 156 80 182Q116 212 157 212Q170 212 188 208Q232 198 258 198H320Q345 198 357 201Q374 207 383 209T398 214T412 216Q420 216 421 212Q424 202 414 170T396 137Q394 137 382 140T362 143Q346 143 337 135T327 104Q327 91 341 80T379 68H514V0Z"/>
+    <glyph unicode="]" glyph-name="close-bracket" d="M213 -200h-195v73h108v770h-108v72h195v-915z"/>
+    <glyph unicode="[" glyph-name="open-bracket" d="M67 -200v915h195v-72h-106v-770h106v-73h-195z"/>
+  </font>
+</defs>
+<g font-family="SVGAr, serif" font-size="12">
+  <!-- This should show a line of Arabic characters in an SVG font with -->
+  <!-- brackets in various places surrounding groups of characters. The -->
+  <!-- Arabic forms should be broken when glyphs are split by brackets. -->
+  <text x="10" y="20">خ] [خ][خ][خ] | [خ] [خخ][خ] | [خ] [خخخ] | [خ خخخ] | خ خخخ]</text>
+</g>
+</svg>

Added: trunk/LayoutTests/svg/custom/glyph-selection-bidi-mirror-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/svg/custom/glyph-selection-bidi-mirror-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/svg/custom/glyph-selection-bidi-mirror-expected.txt (0 => 107211)


--- trunk/LayoutTests/svg/custom/glyph-selection-bidi-mirror-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/glyph-selection-bidi-mirror-expected.txt	2012-02-09 11:40:53 UTC (rev 107211)
@@ -0,0 +1,18 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 100x100
+  RenderSVGRoot {svg} at (20,4) size 80x91
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+    RenderSVGContainer {g} at (20,4) size 80x91
+      RenderSVGText {text} at (20,4) size 60x20 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 60x20
+          chunk 1 text run 1 at (20.00,20.00) startOffset 0 endOffset 7 width 60.00 LTR override: "[hello]"
+      RenderSVGText {text} at (20,23) size 54x22 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 54x22
+          chunk 1 text run 1 at (20.00,40.00) startOffset 0 endOffset 7 width 54.00 LTR override: "[hello]"
+      RenderSVGText {text} at (43,54) size 57x20 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 57x20
+          chunk 1 text run 1 at (43.00,70.00) startOffset 0 endOffset 6 width 57.00 RTL override: "[\x{5E9}\x{5DC}\x{5D5}\x{5DD}]"
+      RenderSVGText {text} at (49,73) size 51x22 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 51x22
+          chunk 1 text run 1 at (49.00,90.00) startOffset 0 endOffset 6 width 51.00 RTL override: "[\x{5E9}\x{5DC}\x{5D5}\x{5DD}]"

Added: trunk/LayoutTests/svg/custom/glyph-selection-bidi-mirror.svg (0 => 107211)


--- trunk/LayoutTests/svg/custom/glyph-selection-bidi-mirror.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/glyph-selection-bidi-mirror.svg	2012-02-09 11:40:53 UTC (rev 107211)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="100px" height="100px">
+<!-- Test that SVG fonts in RTL correctly render mirrored characters -->
+<defs>
+    <font horiz-adv-x="500">
+        <font-face font-family="SVGFont" units-per-em="1000" ascent="800" descent="200" alphabetic="200"/>
+        <glyph unicode="]" glyph-name="close-bracket" d="M0 0L500 0L500 900L0 900L0 800L400 800L400 100L0 100Z"/>
+        <glyph unicode="[" glyph-name="open-bracket" d="M500 0L0 0L0 900L500 900L500 800L100 800L100 100L500 100Z"/>
+    </font>
+</defs>
+<g font-size="20">
+    <!-- SVG Font: Should produce "hello" in brackets: "[hello]" not "]hello[" -->
+    <text font-family="SVGFont, serif" x="20" y="20" direction="ltr" unicode-bidi="bidi-override">[hello]</text>
+    <!-- Regular Font: Should produce "hello" in brackets: "[hello]" not "]hello[" -->
+    <text x="20" y="40" direction="ltr" unicode-bidi="bidi-override">[hello]</text>
+    <!-- SVG Font: Should produce "שלום" in brackets: "[שלום]" not "]שלום["-->
+    <text font-family="SVGFont, serif" x="100" y="70" direction="rtl" unicode-bidi="bidi-override">[שלום]</text>
+    <!-- Regular Font: Should produce "שלום" in brackets: "[שלום]" not "]שלום["-->
+    <text x="100" y="90" direction="rtl" unicode-bidi="bidi-override">[שלום]</text>
+</g>
+</svg>

Added: trunk/LayoutTests/svg/custom/glyph-selection-non-bmp-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/svg/custom/glyph-selection-non-bmp-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/svg/custom/glyph-selection-non-bmp-expected.txt (0 => 107211)


--- trunk/LayoutTests/svg/custom/glyph-selection-non-bmp-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/glyph-selection-non-bmp-expected.txt	2012-02-09 11:40:53 UTC (rev 107211)
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 200x50
+  RenderSVGRoot {svg} at (70,7) size 80x18
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+    RenderSVGContainer {g} at (70,7) size 80x18
+      RenderSVGText {text} at (70,7) size 80x18 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 80x18
+          chunk 1 text run 1 at (70.36,20.00) startOffset 0 endOffset 19 width 79.64 RTL override: "\x{DBC0}\x{DC5B}[\x{D800}\x{DC5B}]\x{DBC0}\x{DC5D} | \x{DBC0}\x{DC5B}[\x{D800}\x{DC5D}]\x{DBC0}\x{DC5D}"

Added: trunk/LayoutTests/svg/custom/glyph-selection-non-bmp.svg (0 => 107211)


--- trunk/LayoutTests/svg/custom/glyph-selection-non-bmp.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/glyph-selection-non-bmp.svg	2012-02-09 11:40:53 UTC (rev 107211)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="200px" height="50px">
+<!-- Test that SVG fonts correctly render non-bmp, complex characters and mirrored characters together -->
+<defs>
+  <font horiz-adv-x="573">
+    <font-face font-family="SVGAr" units-per-em="1000" panose-1="5 1 1 1 1 1 1 1 1 1" ascent="1025" descent="-399" alphabetic="0"/>
+    <missing-glyph horiz-adv-x="500" d="M31 0V800H469V0H31ZM438 31V769H62V31H438Z"/>
+    <glyph unicode=" " glyph-name="space" horiz-adv-x="370"/>
+    <glyph unicode="&#x0005d;" glyph-name="close-bracket" d="M213 -200h-195v73h108v770h-108v72h195v-915z"/>
+    <glyph unicode="&#x0005b;" glyph-name="open-bracket" d="M67 -200v915h195v-72h-106v-770h106v-73h-195z"/>
+    <glyph unicode="&#x1005b;" glyph-name="nonbmp1" d="M200 0L0 0L0 500L500 300L500 300L100 800L100 100L300 100Z"/>
+    <glyph unicode="&#x1005d;" glyph-name="nonbmp2" d="M200 0L0 0L0 300L500 300L500 300L600 800L100 100L300 100Z"/>
+    <glyph unicode="&#x10005b;" glyph-name="nonbmp3" d="M200 0L0 0L0 800L500 300L500 300L100 800L100 100L600 300Z"/>
+    <glyph unicode="&#x10005d;" glyph-name="nonbmp4" d="M200 0L0 0L0 300L500 300L100 500L200 800L100 100L300 100Z"/>
+  </font>
+</defs>
+<g font-family="SVGAr, serif" font-size="12">
+  <!-- This should show 3 non-bmp characters in an SVG font with the center -->
+  <!-- character in brackets. There should then be a space, a pipe, a space,-->
+  <!-- and 3 more non-bmp characters with the center character in brackets. -->
+  <!-- In both sets of 5 characters, the brackets should point inwards, -->
+  <!-- surrounding the center character. -->
+  <text x="150" y="20" direction="rtl" unicode-bidi="bidi-override">&#x10005b;&#x0005b;&#x1005b;&#x0005d;&#x10005d; | &#x10005b;&#x0005b;&#x1005d;&#x0005d;&#x10005d;</text>
+</g>
+</svg>

Modified: trunk/Source/WebCore/ChangeLog (107210 => 107211)


--- trunk/Source/WebCore/ChangeLog	2012-02-09 11:37:16 UTC (rev 107210)
+++ trunk/Source/WebCore/ChangeLog	2012-02-09 11:40:53 UTC (rev 107211)
@@ -1,3 +1,32 @@
+2012-02-09  Philip Rogers  <[email protected]>
+
+        Fix mirroring with SVG fonts
+        https://bugs.webkit.org/show_bug.cgi?id=77067
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG fonts were incorrectly handling mirrored characters in bidi text.
+        In this change I added the function createStringWithMirroredCharacters
+        which handles mirroring the characters when selecting glyphs for SVG
+        fonts. I also made a small cosmetic change in the function
+        charactersWithArabicForm, changing the bool parameter "mirror" to "rtl"
+        which better reflects what it actually does.
+
+        Several new tests were added to test mirroring with SVG fonts in the
+        presence of Arabic forms and non-BMP characters.
+
+        Tests: svg/custom/glyph-selection-arabic-forms.svg
+               svg/custom/glyph-selection-bidi-mirror.svg
+               svg/custom/glyph-selection-non-bmp.svg
+
+        * platform/graphics/SVGGlyph.cpp:
+        (WebCore::charactersWithArabicForm):
+        * svg/SVGFontData.cpp:
+        (WebCore::SVGFontData::applySVGGlyphSelection):
+        (WebCore::SVGFontData::createStringWithMirroredCharacters):
+        * svg/SVGFontData.h:
+        (SVGFontData):
+
 2012-02-09  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: Scripts navigator fails to reopen previously closed script.

Modified: trunk/Source/WebCore/platform/graphics/SVGGlyph.cpp (107210 => 107211)


--- trunk/Source/WebCore/platform/graphics/SVGGlyph.cpp	2012-02-09 11:37:16 UTC (rev 107210)
+++ trunk/Source/WebCore/platform/graphics/SVGGlyph.cpp	2012-02-09 11:40:53 UTC (rev 107211)
@@ -80,7 +80,7 @@
     return curForm;
 }
 
-Vector<SVGGlyph::ArabicForm> charactersWithArabicForm(const String& input, bool mirror)
+Vector<SVGGlyph::ArabicForm> charactersWithArabicForm(const String& input, bool rtl)
 {
     Vector<SVGGlyph::ArabicForm> forms;
     unsigned length = input.length();
@@ -99,7 +99,7 @@
     bool lastCharShapesRight = false;
 
     // Start identifying arabic forms
-    if (mirror) {
+    if (rtl) {
         for (int i = length - 1; i >= 0; --i)
             forms.prepend(processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.first()));
     } else {

Modified: trunk/Source/WebCore/svg/SVGFontData.cpp (107210 => 107211)


--- trunk/Source/WebCore/svg/SVGFontData.cpp	2012-02-09 11:37:16 UTC (rev 107210)
+++ trunk/Source/WebCore/svg/SVGFontData.cpp	2012-02-09 11:40:53 UTC (rev 107211)
@@ -31,7 +31,13 @@
 #include "TextRun.h"
 #include "WidthIterator.h"
 #include "XMLNames.h"
+#include <wtf/text/StringBuilder.h>
+#include <wtf/unicode/CharacterNames.h>
+#include <wtf/unicode/Unicode.h>
 
+using namespace WTF;
+using namespace Unicode;
+
 namespace WebCore {
 
 SVGFontData::SVGFontData(SVGFontFaceElement* fontFaceElement)
@@ -130,6 +136,8 @@
     // Associate text with arabic forms, if needed.
     String remainingTextInRun(run.data(currentCharacter), run.charactersLength() - currentCharacter);
     remainingTextInRun = Font::normalizeSpaces(remainingTextInRun.characters(), remainingTextInRun.length());
+    if (mirror)
+        remainingTextInRun = createStringWithMirroredCharacters(remainingTextInRun.characters(), remainingTextInRun.length());
     if (!currentCharacter && arabicForms.isEmpty())
         arabicForms = charactersWithArabicForm(remainingTextInRun, mirror);
 
@@ -260,7 +268,28 @@
     return haveGlyphs;
 }
 
+String SVGFontData::createStringWithMirroredCharacters(const UChar* characters, unsigned length) const
+{
+    StringBuilder mirroredCharacters;
+    mirroredCharacters.reserveCapacity(length);
 
+    UChar32 character;
+    unsigned i = 0;
+    while (i < length) {
+        U16_NEXT(characters, i, length, character);
+        character = mirroredChar(character);
+
+        if (U16_LENGTH(character) == 1)
+            mirroredCharacters.append(static_cast<UChar>(character));
+        else {
+            mirroredCharacters.append(U16_LEAD(character));
+            mirroredCharacters.append(U16_TRAIL(character));
+        }
+    }
+
+    return mirroredCharacters.toString();
+}
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/svg/SVGFontData.h (107210 => 107211)


--- trunk/Source/WebCore/svg/SVGFontData.h	2012-02-09 11:37:16 UTC (rev 107210)
+++ trunk/Source/WebCore/svg/SVGFontData.h	2012-02-09 11:40:53 UTC (rev 107211)
@@ -56,6 +56,8 @@
     bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
     bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned length, UChar* buffer, const SimpleFontData*) const;
 
+    String createStringWithMirroredCharacters(const UChar* characters, unsigned length) const;
+
     // Ths SVGFontFaceElement is kept alive --
     // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
     //    containing the element;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to