[webkit-changes] [WebKit/WebKit] 41991e: Avoid using .LastResort when converting custom fon...
Wenson Hsieh
noreply at github.com
Fri Dec 15 20:43:35 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 41991eb66a3b02e8d7201e47a789bd2c2988591d
https://github.com/WebKit/WebKit/commit/41991eb66a3b02e8d7201e47a789bd2c2988591d
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2023-12-15 (Fri, 15 Dec 2023)
Changed paths:
M Source/WebCore/editing/cocoa/HTMLConverter.mm
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm
A Tools/TestWebKitAPI/Tests/WebKitCocoa/text-with-web-font.webarchive
Log Message:
-----------
Avoid using .LastResort when converting custom fonts in web archives to NSAttributedString
https://bugs.webkit.org/show_bug.cgi?id=266512
rdar://119679094
Reviewed by Tim Horton.
When converting web archives that contain web fonts to `NSAttributedString` using various WebKit
SPIs and APIs that wrap `WebPageProxy::getContentsAsAttributedString`, text rendered using these
web fonts currently end up with `NSFontAttributeName : '.LastResort'` in the attributes dictionary.
This is because arbitrary web fonts are not (and, for various reasons, should probably not be)
propagated across the process boundary to the recipient of the decoded attributed string; however,
we'll continue to use the web font family name in the platform font, which results in CoreText
falling back to `LastResort` and showing "�" for all characters in these fonts.
To improve on this, we explicitly fall back to the system font instead of `LastResort` for all
remote fonts when converting to attributed string, to ensure that the text is at least legible (even
if it's not in the original web font).
Test: WKWebView.TextWithWebFontAsAttributedString
* Source/WebCore/editing/cocoa/HTMLConverter.mm:
(_font):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/text-with-web-font.webarchive: Added.
Canonical link: https://commits.webkit.org/272159@main
More information about the webkit-changes
mailing list