OpenTypeVerticalData issue with DroidSansFallback.ttf on chromium-android and chromiu...
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Oct 2012 00:38:16 +0000 (00:38 +0000)
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Oct 2012 00:38:16 +0000 (00:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97824

Reviewed by Tony Chang.

Source/WebCore:

The issue occurred when a font that contains vert GSUB table but doesn't have
a DFLT script and the first script doesn't have vert feature. Added logic to
handle the case.

Test: fast/writing-mode/vertical-subst-font-vert-no-dflt.html

* platform/graphics/opentype/OpenTypeVerticalData.cpp:
(FeatureList):
(WebCore::OpenType::FeatureList::findFeature): Added to find the matching feature in FeatureList.
(WebCore::OpenType::GSUBTable::feature): Added logic to handle the case of no DFLT script and no vert feature under the first script.

LayoutTests:

Ref test for the change. The punctuations in the vertical text are expected to
be substituted with the corresponding vertical forms.

* fast/writing-mode/vertical-subst-font-vert-no-dflt-expected.html: Added.
* fast/writing-mode/vertical-subst-font-vert-no-dflt.html: Added.
* platform/mac/TestExpectations: Added the new test as it fails on Mac because of https://bugs.webkit.org/show_bug.cgi?id=98560.

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

LayoutTests/ChangeLog
LayoutTests/fast/writing-mode/resources/DroidSansFallback-reduced.ttf
LayoutTests/fast/writing-mode/vertical-subst-font-vert-no-dflt-expected.html [new file with mode: 0644]
LayoutTests/fast/writing-mode/vertical-subst-font-vert-no-dflt.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp

index f3f9284..f292d87 100644 (file)
@@ -1,3 +1,17 @@
+2012-10-05  Xianzhu Wang  <wangxianzhu@chromium.org>
+
+        OpenTypeVerticalData issue with DroidSansFallback.ttf on chromium-android and chromium-linux
+        https://bugs.webkit.org/show_bug.cgi?id=97824
+
+        Reviewed by Tony Chang.
+
+        Ref test for the change. The punctuations in the vertical text are expected to
+        be substituted with the corresponding vertical forms.
+
+        * fast/writing-mode/vertical-subst-font-vert-no-dflt-expected.html: Added.
+        * fast/writing-mode/vertical-subst-font-vert-no-dflt.html: Added.
+        * platform/mac/TestExpectations: Added the new test as it fails on Mac because of https://bugs.webkit.org/show_bug.cgi?id=98560. 
+
 2012-10-05  Tony Chang  <tony@chromium.org>
 
         Form controls should always be horizontal
index 9d7f9d8..2f62ee8 100644 (file)
Binary files a/LayoutTests/fast/writing-mode/resources/DroidSansFallback-reduced.ttf and b/LayoutTests/fast/writing-mode/resources/DroidSansFallback-reduced.ttf differ
diff --git a/LayoutTests/fast/writing-mode/vertical-subst-font-vert-no-dflt-expected.html b/LayoutTests/fast/writing-mode/vertical-subst-font-vert-no-dflt-expected.html
new file mode 100644 (file)
index 0000000..48bfe64
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<!--
+The difference between the test file and this expectation file is that
+the punctuations are replaced by the characters that they should be
+substituted according to the vert GSUB table.
+-->
+<html>
+<head>
+<title>Vertical punctuations using font with GSUB/vert table not under dflt script</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style type="text/css">
+@font-face {
+    font-family: 'droid';
+    /* DroidSansFallback-reduced.ttf was generated based on Android's
+       DroidSansFallback.ttf by removing many glyphs to meet the size
+       requirement of web font face.
+       It contains GSUB and vert table but not under dflt script.
+    */
+    src: url('resources/DroidSansFallback-reduced.ttf');
+}
+#test {
+    font-size: 25px;
+    font-family: droid;
+    -webkit-writing-mode: vertical-rl;
+    height: 500px;
+}
+</style>
+</head>
+<body>
+Puctuations should be properly rotated and positioned.
+<div id="test">
+<!-- Punctuations are using the vertical substitution characters. -->
+&#xfe35;&#x4e00;&#xfe36;
+&#xfe39;&#x4e01;&#xfe3a;
+&#xfe37;&#x4e02;&#xfe38;
+</div>
+</body>
diff --git a/LayoutTests/fast/writing-mode/vertical-subst-font-vert-no-dflt.html b/LayoutTests/fast/writing-mode/vertical-subst-font-vert-no-dflt.html
new file mode 100644 (file)
index 0000000..73afcf1
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Vertical punctuations using font with GSUB/vert table not under dflt script</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style type="text/css">
+@font-face {
+    font-family: 'droid';
+    /* DroidSansFallback-reduced.ttf was generated based on Android's
+       DroidSansFallback.ttf by removing many glyphs to meet the size
+       requirement of web font face.
+       It contains GSUB and vert table but not under dflt script.
+    */
+    src: url('resources/DroidSansFallback-reduced.ttf');
+}
+#test {
+    font-size: 25px;
+    font-family: droid;
+    -webkit-writing-mode: vertical-rl;
+    height: 500px;
+}
+</style>
+</head>
+<body>
+Puctuations should be properly rotated and positioned.
+<div id="test">
+&#xff08;&#x4e00;&#xff09;
+&#x3014;&#x4e01;&#x3015;
+&#xff5b;&#x4e02;&#xff5d;
+</div>
+</body>
index d33054f..cd0e243 100644 (file)
@@ -1311,3 +1311,6 @@ webkit.org/b/95707 http/tests/images/png-partial-load-no-alpha.html [ ImageOnlyF
 
 # Requires TestRunner displayInvalidatedRegion() support.
 webkit.org/b/98523 fast/images/repaint-subrect-grid.html [ Failure ]
+
+# Rendering/Layout issue of CJK vertical text with some font.
+webkit.org/b/98560 fast/writing-mode/vertical-subst-font-vert-no-dflt.html [ ImageOnlyFailure ]
index 34dc557..1088740 100644 (file)
@@ -1,3 +1,21 @@
+2012-10-05  Xianzhu Wang  <wangxianzhu@chromium.org>
+
+        OpenTypeVerticalData issue with DroidSansFallback.ttf on chromium-android and chromium-linux
+        https://bugs.webkit.org/show_bug.cgi?id=97824
+
+        Reviewed by Tony Chang.
+
+        The issue occurred when a font that contains vert GSUB table but doesn't have
+        a DFLT script and the first script doesn't have vert feature. Added logic to
+        handle the case.
+
+        Test: fast/writing-mode/vertical-subst-font-vert-no-dflt.html
+
+        * platform/graphics/opentype/OpenTypeVerticalData.cpp:
+        (FeatureList):
+        (WebCore::OpenType::FeatureList::findFeature): Added to find the matching feature in FeatureList.
+        (WebCore::OpenType::GSUBTable::feature): Added logic to handle the case of no DFLT script and no vert feature under the first script.
+
 2012-10-05  Tony Chang  <tony@chromium.org>
 
         Form controls should always be horizontal
index 584d78f..67013b1 100644 (file)
@@ -256,6 +256,15 @@ struct FeatureList : TableBase {
             return validateOffset<FeatureTable>(buffer, features[index].featureOffset);
         return 0;
     }
+
+    const FeatureTable* findFeature(OpenType::Tag tag, const SharedBuffer& buffer) const
+    {
+        for (uint16_t i = 0; i < featureCount; ++i) {
+            if (isValidEnd(buffer, &features[i]) && features[i].featureTag == tag)
+                return validateOffset<FeatureTable>(buffer, features[i].featureOffset);
+        }
+        return 0;
+    }
 };
 
 struct LangSysTable : TableBase {
@@ -361,9 +370,17 @@ struct GSUBTable : TableBase {
     {
         const LangSysTable* langSys = defaultLangSys(buffer);
         const FeatureList* features = featureList(buffer);
-        if (!langSys || !features)
+        if (!features)
             return 0;
-        return langSys->feature(featureTag, features, buffer);
+        const FeatureTable* feature = 0;
+        if (langSys)
+            feature = langSys->feature(featureTag, features, buffer);
+        if (!feature) {
+            // If the font has no langSys table, or has no default script and the first script doesn't
+            // have the requested feature, then use the first matching feature directly.
+            feature = features->findFeature(featureTag, buffer);
+        }
+        return feature;
     }
 
     bool getVerticalGlyphSubstitutions(HashMap<Glyph, Glyph>* map, const SharedBuffer& buffer) const