Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 47b07ba22fd84835ba672ee3dce9d376f205ba70
https://github.com/WebKit/WebKit/commit/47b07ba22fd84835ba672ee3dce9d376f205ba70
Author: Zak Ridouh <[email protected]>
Date: 2026-04-15 (Wed, 15 Apr 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-last-resort-weight-selection-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-last-resort-weight-selection-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-last-resort-weight-selection.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-request-italic-only-family-no-crash-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-request-italic-only-family-no-crash.html
M Source/WebCore/platform/graphics/FontSelectionAlgorithm.cpp
Log Message:
-----------
Fix crash in FontSelectionAlgorithm when all font faces are penalized
https://bugs.webkit.org/show_bug.cgi?id=312351
rdar://174644983
Reviewed by Brent Fulgham and Vitor Roriz.
styleDistance's axis-mismatch penalty paths returned the requested slope value,
but filterCapability eliminates faces whose slope range doesn't include that
value. When all faces are penalized (e.g. only italic faces available for an
oblique request), every face gets eliminated, and the next pass crashes on an
empty set.
Fix by clamping the returned value to the face's own slope range in both penalty
paths. This preserves the maximum-distance penalty (so penalised faces always
lose to any unpenalised face) while ensuring the returned value satisfies the
invariant that every other branch in styleDistance() upholds: the value must lie
within capabilities.slope so filterCapability() retains the face as a last
resort.
This patch includes a test that we don't crash under these conditions, as well
as a
test that confirms we make the right font selection in cases where styleDistance
cannot find a proper match.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-last-resort-weight-selection-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-last-resort-weight-selection-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-last-resort-weight-selection.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-request-italic-only-family-no-crash-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/oblique-request-italic-only-family-no-crash.html:
Added.
* Source/WebCore/platform/graphics/FontSelectionAlgorithm.cpp:
(WebCore::FontSelectionAlgorithm::styleDistance const):
(WebCore::FontSelectionAlgorithm::bestValue const):
Canonical link: https://commits.webkit.org/311341@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications