Bug 226334 - Canvas textBaseline "top" inconsistent with Chrome
Summary: Canvas textBaseline "top" inconsistent with Chrome
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: Safari 14
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-27 08:58 PDT by Ashley Gullen
Modified: 2021-06-04 10:59 PDT (History)
5 users (show)

See Also:


Attachments
test case (694 bytes, text/html)
2021-06-04 10:59 PDT, Said Abou-Hallawa
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ashley Gullen 2021-05-27 08:58:01 PDT
When drawing text with canvas2d with the "top" baseline, Safari's positioning is different to Chrome.

Minimal repro: https://downloads.scirra.com/labs/bugs/text-top-baseline/index.html

Comparison Safari vs. Chrome image: https://downloads.scirra.com/labs/bugs/text-top-baseline/comparison.png

Observed result: notice the text in Safari is positioned a few pixels lower from the top.

Expected result: text positioning to be consistent across browsers. This issue makes it difficult to get consistent text positioning when drawing text to canvases, particularly if the text is positioned relatively to other content, such as a box drawn around it, or when trying to calculate vertical alignment.

I am not sure which browser is correct, so I'm filing issues with both Safari and Chrome.
Comment 1 Ashley Gullen 2021-05-27 09:00:34 PDT
Corresponding Chrome issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1213949
Comment 2 Radar WebKit Bug Importer 2021-06-03 08:58:16 PDT
<rdar://problem/78817913>
Comment 3 Said Abou-Hallawa 2021-06-04 10:59:17 PDT
Created attachment 430593 [details]
test case

I think there is also a bug in displaying the text with hanging and middle baseline, see the attached "test case".