New York font erroneously gets synthetic bold
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jul 2019 01:08:29 +0000 (01:08 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jul 2019 01:08:29 +0000 (01:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199653
<rdar://problem/51692592>

Reviewed by Simon Fraser.

Source/WebCore:

This patch adds support for -apple-system-ui-serif, -apple-system-ui-monospaced,
and -apple-system-ui-rounded, behind an SPI that is off-by-default. We don't want
to expose these fonts to the web because we don't a standardization story for them
yet, but we do want some apps to be able to use them.

WebKit clients who want to use these fonts can set
-[WKPreferences _shouldAllowDesignSystemUIFonts] = YES.

The patch generalizes our existing system-ui infrastructure to handle these three
additional fonts. It also explicitly disables the unsupported dot-prefixed names
so they don't leak out into Web content.

Tests: fast/text/design-system-ui-10.html
       fast/text/design-system-ui-11.html
       fast/text/design-system-ui-12.html
       fast/text/design-system-ui-13.html
       fast/text/design-system-ui-14.html
       fast/text/design-system-ui-15.html
       fast/text/design-system-ui-16.html
       fast/text/design-system-ui-2.html
       fast/text/design-system-ui-3.html
       fast/text/design-system-ui-4.html
       fast/text/design-system-ui-5.html
       fast/text/design-system-ui-6.html
       fast/text/design-system-ui-7.html
       fast/text/design-system-ui-8.html
       fast/text/design-system-ui-9.html
       fast/text/design-system-ui.html

* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::shouldAllowDesignSystemUIFonts const):
* css/CSSFontFace.h:
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::load):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::initializeFontStyle):
* page/Settings.yaml:
* platform/graphics/FontDescription.cpp:
(WebCore::m_shouldAllowDesignSystemUIFonts):
(WebCore::m_shouldAllowUserInstalledFonts): Deleted.
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::shouldAllowDesignSystemUIFonts const):
(WebCore::FontDescription::setShouldAllowDesignSystemUIFonts):
(WebCore::FontDescription::operator== const):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::platformFontLookupWithFamily):
(WebCore::fontWithFamily):
* platform/graphics/cocoa/FontCacheCoreText.h:
* platform/graphics/cocoa/FontDescriptionCocoa.cpp:
(WebCore::systemFontUse):
(WebCore::systemFontCascadeList):
(WebCore::FontCascadeDescription::effectiveFamilyCount const):
(WebCore::FontCascadeDescription::effectiveFamilyAt const):
(WebCore::isSystemFontString): Deleted.
(WebCore::isUIFontTextStyle): Deleted.
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::ctFont const):
* platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
(WebCore::SystemFontDatabaseCoreText::createSystemUI):
(WebCore::SystemFontDatabaseCoreText::createDesignSystemUI):
(WebCore::SystemFontDatabaseCoreText::createTextStyle):
(WebCore::SystemFontDatabaseCoreText::cascadeList):
(WebCore::SystemFontDatabaseCoreText::applyWeightItalicsAndFallbackBehavior):
(WebCore::SystemFontDatabaseCoreText::systemFontParameters):
* platform/graphics/cocoa/SystemFontDatabaseCoreText.h:
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::platformFontWithFamilySpecialCase):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformFontWithFamilySpecialCase):
* style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setShouldAllowDesignSystemUIFonts):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:

Source/WebCore/PAL:

* pal/spi/cocoa/CoreTextSPI.h:

Source/WebKit:

Add the SPI to enable the new fonts.

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetShouldAllowDesignSystemUIFonts):
(WKPreferencesGetShouldAllowDesignSystemUIFonts):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _shouldAllowDesignSystemUIFonts]):
(-[WKPreferences _setShouldAllowDesignSystemUIFonts:]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:

Source/WTF:

* wtf/Platform.h:

LayoutTests:

* TestExpectations:
* fast/text/design-system-ui-10-expected-mismatch.html: Added.
* fast/text/design-system-ui-10.html: Added.
* fast/text/design-system-ui-11-expected-mismatch.html: Added.
* fast/text/design-system-ui-11.html: Added.
* fast/text/design-system-ui-12-expected-mismatch.html: Added.
* fast/text/design-system-ui-12.html: Added.
* fast/text/design-system-ui-13-expected-mismatch.html: Added.
* fast/text/design-system-ui-13.html: Added.
* fast/text/design-system-ui-14-expected-mismatch.html: Added.
* fast/text/design-system-ui-14.html: Added.
* fast/text/design-system-ui-15-expected-mismatch.html: Added.
* fast/text/design-system-ui-15.html: Added.
* fast/text/design-system-ui-16-expected-mismatch.html: Added.
* fast/text/design-system-ui-16.html: Added.
* fast/text/design-system-ui-2-expected.html: Added.
* fast/text/design-system-ui-2.html: Added.
* fast/text/design-system-ui-3-expected-mismatch.html: Added.
* fast/text/design-system-ui-3.html: Added.
* fast/text/design-system-ui-4-expected-mismatch.html: Added.
* fast/text/design-system-ui-4.html: Added.
* fast/text/design-system-ui-5-expected-mismatch.html: Added.
* fast/text/design-system-ui-5.html: Added.
* fast/text/design-system-ui-6-expected.html: Added.
* fast/text/design-system-ui-6.html: Added.
* fast/text/design-system-ui-7-expected.html: Added.
* fast/text/design-system-ui-7.html: Added.
* fast/text/design-system-ui-8-expected-mismatch.html: Added.
* fast/text/design-system-ui-8.html: Added.
* fast/text/design-system-ui-9-expected-mismatch.html: Added.
* fast/text/design-system-ui-9.html: Added.
* fast/text/design-system-ui-expected.html: Added.
* fast/text/design-system-ui.html: Added.
* platform/mac/TestExpectations:

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

62 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/text/design-system-ui-10-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-10.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-11-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-11.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-12-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-12.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-13-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-13.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-14-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-14.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-15-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-15.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-16-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-16.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-2-expected.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-2.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-3-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-3.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-4-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-4.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-5-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-5.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-6-expected.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-6.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-7-expected.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-7.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-8-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-8.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-9-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-9.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-expected.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h
Source/WebCore/css/CSSFontFace.cpp
Source/WebCore/css/CSSFontFace.h
Source/WebCore/css/CSSFontFaceSource.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/page/Settings.yaml
Source/WebCore/platform/graphics/FontCache.h
Source/WebCore/platform/graphics/FontDescription.cpp
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h
Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp
Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h
Source/WebCore/platform/graphics/ios/FontCacheIOS.mm
Source/WebCore/platform/graphics/mac/FontCacheMac.mm
Source/WebCore/style/StyleResolveForDocument.cpp
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h

index f44de98..c09bab7 100644 (file)
@@ -1,3 +1,46 @@
+2019-07-11  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        New York font erroneously gets synthetic bold
+        https://bugs.webkit.org/show_bug.cgi?id=199653
+        <rdar://problem/51692592>
+
+        Reviewed by Simon Fraser.
+
+        * TestExpectations:
+        * fast/text/design-system-ui-10-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-10.html: Added.
+        * fast/text/design-system-ui-11-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-11.html: Added.
+        * fast/text/design-system-ui-12-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-12.html: Added.
+        * fast/text/design-system-ui-13-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-13.html: Added.
+        * fast/text/design-system-ui-14-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-14.html: Added.
+        * fast/text/design-system-ui-15-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-15.html: Added.
+        * fast/text/design-system-ui-16-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-16.html: Added.
+        * fast/text/design-system-ui-2-expected.html: Added.
+        * fast/text/design-system-ui-2.html: Added.
+        * fast/text/design-system-ui-3-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-3.html: Added.
+        * fast/text/design-system-ui-4-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-4.html: Added.
+        * fast/text/design-system-ui-5-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-5.html: Added.
+        * fast/text/design-system-ui-6-expected.html: Added.
+        * fast/text/design-system-ui-6.html: Added.
+        * fast/text/design-system-ui-7-expected.html: Added.
+        * fast/text/design-system-ui-7.html: Added.
+        * fast/text/design-system-ui-8-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-8.html: Added.
+        * fast/text/design-system-ui-9-expected-mismatch.html: Added.
+        * fast/text/design-system-ui-9.html: Added.
+        * fast/text/design-system-ui-expected.html: Added.
+        * fast/text/design-system-ui.html: Added.
+        * platform/mac/TestExpectations:
+
 2019-07-11  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         [GTK][WPE] Rebaseline css3/blending tests with an empty homedir.
index 0aeced5..a43462b 100644 (file)
@@ -3443,3 +3443,11 @@ webkit.org/b/199039 editing/deleting/smart-delete-paragraph-003.html [ Skip ]
 webkit.org/b/199028 webgpu/whlsl-test-harness-test.html [ Slow ]
 
 imported/w3c/web-platform-tests/css/cssom-view/offsetTopLeft-inline.html [ ImageOnlyFailure ]
+
+# These tests only work on systems with the design system ui fonts installed.
+fast/text/design-system-ui-11.html [ ImageOnlyFailure ]
+fast/text/design-system-ui-12.html [ ImageOnlyFailure ]
+fast/text/design-system-ui-13.html [ ImageOnlyFailure ]
+fast/text/design-system-ui-14.html [ ImageOnlyFailure ]
+fast/text/design-system-ui-15.html [ ImageOnlyFailure ]
+fast/text/design-system-ui-16.html [ ImageOnlyFailure ]
diff --git a/LayoutTests/fast/text/design-system-ui-10-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-10-expected-mismatch.html
new file mode 100644 (file)
index 0000000..ad59bae
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUIRounded";
+    src: local("-apple-system-ui-rounded");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px 'AppleSystemUIRounded'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-10.html b/LayoutTests/fast/text/design-system-ui-10.html
new file mode 100644 (file)
index 0000000..5f6a3eb
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUIRounded";
+    src: local("-apple-system-ui-rounded");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUIRounded'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-11-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-11-expected-mismatch.html
new file mode 100644 (file)
index 0000000..253794a
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-11.html b/LayoutTests/fast/text/design-system-ui-11.html
new file mode 100644 (file)
index 0000000..b403a7c
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-serif';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-12-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-12-expected-mismatch.html
new file mode 100644 (file)
index 0000000..253794a
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-12.html b/LayoutTests/fast/text/design-system-ui-12.html
new file mode 100644 (file)
index 0000000..2a39637
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-monospaced';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-13-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-13-expected-mismatch.html
new file mode 100644 (file)
index 0000000..253794a
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-13.html b/LayoutTests/fast/text/design-system-ui-13.html
new file mode 100644 (file)
index 0000000..c614391
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-rounded';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-14-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-14-expected-mismatch.html
new file mode 100644 (file)
index 0000000..253794a
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-14.html b/LayoutTests/fast/text/design-system-ui-14.html
new file mode 100644 (file)
index 0000000..d5ca66b
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUISerif";
+    src: local("-apple-system-ui-serif");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px 'AppleSystemUISerif';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-15-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-15-expected-mismatch.html
new file mode 100644 (file)
index 0000000..253794a
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-15.html b/LayoutTests/fast/text/design-system-ui-15.html
new file mode 100644 (file)
index 0000000..2a6fffa
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUIMonospaced";
+    src: local("-apple-system-ui-monospaced");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px 'AppleSystemUIMonospaced';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-16-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-16-expected-mismatch.html
new file mode 100644 (file)
index 0000000..253794a
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-16.html b/LayoutTests/fast/text/design-system-ui-16.html
new file mode 100644 (file)
index 0000000..771d38d
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUIRounded";
+    src: local("-apple-system-ui-rounded");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px 'AppleSystemUIRounded';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-2-expected.html b/LayoutTests/fast/text/design-system-ui-2-expected.html
new file mode 100644 (file)
index 0000000..5adc362
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+This test makes sure that the design system UI fonts don't work unless the shouldAllowDesignSystemUIFonts preference is set. The test passes if all the text below is bold.
+<div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-serif';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-monospaced';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-rounded';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '.AppleSystemUIFontSerif';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '.SF NS Mono';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '.SF UI Mono';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '.AppleSystemUIFontRounded';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-2.html b/LayoutTests/fast/text/design-system-ui-2.html
new file mode 100644 (file)
index 0000000..77f66cd
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+This test makes sure that the design system UI fonts don't work unless the shouldAllowDesignSystemUIFonts preference is set. The test passes if all the text below is bold.
+<div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-serif'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-monospaced'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-rounded'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '.AppleSystemUIFontSerif'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '.SF NS Mono'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '.SF UI Mono'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px '.AppleSystemUIFontRounded'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-3-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-3-expected-mismatch.html
new file mode 100644 (file)
index 0000000..616138f
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-serif'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-3.html b/LayoutTests/fast/text/design-system-ui-3.html
new file mode 100644 (file)
index 0000000..c5334a6
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-serif'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-4-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-4-expected-mismatch.html
new file mode 100644 (file)
index 0000000..fc2e48a
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-monospaced'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-4.html b/LayoutTests/fast/text/design-system-ui-4.html
new file mode 100644 (file)
index 0000000..837f2ba
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-monospaced'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-5-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-5-expected-mismatch.html
new file mode 100644 (file)
index 0000000..2186ce6
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-rounded'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-5.html b/LayoutTests/fast/text/design-system-ui-5.html
new file mode 100644 (file)
index 0000000..cfa6fae
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: bold 72px '-apple-system-ui-rounded'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-6-expected.html b/LayoutTests/fast/text/design-system-ui-6-expected.html
new file mode 100644 (file)
index 0000000..b6cdaed
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that the design system UI fonts don't work unless the shouldAllowDesignSystemUIFonts preference is set. The test passes if all the text below is rendered in Times.
+<div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-6.html b/LayoutTests/fast/text/design-system-ui-6.html
new file mode 100644 (file)
index 0000000..12dabb6
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "AppleSystemUISerif";
+    src: local("-apple-system-ui-serif");
+}
+@font-face {
+    font-family: "AppleSystemUIMonospaced";
+    src: local("-apple-system-ui-monospaced");
+}
+@font-face {
+    font-family: "AppleSystemUIRounded";
+    src: local("-apple-system-ui-rounded");
+}
+@font-face {
+    font-family: "DotAppleSystemUIFontSerif";
+    src: local(".AppleSystemUIFontSerif");
+}
+@font-face {
+    font-family: "DotSFNSMono";
+    src: local(".SF NS Mono");
+}
+@font-face {
+    font-family: "DotSFUIMono";
+    src: local(".SF UI Mono");
+}
+@font-face {
+    font-family: "DotAppleSystemUIFontRounded";
+    src: local(".AppleSystemUIFontRounded");
+}
+</style>
+</head>
+<body>
+This test makes sure that the design system UI fonts don't work unless the shouldAllowDesignSystemUIFonts preference is set. The test passes if all the text below is rendered in Times.
+<div>
+<div style="display: inline-block; font: 72px 'AppleSystemUISerif';">HeJllo</div>
+<div style="display: inline-block; font: 72px 'AppleSystemUIMonospaced';">HeJllo</div>
+<div style="display: inline-block; font: 72px 'AppleSystemUIRounded';">HeJllo</div>
+<div style="display: inline-block; font: 72px 'DotAppleSystemUIFontSerif';">HeJllo</div>
+<div style="display: inline-block; font: 72px 'DotSFNSMono';">HeJllo</div>
+<div style="display: inline-block; font: 72px 'DotSFUIMono';">HeJllo</div>
+<div style="display: inline-block; font: 72px 'DotAppleSystemUIFontRounded';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-7-expected.html b/LayoutTests/fast/text/design-system-ui-7-expected.html
new file mode 100644 (file)
index 0000000..4753870
--- /dev/null
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUISerif";
+    src: local("-apple-system-ui-serif");
+}
+@font-face {
+    font-family: "AppleSystemUIMonospaced";
+    src: local("-apple-system-ui-monospaced");
+}
+@font-face {
+    font-family: "AppleSystemUIRounded";
+    src: local("-apple-system-ui-rounded");
+}
+@font-face {
+    font-family: "DotAppleSystemUIFontSerif";
+    src: local(".AppleSystemUIFontSerif");
+}
+@font-face {
+    font-family: "DotSFNSMono";
+    src: local(".SF NS Mono");
+}
+@font-face {
+    font-family: "DotSFUIMono";
+    src: local(".SF UI Mono");
+}
+@font-face {
+    font-family: "DotAppleSystemUIFontRounded";
+    src: local(".AppleSystemUIFontRounded");
+}
+</style>
+</head>
+<body>
+This test makes sure that the design system UI fonts don't work unless the shouldAllowDesignSystemUIFonts preference is set. The test passes if all the text below is bold.
+<div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUISerif';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUIMonospaced';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUIRounded';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'DotAppleSystemUIFontSerif';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'DotSFNSMono';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'DotSFUIMono';">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'DotAppleSystemUIFontRounded';">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-7.html b/LayoutTests/fast/text/design-system-ui-7.html
new file mode 100644 (file)
index 0000000..616d87d
--- /dev/null
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUISerif";
+    src: local("-apple-system-ui-serif");
+}
+@font-face {
+    font-family: "AppleSystemUIMonospaced";
+    src: local("-apple-system-ui-monospaced");
+}
+@font-face {
+    font-family: "AppleSystemUIRounded";
+    src: local("-apple-system-ui-rounded");
+}
+@font-face {
+    font-family: "DotAppleSystemUIFontSerif";
+    src: local(".AppleSystemUIFontSerif");
+}
+@font-face {
+    font-family: "DotSFNSMono";
+    src: local(".SF NS Mono");
+}
+@font-face {
+    font-family: "DotSFUIMono";
+    src: local(".SF UI Mono");
+}
+@font-face {
+    font-family: "DotAppleSystemUIFontRounded";
+    src: local(".AppleSystemUIFontRounded");
+}
+</style>
+</head>
+<body>
+This test makes sure that the design system UI fonts don't work unless the shouldAllowDesignSystemUIFonts preference is set. The test passes if all the text below is bold.
+<div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUISerif'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUIMonospaced'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUIRounded'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'DotAppleSystemUIFontSerif'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'DotSFNSMono'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'DotSFUIMono'; font-synthesis: none;">HeJllo</div>
+<div style="display: inline-block; font: bold 72px 'DotAppleSystemUIFontRounded'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-8-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-8-expected-mismatch.html
new file mode 100644 (file)
index 0000000..9e98049
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUISerif";
+    src: local("-apple-system-ui-serif");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px 'AppleSystemUISerif'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-8.html b/LayoutTests/fast/text/design-system-ui-8.html
new file mode 100644 (file)
index 0000000..49a1d1d
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUISerif";
+    src: local("-apple-system-ui-serif");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUISerif'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-9-expected-mismatch.html b/LayoutTests/fast/text/design-system-ui-9-expected-mismatch.html
new file mode 100644 (file)
index 0000000..e0fbf78
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUIMonospaced";
+    src: local("-apple-system-ui-monospaced");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: 72px 'AppleSystemUIMonospaced'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-9.html b/LayoutTests/fast/text/design-system-ui-9.html
new file mode 100644 (file)
index 0000000..469eeb4
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.settings.setShouldAllowDesignSystemUIFonts(true);
+</script>
+<style>
+@font-face {
+    font-family: "AppleSystemUIMonospaced";
+    src: local("-apple-system-ui-monospaced");
+}
+</style>
+</head>
+<body>
+<div>
+<div style="display: inline-block; font: bold 72px 'AppleSystemUIMonospaced'; font-synthesis: none;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-expected.html b/LayoutTests/fast/text/design-system-ui-expected.html
new file mode 100644 (file)
index 0000000..b6cdaed
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that the design system UI fonts don't work unless the shouldAllowDesignSystemUIFonts preference is set. The test passes if all the text below is rendered in Times.
+<div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+<div style="display: inline-block; font-size: 72px;">HeJllo</div>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui.html b/LayoutTests/fast/text/design-system-ui.html
new file mode 100644 (file)
index 0000000..40470c0
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that the design system UI fonts don't work unless the shouldAllowDesignSystemUIFonts preference is set. The test passes if all the text below is rendered in Times.
+<div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-serif';">HeJllo</div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-monospaced';">HeJllo</div>
+<div style="display: inline-block; font: 72px '-apple-system-ui-rounded';">HeJllo</div>
+<div style="display: inline-block; font: 72px '.AppleSystemUIFontSerif';">HeJllo</div>
+<div style="display: inline-block; font: 72px '.SF NS Mono';">HeJllo</div>
+<div style="display: inline-block; font: 72px '.SF UI Mono';">HeJllo</div>
+<div style="display: inline-block; font: 72px '.AppleSystemUIFontRounded';">HeJllo</div>
+</div>
+</body>
+</html>
index 28841a8..4aadb1e 100644 (file)
@@ -1972,3 +1972,11 @@ webkit.org/b/195635 scrollingcoordinator/mac/multiple-fixed.html [ Pass Timeout
 [ Catalina+ ] http/wpt/resource-timing/rt-initiatorType-script-module.html [ Pass Failure ]
 [ Catalina+ ] http/wpt/resource-timing/rt-initiatorType-element.html [ Pass Failure ]
 [ Catalina+ ] http/wpt/resource-timing/rt-initiatorType-xmlhttprequest.html [ Pass Failure ]
+
+# These tests require the design system ui fonts to be installed.
+[ Catalina+ ] fast/text/design-system-ui-11.html [ Pass ]
+[ Catalina+ ] fast/text/design-system-ui-12.html [ Pass ]
+[ Catalina+ ] fast/text/design-system-ui-13.html [ Pass ]
+[ Catalina+ ] fast/text/design-system-ui-14.html [ Pass ]
+[ Catalina+ ] fast/text/design-system-ui-15.html [ Pass ]
+[ Catalina+ ] fast/text/design-system-ui-16.html [ Pass ]
index 83c3c86..0151ba9 100644 (file)
@@ -1,3 +1,13 @@
+2019-07-11  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        New York font erroneously gets synthetic bold
+        https://bugs.webkit.org/show_bug.cgi?id=199653
+        <rdar://problem/51692592>
+
+        Reviewed by Simon Fraser.
+
+        * wtf/Platform.h:
+
 2019-07-11  Pablo Saavedra  <psaavedra@igalia.com>
 
         [WPE][GTK] Build failure with ENABLE_ACCESSIBILITY=OFF
index eaa365e..57b59e1 100644 (file)
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
 #define HAVE_SUBVIEWS_IVAR_SPI 1
 #endif
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000)
+#define HAVE_DESIGN_SYSTEM_UI_FONTS 1
+#endif
index 2342774..e4925b0 100644 (file)
@@ -1,3 +1,91 @@
+2019-07-11  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        New York font erroneously gets synthetic bold
+        https://bugs.webkit.org/show_bug.cgi?id=199653
+        <rdar://problem/51692592>
+
+        Reviewed by Simon Fraser.
+
+        This patch adds support for -apple-system-ui-serif, -apple-system-ui-monospaced,
+        and -apple-system-ui-rounded, behind an SPI that is off-by-default. We don't want
+        to expose these fonts to the web because we don't a standardization story for them
+        yet, but we do want some apps to be able to use them.
+
+        WebKit clients who want to use these fonts can set
+        -[WKPreferences _shouldAllowDesignSystemUIFonts] = YES.
+
+        The patch generalizes our existing system-ui infrastructure to handle these three
+        additional fonts. It also explicitly disables the unsupported dot-prefixed names
+        so they don't leak out into Web content.
+
+        Tests: fast/text/design-system-ui-10.html
+               fast/text/design-system-ui-11.html
+               fast/text/design-system-ui-12.html
+               fast/text/design-system-ui-13.html
+               fast/text/design-system-ui-14.html
+               fast/text/design-system-ui-15.html
+               fast/text/design-system-ui-16.html
+               fast/text/design-system-ui-2.html
+               fast/text/design-system-ui-3.html
+               fast/text/design-system-ui-4.html
+               fast/text/design-system-ui-5.html
+               fast/text/design-system-ui-6.html
+               fast/text/design-system-ui-7.html
+               fast/text/design-system-ui-8.html
+               fast/text/design-system-ui-9.html
+               fast/text/design-system-ui.html
+
+        * css/CSSFontFace.cpp:
+        (WebCore::CSSFontFace::shouldAllowDesignSystemUIFonts const):
+        * css/CSSFontFace.h:
+        * css/CSSFontFaceSource.cpp:
+        (WebCore::CSSFontFaceSource::load):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::initializeFontStyle):
+        * page/Settings.yaml:
+        * platform/graphics/FontDescription.cpp:
+        (WebCore::m_shouldAllowDesignSystemUIFonts):
+        (WebCore::m_shouldAllowUserInstalledFonts): Deleted.
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::shouldAllowDesignSystemUIFonts const):
+        (WebCore::FontDescription::setShouldAllowDesignSystemUIFonts):
+        (WebCore::FontDescription::operator== const):
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::platformFontLookupWithFamily):
+        (WebCore::fontWithFamily):
+        * platform/graphics/cocoa/FontCacheCoreText.h:
+        * platform/graphics/cocoa/FontDescriptionCocoa.cpp:
+        (WebCore::systemFontUse):
+        (WebCore::systemFontCascadeList):
+        (WebCore::FontCascadeDescription::effectiveFamilyCount const):
+        (WebCore::FontCascadeDescription::effectiveFamilyAt const):
+        (WebCore::isSystemFontString): Deleted.
+        (WebCore::isUIFontTextStyle): Deleted.
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::ctFont const):
+        * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
+        (WebCore::SystemFontDatabaseCoreText::createSystemUI):
+        (WebCore::SystemFontDatabaseCoreText::createDesignSystemUI):
+        (WebCore::SystemFontDatabaseCoreText::createTextStyle):
+        (WebCore::SystemFontDatabaseCoreText::cascadeList):
+        (WebCore::SystemFontDatabaseCoreText::applyWeightItalicsAndFallbackBehavior):
+        (WebCore::SystemFontDatabaseCoreText::systemFontParameters):
+        * platform/graphics/cocoa/SystemFontDatabaseCoreText.h:
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::platformFontWithFamilySpecialCase):
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::platformFontWithFamilySpecialCase):
+        * style/StyleResolveForDocument.cpp:
+        (WebCore::Style::resolveForDocument):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::dataChanged):
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::Backup::Backup):
+        (WebCore::InternalSettings::Backup::restoreTo):
+        (WebCore::InternalSettings::setShouldAllowDesignSystemUIFonts):
+        * testing/InternalSettings.h:
+        * testing/InternalSettings.idl:
+
 2019-07-11  Pablo Saavedra  <psaavedra@igalia.com>
 
         [WPE][GTK] Build failure with ENABLE_ACCESSIBILITY=OFF
index 320cada..c069a14 100644 (file)
@@ -1,3 +1,13 @@
+2019-07-11  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        New York font erroneously gets synthetic bold
+        https://bugs.webkit.org/show_bug.cgi?id=199653
+        <rdar://problem/51692592>
+
+        Reviewed by Simon Fraser.
+
+        * pal/spi/cocoa/CoreTextSPI.h:
+
 2019-07-11  Jonathan Bedard  <jbedard@apple.com>
 
         [iOS 13] Enable WebKit build
index d62bb25..1b110bf 100644 (file)
@@ -111,6 +111,11 @@ extern const CFStringRef kCTFontCSSWidthAttribute;
 extern const CFStringRef kCTFontDescriptorTextStyleAttribute;
 extern const CFStringRef kCTFontUIFontDesignTrait;
 
+extern const CFStringRef kCTFontUIFontDesignDefault;
+extern const CFStringRef kCTFontUIFontDesignSerif;
+extern const CFStringRef kCTFontUIFontDesignMonospaced;
+extern const CFStringRef kCTFontUIFontDesignRounded;
+
 extern const CFStringRef kCTFrameMaximumNumberOfLinesAttributeName;
 
 bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
index 7377adb..7709b5d 100644 (file)
@@ -594,6 +594,13 @@ AllowUserInstalledFonts CSSFontFace::allowUserInstalledFonts() const
     return AllowUserInstalledFonts::Yes;
 }
 
+bool CSSFontFace::shouldAllowDesignSystemUIFonts() const
+{
+    if (m_fontSelector && m_fontSelector->document())
+        return m_fontSelector->document()->settings().shouldAllowDesignSystemUIFonts();
+    return false;
+}
+
 static Settings::FontLoadTimingOverride fontLoadTimingOverride(CSSFontSelector* fontSelector)
 {
     auto overrideValue = Settings::FontLoadTimingOverride::None;
index a39a926..676fba8 100644 (file)
@@ -162,6 +162,7 @@ public:
     bool purgeable() const;
 
     AllowUserInstalledFonts allowUserInstalledFonts() const;
+    bool shouldAllowDesignSystemUIFonts() const;
 
     void updateStyleIfNeeded();
 
index 30be7f4..00fd160 100644 (file)
@@ -183,6 +183,7 @@ void CSSFontFaceSource::load(CSSFontSelector* fontSelector)
             fontDescription.setOneFamily(m_familyNameOrURI);
             fontDescription.setComputedSize(1);
             fontDescription.setShouldAllowUserInstalledFonts(m_face.allowUserInstalledFonts());
+            fontDescription.setShouldAllowDesignSystemUIFonts(m_face.shouldAllowDesignSystemUIFonts());
             success = FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, nullptr, nullptr, FontSelectionSpecifiedCapabilities(), true);
             if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) {
                 if (auto* document = fontSelector->document())
index 56d8727..8901ab0 100644 (file)
@@ -1936,6 +1936,7 @@ void StyleResolver::initializeFontStyle()
     fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
     setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueMedium, false, document()));
     fontDescription.setShouldAllowUserInstalledFonts(settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No);
+    fontDescription.setShouldAllowDesignSystemUIFonts(settings().shouldAllowDesignSystemUIFonts());
     setFontDescription(WTFMove(fontDescription));
 }
 
index e22d8d4..8a74147 100644 (file)
@@ -738,6 +738,10 @@ shouldAllowUserInstalledFonts:
   initial: true
   onChange: setNeedsRecalcStyleInAllFrames
 
+shouldAllowDesignSystemUIFonts:
+  initial: false
+  onChange: setNeedsRecalcStyleInAllFrames
+
 resizeObserverEnabled:
   initial: false
   conditional: RESIZE_OBSERVER
index f65bf3a..5cae8ac 100644 (file)
@@ -128,7 +128,8 @@ struct FontDescriptionKey {
 private:
     static std::array<unsigned, 2> makeFlagsKey(const FontDescription& description)
     {
-        unsigned first = static_cast<unsigned>(description.script()) << 14
+        unsigned first = static_cast<unsigned>(description.script()) << 15
+            | static_cast<unsigned>(description.shouldAllowDesignSystemUIFonts()) << 14
             | static_cast<unsigned>(description.shouldAllowUserInstalledFonts()) << 13
             | static_cast<unsigned>(description.fontStyleAxis() == FontStyleAxis::slnt) << 12
             | static_cast<unsigned>(description.opticalSizing()) << 11
index 8a924f9..132162c 100644 (file)
@@ -62,6 +62,7 @@ FontDescription::FontDescription()
     , m_opticalSizing(static_cast<unsigned>(FontOpticalSizing::Enabled))
     , m_fontStyleAxis(FontCascadeDescription::initialFontStyleAxis() == FontStyleAxis::ital)
     , m_shouldAllowUserInstalledFonts(static_cast<unsigned>(AllowUserInstalledFonts::No))
+    , m_shouldAllowDesignSystemUIFonts(false)
 {
 }
 
index 18f1de1..21de238 100644 (file)
@@ -97,6 +97,7 @@ public:
     FontOpticalSizing opticalSizing() const { return static_cast<FontOpticalSizing>(m_opticalSizing); }
     FontStyleAxis fontStyleAxis() const { return m_fontStyleAxis ? FontStyleAxis::ital : FontStyleAxis::slnt; }
     AllowUserInstalledFonts shouldAllowUserInstalledFonts() const { return static_cast<AllowUserInstalledFonts>(m_shouldAllowUserInstalledFonts); }
+    bool shouldAllowDesignSystemUIFonts() const { return m_shouldAllowDesignSystemUIFonts; }
 
     void setComputedSize(float s) { m_computedSize = clampToFloat(s); }
     void setItalic(Optional<FontSelectionValue> italic) { m_fontSelectionRequest.slope = italic; }
@@ -132,6 +133,7 @@ public:
     void setOpticalSizing(FontOpticalSizing sizing) { m_opticalSizing = static_cast<unsigned>(sizing); }
     void setFontStyleAxis(FontStyleAxis axis) { m_fontStyleAxis = axis == FontStyleAxis::ital; }
     void setShouldAllowUserInstalledFonts(AllowUserInstalledFonts shouldAllowUserInstalledFonts) { m_shouldAllowUserInstalledFonts = static_cast<unsigned>(shouldAllowUserInstalledFonts); }
+    void setShouldAllowDesignSystemUIFonts(bool allow) { m_shouldAllowDesignSystemUIFonts = allow; }
 
     static AtomString platformResolveGenericFamily(UScriptCode, const AtomString& locale, const AtomString& familyName);
 
@@ -168,6 +170,7 @@ private:
     unsigned m_opticalSizing : 1; // FontOpticalSizing
     unsigned m_fontStyleAxis : 1; // Whether "font-style: italic" or "font-style: oblique 20deg" was specified
     unsigned m_shouldAllowUserInstalledFonts : 1; // AllowUserInstalledFonts: If this description is allowed to match a user-installed font
+    unsigned m_shouldAllowDesignSystemUIFonts : 1; // Whether -apple-system-ui-serif, -apple-system-ui-monospaced, and -apple-system-ui-rounded are supported
 };
 
 inline bool FontDescription::operator==(const FontDescription& other) const
@@ -202,7 +205,8 @@ inline bool FontDescription::operator==(const FontDescription& other) const
         && m_variantEastAsianRuby == other.m_variantEastAsianRuby
         && m_opticalSizing == other.m_opticalSizing
         && m_fontStyleAxis == other.m_fontStyleAxis
-        && m_shouldAllowUserInstalledFonts == other.m_shouldAllowUserInstalledFonts;
+        && m_shouldAllowUserInstalledFonts == other.m_shouldAllowUserInstalledFonts
+        && m_shouldAllowDesignSystemUIFonts == other.m_shouldAllowDesignSystemUIFonts;
 }
 
 }
index 4821186..6fb56e5 100644 (file)
@@ -1181,6 +1181,15 @@ static FontLookup platformFontLookupWithFamily(const AtomString& family, FontSel
     if (!isSystemFont(family) && whitelist.size() && !whitelist.contains(family))
         return { nullptr };
 
+    if (equalLettersIgnoringASCIICase(family, ".applesystemuifontserif")
+        || equalLettersIgnoringASCIICase(family, ".sf ns mono")
+        || equalLettersIgnoringASCIICase(family, ".sf ui mono")
+        || equalLettersIgnoringASCIICase(family, ".applesystemuifontrounded")) {
+        // If you want to use these fonts, set the shouldAllowDesignSystemUIFonts Setting and use
+        // -apple-system-ui-serif, -apple-system-ui-monospaced, and -apple-system-ui-rounded.
+        return { nullptr };
+    }
+
     auto& fontDatabase = allowUserInstalledFonts == AllowUserInstalledFonts::Yes ? FontDatabase::singletonAllowingUserInstalledFonts() : FontDatabase::singletonDisallowingUserInstalledFonts();
     const auto& familyFonts = fontDatabase.collectionForFamily(family.string());
     if (familyFonts.isEmpty()) {
@@ -1238,16 +1247,42 @@ static void invalidateFontCache()
     FontCache::singleton().invalidate();
 }
 
+static RetainPtr<CTFontRef> fontWithFamilySpecialCase(const AtomString& family, const FontDescription& fontDescription, float size, AllowUserInstalledFonts allowUserInstalledFonts)
+{
+#if HAVE(DESIGN_SYSTEM_UI_FONTS)
+    if (!fontDescription.shouldAllowDesignSystemUIFonts())
+        return nullptr;
+
+    Optional<SystemFontDatabaseCoreText::ClientUse> designSystemUI;
+    if (equalLettersIgnoringASCIICase(family, "-apple-system-ui-serif"))
+        designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUISerif;
+    else if (equalLettersIgnoringASCIICase(family, "-apple-system-ui-monospaced"))
+        designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIMonospaced;
+    else if (equalLettersIgnoringASCIICase(family, "-apple-system-ui-rounded"))
+        designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIRounded;
+
+    if (designSystemUI) {
+        auto cascadeList = SystemFontDatabaseCoreText::singleton().cascadeList(fontDescription, family, *designSystemUI, allowUserInstalledFonts);
+        if (!cascadeList.isEmpty())
+            return createFontForInstalledFonts(cascadeList[0].get(), size, allowUserInstalledFonts);
+    }
+#endif
+
+    return nullptr;
+}
+
 static RetainPtr<CTFontRef> fontWithFamily(const AtomString& family, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size)
 {
     if (family.isEmpty())
         return nullptr;
 
-    const auto& request = fontDescription.fontSelectionRequest();
     FontLookup fontLookup;
-    fontLookup.result = platformFontWithFamilySpecialCase(family, request, size, fontDescription.shouldAllowUserInstalledFonts());
-    if (!fontLookup.result)
-        fontLookup = platformFontLookupWithFamily(family, request, size, fontDescription.shouldAllowUserInstalledFonts());
+    fontLookup.result = platformFontWithFamilySpecialCase(family, fontDescription, size, fontDescription.shouldAllowUserInstalledFonts());
+    if (!fontLookup.result) {
+        fontLookup.result = fontWithFamilySpecialCase(family, fontDescription, size, fontDescription.shouldAllowUserInstalledFonts());
+        if (!fontLookup.result)
+            fontLookup = platformFontLookupWithFamily(family, fontDescription.fontSelectionRequest(), size, fontDescription.shouldAllowUserInstalledFonts());
+    }
     return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, !fontLookup.createdFromPostScriptName);
 }
 
index b7a8066..4e37e37 100644 (file)
@@ -52,7 +52,7 @@ struct SynthesisPair {
 
 RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool applyWeightWidthSlopeVariations = true);
 SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false);
-RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomString& family, FontSelectionRequest, float size, AllowUserInstalledFonts);
+RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomString& family, const FontDescription&, float size, AllowUserInstalledFonts);
 RetainPtr<CTFontRef> platformFontWithFamily(const AtomString& family, FontSelectionRequest, TextRenderingMode, float size);
 bool requiresCustomFallbackFont(UChar32 character);
 FontSelectionCapabilities capabilitiesForFontDescriptor(CTFontDescriptorRef);
index 19c7636..43e6a93 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #include "config.h"
-#include "FontDescription.h"
+#include "FontCascadeDescription.h"
 
 #include "SystemFontDatabaseCoreText.h"
 #include <mutex>
@@ -34,14 +34,6 @@ namespace WebCore {
 
 #if USE_PLATFORM_SYSTEM_FALLBACK_LIST
 
-static inline bool isSystemFontString(const AtomString& string)
-{
-    return equalLettersIgnoringASCIICase(string, "-webkit-system-font")
-        || equalLettersIgnoringASCIICase(string, "-apple-system")
-        || equalLettersIgnoringASCIICase(string, "-apple-system-font")
-        || equalLettersIgnoringASCIICase(string, "system-ui");
-}
-
 #if PLATFORM(IOS_FAMILY)
 
 template<typename T, typename U, std::size_t size, std::size_t... indices> std::array<T, size> convertArray(U (&array)[size], std::index_sequence<indices...>)
@@ -53,9 +45,30 @@ template<typename T, typename U, std::size_t size> inline std::array<T, size> co
 {
     return convertArray<T>(array, std::make_index_sequence<size> { });
 }
+#endif
 
-static inline bool isUIFontTextStyle(const AtomString& string)
+static inline Optional<SystemFontDatabaseCoreText::ClientUse> matchSystemFontUse(const AtomString& string, bool shouldAllowDesignSystemUIFonts)
 {
+    if (equalLettersIgnoringASCIICase(string, "-webkit-system-font")
+        || equalLettersIgnoringASCIICase(string, "-apple-system")
+        || equalLettersIgnoringASCIICase(string, "-apple-system-font")
+        || equalLettersIgnoringASCIICase(string, "system-ui"))
+        return SystemFontDatabaseCoreText::ClientUse::ForSystemUI;
+
+#if HAVE(DESIGN_SYSTEM_UI_FONTS)
+    if (shouldAllowDesignSystemUIFonts) {
+        if (equalLettersIgnoringASCIICase(string, "-apple-system-ui-serif"))
+            return SystemFontDatabaseCoreText::ClientUse::ForSystemUISerif;
+        if (equalLettersIgnoringASCIICase(string, "-apple-system-ui-monospaced"))
+            return SystemFontDatabaseCoreText::ClientUse::ForSystemUIMonospaced;
+        if (equalLettersIgnoringASCIICase(string, "-apple-system-ui-rounded"))
+            return SystemFontDatabaseCoreText::ClientUse::ForSystemUIRounded;
+    }
+#else
+    UNUSED_PARAM(shouldAllowDesignSystemUIFonts);
+#endif
+
+#if PLATFORM(IOS_FAMILY)
     static const CFStringRef styles[] = {
         kCTUIFontTextStyleHeadline,
         kCTUIFontTextStyleBody,
@@ -79,11 +92,14 @@ static inline bool isUIFontTextStyle(const AtomString& string)
     };
     
     static auto strings { makeNeverDestroyed(convertArray<AtomString>(styles)) };
-    return std::find(strings.get().begin(), strings.get().end(), string) != strings.get().end();
-}
+    if (std::find(strings.get().begin(), strings.get().end(), string) != strings.get().end())
+        return SystemFontDatabaseCoreText::ClientUse::ForTextStyle;
 #endif
 
-static inline Vector<RetainPtr<CTFontDescriptorRef>> systemFontCascadeList(const FontCascadeDescription& description, const AtomString& cssFamily, SystemFontDatabaseCoreText::ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
+    return WTF::nullopt;
+}
+
+static inline Vector<RetainPtr<CTFontDescriptorRef>> systemFontCascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontDatabaseCoreText::ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
 {
     return SystemFontDatabaseCoreText::singleton().cascadeList(description, cssFamily, clientUse, allowUserInstalledFonts);
 }
@@ -94,12 +110,8 @@ unsigned FontCascadeDescription::effectiveFamilyCount() const
     unsigned result = 0;
     for (unsigned i = 0; i < familyCount(); ++i) {
         const auto& cssFamily = familyAt(i);
-        if (isSystemFontString(cssFamily))
-            result += systemFontCascadeList(*this, cssFamily, SystemFontDatabaseCoreText::ClientUse::ForSystemUI, shouldAllowUserInstalledFonts()).size();
-#if PLATFORM(IOS_FAMILY)
-        else if (isUIFontTextStyle(cssFamily))
-            result += systemFontCascadeList(*this, cssFamily, SystemFontDatabaseCoreText::ClientUse::ForTextStyle, shouldAllowUserInstalledFonts()).size();
-#endif
+        if (auto use = matchSystemFontUse(cssFamily, shouldAllowDesignSystemUIFonts()))
+            result += systemFontCascadeList(*this, cssFamily, *use, shouldAllowUserInstalledFonts()).size();
         else
             ++result;
     }
@@ -117,20 +129,12 @@ FontFamilySpecification FontCascadeDescription::effectiveFamilyAt(unsigned index
     // These two behaviors should be unified, which would hopefully allow us to delete this duplicate code.
     for (unsigned i = 0; i < familyCount(); ++i) {
         const auto& cssFamily = familyAt(i);
-        if (isSystemFontString(cssFamily)) {
-            auto cascadeList = systemFontCascadeList(*this, cssFamily, SystemFontDatabaseCoreText::ClientUse::ForSystemUI, shouldAllowUserInstalledFonts());
+        if (auto use = matchSystemFontUse(cssFamily, shouldAllowDesignSystemUIFonts())) {
+            auto cascadeList = systemFontCascadeList(*this, cssFamily, *use, shouldAllowUserInstalledFonts());
             if (index < cascadeList.size())
                 return FontFamilySpecification(cascadeList[index].get());
             index -= cascadeList.size();
         }
-#if PLATFORM(IOS_FAMILY)
-        else if (isUIFontTextStyle(cssFamily)) {
-            auto cascadeList = systemFontCascadeList(*this, cssFamily, SystemFontDatabaseCoreText::ClientUse::ForTextStyle, shouldAllowUserInstalledFonts());
-            if (index < cascadeList.size())
-                return FontFamilySpecification(cascadeList[index].get());
-            index -= cascadeList.size();
-        }
-#endif
         else if (!index)
             return cssFamily;
         else
index 76e0928..6f7ab46 100644 (file)
@@ -155,7 +155,7 @@ CTFontRef FontPlatformData::ctFont() const
         return m_ctFont.get();
 
     ASSERT(m_font);
-    m_ctFont = adoptCF(CTFontCreateCopyWithAttributes(m_font.get(), m_size, 0, cascadeToLastResortAndVariationsFontDescriptor(m_font.get()).get()));
+    m_ctFont = adoptCF(CTFontCreateCopyWithAttributes(m_font.get(), m_size, nullptr, cascadeToLastResortAndVariationsFontDescriptor(m_font.get()).get()));
 
     if (m_widthVariant != FontWidthVariant::RegularWidth) {
         int featureTypeValue = kTextSpacingType;
index b3d02ff..3283280 100644 (file)
@@ -47,28 +47,70 @@ SystemFontDatabaseCoreText::SystemFontDatabaseCoreText()
 
 #if USE_PLATFORM_SYSTEM_FALLBACK_LIST
 
+RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createSystemUIFont(const CascadeListParameters& parameters, CFStringRef locale)
+{
+    auto result = adoptCF(CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, parameters.size, locale));
+    ASSERT(result);
+    return createFontByApplyingWeightItalicsAndFallbackBehavior(result.get(), parameters.weight, parameters.italic, parameters.size, parameters.allowUserInstalledFonts);
+}
+
+#if HAVE(DESIGN_SYSTEM_UI_FONTS)
+RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createDesignSystemUIFont(ClientUse clientUse, const CascadeListParameters& parameters)
+{
+    CFStringRef design = kCTFontUIFontDesignDefault;
+    switch (clientUse) {
+    case ClientUse::ForSystemUISerif:
+        design = kCTFontUIFontDesignSerif;
+        break;
+    case ClientUse::ForSystemUIMonospaced:
+        design = kCTFontUIFontDesignMonospaced;
+        break;
+    case ClientUse::ForSystemUIRounded:
+        design = kCTFontUIFontDesignRounded;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+    }
+    return createFontByApplyingWeightItalicsAndFallbackBehavior(nullptr, parameters.weight, parameters.italic, parameters.size, parameters.allowUserInstalledFonts, design);
+}
+#endif
+
+RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createTextStyleFont(const CascadeListParameters& parameters)
+{
+#if PLATFORM(IOS_FAMILY)
+    auto fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(parameters.fontName.string().createCFString().get(), RenderThemeIOS::contentSizeCategory(), nullptr));
+    // FIXME: Use createFontByApplyingWeightItalicsAndFallbackBehavior() once <rdar://problem/33046041> is fixed.
+    CTFontSymbolicTraits traits = (parameters.weight >= kCTFontWeightSemibold ? kCTFontTraitBold : 0) | (parameters.italic ? kCTFontTraitItalic : 0);
+    if (traits)
+        fontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithSymbolicTraits(fontDescriptor.get(), traits, traits));
+    return createFontForInstalledFonts(fontDescriptor.get(), parameters.size, parameters.allowUserInstalledFonts);
+#else
+    UNUSED_PARAM(parameters);
+    ASSERT_NOT_REACHED();
+    return nullptr;
+#endif
+}
+
 Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const CascadeListParameters& parameters, ClientUse clientUse)
 {
     ASSERT(!parameters.fontName.isNull());
     return m_systemFontCache.ensure(parameters, [&] {
         auto localeString = parameters.locale.string().createCFString();
         RetainPtr<CTFontRef> systemFont;
-        if (clientUse == ClientUse::ForSystemUI) {
-            systemFont = adoptCF(CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, parameters.size, localeString.get()));
-            ASSERT(systemFont);
-            // FIXME: Use applyWeightItalicsAndFallbackBehavior() in both cases once <rdar://problem/33046041> is fixed.
-            systemFont = applyWeightItalicsAndFallbackBehavior(systemFont.get(), parameters.weight, parameters.italic, parameters.size, parameters.allowUserInstalledFonts);
-        } else {
-#if PLATFORM(IOS_FAMILY)
-            ASSERT(clientUse == ClientUse::ForTextStyle);
-            auto fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(parameters.fontName.string().createCFString().get(), RenderThemeIOS::contentSizeCategory(), nullptr));
-            CTFontSymbolicTraits traits = (parameters.weight >= kCTFontWeightSemibold ? kCTFontTraitBold : 0) | (parameters.italic ? kCTFontTraitItalic : 0);
-            if (traits)
-                fontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithSymbolicTraits(fontDescriptor.get(), traits, traits));
-            systemFont = createFontForInstalledFonts(fontDescriptor.get(), parameters.size, parameters.allowUserInstalledFonts);
-#else
-            ASSERT_NOT_REACHED();
+        switch (clientUse) {
+        case ClientUse::ForSystemUI:
+            systemFont = createSystemUIFont(parameters, localeString.get());
+            break;
+        case ClientUse::ForSystemUISerif:
+        case ClientUse::ForSystemUIMonospaced:
+        case ClientUse::ForSystemUIRounded:
+#if HAVE(DESIGN_SYSTEM_UI_FONTS)
+            systemFont = createDesignSystemUIFont(clientUse, parameters);
 #endif
+            break;
+        case ClientUse::ForTextStyle:
+            systemFont = createTextStyleFont(parameters);
+            break;
         }
         ASSERT(systemFont);
         auto result = computeCascadeList(systemFont.get(), localeString.get());
@@ -87,20 +129,22 @@ void SystemFontDatabaseCoreText::clear()
     m_monospaceFamilies.clear();
 }
 
-RetainPtr<CTFontRef> SystemFontDatabaseCoreText::applyWeightItalicsAndFallbackBehavior(CTFontRef font, CGFloat weight, bool italic, float size, AllowUserInstalledFonts allowUserInstalledFonts)
+RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createFontByApplyingWeightItalicsAndFallbackBehavior(CTFontRef font, CGFloat weight, bool italic, float size, AllowUserInstalledFonts allowUserInstalledFonts, CFStringRef design)
 {
     auto weightNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &weight));
     const float systemFontItalicSlope = 0.07;
     float italicsRawNumber = italic ? systemFontItalicSlope : 0;
     auto italicsNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &italicsRawNumber));
     CFTypeRef traitsKeys[] = { kCTFontWeightTrait, kCTFontSlantTrait, kCTFontUIFontDesignTrait };
-    CFTypeRef traitsValues[] = { weightNumber.get(), italicsNumber.get(), kCFBooleanTrue };
+    CFTypeRef traitsValues[] = { weightNumber.get(), italicsNumber.get(), design ? static_cast<CFTypeRef>(design) : static_cast<CFTypeRef>(kCTFontUIFontDesignDefault) };
     auto traitsDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, traitsKeys, traitsValues, WTF_ARRAY_LENGTH(traitsKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
     auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
     CFDictionaryAddValue(attributes.get(), kCTFontTraitsAttribute, traitsDictionary.get());
     addAttributesForInstalledFonts(attributes.get(), allowUserInstalledFonts);
     auto modification = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
-    return adoptCF(CTFontCreateCopyWithAttributes(font, size, nullptr, modification.get()));
+    if (font)
+        return adoptCF(CTFontCreateCopyWithAttributes(font, size, nullptr, modification.get()));
+    return adoptCF(CTFontCreateWithFontDescriptor(modification.get(), size, nullptr));
 }
 
 RetainPtr<CTFontDescriptorRef> SystemFontDatabaseCoreText::removeCascadeList(CTFontDescriptorRef fontDescriptor)
@@ -129,12 +173,13 @@ Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::computeCascad
     return result;
 }
 
-SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontCascadeDescription& description, const AtomString& familyName, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
+SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontDescription& description, const AtomString& familyName, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
 {
     CascadeListParameters result;
     result.locale = description.locale();
     result.size = description.computedSize();
     result.italic = isItalic(description.italic());
+    result.allowUserInstalledFonts = allowUserInstalledFonts;
 
     auto weight = description.weight();
     if (FontCache::singleton().shouldMockBoldSystemFontForAccessibility())
@@ -159,20 +204,36 @@ SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::sy
     else
         result.weight = kCTFontWeightBlack;
 
-    if (clientUse == ClientUse::ForSystemUI) {
+    switch (clientUse) {
+    case ClientUse::ForSystemUI: {
         static NeverDestroyed<AtomString> systemUI = AtomString("system-ui", AtomString::ConstructFromLiteral);
         result.fontName = systemUI.get();
-    } else {
-        ASSERT(clientUse == ClientUse::ForTextStyle);
+        break;
+    }
+    case ClientUse::ForSystemUISerif: {
+        static NeverDestroyed<AtomString> systemUISerif = AtomString("system-ui-serif", AtomString::ConstructFromLiteral);
+        result.fontName = systemUISerif.get();
+        break;
+    }
+    case ClientUse::ForSystemUIMonospaced: {
+        static NeverDestroyed<AtomString> systemUIMonospaced = AtomString("system-ui-monospaced", AtomString::ConstructFromLiteral);
+        result.fontName = systemUIMonospaced.get();
+        break;
+    }
+    case ClientUse::ForSystemUIRounded: {
+        static NeverDestroyed<AtomString> systemUIRounded = AtomString("system-ui-rounded", AtomString::ConstructFromLiteral);
+        result.fontName = systemUIRounded.get();
+        break;
+    }
+    case ClientUse::ForTextStyle:
         result.fontName = familyName;
+        break;
     }
 
-    result.allowUserInstalledFonts = allowUserInstalledFonts;
-
     return result;
 }
 
-Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const FontCascadeDescription& description, const AtomString& cssFamily, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
+Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const FontDescription& description, const AtomString& cssFamily, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
 {
     return cascadeList(systemFontParameters(description, cssFamily, clientUse, allowUserInstalledFonts), clientUse);
 }
index 323ab29..24af087 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "FontCascadeDescription.h"
+#include "FontDescription.h"
 #include <pal/spi/cocoa/CoreTextSPI.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashTraits.h>
@@ -96,9 +96,15 @@ public:
 
     static SystemFontDatabaseCoreText& singleton();
 
-    enum class ClientUse { ForSystemUI, ForTextStyle };
+    enum class ClientUse : uint8_t {
+        ForSystemUI,
+        ForSystemUISerif,
+        ForSystemUIMonospaced,
+        ForSystemUIRounded,
+        ForTextStyle
+    };
 
-    Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const FontCascadeDescription&, const AtomString& cssFamily, ClientUse, AllowUserInstalledFonts);
+    Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const FontDescription&, const AtomString& cssFamily, ClientUse, AllowUserInstalledFonts);
 
     String serifFamily(const String& locale);
     String sansSerifFamily(const String& locale);
@@ -113,10 +119,14 @@ private:
 
     Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const CascadeListParameters&, ClientUse);
 
-    static RetainPtr<CTFontRef> applyWeightItalicsAndFallbackBehavior(CTFontRef, CGFloat weight, bool italic, float size, AllowUserInstalledFonts);
+    RetainPtr<CTFontRef> createSystemUIFont(const CascadeListParameters&, CFStringRef locale);
+    RetainPtr<CTFontRef> createDesignSystemUIFont(ClientUse, const CascadeListParameters&);
+    RetainPtr<CTFontRef> createTextStyleFont(const CascadeListParameters&);
+
+    static RetainPtr<CTFontRef> createFontByApplyingWeightItalicsAndFallbackBehavior(CTFontRef, CGFloat weight, bool italic, float size, AllowUserInstalledFonts, CFStringRef design = nullptr);
     static RetainPtr<CTFontDescriptorRef> removeCascadeList(CTFontDescriptorRef);
     static Vector<RetainPtr<CTFontDescriptorRef>> computeCascadeList(CTFontRef, CFStringRef locale);
-    static CascadeListParameters systemFontParameters(const FontCascadeDescription&, const AtomString& familyName, ClientUse, AllowUserInstalledFonts);
+    static CascadeListParameters systemFontParameters(const FontDescription&, const AtomString& familyName, ClientUse, AllowUserInstalledFonts);
 
     HashMap<CascadeListParameters, Vector<RetainPtr<CTFontDescriptorRef>>, CascadeListParameters::CascadeListParametersHash, SimpleClassHashTraits<CascadeListParameters>> m_systemFontCache;
 
index 8ba3960..ce3f8db 100644 (file)
@@ -33,6 +33,7 @@
 
 #import "FontCascade.h"
 #import "RenderThemeIOS.h"
+#import "SystemFontDatabaseCoreText.h"
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/cocoa/CoreTextSPI.h>
 #import <wtf/HashSet.h>
@@ -128,9 +129,11 @@ static RetainPtr<CTFontDescriptorRef> systemFontDescriptor(FontSelectionValue we
     return adoptCF(CTFontDescriptorCreateCopyWithAttributes(fontDescriptor.get(), static_cast<CFDictionaryRef>(attributes.get())));
 }
 
-RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomString& family, FontSelectionRequest request, float size, AllowUserInstalledFonts allowUserInstalledFonts)
+RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomString& family, const FontDescription& fontDescription, float size, AllowUserInstalledFonts allowUserInstalledFonts)
 {
     // FIXME: See comment in FontCascadeDescription::effectiveFamilyAt() in FontDescriptionCocoa.cpp
+    const auto& request = fontDescription.fontSelectionRequest();
+
     if (family.startsWith("UICTFontTextStyle")) {
         CTFontSymbolicTraits traits = (isFontWeightBold(request.weight) || FontCache::singleton().shouldMockBoldSystemFontForAccessibility() ? kCTFontTraitBold : 0) | (isItalic(request.slope) ? kCTFontTraitItalic : 0);
         RetainPtr<CFStringRef> familyNameStr = family.string().createCFString();
@@ -140,6 +143,7 @@ RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomString& family,
         return createFontForInstalledFonts(fontDescriptor.get(), size, allowUserInstalledFonts);
     }
 
+    // FIXME: Migrate this to use SystemFontDatabaseCoreText like the design system-ui block below.
     if (equalLettersIgnoringASCIICase(family, "-webkit-system-font") || equalLettersIgnoringASCIICase(family, "-apple-system") || equalLettersIgnoringASCIICase(family, "-apple-system-font") || equalLettersIgnoringASCIICase(family, "system-ui")) {
         auto fontDescriptor = systemFontDescriptor(request.weight, isFontWeightBold(request.weight), isItalic(request.slope), size);
         return createFontForInstalledFonts(fontDescriptor.get(), size, allowUserInstalledFonts);
index b3dcdcc..2f5d4c2 100644 (file)
@@ -33,6 +33,7 @@
 #import "Font.h"
 #import "FontCascade.h"
 #import "FontPlatformData.h"
+#import "SystemFontDatabaseCoreText.h"
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <pal/spi/cocoa/CoreTextSPI.h>
 
@@ -73,9 +74,12 @@ static CGFloat toNSFontWeight(FontSelectionValue fontWeight)
     return NSFontWeightBlack;
 }
 
-RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomString& family, FontSelectionRequest request, float size, AllowUserInstalledFonts allowUserInstalledFonts)
+RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomString& family, const FontDescription& fontDescription, float size, AllowUserInstalledFonts allowUserInstalledFonts)
 {
     // FIXME: See comment in FontCascadeDescription::effectiveFamilyAt() in FontDescriptionCocoa.cpp
+    const auto& request = fontDescription.fontSelectionRequest();
+
+    // FIXME: Migrate this to use SystemFontDatabaseCoreText like the design system-ui block below.
     if (equalLettersIgnoringASCIICase(family, "-webkit-system-font") || equalLettersIgnoringASCIICase(family, "-apple-system") || equalLettersIgnoringASCIICase(family, "-apple-system-font") || equalLettersIgnoringASCIICase(family, "system-ui")) {
         RetainPtr<CTFontRef> result = toCTFont([NSFont systemFontOfSize:size weight:toNSFontWeight(request.weight)]);
         if (isItalic(request.slope)) {
index 0e43d41..dde8818 100644 (file)
@@ -110,6 +110,7 @@ RenderStyle resolveForDocument(const Document& document)
     fontDescription.setRenderingMode(settings.fontRenderingMode());
     fontDescription.setOneFamily(standardFamily);
     fontDescription.setShouldAllowUserInstalledFonts(settings.shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No);
+    fontDescription.setShouldAllowDesignSystemUIFonts(settings.shouldAllowDesignSystemUIFonts());
 
     fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
     int size = fontSizeForKeyword(CSSValueMedium, false, document);
index b2db1a6..b3f22cb 100644 (file)
@@ -471,6 +471,7 @@ EncodedDataStatus SVGImage::dataChanged(bool allDataReceived)
         m_page->settings().setPluginsEnabled(false);
         m_page->settings().setAcceleratedCompositingEnabled(false);
         m_page->settings().setShouldAllowUserInstalledFonts(false);
+        m_page->settings().setShouldAllowDesignSystemUIFonts(false);
 
         Frame& frame = m_page->mainFrame();
         frame.setView(FrameView::create(frame));
index ce571eb..96e5c82 100644 (file)
@@ -1,3 +1,23 @@
+2019-07-11  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        New York font erroneously gets synthetic bold
+        https://bugs.webkit.org/show_bug.cgi?id=199653
+        <rdar://problem/51692592>
+
+        Reviewed by Simon Fraser.
+
+        Add the SPI to enable the new fonts.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetShouldAllowDesignSystemUIFonts):
+        (WKPreferencesGetShouldAllowDesignSystemUIFonts):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences _shouldAllowDesignSystemUIFonts]):
+        (-[WKPreferences _setShouldAllowDesignSystemUIFonts:]):
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+
 2019-07-11  Chris Dumez  <cdumez@apple.com>
 
         ASSERTION FAILED: RunLoop::isMain() under IPC::Connection::sendWithAsyncReply()
index 4174681..dff5569 100644 (file)
@@ -1126,6 +1126,10 @@ ShouldAllowUserInstalledFonts:
   type: bool
   defaultValue: true
 
+ShouldAllowDesignSystemUIFonts:
+  type: bool
+  defaultValue: false
+
 MediaCapabilitiesEnabled:
   type: bool
   defaultValue: true
index e06f47e..85c2ab7 100644 (file)
@@ -713,6 +713,16 @@ static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPo
     _preferences->setShouldAllowUserInstalledFonts(_shouldAllowUserInstalledFonts);
 }
 
+- (BOOL)_shouldAllowDesignSystemUIFonts
+{
+    return _preferences->shouldAllowDesignSystemUIFonts();
+}
+
+- (void)_setShouldAllowDesignSystemUIFonts:(BOOL)_shouldAllowDesignSystemUIFonts
+{
+    _preferences->setShouldAllowDesignSystemUIFonts(_shouldAllowDesignSystemUIFonts);
+}
+
 static _WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
 {
     switch (behavior) {
index ef18193..3907428 100644 (file)
@@ -126,6 +126,7 @@ typedef NS_ENUM(NSInteger, _WKEditableLinkBehavior) {
 @property (nonatomic, setter=_setDOMPasteAllowed:) BOOL _domPasteAllowed WK_API_AVAILABLE(macos(10.13), ios(11.0));
 
 @property (nonatomic, setter=_setShouldAllowUserInstalledFonts:) BOOL _shouldAllowUserInstalledFonts WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
+@property (nonatomic, setter=_setShouldAllowDesignSystemUIFonts:) BOOL _shouldAllowDesignSystemUIFonts WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property (nonatomic, setter=_setEditableLinkBehavior:) _WKEditableLinkBehavior _editableLinkBehavior WK_API_AVAILABLE(macos(10.13.4), ios(11.3));