[Cocoa] Ask platform for generic font family mappings
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2019 02:19:19 +0000 (02:19 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2019 02:19:19 +0000 (02:19 +0000)
commit43492d417683fd827b3342723d84ccf79d067be1
tree46fd5754014ad5d32741687be9f86677ee194d95
parent5926b767c2304c6a98d6c7dba5f7fdf26e7da40a
[Cocoa] Ask platform for generic font family mappings
https://bugs.webkit.org/show_bug.cgi?id=187723
<rdar://problem/41892438>

Reviewed by Brent Fulgham.

Source/WebCore:

WebKit API allows setting the generic font families for the USCRIPT_COMMON script.
When trying to style a character with a generic font family, we first look to see if
we have a mapping for the particular script the character is rendered with, and if we
don't find a match, we then check USCRIPT_COMMON.

In the Cocoa ports, the only way families get set for non-USCRIPT_COMMON scripts (aka
the only scripts which won't use the API families) is in
SettingsBase::initializeDefaultFontFamilies(). That function only sets the families
for the CJK scripts.

The mappings inside SettingsBase are incorrect and conflict with our policy regarding
user-installed fonts. Instead, we should be consulting with the platform for some of
these mappings, by calling CTFontDescriptorCreateForCSSFamily(). However, the WebKit
API still has to work to set the mappings for untagged content. Therefore, we use the
system mappings for language-tagged content, and the API mappings for non-language-tagged
content. This is a good balance that makes sure we always have a good mapping for every
language, but API clients can still set the mappings, too.

Test: fast/text/ja-sans-serif.html

* css/CSSComputedStyleDeclaration.cpp:
* css/CSSFontSelector.cpp:
(WebCore::resolveGenericFamily):
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeFontFamily):
* page/cocoa/SettingsBaseCocoa.mm:
(WebCore::SettingsBase::initializeDefaultFontFamilies):
(WebCore::osakaMonoIsInstalled): Deleted.
* platform/graphics/FontDescription.cpp:
(WebCore::FontDescription::platformResolveGenericFamily):
* platform/graphics/FontDescription.h:
* platform/graphics/cocoa/FontDescriptionCocoa.cpp:
(WebCore::computeSpecializedChineseLocale):
(WebCore::cachedSpecializedChineseLocale):
(WebCore::languageChanged):
(WebCore::FontDescription::platformResolveGenericFamily):
* platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
(WebCore::SystemFontDatabaseCoreText::clear):
(WebCore::genericFamily):
(WebCore::SystemFontDatabaseCoreText::serifFamily):
(WebCore::SystemFontDatabaseCoreText::sansSerifFamily):
(WebCore::SystemFontDatabaseCoreText::cursiveFamily):
(WebCore::SystemFontDatabaseCoreText::fantasyFamily):
(WebCore::SystemFontDatabaseCoreText::monospaceFamily):
* platform/graphics/cocoa/SystemFontDatabaseCoreText.h:

Source/WebCore/PAL:

* pal/spi/cocoa/CoreTextSPI.h:

Source/WTF:

Add an ENABLE in Platform.

* wtf/Platform.h:

Tools:

Allow testing infrastructure to use fonts that are returned from CTFontDescriptorCreateForCSSFamily().

* DumpRenderTree/mac/DumpRenderTree.mm:
(allowedFontFamilySet):
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::allowedFontFamilySet):

LayoutTests:

Update the tests to work with this new model.

* fast/text/international/font-fallback-to-common-script-expected.html: Removed.
* fast/text/international/font-fallback-to-common-script.html: Removed.
* fast/text/international/lang-sensitive-fonts-expected.html:
* fast/text/international/lang-sensitive-fonts-xml-expected.html:
* fast/text/international/lang-sensitive-fonts-xml.xhtml:
* fast/text/international/lang-sensitive-fonts.html:
* fast/text/international/locale-sensitive-fonts-expected.html:
* fast/text/international/locale-sensitive-fonts.html:
* fast/text/ja-sans-serif-expected-mismatch.html: Added.
* fast/text/ja-sans-serif.html: Added.
* platform/ios/fast/block/float/016-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html [deleted file]
LayoutTests/fast/text/international/font-fallback-to-common-script.html [deleted file]
LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html
LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html
LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml
LayoutTests/fast/text/international/lang-sensitive-fonts.html
LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html
LayoutTests/fast/text/international/locale-sensitive-fonts.html
LayoutTests/fast/text/ja-sans-serif-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/ja-sans-serif.html [new file with mode: 0644]
LayoutTests/platform/ios/fast/block/float/016-expected.txt
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/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/parser/CSSPropertyParser.cpp
Source/WebCore/page/cocoa/SettingsBaseCocoa.mm
Source/WebCore/platform/graphics/FontDescription.cpp
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp
Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm