Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5ee6c014d2b88cc267eacd872f63aa987bfca9ed
https://github.com/WebKit/WebKit/commit/5ee6c014d2b88cc267eacd872f63aa987bfca9ed
Author: shierote <[email protected]>
Date: 2026-08-05 (Wed, 05 Aug 2026)
Changed paths:
M LayoutTests/TestExpectations
A LayoutTests/fast/text/font-face-metric-overrides-cache-expected.txt
A LayoutTests/fast/text/font-face-metric-overrides-cache.html
M LayoutTests/ipc/cache-font-null-palette-colors-crash.html
M LayoutTests/ipc/move-to-image-buffer-cross-thread-font-crash.html
M Source/WebCore/Headers.cmake
M Source/WebCore/Sources.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/css/CSSFontFace.cpp
M Source/WebCore/css/CSSFontFace.h
M Source/WebCore/platform/graphics/Font.cpp
M Source/WebCore/platform/graphics/Font.h
M Source/WebCore/platform/graphics/FontCache.cpp
M Source/WebCore/platform/graphics/FontCreationContext.h
A Source/WebCore/platform/graphics/FontMetricsOverrides.h
M Source/WebCore/platform/graphics/FontPlatformData.cpp
M Source/WebCore/platform/graphics/FontPlatformData.h
M Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
M Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
M Source/WebCore/platform/graphics/coretext/FontCoreText.cpp
M
Source/WebCore/platform/graphics/coretext/FontCustomPlatformDataCoreText.cpp
M Source/WebCore/platform/graphics/coretext/FontPlatformDataCoreText.cpp
M Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
M
Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
M Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
M Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
M Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp
M Source/WebCore/platform/graphics/skia/FontCustomPlatformDataSkia.cpp
M Source/WebCore/platform/graphics/skia/FontPlatformDataSkia.cpp
M Source/WebCore/platform/graphics/skia/FontSkia.cpp
M Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
M Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
M Source/WebCore/platform/graphics/win/cairo/FontCacheWinCairo.cpp
M
Source/WebCore/platform/graphics/win/cairo/FontCustomPlatformDataWinCairo.cpp
M Source/WebCore/platform/graphics/win/cairo/FontPlatformDataWinCairo.cpp
A Source/WebCore/style/values/fonts/StyleFontMetricsOverride.cpp
A Source/WebCore/style/values/fonts/StyleFontMetricsOverride.h
M Source/WebKit/Shared/WebCoreFont.serialization.in
Log Message:
-----------
[CSS Fonts] Apply @font-face metric override descriptors to font metrics
https://bugs.webkit.org/show_bug.cgi?id=219735
Reviewed by Vitor Roriz.
This completes WebKit's implementation of the CSS Fonts 4 @font-face
ascent-override, descent-override, and line-gap-override descriptors.
316829@main added parser support, and 316933@main exposed the descriptors
through FontFace and CSSFontFaceDescriptors.
Convert each descriptor to a used-size factor and carry it through
FontCreationContext. Store the factors in FontPlatformData::FontMetadata during
construction, before the data can be used as a FontDataCache key. This makes
the overrides part of FontDataCache identity and applies them once during Font
construction without cloning a cached Font.
Font size adjustment reads cap height, zero width, ideogram width, or x-height,
while metric overrides change only ascent, descent, line gap, and line spacing.
Constructing FontPlatformData with the factors therefore does not affect the
adjusted size. Font applies the factors against the final FontPlatformData size.
Preserve the metadata through derived fonts, system fallback fonts, platform
reconstruction, and remote rendering.
Tests: fast/text/font-face-metric-overrides-cache.html
imported/w3c/web-platform-tests/css/css-fonts/ascent-descent-override.html
imported/w3c/web-platform-tests/css/css-fonts/line-gap-override.html
imported/w3c/web-platform-tests/css/css-fonts/font-size-adjust-metrics-override.html
imported/w3c/web-platform-tests/css/css-fonts/font-face-unicode-range-nbsp.html
imported/w3c/web-platform-tests/css/css-font-loading/fontface-override-descriptors.html
ipc/cache-font-null-palette-colors-crash.html
ipc/move-to-image-buffer-cross-thread-font-crash.html
* LayoutTests/TestExpectations:
Removed expectations for the metric override tests that now pass.
* LayoutTests/fast/text/font-face-metric-overrides-cache-expected.txt: Added.
Added expected output, including the trailing blank line emitted after
TEST COMPLETE.
* LayoutTests/fast/text/font-face-metric-overrides-cache.html: Added.
Verified metric overrides across local font cache entries and URL fonts, and
that updating loaded descriptors invalidates cached font data.
* LayoutTests/ipc/cache-font-null-palette-colors-crash.html:
* LayoutTests/ipc/move-to-image-buffer-cross-thread-font-crash.html:
Added normal metric overrides to hand-written FontMetadata payloads.
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
Added the new metric override types to the build.
* Source/WebCore/css/CSSFontFace.cpp:
(WebCore::CSSFontFace::setAscentOverride):
(WebCore::CSSFontFace::setDescentOverride):
(WebCore::CSSFontFace::setLineGapOverride):
Converted descriptor percentages to factors and invalidated clients when they
change.
(WebCore::CSSFontFace::font):
Passed metric overrides through FontCreationContext.
* Source/WebCore/css/CSSFontFace.h:
Stored the computed metric overrides.
* Source/WebCore/platform/graphics/Font.cpp:
(WebCore::Font::Font):
(WebCore::Font::applyFontMetricsOverrides):
Applied overrides against the effective FontPlatformData size after normal font
metrics initialization.
* Source/WebCore/platform/graphics/Font.h:
Declared metric override application.
* Source/WebCore/platform/graphics/FontCache.cpp:
(WebCore::FontCache::cachedFontPlatformData):
Disabled zero-bit empty keys for every platform.
* Source/WebCore/platform/graphics/FontCreationContext.h:
(WebCore::FontCreationContextRareData::create):
(WebCore::FontCreationContextRareData::metricsOverrides const):
(WebCore::FontCreationContextRareData::operator== const):
(WebCore::FontCreationContextRareData::FontCreationContextRareData):
(WebCore::FontCreationContext::FontCreationContext):
(WebCore::FontCreationContext::metricsOverrides const):
(WebCore::add):
Carried metric overrides through font creation, equality, and hashing.
* Source/WebCore/platform/graphics/FontMetricsOverrides.h: Added.
(WebCore::FontMetricsOverride::isNormal const):
(WebCore::FontMetricsOverrides::isNormal const):
(WebCore::add):
Defined the computed override representation and hashing, including normalized
signed zero.
* Source/WebCore/platform/graphics/FontPlatformData.cpp:
(WebCore::FontPlatformData::FontPlatformData):
* Source/WebCore/platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::metricsOverrides const):
Added metric overrides to FontMetadata and the platform data constructors,
making them part of FontPlatformData equality at construction.
* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacterCluster):
Passed metric overrides through normal CoreText platform construction and
system fallback fonts.
* Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::hash const):
Included metric overrides in the Cocoa platform data hash.
* Source/WebCore/platform/graphics/coretext/FontCoreText.cpp:
(WebCore::createDerivativeFont):
(WebCore::Font::createFontWithoutSynthesizableFeatures const):
(WebCore::Font::platformCreateScaledFont const):
(WebCore::Font::platformCreateHalfWidthFont const):
Preserved metric overrides in CoreText derivative fonts.
* Source/WebCore/platform/graphics/coretext/FontCustomPlatformDataCoreText.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
Passed metric overrides when constructing custom CoreText platform data.
* Source/WebCore/platform/graphics/coretext/FontPlatformDataCoreText.cpp:
(WebCore::FontPlatformData::FontPlatformData):
Accepted metric overrides in CoreText platform data.
* Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::FontCache::createFontPlatformData):
Passed metric overrides when constructing FreeType platform data.
* Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
Passed metric overrides when constructing custom FreeType platform data.
* Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::create):
Preserved metric overrides when constructing and reconstructing FreeType
platform data.
* Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp:
(WebCore::Font::platformCreateScaledFont const):
Preserved metric overrides in scaled FreeType fonts.
* Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp:
(WebCore::FontCache::createFontPlatformData):
Passed metric overrides when constructing Skia platform data.
* Source/WebCore/platform/graphics/skia/FontCustomPlatformDataSkia.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
Passed metric overrides when constructing custom Skia platform data.
* Source/WebCore/platform/graphics/skia/FontPlatformDataSkia.cpp:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::hash const):
Accepted and hashed metric overrides in Skia platform data.
* Source/WebCore/platform/graphics/skia/FontSkia.cpp:
(WebCore::Font::platformCreateScaledFont const):
(WebCore::Font::platformCreateHalfWidthFont const):
Preserved metric overrides in Skia derivative fonts.
* Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::create):
(WebCore::FontPlatformData::fromIPCData):
Preserved metric overrides when constructing and reconstructing Windows
platform data.
* Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp:
(WebCore::Font::platformCreateScaledFont const):
Preserved metric overrides in scaled Windows fonts.
* Source/WebCore/platform/graphics/win/cairo/FontCacheWinCairo.cpp:
(WebCore::FontCache::createFontPlatformData):
Passed metric overrides when constructing Windows Cairo platform data.
* Source/WebCore/platform/graphics/win/cairo/FontCustomPlatformDataWinCairo.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
Passed metric overrides when constructing custom Windows Cairo platform data.
* Source/WebCore/platform/graphics/win/cairo/FontPlatformDataWinCairo.cpp:
(WebCore::FontPlatformData::FontPlatformData):
Accepted metric overrides in custom Windows Cairo platform data.
* Source/WebCore/style/values/fonts/StyleFontMetricsOverride.cpp: Added.
(WebCore::Style::DeprecatedCSSValueConversion<FontMetricsOverride>::operator()):
* Source/WebCore/style/values/fonts/StyleFontMetricsOverride.h: Added.
(WebCore::Style::FontMetricsOverride):
Added the shared normal-or-nonnegative-percentage descriptor value and its CSS
conversion.
* Source/WebKit/Shared/WebCoreFont.serialization.in:
Serialized metric overrides as part of FontMetadata.
Canonical link: https://commits.webkit.org/318680@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications