Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas textBaseline needs better tests #6731

Open
AshleyScirra opened this issue Jun 2, 2021 · 8 comments
Open

Canvas textBaseline needs better tests #6731

AshleyScirra opened this issue Jun 2, 2021 · 8 comments
Labels
interop Implementations are not interoperable with each other needs tests Moving the issue forward requires someone to write tests topic: canvas

Comments

@AshleyScirra
Copy link

AshleyScirra commented Jun 2, 2021

Chrome and Safari draw text with the "top" baseline at different positions in canvas2d. See the following issues:

https://bugs.webkit.org/show_bug.cgi?id=226334
https://bugs.chromium.org/p/chromium/issues/detail?id=1213949

Image demonstrating comparison: https://downloads.scirra.com/labs/bugs/text-top-baseline/comparison.png

This causes web compat issues. For example our web game engine cannot display text consistently across platforms because each browser positions text slightly differently. This makes it difficult to do things like perfectly align text relative to other canvas drawings, such as in a border or button graphic.

Apparently this was previously discussed to some extent in #2470 but is not adequately resolved as it is still actively causing web compat issues and the spec does not appear to cover a definition of "the em square".

The spec should clearly define this so browser makers can identify if their browser complies with the spec in this regard, and if necessary make changes to their implementation to ensure compatibility. As it is I don't think it's clear which browser is doing it right (if any).

@annevk
Copy link
Member

annevk commented Jun 2, 2021

See #5826.

@AshleyScirra
Copy link
Author

Any updates on this? We still get users complaining about inconsistencies in text positioning between Chrome and Safari, and it doesn't seem there's anything we can do about it until this gets sorted.

@annevk
Copy link
Member

annevk commented Sep 27, 2022

cc @whatwg/canvas

@AshleyScirra

This comment was marked as duplicate.

@annevk
Copy link
Member

annevk commented May 12, 2023

No, I didn't manage to get review on #5826. I'll agenda+ it to see if I can get some attention on it that way.

Meanwhile, you could read up on the CSS definition of this concept and determine which browser is in the wrong here. Coupled with some WPT tests, the affected browser might be willing to change and that could suffice as an interim solution.

@AshleyScirra

This comment was marked as duplicate.

@schenney-chromium
Copy link
Contributor

I think this depends on resolving #5830, which in turn depends on resolving a CSS WG issue (w3c/csswg-drafts#5380)

@AshleyScirra

This comment was marked as duplicate.

@annevk annevk changed the title Canvas textBaseline "em square" not defined Canvas textBaseline needs better tests Dec 5, 2024
@annevk annevk added the needs tests Moving the issue forward requires someone to write tests label Dec 5, 2024
annevk added a commit that referenced this issue Dec 5, 2024
See w3c/csswg-drafts#5312. And also #5429 for where all of this started.

This should help #6731 quite a bit too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other needs tests Moving the issue forward requires someone to write tests topic: canvas
Development

No branches or pull requests

3 participants