Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 78f657ca44f63973f129fab4e29cf8e5e36f128c
https://github.com/WebKit/WebKit/commit/78f657ca44f63973f129fab4e29cf8e5e36f128c
Author: Myles C. Maxfield <[email protected]>
Date: 2023-02-17 (Fri, 17 Feb 2023)
Changed paths:
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
M Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h
M Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
A Source/WebCore/platform/graphics/cocoa/FontInterrogation.h
A Source/WebCore/platform/graphics/cocoa/FontMetricsNormalization.h
M Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
M Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.cpp
M Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.h
Log Message:
-----------
Regression: "font-optical-sizing: auto" has no effect in Safari 16 on macOS
Ventura & iOS 16
https://bugs.webkit.org/show_bug.cgi?id=247987
rdar://102432138
Reviewed by Alan Baradlay.
This patch hooks up the newly-created UnrealizedCoreTextFont to the logic that
was formerly
in preparePlatformFont(). The purpose of UnrealizedCoreTextFont is so that we
can make all
the font modifications we want without actually hitting Core Text; once we're
done making
modifications there's a final "commit" step that finally ends up making a font.
Most of the reason for this is for preparePlatformFont(): its job used to be to
take a font
as input, modify it, and produce a new font, but now with this patch its
functionality is
represented as a set of modifications just on a dictionary of attributes inside
the
UnrealizedCoreTextFont. This means we create no temporary fonts, and also means
we are going
fast enough that we can enable optical sizing on every font - because doing so
is just an
attribute in a dictionary, rather than creating a whole new CTFont. That is the
fix for this
bug: enabling optical sizing on all fonts. All the previous patches in this
series of
patches I've been writing were just to set up UnrealizedCoreTextFont so that we
could make
enabling optical sizing fast enough to do unconditionally, and to not create
temporary font
objects when doing so.
There is one caveat to this: Without inspecting a CTFont, we can't know whether
a font is
an OpenType or a TrueType font, and we need to know that in order to set the
appropriate
values for the 'wght', 'wdth', 'slnt', and 'ital' variation axes. This patch
works around
that by exploiting the fact that the vast majority of fonts out there are A)
not variable
fonts, and B) are OpenType fonts, so its actually beneficial to just assume the
font is an
OpenType font and set it up accordingly, and then check after we've created it
whether our
guess was right. If our guess wasn't right, we can just fix up the font object
we've just
created, rather than creating a whole new one from scratch.
I originally wrote 2 tests, and the he test font Newsreader was downloaded from
https://fonts.google.com/specimen/Newsreader/about?preview.size=35&preview.layout=row&category=Serif&vfonly=true
and is licensed with the Open Font License, which means we can use it in layout
tests. We
have to keep it and all its files unmodified, which is why there are so many
extra font
files - those just come with the one font file we actually want to test this.
However,
because we have to check in the entire release unmodified, that would add
megabytes to the
WebKit repo forever, we've decided to check in this patch without a test and
then I'll
asynchronously write a test that can use a smaller font.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont):
(WebCore::variationCapabilitiesForFontDescriptor):
(WebCore::appendOpenTypeFeature): Deleted.
(WebCore::normalizeGXWeight): Deleted.
(WebCore::normalizeCTWeight): Deleted.
(WebCore::normalizeSlope): Deleted.
(WebCore::denormalizeGXWeight): Deleted.
(WebCore::denormalizeCTWeight): Deleted.
(WebCore::denormalizeSlope): Deleted.
(WebCore::denormalizeVariationWidth): Deleted.
(WebCore::normalizeVariationWidth): Deleted.
(WebCore::FontType::FontType): Deleted.
(WebCore::addLightPalette): Deleted.
(WebCore::addDarkPalette): Deleted.
(WebCore::addAttributesForCustomFontPalettes): Deleted.
(WebCore::addAttributesForFontPalettes): Deleted.
* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h:
* Source/WebCore/platform/graphics/cocoa/FontInterrogation.h: Added.
(WebCore::FontInterrogation::FontInterrogation):
* Source/WebCore/platform/graphics/cocoa/FontMetricsNormalization.h: Added.
(WebCore::normalizeGXWeight):
(WebCore::normalizeCTWeight):
(WebCore::normalizeSlope):
(WebCore::denormalizeGXWeight):
(WebCore::denormalizeCTWeight):
(WebCore::denormalizeSlope):
(WebCore::denormalizeVariationWidth):
(WebCore::normalizeVariationWidth):
* Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
* Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.cpp:
(WebCore::appendOpenTypeFeature):
(WebCore::addLightPalette):
(WebCore::addDarkPalette):
(WebCore::addAttributesForCustomFontPalettes):
(WebCore::addAttributesForFontPalettes):
(WebCore::applyFeatures):
(WebCore::applyVariations):
(WebCore::modifyFromContext):
(WebCore::UnrealizedCoreTextFont::modifyFromContext):
(WebCore::UnrealizedCoreTextFont::realize const):
* Source/WebCore/platform/graphics/cocoa/UnrealizedCoreTextFont.h:
Canonical link: https://commits.webkit.org/260447@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes