Diff
Modified: branches/safari-608-branch/LayoutTests/ChangeLog (247631 => 247632)
--- branches/safari-608-branch/LayoutTests/ChangeLog 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/LayoutTests/ChangeLog 2019-07-19 01:40:00 UTC (rev 247632)
@@ -1,3 +1,78 @@
+2019-07-18 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r247566. rdar://problem/53279081
+
+ Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts
+ https://bugs.webkit.org/show_bug.cgi?id=199769
+ <rdar://problem/49390297>
+
+ Reviewed by Myles C. Maxfield.
+
+ Source/WebCore:
+
+ When getting a system font, set the appropriate attribute so that it
+ does not fallback to a user initiated font.
+ Add an ASSERT that checks that the font in use is not a user font if
+ policy is to not use user installed fonts.
+
+ Tests: fast/text/user-installed-fonts/extended-character-with-user-font.html
+ fast/text/user-installed-fonts/extended-character.html
+
+ * platform/graphics/Font.h:
+ * platform/graphics/FontCascadeFonts.cpp:
+ (WebCore::FontCascadeFonts::glyphDataForSystemFallback):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::preparePlatformFont):
+ (WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
+ (WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
+ (WebCore::addAttributesForInstalledFonts):
+ (WebCore::addAttributesForWebFonts):
+ (WebCore::installedFontMandatoryAttributes):
+ * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+ (WebCore::Font::isUserInstalledFont const):
+
+ Source/WTF:
+
+ * wtf/Platform.h:
+
+ Tools:
+
+ Add a font containing one extended character not found in system fonts.
+
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+ * WebKitTestRunner/fonts/FakeHelvetica-SingleExtendedCharacter.ttf: Added.
+
+ LayoutTests:
+
+ Tests require WTR and recent MacOS, hence why they are disabled elsewhere.
+
+ * TestExpectations:
+ * platform/mac-wk2/TestExpectations:
+ * fast/text/user-installed-fonts/extended-character-expected.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font-expected-mismatch.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font.html: Added.
+ * fast/text/user-installed-fonts/extended-character.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247566 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-18 Youenn Fablet <you...@apple.com>
+
+ Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts
+ https://bugs.webkit.org/show_bug.cgi?id=199769
+ <rdar://problem/49390297>
+
+ Reviewed by Myles C. Maxfield.
+
+ Tests require WTR and recent MacOS, hence why they are disabled elsewhere.
+
+ * TestExpectations:
+ * platform/mac-wk2/TestExpectations:
+ * fast/text/user-installed-fonts/extended-character-expected.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font-expected-mismatch.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font.html: Added.
+ * fast/text/user-installed-fonts/extended-character.html: Added.
+
2019-07-17 Kocsen Chung <kocsen_ch...@apple.com>
Cherry-pick r247544. rdar://problem/53230040
Modified: branches/safari-608-branch/LayoutTests/TestExpectations (247631 => 247632)
--- branches/safari-608-branch/LayoutTests/TestExpectations 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/LayoutTests/TestExpectations 2019-07-19 01:40:00 UTC (rev 247632)
@@ -1669,6 +1669,10 @@
webkit.org/b/190626 imported/w3c/web-platform-tests/html/semantics/forms/the-datalist-element/datalistoptions.html [ Failure ]
webkit.org/b/190613 imported/blink/fast/forms/datalist/slider-appearance-with-ticks-crash.html [ Skip ]
+# Tests require WTR and disabling of user installed fonts. Reenabling them in supported platforms
+fast/text/user-installed-fonts/extended-character.html [ Skip ]
+fast/text/user-installed-fonts/extended-character-with-user-font.html [ Skip ]
+
# Does timeout
imported/w3c/web-platform-tests/webaudio/idlharness.https.html [ Skip ]
# Do assert in OfflineAudioContext
Added: branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-expected.html (0 => 247632)
--- branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-expected.html (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-expected.html 2019-07-19 01:40:00 UTC (rev 247632)
@@ -0,0 +1,10 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <!-- unknown character -->
+ <td>𑝀</td>
+ </body>
+</html>
Added: branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font-expected-mismatch.html (0 => 247632)
--- branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font-expected-mismatch.html (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font-expected-mismatch.html 2019-07-19 01:40:00 UTC (rev 247632)
@@ -0,0 +1,10 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <!-- unknown character -->
+ <td>𑝀</td>
+ </body>
+</html>
Added: branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font.html (0 => 247632)
--- branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font.html (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character-with-user-font.html 2019-07-19 01:40:00 UTC (rev 247632)
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <script>
+if (window.testRunner)
+ testRunner.installFakeHelvetica("SingleExtendedCharacter");
+ </script>
+ <!-- Character known by user installed font only -->
+ <td>𑜡</td>
+ </body>
+</html>
Added: branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character.html (0 => 247632)
--- branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character.html (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/text/user-installed-fonts/extended-character.html 2019-07-19 01:40:00 UTC (rev 247632)
@@ -0,0 +1,16 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <script>
+if (window.internals)
+ internals.settings.setShouldAllowUserInstalledFonts(false);
+if (window.testRunner)
+ testRunner.installFakeHelvetica("SingleExtendedCharacter");
+ </script>
+ <!-- Character known by user installed font only -->
+ <td>𑜡</td>
+ </body>
+</html>
Modified: branches/safari-608-branch/LayoutTests/platform/mac-wk2/TestExpectations (247631 => 247632)
--- branches/safari-608-branch/LayoutTests/platform/mac-wk2/TestExpectations 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/LayoutTests/platform/mac-wk2/TestExpectations 2019-07-19 01:40:00 UTC (rev 247632)
@@ -773,6 +773,10 @@
webkit.org/b/185994 fast/text/user-installed-fonts/shadow-family.html [ Pass ImageOnlyFailure ]
webkit.org/b/185994 fast/text/user-installed-fonts/shadow-postscript-family.html [ Pass ImageOnlyFailure ]
+# Reenabled tests for supported platforms
+[ Mojave+ ] fast/text/user-installed-fonts/extended-character.html [ Pass ]
+[ Mojave+ ] fast/text/user-installed-fonts/extended-character-with-user-font.html [ Pass ]
+
# <rdar://problem/25010307>
[ HighSierra+ ] http/tests/ssl/applepay/ApplePayError.html [ Pass ]
[ HighSierra+ ] http/tests/ssl/applepay/ApplePaySessionV3.html [ Pass ]
Modified: branches/safari-608-branch/Source/WTF/ChangeLog (247631 => 247632)
--- branches/safari-608-branch/Source/WTF/ChangeLog 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Source/WTF/ChangeLog 2019-07-19 01:40:00 UTC (rev 247632)
@@ -1,3 +1,71 @@
+2019-07-18 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r247566. rdar://problem/53279081
+
+ Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts
+ https://bugs.webkit.org/show_bug.cgi?id=199769
+ <rdar://problem/49390297>
+
+ Reviewed by Myles C. Maxfield.
+
+ Source/WebCore:
+
+ When getting a system font, set the appropriate attribute so that it
+ does not fallback to a user initiated font.
+ Add an ASSERT that checks that the font in use is not a user font if
+ policy is to not use user installed fonts.
+
+ Tests: fast/text/user-installed-fonts/extended-character-with-user-font.html
+ fast/text/user-installed-fonts/extended-character.html
+
+ * platform/graphics/Font.h:
+ * platform/graphics/FontCascadeFonts.cpp:
+ (WebCore::FontCascadeFonts::glyphDataForSystemFallback):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::preparePlatformFont):
+ (WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
+ (WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
+ (WebCore::addAttributesForInstalledFonts):
+ (WebCore::addAttributesForWebFonts):
+ (WebCore::installedFontMandatoryAttributes):
+ * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+ (WebCore::Font::isUserInstalledFont const):
+
+ Source/WTF:
+
+ * wtf/Platform.h:
+
+ Tools:
+
+ Add a font containing one extended character not found in system fonts.
+
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+ * WebKitTestRunner/fonts/FakeHelvetica-SingleExtendedCharacter.ttf: Added.
+
+ LayoutTests:
+
+ Tests require WTR and recent MacOS, hence why they are disabled elsewhere.
+
+ * TestExpectations:
+ * platform/mac-wk2/TestExpectations:
+ * fast/text/user-installed-fonts/extended-character-expected.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font-expected-mismatch.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font.html: Added.
+ * fast/text/user-installed-fonts/extended-character.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247566 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-18 Youenn Fablet <you...@apple.com>
+
+ Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts
+ https://bugs.webkit.org/show_bug.cgi?id=199769
+ <rdar://problem/49390297>
+
+ Reviewed by Myles C. Maxfield.
+
+ * wtf/Platform.h:
+
2019-07-17 Kocsen Chung <kocsen_ch...@apple.com>
Cherry-pick r247482. rdar://problem/53229731
Modified: branches/safari-608-branch/Source/WTF/wtf/Platform.h (247631 => 247632)
--- branches/safari-608-branch/Source/WTF/wtf/Platform.h 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Source/WTF/wtf/Platform.h 2019-07-19 01:40:00 UTC (rev 247632)
@@ -1536,6 +1536,10 @@
#define ENABLE_MONOSPACE_FONT_EXCEPTION (__IPHONE_OS_VERSION_MIN_REQUIRED < 130000)
#endif
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS_FAMILY)
+#define HAVE_DISALLOWABLE_USER_INSTALLED_FONTS 1
+#endif
+
#if PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
#define HAVE_ARKIT_QUICK_LOOK_PREVIEW_ITEM 1
#endif
Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (247631 => 247632)
--- branches/safari-608-branch/Source/WebCore/ChangeLog 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog 2019-07-19 01:40:00 UTC (rev 247632)
@@ -1,5 +1,92 @@
2019-07-18 Alan Coon <alanc...@apple.com>
+ Cherry-pick r247566. rdar://problem/53279081
+
+ Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts
+ https://bugs.webkit.org/show_bug.cgi?id=199769
+ <rdar://problem/49390297>
+
+ Reviewed by Myles C. Maxfield.
+
+ Source/WebCore:
+
+ When getting a system font, set the appropriate attribute so that it
+ does not fallback to a user initiated font.
+ Add an ASSERT that checks that the font in use is not a user font if
+ policy is to not use user installed fonts.
+
+ Tests: fast/text/user-installed-fonts/extended-character-with-user-font.html
+ fast/text/user-installed-fonts/extended-character.html
+
+ * platform/graphics/Font.h:
+ * platform/graphics/FontCascadeFonts.cpp:
+ (WebCore::FontCascadeFonts::glyphDataForSystemFallback):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::preparePlatformFont):
+ (WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
+ (WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
+ (WebCore::addAttributesForInstalledFonts):
+ (WebCore::addAttributesForWebFonts):
+ (WebCore::installedFontMandatoryAttributes):
+ * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+ (WebCore::Font::isUserInstalledFont const):
+
+ Source/WTF:
+
+ * wtf/Platform.h:
+
+ Tools:
+
+ Add a font containing one extended character not found in system fonts.
+
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+ * WebKitTestRunner/fonts/FakeHelvetica-SingleExtendedCharacter.ttf: Added.
+
+ LayoutTests:
+
+ Tests require WTR and recent MacOS, hence why they are disabled elsewhere.
+
+ * TestExpectations:
+ * platform/mac-wk2/TestExpectations:
+ * fast/text/user-installed-fonts/extended-character-expected.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font-expected-mismatch.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font.html: Added.
+ * fast/text/user-installed-fonts/extended-character.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247566 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-18 Youenn Fablet <you...@apple.com>
+
+ Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts
+ https://bugs.webkit.org/show_bug.cgi?id=199769
+ <rdar://problem/49390297>
+
+ Reviewed by Myles C. Maxfield.
+
+ When getting a system font, set the appropriate attribute so that it
+ does not fallback to a user initiated font.
+ Add an ASSERT that checks that the font in use is not a user font if
+ policy is to not use user installed fonts.
+
+ Tests: fast/text/user-installed-fonts/extended-character-with-user-font.html
+ fast/text/user-installed-fonts/extended-character.html
+
+ * platform/graphics/Font.h:
+ * platform/graphics/FontCascadeFonts.cpp:
+ (WebCore::FontCascadeFonts::glyphDataForSystemFallback):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::preparePlatformFont):
+ (WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
+ (WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
+ (WebCore::addAttributesForInstalledFonts):
+ (WebCore::addAttributesForWebFonts):
+ (WebCore::installedFontMandatoryAttributes):
+ * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+ (WebCore::Font::isUserInstalledFont const):
+
+2019-07-18 Alan Coon <alanc...@apple.com>
+
Cherry-pick r247562. rdar://problem/53279086
[LFC][IFC] InlineFormattingContext::LineLayout::placeInlineItems is getting too complex.
Modified: branches/safari-608-branch/Source/WebCore/platform/graphics/Font.h (247631 => 247632)
--- branches/safari-608-branch/Source/WebCore/platform/graphics/Font.h 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Source/WebCore/platform/graphics/Font.h 2019-07-19 01:40:00 UTC (rev 247632)
@@ -204,6 +204,10 @@
const BitVector& glyphsSupportedByAllPetiteCaps() const;
#endif
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
+ bool isUserInstalledFont() const;
+#endif
+
bool canRenderCombiningCharacterSequence(const UChar*, size_t) const;
bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t glyphCount, bool enableKerning, bool requiresShaping) const;
Modified: branches/safari-608-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp (247631 => 247632)
--- branches/safari-608-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp 2019-07-19 01:40:00 UTC (rev 247632)
@@ -349,6 +349,10 @@
if (!systemFallbackFont)
return GlyphData();
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
+ ASSERT(!systemFallbackFont->isUserInstalledFont() || description.shouldAllowUserInstalledFonts() == AllowUserInstalledFonts::Yes);
+#endif
+
if (systemFallbackShouldBeInvisible)
systemFallbackFont = const_cast<Font*>(&systemFallbackFont->invisibleFont());
Modified: branches/safari-608-branch/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (247631 => 247632)
--- branches/safari-608-branch/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2019-07-19 01:40:00 UTC (rev 247632)
@@ -38,7 +38,6 @@
#include <wtf/NeverDestroyed.h>
#define HAS_CORE_TEXT_WIDTH_ATTRIBUTE ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000))
-#define CAN_DISALLOW_USER_INSTALLED_FONTS ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000))
namespace WebCore {
@@ -570,7 +569,7 @@
bool fontFaceDoesntSpecifyFeatures = !fontFaceFeatures || fontFaceFeatures->isEmpty();
bool fontFaceDoesntSpecifyVariations = !fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal();
if (noFontFeatureSettings && noFontVariationSettings && textRenderingModeIsAuto && variantSettingsIsNormal && dontNeedToApplyOpticalSizing && fontFaceDoesntSpecifyFeatures && fontFaceDoesntSpecifyVariations)
- return originalFont;
+ return createFontForInstalledFonts(originalFont, fontDescription.shouldAllowUserInstalledFonts());
// This algorithm is described at http://www.w3.org/TR/css3-fonts/#feature-precedence
FeaturesMap featuresToBeApplied;
@@ -685,9 +684,10 @@
#endif
}
+ addAttributesForInstalledFonts(attributes.get(), fontDescription.shouldAllowUserInstalledFonts());
+
auto descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
- auto result = adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get()));
- return result;
+ return adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get()));
}
RefPtr<Font> FontCache::similarFont(const FontDescription& description, const AtomString& family)
@@ -838,7 +838,7 @@
class FontDatabase {
public:
-#if !CAN_DISALLOW_USER_INSTALLED_FONTS
+#if !HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
static FontDatabase& singleton()
{
static NeverDestroyed<FontDatabase> database(AllowUserInstalledFonts::Yes);
@@ -848,7 +848,7 @@
static FontDatabase& singletonAllowingUserInstalledFonts()
{
-#if CAN_DISALLOW_USER_INSTALLED_FONTS
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
static NeverDestroyed<FontDatabase> database(AllowUserInstalledFonts::Yes);
return database;
#else
@@ -858,7 +858,7 @@
static FontDatabase& singletonDisallowingUserInstalledFonts()
{
-#if CAN_DISALLOW_USER_INSTALLED_FONTS
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
static NeverDestroyed<FontDatabase> database(AllowUserInstalledFonts::No);
return database;
#else
@@ -872,10 +872,15 @@
struct InstalledFont {
InstalledFont() = default;
- InstalledFont(CTFontDescriptorRef fontDescriptor)
+ InstalledFont(CTFontDescriptorRef fontDescriptor, AllowUserInstalledFonts allowUserInstalledFonts)
: fontDescriptor(fontDescriptor)
, capabilities(capabilitiesForFontDescriptor(fontDescriptor))
{
+ if (allowUserInstalledFonts != AllowUserInstalledFonts::No)
+ return;
+ auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ addAttributesForInstalledFonts(attributes.get(), allowUserInstalledFonts);
+ this->fontDescriptor = CTFontDescriptorCreateCopyWithAttributes(fontDescriptor, attributes.get());
}
RetainPtr<CTFontDescriptorRef> fontDescriptor;
@@ -933,7 +938,7 @@
Vector<InstalledFont> result;
result.reserveInitialCapacity(count);
for (CFIndex i = 0; i < count; ++i) {
- InstalledFont installedFont(static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(matches.get(), i)));
+ InstalledFont installedFont(static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(matches.get(), i)), m_allowUserInstalledFonts);
result.uncheckedAppend(WTFMove(installedFont));
}
return InstalledFontFamily(WTFMove(result));
@@ -962,7 +967,7 @@
auto fontDescriptorToMatch = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
auto mandatoryAttributes = installedFontMandatoryAttributes(m_allowUserInstalledFonts);
auto match = adoptCF(CTFontDescriptorCreateMatchingFontDescriptor(fontDescriptorToMatch.get(), mandatoryAttributes.get()));
- return InstalledFont(match.get());
+ return InstalledFont(match.get(), m_allowUserInstalledFonts);
}).iterator->value;
}
@@ -1506,7 +1511,7 @@
void addAttributesForInstalledFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts allowUserInstalledFonts)
{
-#if CAN_DISALLOW_USER_INSTALLED_FONTS
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
if (allowUserInstalledFonts == AllowUserInstalledFonts::No) {
CFDictionaryAddValue(attributes, kCTFontUserInstalledAttribute, kCFBooleanFalse);
CTFontFallbackOption fallbackOption = kCTFontFallbackOptionSystem;
@@ -1530,8 +1535,30 @@
return adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor, size, nullptr));
}
+static inline bool isFontMatchingUserInstalledFontFallback(CTFontRef font, AllowUserInstalledFonts allowUserInstalledFonts)
+{
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
+ bool willFallbackToSystemOnly = false;
+ if (auto fontFallbackOptionAttributeRef = adoptCF(static_cast<CFNumberRef>(CTFontCopyAttribute(font, kCTFontFallbackOptionAttribute)))) {
+ int64_t fontFallbackOptionAttribute;
+ CFNumberGetValue(fontFallbackOptionAttributeRef.get(), kCFNumberSInt64Type, &fontFallbackOptionAttribute);
+ willFallbackToSystemOnly = fontFallbackOptionAttribute == kCTFontFallbackOptionSystem;
+ }
+
+ bool shouldFallbackToSystemOnly = allowUserInstalledFonts == AllowUserInstalledFonts::No;
+ return willFallbackToSystemOnly == shouldFallbackToSystemOnly;
+#else
+ UNUSED_PARAM(font);
+ UNUSED_PARAM(allowUserInstalledFonts);
+ return true;
+#endif
+}
+
RetainPtr<CTFontRef> createFontForInstalledFonts(CTFontRef font, AllowUserInstalledFonts allowUserInstalledFonts)
{
+ if (isFontMatchingUserInstalledFontFallback(font, allowUserInstalledFonts))
+ return font;
+
auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
addAttributesForInstalledFonts(attributes.get(), allowUserInstalledFonts);
if (CFDictionaryGetCount(attributes.get())) {
@@ -1543,7 +1570,7 @@
void addAttributesForWebFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts allowUserInstalledFonts)
{
-#if CAN_DISALLOW_USER_INSTALLED_FONTS
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
if (allowUserInstalledFonts == AllowUserInstalledFonts::No) {
CTFontFallbackOption fallbackOption = kCTFontFallbackOptionSystem;
auto fallbackOptionNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &fallbackOption));
@@ -1557,7 +1584,7 @@
RetainPtr<CFSetRef> installedFontMandatoryAttributes(AllowUserInstalledFonts allowUserInstalledFonts)
{
-#if CAN_DISALLOW_USER_INSTALLED_FONTS
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
if (allowUserInstalledFonts == AllowUserInstalledFonts::No) {
CFTypeRef mandatoryAttributesValues[] = { kCTFontFamilyNameAttribute, kCTFontPostScriptNameAttribute, kCTFontEnabledAttribute, kCTFontUserInstalledAttribute, kCTFontFallbackOptionAttribute };
return adoptCF(CFSetCreate(kCFAllocatorDefault, mandatoryAttributesValues, WTF_ARRAY_LENGTH(mandatoryAttributesValues), &kCFTypeSetCallBacks));
Modified: branches/safari-608-branch/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp (247631 => 247632)
--- branches/safari-608-branch/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp 2019-07-19 01:40:00 UTC (rev 247632)
@@ -28,6 +28,7 @@
#include "Font.h"
#include <CoreText/CoreText.h>
+#include <pal/spi/cocoa/CoreTextSPI.h>
namespace WebCore {
@@ -53,4 +54,12 @@
return attributesDictionary.get();
}
+#if HAVE(DISALLOWABLE_USER_INSTALLED_FONTS)
+bool Font::isUserInstalledFont() const
+{
+ auto isUserInstalledFont = adoptCF(static_cast<CFBooleanRef>(CTFontCopyAttribute(getCTFont(), kCTFontUserInstalledAttribute)));
+ return isUserInstalledFont && CFBooleanGetValue(isUserInstalledFont.get());
+}
+#endif
+
} // namespace WebCore
Modified: branches/safari-608-branch/Tools/ChangeLog (247631 => 247632)
--- branches/safari-608-branch/Tools/ChangeLog 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Tools/ChangeLog 2019-07-19 01:40:00 UTC (rev 247632)
@@ -1,3 +1,74 @@
+2019-07-18 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r247566. rdar://problem/53279081
+
+ Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts
+ https://bugs.webkit.org/show_bug.cgi?id=199769
+ <rdar://problem/49390297>
+
+ Reviewed by Myles C. Maxfield.
+
+ Source/WebCore:
+
+ When getting a system font, set the appropriate attribute so that it
+ does not fallback to a user initiated font.
+ Add an ASSERT that checks that the font in use is not a user font if
+ policy is to not use user installed fonts.
+
+ Tests: fast/text/user-installed-fonts/extended-character-with-user-font.html
+ fast/text/user-installed-fonts/extended-character.html
+
+ * platform/graphics/Font.h:
+ * platform/graphics/FontCascadeFonts.cpp:
+ (WebCore::FontCascadeFonts::glyphDataForSystemFallback):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::preparePlatformFont):
+ (WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
+ (WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
+ (WebCore::addAttributesForInstalledFonts):
+ (WebCore::addAttributesForWebFonts):
+ (WebCore::installedFontMandatoryAttributes):
+ * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+ (WebCore::Font::isUserInstalledFont const):
+
+ Source/WTF:
+
+ * wtf/Platform.h:
+
+ Tools:
+
+ Add a font containing one extended character not found in system fonts.
+
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+ * WebKitTestRunner/fonts/FakeHelvetica-SingleExtendedCharacter.ttf: Added.
+
+ LayoutTests:
+
+ Tests require WTR and recent MacOS, hence why they are disabled elsewhere.
+
+ * TestExpectations:
+ * platform/mac-wk2/TestExpectations:
+ * fast/text/user-installed-fonts/extended-character-expected.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font-expected-mismatch.html: Added.
+ * fast/text/user-installed-fonts/extended-character-with-user-font.html: Added.
+ * fast/text/user-installed-fonts/extended-character.html: Added.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247566 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-18 Youenn Fablet <you...@apple.com>
+
+ Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts
+ https://bugs.webkit.org/show_bug.cgi?id=199769
+ <rdar://problem/49390297>
+
+ Reviewed by Myles C. Maxfield.
+
+ Add a font containing one extended character not found in system fonts.
+
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+ * WebKitTestRunner/fonts/FakeHelvetica-SingleExtendedCharacter.ttf: Added.
+
2019-07-17 Kocsen Chung <kocsen_ch...@apple.com>
Cherry-pick r247536. rdar://problem/53229635
Modified: branches/safari-608-branch/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (247631 => 247632)
--- branches/safari-608-branch/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj 2019-07-19 01:39:54 UTC (rev 247631)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj 2019-07-19 01:40:00 UTC (rev 247632)
@@ -96,6 +96,7 @@
2E749BF21891EBFA007FC175 /* EventSenderProxyIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E63ED7A1891ACE9002A7AFC /* EventSenderProxyIOS.mm */; };
31DA8A3D1E7205CC00E1DF2F /* IOSLayoutTestCommunication.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3148A0531E6F85B600D3B316 /* IOSLayoutTestCommunication.cpp */; };
41C5378E21F13414008B1FAD /* TestWebsiteDataStoreDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41C5378D21F1333C008B1FAD /* TestWebsiteDataStoreDelegate.mm */; };
+ 41D5B62622DD9D36000F4C4A /* FakeHelvetica-SingleExtendedCharacter.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 41D5B62522DD9D36000F4C4A /* FakeHelvetica-SingleExtendedCharacter.ttf */; };
4430AE191F82C4FD0099915A /* GeneratedTouchesDebugWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4430AE171F82C4EE0099915A /* GeneratedTouchesDebugWindow.mm */; };
51058AD51D678820009A538C /* libWebCoreTestSupport.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 41230E16138C78BF00BCCFCA /* libWebCoreTestSupport.dylib */; };
51058AD61D678825009A538C /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; };
@@ -300,6 +301,7 @@
4181731B138AD39D0057AAA4 /* WebCoreTestSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreTestSupport.h; path = WebCoreTestSupport/WebCoreTestSupport.h; sourceTree = BUILT_PRODUCTS_DIR; };
41C5378C21F1333C008B1FAD /* TestWebsiteDataStoreDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestWebsiteDataStoreDelegate.h; path = cocoa/TestWebsiteDataStoreDelegate.h; sourceTree = "<group>"; };
41C5378D21F1333C008B1FAD /* TestWebsiteDataStoreDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestWebsiteDataStoreDelegate.mm; path = cocoa/TestWebsiteDataStoreDelegate.mm; sourceTree = "<group>"; };
+ 41D5B62522DD9D36000F4C4A /* FakeHelvetica-SingleExtendedCharacter.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "FakeHelvetica-SingleExtendedCharacter.ttf"; path = "fonts/FakeHelvetica-SingleExtendedCharacter.ttf"; sourceTree = "<group>"; };
4429FC5E1627089600F66D8B /* WorkQueueManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueManager.cpp; sourceTree = "<group>"; };
4429FC611627089600F66D8B /* WorkQueueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkQueueManager.h; sourceTree = "<group>"; };
4430AE171F82C4EE0099915A /* GeneratedTouchesDebugWindow.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GeneratedTouchesDebugWindow.mm; sourceTree = "<group>"; };
@@ -749,6 +751,7 @@
1CBA02931FD86EA100179C7D /* FakeHelvetica-Helvetica-500.ttf */,
1CBA02921FD86EA100179C7D /* FakeHelvetica-Helvetica2-400.ttf */,
1CBA02951FD86EA100179C7D /* FakeHelvetica-Helvetica2-500.ttf */,
+ 41D5B62522DD9D36000F4C4A /* FakeHelvetica-SingleExtendedCharacter.ttf */,
1CA211C71BCA107300B2101F /* FontWithFeatures.otf */,
1CA211C81BCA107300B2101F /* FontWithFeatures.ttf */,
BC25186311D15D54002EBC01 /* InjectedBundle-Info.plist */,
@@ -1028,6 +1031,7 @@
1CBA02981FD87DF000179C7D /* FakeHelvetica-Helvetica-500.ttf in Resources */,
1CBA02971FD87DEE00179C7D /* FakeHelvetica-Helvetica2-400.ttf in Resources */,
1CBA02961FD87DEC00179C7D /* FakeHelvetica-Helvetica2-500.ttf in Resources */,
+ 41D5B62622DD9D36000F4C4A /* FakeHelvetica-SingleExtendedCharacter.ttf in Resources */,
1CA211C91BCA107300B2101F /* FontWithFeatures.otf in Resources */,
1CA211CA1BCA107300B2101F /* FontWithFeatures.ttf in Resources */,
6510A78411EC643800410867 /* WebKitWeightWatcher100.ttf in Resources */,
Added: branches/safari-608-branch/Tools/WebKitTestRunner/fonts/FakeHelvetica-SingleExtendedCharacter.ttf (0 => 247632)
--- branches/safari-608-branch/Tools/WebKitTestRunner/fonts/FakeHelvetica-SingleExtendedCharacter.ttf (rev 0)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/fonts/FakeHelvetica-SingleExtendedCharacter.ttf 2019-07-19 01:40:00 UTC (rev 247632)
@@ -0,0 +1,5 @@
+\x80`FFTM\x8B}j\xDD4GDEFOS/2J\xADd\xC3h`cmap2\xDC\xD8fcvt Q@gasp\xFF\xFFglyfVR\xA3Pthead2J\xA5\xEC6hhea\xCC\xED$$hmtx#\xB8%\xC8locabPD
+maxpH9H nameM\x8BL+\xC4postc1=\xB0\xDC1$5\x8B7_<\xF5\x80\xD9S-\xD9S\xA6jUU\xE8j@.\xE8\x90SYSY=! PfEd\x80\xFF\xFF\xFF\xFFf\xFF\xE6U \xE8\xE8\xE8!,D`,
+D\xFF\xFF\xFF\xFF!!Q(((:$U.\xB1/<\xB2\xED2\xB1\xDC<\xB2\xED2\xB1/<\xB2\xED2\xB2\xFC<\xB2\xED2353'35# UUM!!jU6462"!0\xAE6 e%\xD3 +9
 ^ 4 Q o J\x87 \xF9   JCopyright (c) 2019, youennCopyright (c) 2019, youennUntitled1Untitled1RegularRegularFontForge 2.0 : Untitled1 : 16-7-2019FontForge 2.0 : Untitled1 : 16-7-2019Untitled1Untitled1Vers
ion 001.000 Version 001.000 Untitled1Untitled1\xFF\xF7u11721\xFF\xFF\xD8\xD7^ \xD9S-\xD9S\xA6
\ No newline at end of file