[iOS] Arabic text styled with Georgia is rendered as boxes
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Jun 2015 20:53:26 +0000 (20:53 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Jun 2015 20:53:26 +0000 (20:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145681
<rdar://problem/21169844>

Reviewed by Darin Adler.

Source/WebCore:

Georgia doesn't support Arabic, so we ask CoreText what font does support Arabic. It returns
TimesNewRomanPSMT. However, WebKit explicitly disallows this font on iOS. Therefore, instead
of using TimesNewRomanPSMT, we will simply just use GeezaPro.

Test: fast/text/arabic-times-new-roman.html

* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/Font.h: Let FontCacheIOS call fontFamilyShouldNotBeUsedForArabic()
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::fontFamilyShouldNotBeUsedForArabic):

LayoutTests:

* fast/text/arabic-times-new-roman.html: Added.
* platform/ios-simulator/fast/text/arabic-times-new-roman-expected.txt: Added.
* platform/ios-simulator/fast/text/arabic-times-new-roman-expected.png: Added.
* platform/mac-mavericks/fast/text/arabic-times-new-roman-expected.txt: Added.
* platform/mac/fast/text/arabic-times-new-roman-expected.txt: Added.
* platform/mac/fast/text/arabic-times-new-roman-expected.png: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/arabic-times-new-roman.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/text/arabic-times-new-roman-expected.png [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/text/arabic-times-new-roman-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-mavericks/fast/text/arabic-times-new-roman-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/arabic-times-new-roman-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/arabic-times-new-roman-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/cocoa/FontCocoa.mm
Source/WebCore/platform/graphics/ios/FontCacheIOS.mm

index f279f00..9458504 100644 (file)
@@ -1,3 +1,18 @@
+2015-06-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Arabic text styled with Georgia is rendered as boxes
+        https://bugs.webkit.org/show_bug.cgi?id=145681
+        <rdar://problem/21169844>
+
+        Reviewed by Darin Adler.
+
+        * fast/text/arabic-times-new-roman.html: Added.
+        * platform/ios-simulator/fast/text/arabic-times-new-roman-expected.txt: Added.
+        * platform/ios-simulator/fast/text/arabic-times-new-roman-expected.png: Added.
+        * platform/mac-mavericks/fast/text/arabic-times-new-roman-expected.txt: Added.
+        * platform/mac/fast/text/arabic-times-new-roman-expected.txt: Added.
+        * platform/mac/fast/text/arabic-times-new-roman-expected.png: Added.
+
 2015-06-22  Zalan Bujtas  <zalan@apple.com>
 
         REGRESSION(r169105) Dangling renderer pointer in SelectionSubtreeRoot::SelectionSubtreeData.
diff --git a/LayoutTests/fast/text/arabic-times-new-roman.html b/LayoutTests/fast/text/arabic-times-new-roman.html
new file mode 100644 (file)
index 0000000..a7b9158
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that rendering Arabic with Georgia (which doesn't support Arabic) has a sensible result (e.g. not .notdef boxes)
+<div style="font: 50px Georgia;">&#x62f;&#x64a;&#x645;&#x648;&#x63a;&#x631;&#x627;&#x641;&#x64a;&#x627;&#x62a;</div>
+<div style="font: 50px 'Times New Roman';">&#x62f;&#x64a;&#x645;&#x648;&#x63a;&#x631;&#x627;&#x641;&#x64a;&#x627;&#x62a;</div>
+</body>
+</html>
diff --git a/LayoutTests/platform/ios-simulator/fast/text/arabic-times-new-roman-expected.png b/LayoutTests/platform/ios-simulator/fast/text/arabic-times-new-roman-expected.png
new file mode 100644 (file)
index 0000000..fba9592
Binary files /dev/null and b/LayoutTests/platform/ios-simulator/fast/text/arabic-times-new-roman-expected.png differ
diff --git a/LayoutTests/platform/ios-simulator/fast/text/arabic-times-new-roman-expected.txt b/LayoutTests/platform/ios-simulator/fast/text/arabic-times-new-roman-expected.txt
new file mode 100644 (file)
index 0000000..70df317
--- /dev/null
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x194
+  RenderBlock {HTML} at (0,0) size 800x194
+    RenderBody {BODY} at (8,8) size 784x178
+      RenderBlock (anonymous) at (0,0) size 784x40
+        RenderText {#text} at (0,0) size 750x39
+          text run at (0,0) width 750: "This test makes sure that rendering Arabic with Georgia (which doesn't support Arabic) has a sensible result (e.g. not"
+          text run at (0,20) width 92: ".notdef boxes)"
+      RenderBlock {DIV} at (0,40) size 784x69
+        RenderText {#text} at (0,2) size 207x57
+          text run at (0,2) width 207 RTL: "\x{62F}\x{64A}\x{645}\x{648}\x{63A}\x{631}\x{627}\x{641}\x{64A}\x{627}\x{62A}"
+      RenderBlock {DIV} at (0,109) size 784x69
+        RenderText {#text} at (0,3) size 207x56
+          text run at (0,3) width 207 RTL: "\x{62F}\x{64A}\x{645}\x{648}\x{63A}\x{631}\x{627}\x{641}\x{64A}\x{627}\x{62A}"
diff --git a/LayoutTests/platform/mac-mavericks/fast/text/arabic-times-new-roman-expected.txt b/LayoutTests/platform/mac-mavericks/fast/text/arabic-times-new-roman-expected.txt
new file mode 100644 (file)
index 0000000..74d5650
--- /dev/null
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x179
+  RenderBlock {HTML} at (0,0) size 800x179
+    RenderBody {BODY} at (8,8) size 784x163
+      RenderBlock (anonymous) at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 750x36
+          text run at (0,0) width 750: "This test makes sure that rendering Arabic with Georgia (which doesn't support Arabic) has a sensible result (e.g. not"
+          text run at (0,18) width 92: ".notdef boxes)"
+      RenderBlock {DIV} at (0,36) size 784x69
+        RenderText {#text} at (0,2) size 207x57
+          text run at (0,2) width 207 RTL: "\x{62F}\x{64A}\x{645}\x{648}\x{63A}\x{631}\x{627}\x{641}\x{64A}\x{627}\x{62A}"
+      RenderBlock {DIV} at (0,105) size 784x58
+        RenderText {#text} at (0,1) size 205x56
+          text run at (0,1) width 205 RTL: "\x{62F}\x{64A}\x{645}\x{648}\x{63A}\x{631}\x{627}\x{641}\x{64A}\x{627}\x{62A}"
diff --git a/LayoutTests/platform/mac/fast/text/arabic-times-new-roman-expected.png b/LayoutTests/platform/mac/fast/text/arabic-times-new-roman-expected.png
new file mode 100644 (file)
index 0000000..08c8762
Binary files /dev/null and b/LayoutTests/platform/mac/fast/text/arabic-times-new-roman-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/text/arabic-times-new-roman-expected.txt b/LayoutTests/platform/mac/fast/text/arabic-times-new-roman-expected.txt
new file mode 100644 (file)
index 0000000..74d5650
--- /dev/null
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x179
+  RenderBlock {HTML} at (0,0) size 800x179
+    RenderBody {BODY} at (8,8) size 784x163
+      RenderBlock (anonymous) at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 750x36
+          text run at (0,0) width 750: "This test makes sure that rendering Arabic with Georgia (which doesn't support Arabic) has a sensible result (e.g. not"
+          text run at (0,18) width 92: ".notdef boxes)"
+      RenderBlock {DIV} at (0,36) size 784x69
+        RenderText {#text} at (0,2) size 207x57
+          text run at (0,2) width 207 RTL: "\x{62F}\x{64A}\x{645}\x{648}\x{63A}\x{631}\x{627}\x{641}\x{64A}\x{627}\x{62A}"
+      RenderBlock {DIV} at (0,105) size 784x58
+        RenderText {#text} at (0,1) size 205x56
+          text run at (0,1) width 205 RTL: "\x{62F}\x{64A}\x{645}\x{648}\x{63A}\x{631}\x{627}\x{641}\x{64A}\x{627}\x{62A}"
index 58fc8b3..ed0abd9 100644 (file)
@@ -1,3 +1,23 @@
+2015-06-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Arabic text styled with Georgia is rendered as boxes
+        https://bugs.webkit.org/show_bug.cgi?id=145681
+        <rdar://problem/21169844>
+
+        Reviewed by Darin Adler.
+
+        Georgia doesn't support Arabic, so we ask CoreText what font does support Arabic. It returns
+        TimesNewRomanPSMT. However, WebKit explicitly disallows this font on iOS. Therefore, instead
+        of using TimesNewRomanPSMT, we will simply just use GeezaPro.
+
+        Test: fast/text/arabic-times-new-roman.html
+
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/Font.h: Let FontCacheIOS call fontFamilyShouldNotBeUsedForArabic()
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::fontFamilyShouldNotBeUsedForArabic):
+
 2015-06-22  Alex Christensen  <achristensen@webkit.org>
 
         Unreviewed non-mac debug build fix after r185840.
index 6b68bac..b04b0da 100644 (file)
@@ -322,6 +322,10 @@ private:
 #endif
 };
 
+#if PLATFORM(IOS)
+bool fontFamilyShouldNotBeUsedForArabic(CFStringRef);
+#endif
+
 ALWAYS_INLINE FloatRect Font::boundsForGlyph(Glyph glyph) const
 {
     if (isZeroWidthSpaceGlyph(glyph))
index f004fd4..4a3a5ef 100644 (file)
@@ -79,7 +79,7 @@ static NSString *webFallbackFontFamily(void)
     return webFallbackFontFamily;
 }
 #else
-static bool fontFamilyShouldNotBeUsedForArabic(CFStringRef fontFamilyName)
+bool fontFamilyShouldNotBeUsedForArabic(CFStringRef fontFamilyName)
 {
     if (!fontFamilyName)
         return false;
index 49a4796..fd49b7d 100644 (file)
@@ -446,8 +446,14 @@ RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr
     }
 #else
     RetainPtr<CTFontDescriptorRef> fallbackFontDescriptor = adoptCF(CTFontCreatePhysicalFontDescriptorForCharactersWithLanguage(originalFontData->getCTFont(), characters, length, nullptr, nullptr));
-    if (RetainPtr<CFStringRef> foundFontName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(fallbackFontDescriptor.get(), kCTFontNameAttribute))))
+    if (auto foundFontName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(fallbackFontDescriptor.get(), kCTFontNameAttribute)))) {
+        if (c >= 0x0600 && c <= 0x06ff) { // Arabic
+            auto familyName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(fallbackFontDescriptor.get(), kCTFontFamilyNameAttribute)));
+            if (fontFamilyShouldNotBeUsedForArabic(familyName.get()))
+                foundFontName = isFontWeightBold(description.weight()) ? CFSTR("GeezaPro-Bold") : CFSTR("GeezaPro");
+        }
         font = fontForFamily(description, foundFontName.get(), false);
+    }
 #endif
 
     if (font)