Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8554625dd5ad243cee47dbfb3aaab6a22adebdc0
      
https://github.com/WebKit/WebKit/commit/8554625dd5ad243cee47dbfb3aaab6a22adebdc0
  Author: Brent Fulgham <[email protected]>
  Date:   2026-08-20 (Thu, 20 Aug 2026)

  Changed paths:
    A LayoutTests/fast/text/combining-mark-on-space-paint-offset-expected.txt
    A LayoutTests/fast/text/combining-mark-on-space-paint-offset.html
    M Source/WebCore/platform/graphics/ComplexTextController.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp

  Log Message:
  -----------
  [CoreText] Compensate glyph origins when substituting a space's base advance
https://bugs.webkit.org/show_bug.cgi?id=321246
<rdar://180227130>

Reviewed by Vitor Roriz.

ComplexTextController::adjustGlyphsAndAdvances() replaces CoreText's base 
advance with the
font's space width for treatAsSpace glyphs, but leaves CoreText's glyph origins 
untouched.
CoreText only guarantees the sum of its advances and origins, so for a [space, 
combining mark]
grapheme cluster (where it attributes the cluster's whole advance to the space 
and gives
the mark a negative origin) the substitution slides the mark relative to its 
base instead
of moving the cluster as a whole.

With a one-em-wide mark such as U+0336 COMBINING LONG STROKE OVERLAY in 
Hiragino, the mark
lands a full em to the left of where CoreText placed it, striking through the 
preceding glyph.

This patch addresses this by adding the opposite amount to the origins of the 
cluster's
trailing zero-advance glyphs, so the cluster moves as a unit. Layout advances 
but ink bounds
and m_adjustedGlyphs are untouched.

CoreText emits glyphs in visual order, so a right-to-left cluster's marks 
precede their base
and the substitution never moves the pen they are positioned against. We do not 
need to
make special corrections for RTL cases. The two new API tests pin that 
reasoning down: they
run the same [space, wide mark] geometry through an LTR and an RTL run, and the 
RTL one is
the case the direction check exists for, since there the glyph preceding a mark 
is the
neighboring cluster's base rather than the mark's own.

Tests: fast/text/combining-mark-on-space-paint-offset.html
       
TestWebKitAPI.ComplexTextControllerTest.SubstitutedSpaceAdvanceCompensatesFollowingMarkInLTR
       
TestWebKitAPI.ComplexTextControllerTest.SubstitutedSpaceAdvanceDoesNotCompensateInRTL

* LayoutTests/fast/text/combining-mark-on-space-paint-offset-expected.txt: 
Added.
* LayoutTests/fast/text/combining-mark-on-space-paint-offset.html: Added.
* Source/WebCore/platform/graphics/ComplexTextController.cpp:
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):
* Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp:
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/319556@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to