Title: [188167] trunk
Revision
188167
Author
mmaxfi...@apple.com
Date
2015-08-07 14:49:42 -0700 (Fri, 07 Aug 2015)

Log Message

Source/WebCore:
[Cocoa] Font fallback is not language-sensitive
https://bugs.webkit.org/show_bug.cgi?id=147390

Reviewed by Dean Jackson.

We need to make our font fallback code sensitive to locale.

This patch rolls r187729 back in. However, only particular versions of iOS and OS X are
performant enough to enable this language-sensitivity.

This patch also applies to iOS.

Test: fast/text/fallback-language-han.html

* platform/graphics/mac/FontCacheMac.mm:
(WebCore::lookupCTFont):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/mac/FontCacheIOS.mm:
(WebCore::FontCache::systemFallbackForCharacters):

LayoutTests:
[OS X] Font fallback is not language-sensitive
https://bugs.webkit.org/show_bug.cgi?id=147390

Reviewed by Dean Jackson.

This test is expected to fail most places.

* fast/text/fallback-language-han-expected.html: Added.
* fast/text/fallback-language-han.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/win/TestExpectations:
* platform/mac/TestExpectations:
* platform/iOS/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (188166 => 188167)


--- trunk/LayoutTests/ChangeLog	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/ChangeLog	2015-08-07 21:49:42 UTC (rev 188167)
@@ -1,3 +1,20 @@
+2015-08-07  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [OS X] Font fallback is not language-sensitive
+        https://bugs.webkit.org/show_bug.cgi?id=147390
+
+        Reviewed by Dean Jackson.
+
+        This test is expected to fail most places.
+
+        * fast/text/fallback-language-han-expected.html: Added.
+        * fast/text/fallback-language-han.html: Added.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/win/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/iOS/TestExpectations:
+
 2015-08-07  Simon Fraser  <simon.fra...@apple.com>
 
         Move platform/mac/fast/scrolling/ tests into fast/scrolling/latching/

Added: trunk/LayoutTests/fast/text/fallback-language-han-expected.html (0 => 188167)


--- trunk/LayoutTests/fast/text/fallback-language-han-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/fallback-language-han-expected.html	2015-08-07 21:49:42 UTC (rev 188167)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+This test makes sure that the "lang" attribute is properly consulted when using fallback fonts. The first character
+is shown with a lang which represents Simplified Chinese, and the second character is shown with a lang which
+represents Traditional Chinese. The character is one which is drawn differently in the two languages, so the
+two characters should look different. This tests against a hardcoded font selection which should be the result of
+FontCache::systemFallbackForCharacters().
+<div style="font: 200px Times;">
+<span lang="zh-Hans" style="font-family: STSongti-SC-Regular;">&#x9ad4;</span>
+<span lang="zh-Hant" style="font-family: STSongti-TC-Regular;">&#x9ad4;</span>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/fallback-language-han.html (0 => 188167)


--- trunk/LayoutTests/fast/text/fallback-language-han.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/fallback-language-han.html	2015-08-07 21:49:42 UTC (rev 188167)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that the "lang" attribute is properly consulted when using fallback fonts. The first character
+is shown with a lang which represents Simplified Chinese, and the second character is shown with a lang which
+represents Traditional Chinese. The character is one which is drawn differently in the two languages, so the
+two characters should look different. This tests against a hardcoded font selection which should be the result of
+FontCache::systemFallbackForCharacters().
+<div style="font: 200px Times;">
+<span lang="zh-Hans">&#x9ad4;</span>
+<span lang="zh-Hant">&#x9ad4;</span>
+</div>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/efl/TestExpectations (188166 => 188167)


--- trunk/LayoutTests/platform/efl/TestExpectations	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2015-08-07 21:49:42 UTC (rev 188167)
@@ -2250,3 +2250,6 @@
 webkit.org/b/146887 accessibility/table-fallback-roles-expose-element-attributes.html [ Failure ]
 webkit.org/b/146887 accessibility/table-with-footer-section-above-body.html [ Failure ]
 webkit.org/b/146887 accessibility/table-with-missing-aria-role-rows.html [ Failure ]
+
+# This test hardcodes the result of a platform-dependent font lookup algorithm.
+fast/text/fallback-language-han.html [ Skip ]

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (188166 => 188167)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2015-08-07 21:49:42 UTC (rev 188167)
@@ -2417,3 +2417,6 @@
 # Test requires hardcoded font names, which I do not have for this port.
 fast/text/han-generic-font-families.html [ WontFix ]
 fast/text/hangul-generic-font-families.html [ WontFix ]
+
+# This test hardcodes the result of a platform-dependent font lookup algorithm.
+fast/text/fallback-language-han.html [ Skip ]

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (188166 => 188167)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2015-08-07 21:49:42 UTC (rev 188167)
@@ -2699,3 +2699,6 @@
 # This test depends on location, and it is impossible to mock the particular mechanism
 # this test uses to determine location.
 fast/text/softbank-emoji.html [ Failure Pass ]
+
+# This test hardcodes the result of the Mac font lookup algorithm.
+fast/text/fallback-language-han.html [ Skip ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (188166 => 188167)


--- trunk/LayoutTests/platform/mac/TestExpectations	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2015-08-07 21:49:42 UTC (rev 188167)
@@ -1310,3 +1310,6 @@
 
 webkit.org/b/147763 [ Mavericks ] accessibility/mac/loaded-notification.html [ Skip ]
 webkit.org/b/147763 [ Yosemite ] accessibility/mac/loaded-notification.html [ Skip ]
+
+# Language-specific font fallback is disabled on certain versions of OS X
+webkit.org/b/147390 fast/text/fallback-language-han.html [ Failure ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (188166 => 188167)


--- trunk/LayoutTests/platform/win/TestExpectations	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/LayoutTests/platform/win/TestExpectations	2015-08-07 21:49:42 UTC (rev 188167)
@@ -3146,3 +3146,6 @@
 fast/repaint/block-inputrange-repaint.html [ Pass Failure ]
 
 fast/inline/padding-ellipsis-right.html [ ImageOnlyFailure ]
+
+# This test hardcodes the result of a platform-dependent font lookup algorithm.
+fast/text/fallback-language-han.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (188166 => 188167)


--- trunk/Source/WebCore/ChangeLog	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/Source/WebCore/ChangeLog	2015-08-07 21:49:42 UTC (rev 188167)
@@ -1,3 +1,25 @@
+2015-08-07  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] Font fallback is not language-sensitive
+        https://bugs.webkit.org/show_bug.cgi?id=147390
+
+        Reviewed by Dean Jackson.
+
+        We need to make our font fallback code sensitive to locale.
+
+        This patch rolls r187729 back in. However, only particular versions of iOS and OS X are
+        performant enough to enable this language-sensitivity.
+
+        This patch also applies to iOS.
+
+        Test: fast/text/fallback-language-han.html
+
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::lookupCTFont):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/mac/FontCacheIOS.mm:
+        (WebCore::FontCache::systemFallbackForCharacters):
+
 2015-08-07  Zalan Bujtas  <za...@apple.com>
 
         RenderTheme::volumeSliderOffsetFromMuteButton should take const& RenderBox.

Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (188166 => 188167)


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-08-07 21:49:42 UTC (rev 188167)
@@ -80,8 +80,14 @@
     const FontPlatformData& platformData = originalFontData->platformData();
     CTFontRef ctFont = platformData.font();
 
+    RetainPtr<CFStringRef> localeString;
+#if __IPHONE_OS_VERSION_MIN_REQUIRED > 90000
+    if (!description.locale().isNull())
+        localeString = description.locale().string().createCFString();
+#endif
+
     CFIndex coveredLength = 0;
-    RetainPtr<CTFontRef> substituteFont = adoptCF(CTFontCreatePhysicalFontForCharactersWithLanguage(ctFont, (const UTF16Char*)characters, (CFIndex)length, 0, &coveredLength));
+    RetainPtr<CTFontRef> substituteFont = adoptCF(CTFontCreatePhysicalFontForCharactersWithLanguage(ctFont, (const UTF16Char*)characters, (CFIndex)length, localeString.get(), &coveredLength));
     if (!substituteFont)
         return nullptr;
 

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (188166 => 188167)


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-08-07 21:44:56 UTC (rev 188166)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-08-07 21:49:42 UTC (rev 188167)
@@ -484,9 +484,11 @@
         fallbackDedupSet().remove(font);
 }
 
-static inline RetainPtr<CTFontRef> lookupCTFont(CTFontRef font, float fontSize, const UChar* characters, unsigned length)
+static inline RetainPtr<CTFontRef> lookupCTFont(CTFontRef font, float fontSize, const AtomicString& locale, const UChar* characters, unsigned length)
 {
+    RetainPtr<CFStringRef> localeString;
 #if __MAC_OS_X_VERSION_MIN_REQUIRED == 1090
+    UNUSED_PARAM(locale);
     if (!font) {
         font = reinterpret_cast<CTFontRef>([NSFont userFontOfSize:fontSize]);
         bool acceptable = true;
@@ -501,18 +503,24 @@
         if (acceptable)
             return font;
     }
+#elif __MAC_OS_X_VERSION_MIN_REQUIRED > 101100
+    UNUSED_PARAM(fontSize);
+    if (!locale.isNull())
+        localeString = locale.string().createCFString();
 #else
     UNUSED_PARAM(fontSize);
+    UNUSED_PARAM(locale);
 #endif
+
     CFIndex coveredLength = 0;
-    return adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, nullptr, &coveredLength));
+    return adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, localeString.get(), &coveredLength));
 }
 
 RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font* originalFontData, bool isPlatformFont, const UChar* characters, unsigned length)
 {
     const FontPlatformData& platformData = originalFontData->platformData();
     NSFont *nsFont = platformData.nsFont();
-    RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), characters, length);
+    RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), description.locale(), characters, length);
     if (result && description.featureSettings() && description.featureSettings()->size())
         result = applyFontFeatureSettings(result.get(), *description.featureSettings());
     if (!result)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to