Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b8b5a6a183e46f357e2cf2dd40648089ce7522b7
      
https://github.com/WebKit/WebKit/commit/b8b5a6a183e46f357e2cf2dd40648089ce7522b7
  Author: Charlie Wolfe <[email protected]>
  Date:   2026-09-28 (Mon, 28 Sep 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/text/2d.text.measure.emHeights-low-ascent-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/text/2d.text.measure.emHeights-zero-descent-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights-low-ascent-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights-low-ascent.worker-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights-zero-descent-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights-zero-descent.worker-expected.txt
    M 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/canvas/element/text/2d.text.measure.baselines-expected.txt
    M 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.baselines-expected.txt
    M 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.baselines.worker-expected.txt
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp

  Log Message:
  -----------
  Canvas TextMetrics emHeightAscent/emHeightDescent should add up to the font's 
em size
https://bugs.webkit.org/show_bug.cgi?id=325255
rdar://188368945

Reviewed by Sam Weinig.

The spec defines the em square as exactly one em tall. We were using the font's 
ascent and descent
metrics directly, so the em heights were wrong for fonts whose ascent + descent 
is not equal to the
em size. Now we take the em size and divide it between ascent and descent in 
the same proportion as
the font's ascent and descent metrics.

textOffset() now uses these values for the top, hanging, bottom, ideographic 
and middle baselines as
well, so text drawing and measurement agree.

* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/text/2d.text.measure.emHeights-low-ascent-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/text/2d.text.measure.emHeights-zero-descent-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights-low-ascent-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights-low-ascent.worker-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights-zero-descent-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.emHeights-zero-descent.worker-expected.txt:
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/canvas/element/text/2d.text.measure.baselines-expected.txt:
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.baselines-expected.txt:
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.measure.baselines.worker-expected.txt:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::emHeightAscentAndDescent):
(WebCore::CanvasRenderingContext2DBase::measureTextInternal):
(WebCore::CanvasRenderingContext2DBase::textOffset):

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



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

Reply via email to