[iOS] Narrow non-breaking space does not fall back to a correct font
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Dec 2014 22:10:40 +0000 (22:10 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Dec 2014 22:10:40 +0000 (22:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139335

Reviewed by Enrica Casucci.

Source/WebCore:

Test: fast/text/narrow-non-breaking-space.html

* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::requiresCustomFallbackFont):
(WebCore::FontCache::getCustomFallbackFont):

LayoutTests:

* fast/text/narrow-non-breaking-space-expected.html: Added.
* fast/text/narrow-non-breaking-space.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/narrow-non-breaking-space-expected.html [new file with mode: 0644]
LayoutTests/fast/text/narrow-non-breaking-space.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ios/FontCacheIOS.mm

index 33124158226694880d9300c995a22ce9695687f0..f0d07bdae9b71f3f4b1a5b9c8d862d4dd7559594 100644 (file)
@@ -1,3 +1,13 @@
+2014-12-08  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Narrow non-breaking space does not fall back to a correct font
+        https://bugs.webkit.org/show_bug.cgi?id=139335
+
+        Reviewed by Enrica Casucci.
+
+        * fast/text/narrow-non-breaking-space-expected.html: Added.
+        * fast/text/narrow-non-breaking-space.html: Added.
+
 2014-12-08  Javier Fernandez  <jfernandez@igalia.com>
 
         [CSS Grid Layout] Grid items must set a new formatting context.
diff --git a/LayoutTests/fast/text/narrow-non-breaking-space-expected.html b/LayoutTests/fast/text/narrow-non-breaking-space-expected.html
new file mode 100644 (file)
index 0000000..da5f83a
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html style="-webkit-writing-mode: vertical-rl; font-family: STHeitiTC-Light, 'Heiti TC';">
+<body>
+This test makes sure that a narrow non-breaking space does not draw as a .notdef character.
+This character is a U+202f narrow non-breaking space: ""
+</body>
+</html>
+
diff --git a/LayoutTests/fast/text/narrow-non-breaking-space.html b/LayoutTests/fast/text/narrow-non-breaking-space.html
new file mode 100644 (file)
index 0000000..b6129a2
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html style="-webkit-writing-mode: vertical-rl; font-family: STHeitiTC-Light, 'Heiti TC';">
+<body>
+This test makes sure that a narrow non-breaking space does not draw as a .notdef character.
+This character is a U+202f narrow non-breaking space: "&#x202f;"
+</body>
+</html>
+
index e8d02531a5b24074041a0a9b3aab3be8449bcc27..10ba965e4d1b7e7f2c5cad3be5e5044a6e282227 100644 (file)
@@ -1,3 +1,16 @@
+2014-12-08  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Narrow non-breaking space does not fall back to a correct font
+        https://bugs.webkit.org/show_bug.cgi?id=139335
+
+        Reviewed by Enrica Casucci.
+
+        Test: fast/text/narrow-non-breaking-space.html
+
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::requiresCustomFallbackFont):
+        (WebCore::FontCache::getCustomFallbackFont):
+
 2014-12-08  Daniel Bates  <dabates@apple.com>
 
         [iOS] Fix the WebKit build with the public SDK
index 059a0c8d6153ca7f4f5a542e71c56a896bf57ee9..b6306b12fd7b028b4a76107fd70d878808142016 100644 (file)
@@ -50,7 +50,7 @@ static inline bool isFontWeightBold(NSInteger fontWeight)
 
 static inline bool requiresCustomFallbackFont(const UInt32 character)
 {
-    return character == AppleLogo || character == blackCircle;
+    return character == AppleLogo || character == blackCircle || character == narrowNonBreakingSpace;
 }
 
 static CFCharacterSetRef copyFontCharacterSet(CFStringRef fontName)
@@ -487,15 +487,30 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
 FontPlatformData* FontCache::getCustomFallbackFont(const UInt32 c, const FontDescription& description)
 {
     ASSERT(requiresCustomFallbackFont(c));
-    if (c == AppleLogo) {
-        static NeverDestroyed<AtomicString> helveticaFamily("Helvetica Neue", AtomicString::ConstructFromLiteral);
-        return getCachedFontPlatformData(description, helveticaFamily);
-    }
-    if (c == blackCircle) {
-        static NeverDestroyed<AtomicString> lockClockFamily("LockClock-Light", AtomicString::ConstructFromLiteral);
-        return getCachedFontPlatformData(description, lockClockFamily);
+
+    static NeverDestroyed<AtomicString> helveticaFamily("Helvetica Neue", AtomicString::ConstructFromLiteral);
+    static NeverDestroyed<AtomicString> lockClockFamily("LockClock-Light", AtomicString::ConstructFromLiteral);
+    static NeverDestroyed<AtomicString> timesNewRomanPSMTFamily("TimesNewRomanPSMT", AtomicString::ConstructFromLiteral);
+
+    AtomicString* family = nullptr;
+    switch (c) {
+    case AppleLogo:
+        family = &helveticaFamily.get();
+        break;
+    case blackCircle:
+        family = &lockClockFamily.get();
+        break;
+    case narrowNonBreakingSpace:
+        family = &timesNewRomanPSMTFamily.get();
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        return nullptr;
     }
-    return nullptr;
+    ASSERT(family);
+    if (!family)
+        return nullptr;
+    return getCachedFontPlatformData(description, *family);
 }
 
 static inline FontTraitsMask toTraitsMask(CTFontSymbolicTraits ctFontTraits)