Title: [216342] trunk
Revision
216342
Author
mmaxfi...@apple.com
Date
2017-05-06 22:43:29 -0700 (Sat, 06 May 2017)

Log Message

[Cocoa] CTFontDescriptorCreateMatchingFontDescriptor() is not case insensitive
https://bugs.webkit.org/show_bug.cgi?id=171636
<rdar://problem/30811218>

Reviewed by Dean Jackson.

Source/WebCore:

LastResort is the only name which needs to be looked up case-sensitively. We can handle
this in our existing function which handles special font names (like -apple-system) to
make sure that we always do the right thing.

Test: fast/text/lastResort.html

* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::platformFontWithFamilySpecialCase):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformFontWithFamilySpecialCase):
* platform/spi/cocoa/CoreTextSPI.h:

LayoutTests:

* fast/text/lastResort-expected.html: Added.
* fast/text/lastResort.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (216341 => 216342)


--- trunk/LayoutTests/ChangeLog	2017-05-07 05:18:34 UTC (rev 216341)
+++ trunk/LayoutTests/ChangeLog	2017-05-07 05:43:29 UTC (rev 216342)
@@ -1,3 +1,14 @@
+2017-05-06  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] CTFontDescriptorCreateMatchingFontDescriptor() is not case insensitive
+        https://bugs.webkit.org/show_bug.cgi?id=171636
+        <rdar://problem/30811218>
+
+        Reviewed by Dean Jackson.
+
+        * fast/text/lastResort-expected.html: Added.
+        * fast/text/lastResort.html: Added.
+
 2017-05-06  Chris Dumez  <cdu...@apple.com>
 
         Implement the concept of cookie-averse document

Added: trunk/LayoutTests/fast/text/lastResort-expected.html (0 => 216342)


--- trunk/LayoutTests/fast/text/lastResort-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/lastResort-expected.html	2017-05-07 05:43:29 UTC (rev 216342)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that Last Resort is always looked up correctly.
+<div style="font-family: LastResort;">hi</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/lastResort.html (0 => 216342)


--- trunk/LayoutTests/fast/text/lastResort.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/lastResort.html	2017-05-07 05:43:29 UTC (rev 216342)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that Last Resort is always looked up correctly.
+<div style="font-family: lastresort;">hi</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (216341 => 216342)


--- trunk/Source/WebCore/ChangeLog	2017-05-07 05:18:34 UTC (rev 216341)
+++ trunk/Source/WebCore/ChangeLog	2017-05-07 05:43:29 UTC (rev 216342)
@@ -1,3 +1,23 @@
+2017-05-06  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] CTFontDescriptorCreateMatchingFontDescriptor() is not case insensitive
+        https://bugs.webkit.org/show_bug.cgi?id=171636
+        <rdar://problem/30811218>
+
+        Reviewed by Dean Jackson.
+
+        LastResort is the only name which needs to be looked up case-sensitively. We can handle
+        this in our existing function which handles special font names (like -apple-system) to
+        make sure that we always do the right thing.
+
+        Test: fast/text/lastResort.html
+
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::platformFontWithFamilySpecialCase):
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::platformFontWithFamilySpecialCase):
+        * platform/spi/cocoa/CoreTextSPI.h:
+
 2017-05-06  Chris Dumez  <cdu...@apple.com>
 
         Implement the concept of cookie-averse document

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


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2017-05-07 05:18:34 UTC (rev 216341)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2017-05-07 05:43:29 UTC (rev 216342)
@@ -33,11 +33,17 @@
 #import "CoreTextSPI.h"
 #import "FontCascade.h"
 #import "RenderThemeIOS.h"
+#import "SoftLinking.h"
 #import <wtf/HashSet.h>
 #import <wtf/NeverDestroyed.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/text/CString.h>
 
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+SOFT_LINK_FRAMEWORK(CoreText);
+SOFT_LINK_MAY_FAIL(CoreText, CTFontDescriptorCreateLastResort, CTFontDescriptorRef, (), ());
+#endif
+
 namespace WebCore {
 
 bool requiresCustomFallbackFont(UChar32 character)
@@ -164,6 +170,18 @@
         return adoptCF(CTFontCreateWithFontDescriptor(monospaceFontDescriptor.get(), size, nullptr));
     }
 
+    if (equalLettersIgnoringASCIICase(family, "lastresort")) {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+        if (canLoadCTFontDescriptorCreateLastResort()) {
+            static NeverDestroyed<RetainPtr<CTFontDescriptorRef>> lastResort = adoptCF(CTFontDescriptorCreateLastResort());
+            return adoptCF(CTFontCreateWithFontDescriptor(lastResort.get().get(), size, nullptr));
+        }
+#endif
+        // LastResort is special, so it's important to look this exact string up, and not some case-folded version.
+        // We handle this here so any caching and case folding we do in our general text codepath is bypassed.
+        return adoptCF(CTFontCreateWithName(CFSTR("LastResort"), size, nullptr));
+    }
+
     return nullptr;
 }
 

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


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2017-05-07 05:18:34 UTC (rev 216341)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2017-05-07 05:43:29 UTC (rev 216342)
@@ -48,6 +48,13 @@
 #import <wtf/text/AtomicStringHash.h>
 #endif
 
+#import "SoftLinking.h"
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+SOFT_LINK_FRAMEWORK(CoreText);
+SOFT_LINK_MAY_FAIL(CoreText, CTFontDescriptorCreateLastResort, CTFontDescriptorRef, (), ());
+#endif
+
 namespace WebCore {
 
 #if PLATFORM(MAC)
@@ -111,6 +118,18 @@
     if (equalLettersIgnoringASCIICase(family, "-apple-status-bar"))
         return toCTFont([NSFont labelFontOfSize:size]);
 
+    if (equalLettersIgnoringASCIICase(family, "lastresort")) {
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+        if (canLoadCTFontDescriptorCreateLastResort()) {
+            static NeverDestroyed<RetainPtr<CTFontDescriptorRef>> lastResort = adoptCF(CTFontDescriptorCreateLastResort());
+            return adoptCF(CTFontCreateWithFontDescriptor(lastResort.get().get(), size, nullptr));
+        }
+#endif
+        // LastResort is special, so it's important to look this exact string up, and not some case-folded version.
+        // We handle this here so any caching and case folding we do in our general text codepath is bypassed.
+        return adoptCF(CTFontCreateWithName(CFSTR("LastResort"), size, nullptr));
+    }
+
     return nullptr;
 }
 

Modified: trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h (216341 => 216342)


--- trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2017-05-07 05:18:34 UTC (rev 216341)
+++ trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2017-05-07 05:43:29 UTC (rev 216342)
@@ -83,6 +83,7 @@
 CFBitVectorRef CTFontCopyGlyphCoverageForFeature(CTFontRef, CFDictionaryRef feature);
 
 CTFontDescriptorRef CTFontDescriptorCreateWithAttributesAndOptions(CFDictionaryRef attributes, CTFontDescriptorOptions);
+CTFontDescriptorRef CTFontDescriptorCreateLastResort();
 
 extern const CFStringRef kCTFontCSSWeightAttribute;
 extern const CFStringRef kCTFontCSSWidthAttribute;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to