Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: b2e8181dbd7510819ee516e847f139fa7cb1b636 https://github.com/WebKit/WebKit/commit/b2e8181dbd7510819ee516e847f139fa7cb1b636 Author: Myles C. Maxfield <mmaxfi...@apple.com> Date: 2023-02-23 (Thu, 23 Feb 2023)
Changed paths: M Source/WTF/wtf/PlatformUse.h M Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.cpp M Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.h Log Message: ----------- [Cocoa] font-optical-sizing:auto doesn't set the opsz variation axis for all fonts that need it https://bugs.webkit.org/show_bug.cgi?id=252552 rdar://105662167 Reviewed by Alan Baradlay. This is a follow-up from 260447@main. That previous patch went almost all the way toward fixing the problem, but couldn't actually apply optical sizing to all text that requested it. The reason for this is that the trigger we were using to enable optical sizing, `kCTFontOpticalSizeAttribute`, enables the `opsz` variation axis, but also enables the `trak` table. Unfortunately, we have a lot of tests which use fonts that don't support the optical sizing variation axis, but do have a `trak` table. So, if we just naively started enabling `kCTFontOpticalSizeAttribute` for all text that requests it, we'll get tons of test failures. It's not really great if we make tons of text on the web look different, without it being a deliberate decision. So, the previous patch stopped just short of enabling `kCTFontOpticalSizeAttribute` everywhere. However, all fonts which *do* support the `opsz` variation axis should have it set automatically, which is what 260447@main was aiming to address. We have the ability to *just* set the variation axis without also setting `trak`, so that's what we need to do for fonts that request optical sizing but for which we can't use `kCTFontOpticalSizeAttribute` because of compatibility. So, we need 3 buckets: - Disable optical sizing. This is triggered by font-optical-sizing:none. This maps to telling Core Text to use `kCTFontOpticalSizeAttribute`: `none`. - Enable full optical sizing, including `trak`. This is triggered by text-rendering:optimizeLegibility. This maps to telling Core Text to use `kCTFontOpticalSizeAttribute`: `auto`. - Enable optical sizing, but just the `opsz` variation, and not `trak`, for compatibility. This is what all situations not captured by the above use. This maps to telling Core Text to use `kCTFontVariationAttribute`: {`opsz`: font size}. This patch implements the third bucket, which wasn't implemented in the previous patch. The third bucket doesn't actually work correctly on older OSes, so it's guarded behind a OS version check. https://bugs.webkit.org/show_bug.cgi?id=252592 is about deleting the compatibility third bucket in favor of the second bucket: actually enabling `trak` for all text that should have optical sizing enabled. Just like 260447@main, the tests for this adds a megabyte of fonts (because we have to keep the whole release of an OFL font together) so I'm not including the test with this PR, and will upload another PR later with a custom font that I create from scratch for testing this. * Source/WTF/wtf/PlatformUse.h: * Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.cpp: (WebCore::UnrealizedCoreTextFont::addAttributesForOpticalSizing): (WebCore::UnrealizedCoreTextFont::applyVariations): (WebCore::UnrealizedCoreTextFont::modifyFromContext): (WebCore::UnrealizedCoreTextFont::realize const): (WebCore::applyVariations): Deleted. (WebCore::modifyFromContext): Deleted. * Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.h: Canonical link: https://commits.webkit.org/260781@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes