Log Message
Use CTFontCreateForCharactersWithLanguageAndOption if available instead of CTFontCreateForCharactersWithLanguage https://bugs.webkit.org/show_bug.cgi?id=200241
Source/WebCore: Reviewed by Myles C. Maxfield. We can use CTFontCreateForCharactersWithLanguageAndOption instead of CTFontCreateForCharactersWithLanguage as it allows setting more easily the fallback option. This allows us to never fallback to user installed fonts. In such a case, we no longer need to wrap the fonts to change the fallback option. We also prewarm the fonts with the same SPI and use system fallback as the default value. Covered by existing tests. * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::preparePlatformFont): (WebCore::lookupFallbackFont): (WebCore::FontCache::systemFallbackForCharacters): (WebCore::FontCache::prewarm): (WebCore::fontFamiliesForPrewarming): Source/WebCore/PAL: Reviewed by Myles C. Maxfield. Add new SPI. * pal/spi/cocoa/CoreTextSPI.h: Source/WTF: Reviewed by Myles C. Maxfield. * wtf/Platform.h: Add macro to enable/disable new SPI. LayoutTests: We update the tests to flush font caches as otherwise some debug asserts would be hit. This is due to changing the user installed font runtime flag while browsing which is not a typical situation. Reviewed by Myles C. Maxfield. * fast/text/user-installed-fonts/extended-character-with-user-font.html: * fast/text/user-installed-fonts/extended-character.html:
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font.html
- trunk/LayoutTests/fast/text/user-installed-fonts/extended-character.html
- trunk/Source/WTF/ChangeLog
- trunk/Source/WTF/wtf/Platform.h
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/PAL/ChangeLog
- trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h
- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Diff
Modified: trunk/LayoutTests/ChangeLog (248070 => 248071)
--- trunk/LayoutTests/ChangeLog 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/LayoutTests/ChangeLog 2019-07-31 20:59:00 UTC (rev 248071)
@@ -1,5 +1,18 @@
2019-07-31 Youenn Fablet <[email protected]>
+ Use CTFontCreateForCharactersWithLanguageAndOption if available instead of CTFontCreateForCharactersWithLanguage
+ https://bugs.webkit.org/show_bug.cgi?id=200241
+
+ We update the tests to flush font caches as otherwise some debug asserts would be hit.
+ This is due to changing the user installed font runtime flag while browsing which is not a typical situation.
+
+ Reviewed by Myles C. Maxfield.
+
+ * fast/text/user-installed-fonts/extended-character-with-user-font.html:
+ * fast/text/user-installed-fonts/extended-character.html:
+
+2019-07-31 Youenn Fablet <[email protected]>
+
Owners of MultiChannelResampler should make sure that the output bus given to it has the same number of channels
https://bugs.webkit.org/show_bug.cgi?id=200248
<rdar://problem/53411051>
Modified: trunk/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font.html (248070 => 248071)
--- trunk/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font.html 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font.html 2019-07-31 20:59:00 UTC (rev 248071)
@@ -5,6 +5,8 @@
</head>
<body>
<script>
+if (window.internals)
+ internals.invalidateFontCache();
if (window.testRunner)
testRunner.installFakeHelvetica("SingleExtendedCharacter");
</script>
Modified: trunk/LayoutTests/fast/text/user-installed-fonts/extended-character.html (248070 => 248071)
--- trunk/LayoutTests/fast/text/user-installed-fonts/extended-character.html 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/LayoutTests/fast/text/user-installed-fonts/extended-character.html 2019-07-31 20:59:00 UTC (rev 248071)
@@ -5,8 +5,10 @@
</head>
<body>
<script>
-if (window.internals)
+if (window.internals) {
+ internals.invalidateFontCache();
internals.settings.setShouldAllowUserInstalledFonts(false);
+}
if (window.testRunner)
testRunner.installFakeHelvetica("SingleExtendedCharacter");
</script>
Modified: trunk/Source/WTF/ChangeLog (248070 => 248071)
--- trunk/Source/WTF/ChangeLog 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/Source/WTF/ChangeLog 2019-07-31 20:59:00 UTC (rev 248071)
@@ -1,3 +1,12 @@
+2019-07-31 Youenn Fablet <[email protected]>
+
+ Use CTFontCreateForCharactersWithLanguageAndOption if available instead of CTFontCreateForCharactersWithLanguage
+ https://bugs.webkit.org/show_bug.cgi?id=200241
+
+ Reviewed by Myles C. Maxfield.
+
+ * wtf/Platform.h: Add macro to enable/disable new SPI.
+
2019-07-31 Keith Rollin <[email protected]>
Fix 64-bit vs 32-bit mismatch in PersistentCoders.h
Modified: trunk/Source/WTF/wtf/Platform.h (248070 => 248071)
--- trunk/Source/WTF/wtf/Platform.h 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/Source/WTF/wtf/Platform.h 2019-07-31 20:59:00 UTC (rev 248071)
@@ -1544,6 +1544,10 @@
#define HAVE_DISALLOWABLE_USER_INSTALLED_FONTS 1
#endif
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
+#define HAVE_CTFONTCREATEFORCHARACTERSWITHLANGUAGEANDOPTION 1
+#endif
+
#if PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
#define HAVE_ARKIT_QUICK_LOOK_PREVIEW_ITEM 1
#endif
Modified: trunk/Source/WebCore/ChangeLog (248070 => 248071)
--- trunk/Source/WebCore/ChangeLog 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/Source/WebCore/ChangeLog 2019-07-31 20:59:00 UTC (rev 248071)
@@ -1,3 +1,25 @@
+2019-07-31 Youenn Fablet <[email protected]>
+
+ Use CTFontCreateForCharactersWithLanguageAndOption if available instead of CTFontCreateForCharactersWithLanguage
+ https://bugs.webkit.org/show_bug.cgi?id=200241
+
+ Reviewed by Myles C. Maxfield.
+
+ We can use CTFontCreateForCharactersWithLanguageAndOption instead of CTFontCreateForCharactersWithLanguage
+ as it allows setting more easily the fallback option.
+ This allows us to never fallback to user installed fonts.
+ In such a case, we no longer need to wrap the fonts to change the fallback option.
+ We also prewarm the fonts with the same SPI and use system fallback as the default value.
+
+ Covered by existing tests.
+
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::preparePlatformFont):
+ (WebCore::lookupFallbackFont):
+ (WebCore::FontCache::systemFallbackForCharacters):
+ (WebCore::FontCache::prewarm):
+ (WebCore::fontFamiliesForPrewarming):
+
2019-07-31 Devin Rousso <[email protected]>
Web Inspector: Overlay: add page width/height display
Modified: trunk/Source/WebCore/PAL/ChangeLog (248070 => 248071)
--- trunk/Source/WebCore/PAL/ChangeLog 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/Source/WebCore/PAL/ChangeLog 2019-07-31 20:59:00 UTC (rev 248071)
@@ -1,3 +1,14 @@
+2019-07-31 Youenn Fablet <[email protected]>
+
+ Use CTFontCreateForCharactersWithLanguageAndOption if available instead of CTFontCreateForCharactersWithLanguage
+ https://bugs.webkit.org/show_bug.cgi?id=200241
+
+ Reviewed by Myles C. Maxfield.
+
+ Add new SPI.
+
+ * pal/spi/cocoa/CoreTextSPI.h:
+
2019-07-25 Brent Fulgham <[email protected]>
Use IWICBitmap (rather than ID2D1Bitmap) for NativeImagePtr on FTW
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h (248070 => 248071)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2019-07-31 20:59:00 UTC (rev 248071)
@@ -132,6 +132,7 @@
bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
CTFontRef CTFontCreateForCSS(CFStringRef name, uint16_t weight, CTFontSymbolicTraits, CGFloat size);
CTFontRef CTFontCreateForCharactersWithLanguage(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFStringRef language, CFIndex *coveredLength);
+CTFontRef CTFontCreateForCharactersWithLanguageAndOption(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFStringRef language, CTFontFallbackOption option, CFIndex *coveredLength);
CTFontRef CTFontCopyPhysicalFont(CTFontRef);
extern const CFStringRef kCTUIFontTextStyleShortHeadline;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (248070 => 248071)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2019-07-31 20:56:52 UTC (rev 248070)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2019-07-31 20:59:00 UTC (rev 248071)
@@ -570,8 +570,13 @@
bool dontNeedToApplyOpticalSizing = fontOpticalSizing == FontOpticalSizing::Enabled && !forceOpticalSizingOn;
bool fontFaceDoesntSpecifyFeatures = !fontFaceFeatures || fontFaceFeatures->isEmpty();
bool fontFaceDoesntSpecifyVariations = !fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal();
- if (noFontFeatureSettings && noFontVariationSettings && textRenderingModeIsAuto && variantSettingsIsNormal && dontNeedToApplyOpticalSizing && fontFaceDoesntSpecifyFeatures && fontFaceDoesntSpecifyVariations)
+ if (noFontFeatureSettings && noFontVariationSettings && textRenderingModeIsAuto && variantSettingsIsNormal && dontNeedToApplyOpticalSizing && fontFaceDoesntSpecifyFeatures && fontFaceDoesntSpecifyVariations) {
+#if HAVE(CTFONTCREATEFORCHARACTERSWITHLANGUAGEANDOPTION)
+ return originalFont;
+#else
return createFontForInstalledFonts(originalFont, fontDescription.shouldAllowUserInstalledFonts());
+#endif
+ }
// This algorithm is described at http://www.w3.org/TR/css3-fonts/#feature-precedence
FeaturesMap featuresToBeApplied;
@@ -883,11 +888,15 @@
: fontDescriptor(fontDescriptor)
, capabilities(capabilitiesForFontDescriptor(fontDescriptor))
{
+#if HAVE(CTFONTCREATEFORCHARACTERSWITHLANGUAGEANDOPTION)
+ UNUSED_PARAM(allowUserInstalledFonts);
+#else
if (allowUserInstalledFonts != AllowUserInstalledFonts::No)
return;
auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
addAttributesForInstalledFonts(attributes.get(), allowUserInstalledFonts);
this->fontDescriptor = CTFontDescriptorCreateCopyWithAttributes(fontDescriptor, attributes.get());
+#endif
}
RetainPtr<CTFontDescriptorRef> fontDescriptor;
@@ -1390,8 +1399,42 @@
}
#endif
-static RetainPtr<CTFontRef> lookupFallbackFont(CTFontRef font, FontSelectionValue fontWeight, const AtomString& locale, const UChar* characters, unsigned length)
+#if !ASSERT_DISABLED
+static inline bool isUserInstalledFont(CTFontRef font)
{
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
+ auto isUserInstalledFont = adoptCF(static_cast<CFBooleanRef>(CTFontCopyAttribute(font, kCTFontUserInstalledAttribute)));
+ return isUserInstalledFont && CFBooleanGetValue(isUserInstalledFont.get());
+#else
+ UNUSED_PARAM(font);
+ return false;
+#endif
+}
+#endif
+
+#if !USE(PLATFORM_SYSTEM_FALLBACK_LIST) && (PLATFORM(MAC) || (PLATFORM(IOS_FAMILY) && TARGET_OS_IOS))
+static RetainPtr<CTFontRef> createFontForCharacters(CTFontRef font, CFStringRef localeString, AllowUserInstalledFonts, const UChar* characters, unsigned length)
+{
+ CFIndex coveredLength = 0;
+ return adoptCF(CTFontCreatePhysicalFontForCharactersWithLanguage(font, characters, length, localeString, &coveredLength));
+}
+#elif HAVE(CTFONTCREATEFORCHARACTERSWITHLANGUAGEANDOPTION)
+static RetainPtr<CTFontRef> createFontForCharacters(CTFontRef font, CFStringRef localeString, AllowUserInstalledFonts allowUserInstalledFonts, const UChar* characters, unsigned length)
+{
+ CFIndex coveredLength = 0;
+ auto fallbackOption = allowUserInstalledFonts == AllowUserInstalledFonts::No ? kCTFontFallbackOptionSystem : kCTFontFallbackOptionDefault;
+ return adoptCF(CTFontCreateForCharactersWithLanguageAndOption(font, characters, length, localeString, fallbackOption, &coveredLength));
+}
+#else
+static RetainPtr<CTFontRef> createFontForCharacters(CTFontRef font, CFStringRef localeString, AllowUserInstalledFonts, const UChar* characters, unsigned length)
+{
+ CFIndex coveredLength = 0;
+ return adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, localeString, &coveredLength));
+}
+#endif
+
+static RetainPtr<CTFontRef> lookupFallbackFont(CTFontRef font, FontSelectionValue fontWeight, const AtomString& locale, AllowUserInstalledFonts allowUserInstalledFonts, const UChar* characters, unsigned length)
+{
ASSERT(length > 0);
RetainPtr<CFStringRef> localeString;
@@ -1402,13 +1445,8 @@
UNUSED_PARAM(locale);
#endif
- CFIndex coveredLength = 0;
- RetainPtr<CTFontRef> result;
-#if !USE(PLATFORM_SYSTEM_FALLBACK_LIST) && (PLATFORM(MAC) || (PLATFORM(IOS_FAMILY) && TARGET_OS_IOS))
- result = adoptCF(CTFontCreatePhysicalFontForCharactersWithLanguage(font, characters, length, localeString.get(), &coveredLength));
-#else
- result = adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, localeString.get(), &coveredLength));
-#endif
+ auto result = createFontForCharacters(font, localeString.get(), allowUserInstalledFonts, characters, length);
+ ASSERT(!isUserInstalledFont(result.get()) || allowUserInstalledFonts == AllowUserInstalledFonts::Yes);
#if PLATFORM(IOS_FAMILY)
// Callers of this function won't include multiple code points. "Length" is to know how many code units
@@ -1449,7 +1487,7 @@
if (!fullName.isEmpty())
m_fontNamesRequiringSystemFallbackForPrewarming.add(fullName);
- auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
+ auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), description.shouldAllowUserInstalledFonts(), characters, length);
result = preparePlatformFont(result.get(), description, nullptr, nullptr, { });
if (!result)
@@ -1648,7 +1686,12 @@
// This is sufficient to warm CoreText caches for language and character specific fallbacks.
CFIndex coveredLength = 0;
UChar character = ' ';
+
+#if HAVE(CTFONTCREATEFORCHARACTERSWITHLANGUAGEANDOPTION)
+ auto fallbackWarmingFont = adoptCF(CTFontCreateForCharactersWithLanguageAndOption(warmingFont.get(), &character, 1, nullptr, kCTFontFallbackOptionSystem, &coveredLength));
+#else
auto fallbackWarmingFont = adoptCF(CTFontCreateForCharactersWithLanguage(warmingFont.get(), &character, 1, nullptr, &coveredLength));
+#endif
}
}
});
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
