[iOS] Codepoints not associated with languages are drawn as boxes
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Dec 2014 19:05:14 +0000 (19:05 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Dec 2014 19:05:14 +0000 (19:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138906

Patch by Myles C. Maxfield <mmaxfield@apple.com> on 2014-12-15
Reviewed by Darin Adler.

Source/WebCore:

Use SPI CTFontCreateForCharacters(), but only if we don't already know what to do
with the characters.

Test: platform/ios-simulator/fast/text/non-language-font-fallback.html

* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::FontCache::systemFallbackForCharacters):
* platform/spi/cocoa/CoreTextSPI.h:

LayoutTests:

* platform/ios-simulator/fast/text/non-language-font-fallback-expected.html: Added.
* platform/ios-simulator/fast/text/non-language-font-fallback.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/ios-simulator/fast/text/non-language-font-fallback-expected.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/text/non-language-font-fallback.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ios/FontCacheIOS.mm
Source/WebCore/platform/spi/cocoa/CoreTextSPI.h

index d322324..20629cd 100644 (file)
@@ -1,3 +1,13 @@
+2014-12-15  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Codepoints not associated with languages are drawn as boxes
+        https://bugs.webkit.org/show_bug.cgi?id=138906
+
+        Reviewed by Darin Adler.
+
+        * platform/ios-simulator/fast/text/non-language-font-fallback-expected.html: Added.
+        * platform/ios-simulator/fast/text/non-language-font-fallback.html: Added.
+
 2014-12-15  Alexey Proskuryakov  <ap@apple.com>
 
         http/tests/misc/webtiming-origins.html is flaky
diff --git a/LayoutTests/platform/ios-simulator/fast/text/non-language-font-fallback-expected.html b/LayoutTests/platform/ios-simulator/fast/text/non-language-font-fallback-expected.html
new file mode 100644 (file)
index 0000000..359141d
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that glyphs not associated with a particular language have an appropriate font chosen for them.
+<div style="font-size: 256px; font-family: Menlo-Regular;">&#x261A;</div>
+</body>
+</html>
diff --git a/LayoutTests/platform/ios-simulator/fast/text/non-language-font-fallback.html b/LayoutTests/platform/ios-simulator/fast/text/non-language-font-fallback.html
new file mode 100644 (file)
index 0000000..38f93a9
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that glyphs not associated with a particular language have an appropriate font chosen for them.
+<div style="font-size: 256px;">&#x261A;</div>
+</body>
+</html>
index 69fb1e8..673bdb5 100644 (file)
@@ -1,3 +1,19 @@
+2014-12-15  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Codepoints not associated with languages are drawn as boxes
+        https://bugs.webkit.org/show_bug.cgi?id=138906
+
+        Reviewed by Darin Adler.
+
+        Use SPI CTFontCreateForCharacters(), but only if we don't already know what to do
+        with the characters.
+
+        Test: platform/ios-simulator/fast/text/non-language-font-fallback.html
+
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/spi/cocoa/CoreTextSPI.h:
+
 2014-12-15  Bem Jones-Bey  <bjonesbe@adobe.com>
 
         [CSS Shapes] Fix StyleBuilder code to use CSSValueNone to match spec and other code
index b6306b1..8b36a42 100644 (file)
@@ -427,6 +427,11 @@ PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDesc
         }
         if (useEmojiFont)
             simpleFontData = getCachedFontData(description, appleColorEmoji, false, DoNotRetain);
+        else {
+            RetainPtr<CTFontRef> fallbackFont = adoptCF(CTFontCreateForCharacters(originalFontData->getCTFont(), characters, length, nullptr));
+            if (RetainPtr<CFStringRef> foundFontName = adoptCF(CTFontCopyPostScriptName(fallbackFont.get())))
+                simpleFontData = getCachedFontData(description, foundFontName.get(), false, DoNotRetain);
+        }
         break;
     }
     }
index f18d05e..23362b7 100644 (file)
@@ -90,6 +90,7 @@ CTFontRef CTFontCreatePhysicalFontForCharactersWithLanguage(CTFontRef, const UTF
 bool CTFontIsAppleColorEmoji(CTFontRef);
 bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
 CTFontRef CTFontCreateForCSS(CFStringRef name, uint16_t weight, CTFontSymbolicTraits, CGFloat size);
+CTFontRef CTFontCreateForCharacters(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFIndex *coveredLength);
 
 }