[Cairo] Add complex font drawing using HarfbuzzNG
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2012 14:21:10 +0000 (14:21 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2012 14:21:10 +0000 (14:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91864

Patch by Dominik Röttsches <dominik.rottsches@intel.com> on 2012-08-02
Reviewed by Martin Robinson.

Source/WebCore:

Unfortunately the Freetype based approach that avoids allocations and UTF8 conversion
fails to produce correct results for some tests.

No new tests, at least
  fast/dom/52776.html
  fast/text/atsui-negative-spacing-features.html
  fast/text/atsui-spacing-features.html
expose this problem.

* platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp:
(WebCore::harfbuzzGetGlyph): Revert to initial cairo_scaled_font based approach.

LayoutTests:

Unskipping tests, now passing with valid complex font results.

* platform/efl/TestExpectations:
* platform/efl/fast/text/atsui-pointtooffset-calls-cg-expected.txt:
* platform/efl/fast/text/international/text-spliced-font-expected.png: Added.
* platform/efl/fast/text/international/text-spliced-font-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124454 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/efl/fast/text/atsui-pointtooffset-calls-cg-expected.txt
LayoutTests/platform/efl/fast/text/international/text-spliced-font-expected.png [new file with mode: 0644]
LayoutTests/platform/efl/fast/text/international/text-spliced-font-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp

index 0966cb8..6a15acf 100644 (file)
@@ -1,3 +1,17 @@
+2012-08-02  Dominik Röttsches  <dominik.rottsches@intel.com>
+
+        [Cairo] Add complex font drawing using HarfbuzzNG
+        https://bugs.webkit.org/show_bug.cgi?id=91864
+
+        Reviewed by Martin Robinson.
+
+        Unskipping tests, now passing with valid complex font results.
+
+        * platform/efl/TestExpectations:
+        * platform/efl/fast/text/atsui-pointtooffset-calls-cg-expected.txt:
+        * platform/efl/fast/text/international/text-spliced-font-expected.png: Added.
+        * platform/efl/fast/text/international/text-spliced-font-expected.txt: Added.
+
 2012-08-02  Alexander Pavlov  <apavlov@chromium.org>
 
         [Chromium] Unreviewed, mark accessibility/loading-iframe-updates-axtree.html as crashy on Mac.
index 5e1e2fc..ee27138 100644 (file)
@@ -359,13 +359,6 @@ BUGWK84593 : animations/animation-api-1.html = TEXT
 BUGWKEFL SKIP : storage/indexeddb = PASS
 BUGWKEFL SKIP : http/tests/inspector/indexeddb = PASS
 
-// harfbuzzGetGlyph is producing incorrect results.
-BUGWK91864 : fast/dom/52776.html = TEXT
-BUGWK91864 : fast/text/atsui-negative-spacing-features.html = TEXT
-BUGWK91864 : fast/text/atsui-pointtooffset-calls-cg.html = TEXT
-BUGWK91864 : fast/text/atsui-spacing-features.html = TEXT
-BUGWK91864 : fast/text/international/text-spliced-font.html = MISSING
-
 // Quota API is not supported.
 BUGWKEFL SKIP : storage/storageinfo-missing-arguments.html = PASS
 BUGWKEFL SKIP : storage/storageinfo-no-callbacks.html = PASS
index e61b67b..f9a4837 100644 (file)
@@ -16,4 +16,4 @@ layer at (0,0) size 800x600
             text run at (0,18) width 62: "code path"
         RenderText {#text} at (62,18) size 632x19
           text run at (62,18) width 632: " by clicking the X and verifying that the correct caret position (13) is reported to the editing delegate."
-caret: position 11 of child 2 {#text} of body
+caret: position 13 of child 2 {#text} of body
diff --git a/LayoutTests/platform/efl/fast/text/international/text-spliced-font-expected.png b/LayoutTests/platform/efl/fast/text/international/text-spliced-font-expected.png
new file mode 100644 (file)
index 0000000..cd9e6d2
Binary files /dev/null and b/LayoutTests/platform/efl/fast/text/international/text-spliced-font-expected.png differ
diff --git a/LayoutTests/platform/efl/fast/text/international/text-spliced-font-expected.txt b/LayoutTests/platform/efl/fast/text/international/text-spliced-font-expected.txt
new file mode 100644 (file)
index 0000000..a77cf0a
--- /dev/null
@@ -0,0 +1,44 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x522
+  RenderBlock {HTML} at (0,0) size 800x522
+    RenderBody {BODY} at (8,16) size 784x498
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 110x19
+          text run at (0,0) width 110: "Simple text path: "
+        RenderInline {SPAN} at (0,0) size 163x19
+          RenderText {#text} at (110,0) size 163x19
+            text run at (110,0) width 163: "string\x{300C}\x{3042}\x{3001}\x{5909}\x{3063}\x{FF01}\x{300D}\x{3002}"
+      RenderBlock (anonymous) at (0,34) size 784x202
+        RenderBlock {SPAN} at (0,0) size 18x163
+          RenderText {#text} at (0,0) size 19x163
+            text run at (0,0) width 163: "string\x{300C}\x{3042}\x{3001}\x{5909}\x{3063}\x{FF01}\x{300D}\x{3002}"
+        RenderBR {BR} at (18,148) size 0x19
+        RenderInline {SPAN} at (0,0) size 220x19
+          RenderText {#text} at (0,166) size 220x19
+            text run at (0,166) width 220: "\x{90CA}\x{5916}\x{306E}\x{304E}\x{3089}\x{304E}\x{3089}\x{3072}\x{304B}\x{308B}\x{8349}\x{306E}\x{6CE2}\x{3002}"
+        RenderBR {BR} at (220,166) size 0x19
+        RenderInline {SPAN} at (0,0) size 314x19
+          RenderText {#text} at (0,184) size 314x19
+            text run at (0,184) width 314: "ABCDEFGHIJKLM abcdefghijklm 1234567890"
+        RenderBR {BR} at (314,184) size 0x19
+      RenderBlock {HR} at (0,244) size 784x2 [border: (1px inset #000000)]
+      RenderBlock {P} at (0,262) size 784x18
+        RenderText {#text} at (0,0) size 124x19
+          text run at (0,0) width 124: "Complex text path: "
+        RenderInline {SPAN} at (0,0) size 163x19
+          RenderText {#text} at (124,0) size 163x19
+            text run at (124,0) width 163: "string\x{300C}\x{3042}\x{3001}\x{5909}\x{3063}\x{FF01}\x{300D}\x{3002}"
+      RenderBlock (anonymous) at (0,296) size 784x202
+        RenderBlock {SPAN} at (0,0) size 18x163
+          RenderText {#text} at (0,0) size 19x163
+            text run at (0,0) width 163: "string\x{300C}\x{3042}\x{3001}\x{5909}\x{3063}\x{FF01}\x{300D}\x{3002}"
+        RenderBR {BR} at (18,148) size 0x19
+        RenderInline {SPAN} at (0,0) size 220x19
+          RenderText {#text} at (0,166) size 220x19
+            text run at (0,166) width 220: "\x{90CA}\x{5916}\x{306E}\x{304E}\x{3089}\x{304E}\x{3089}\x{3072}\x{304B}\x{308B}\x{8349}\x{306E}\x{6CE2}\x{3002}"
+        RenderBR {BR} at (220,166) size 0x19
+        RenderInline {SPAN} at (0,0) size 314x19
+          RenderText {#text} at (0,184) size 314x19
+            text run at (0,184) width 314: "ABCDEFGHIJKLM abcdefghijklm 1234567890"
+        RenderBR {BR} at (314,184) size 0x19
index 86db2dc..82e45c3 100644 (file)
@@ -1,3 +1,22 @@
+2012-08-02  Dominik Röttsches  <dominik.rottsches@intel.com>
+
+        [Cairo] Add complex font drawing using HarfbuzzNG
+        https://bugs.webkit.org/show_bug.cgi?id=91864
+
+        Reviewed by Martin Robinson.
+
+        Unfortunately the Freetype based approach that avoids allocations and UTF8 conversion
+        fails to produce correct results for some tests.
+
+        No new tests, at least
+          fast/dom/52776.html
+          fast/text/atsui-negative-spacing-features.html
+          fast/text/atsui-spacing-features.html
+        expose this problem.
+
+        * platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp:
+        (WebCore::harfbuzzGetGlyph): Revert to initial cairo_scaled_font based approach.
+
 2012-08-02  Eugene Klyuchnikov  <eustas.big@gmail.com>
 
         Web Inspector: Fix protocol version check.
index 8c56f2a..0f9bb43 100644 (file)
@@ -95,11 +95,17 @@ static hb_bool_t harfbuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin
     FontPlatformData* platformData = reinterpret_cast<FontPlatformData*>(fontData);
     cairo_scaled_font_t* scaledFont = platformData->scaledFont();
     ASSERT(scaledFont);
-    CairoFtFaceLocker cairoFtFaceLocker(scaledFont);
-    FT_Face ftFace = cairoFtFaceLocker.lock();
-    ASSERT(ftFace);
-    *glyph = FT_Get_Char_Index(ftFace, unicode);
-    return !!*glyph;
+
+    cairo_glyph_t* glyphs = 0;
+    int numGlyphs = 0;
+    CString utf8Codepoint = UTF8Encoding().encode(reinterpret_cast<UChar*>(&unicode), 1, QuestionMarksForUnencodables);
+    if (CAIRO_STATUS_SUCCESS != cairo_scaled_font_text_to_glyphs(scaledFont, 0, 0, utf8Codepoint.data(), utf8Codepoint.length(), &glyphs, &numGlyphs, 0, 0, 0))
+        return false;
+    if (!numGlyphs)
+        return false;
+    *glyph = glyphs[0].index;
+    cairo_glyph_free(glyphs);
+    return true;
 }
 
 static hb_position_t harfbuzzGetGlyphHorizontalAdvance(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, void* userData)