Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Intent to Ship: Language support for CanvasTextDrawingStyles

112 views
Skip to first unread message

Chromestatus

unread,
Mar 4, 2025, 11:17:42 AMMar 4
to blin...@chromium.org, sche...@chromium.org

Contact emails

sche...@chromium.org

Explainer

https://github.com/whatwg/html/pull/10873

Specification

https://github.com/whatwg/html/pull/10873

Summary

The <canvas> DOM element, like all DOM elements, accepts a `lang` attribute that is used to define language specific treatment for font selection (when fonts have locale specific glyphs). Browsers respect this attribute. However, when an OffscreenCanvas is created there is no way to set locale information, possibly resulting in a state where an offscreen canvas produces rendered results that differ from the canvas in which it's output is used. This feature adds a `lang` IDL attribute to CanvasTextDrawingStyles to give developers direct control over the language for the text drawing and metrics.



Blink component

Blink>Canvas

TAG review

None

TAG review status

Not applicable

Risks



Interoperability and Compatibility

None



Gecko: No signal (https://github.com/mozilla/standards-positions/issues/1150) Non official support in WHATWG meetings.

WebKit: Support (https://github.com/WebKit/standards-positions/issues/439)

Web developers: No signals

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

Pure addition of functionality.



Debuggability

None



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?

Yes

Feature is useful on all platforms and important for localization.



Is this feature fully tested by web-platform-tests?

Yes

https://wpt.fyi/results/html/canvas/element/manual/text?label=master&label=experimental canvas.2d.lang.dynamic.html canvas.2d.lang.empty.canvas.html canvas.2d.lang.inherit.canvas.html canvas.2d.lang.inherit.disconnected.canvas.html canvas.2d.lang.inherit.document.disconnected.canvas.html canvas.2d.lang.inherit.document.html canvas.2d.lang.html https://wpt.fyi/results/html/canvas/offscreen/manual/text?label=master&label=experimental canvas.2d.offscreen.lang.inherit.html canvas.2d.offscreen.lang.html canvas.2d.offscreen.transferred.lang.inherit.document.html canvas.2d.offscreen.transferred.lang.inherit.html canvas.2d.offscreen.transferred.lang.html canvas.2d.offscreen.worker.lang.inherit.html canvas.2d.offscreen.worker.lang.html https://wpt.fyi/results/html/canvas/element/text?label=master&label=experimental 2d.text.lang.default.html 2d.text.lang.valid.html https://wpt.fyi/results/html/canvas/offscreen/text?label=master&label=experimental 2d.text.lang.default.html 2d.text.lang.valid.html



Flag name on about://flags

Experimental Web Platform Features

Finch feature name

CanvasTextLang

Non-finch justification

This is a feature addition with very very little expected impact on performance or changes in existing website functionality.



Requires code in //chrome?

False

Tracking bug

https://issues.chromium.org/issues/385006131

Availability expectation

WebKit implementation is moving forward. There is agreement that the feature is needed and implementation is not complex. I would anticipate all browsers have implemented within 2 years.

Adoption expectation

I would expect that the feature is adopted by default, in that the default value for the new attribute is likely to be by far the most common. So sites will immediately "adopt" the feature and get the benefits without taking any action.

Adoption plan

The feature is publicized at https://blogs.igalia.com/schenney/canvas-localization-support/ and will have an MDN page.

Non-OSS dependencies

Does the feature depend on any code or APIs outside the Chromium open source repository and its open-source dependencies to function?

None.

Sample links


https://blogs.igalia.com/schenney/canvas-localization-support

Estimated milestones

Shipping on desktop 136
DevTrial on desktop 135
Shipping on Android 136
DevTrial on Android 135
Shipping on WebView 136


Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

None.

Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5066778773028864?gate=5145440662847488

Links to previous Intent discussions

Intent to Prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/WEjhPwI6lLc


This intent message was generated by Chrome Platform Status.

Vladimir Levin

unread,
Mar 4, 2025, 10:34:56 PMMar 4
to blink-dev, Chromestatus, Stephen Chenney
On Tuesday, March 4, 2025 at 11:17:42 AM UTC-5 Chromestatus wrote:
Contact emails sche...@chromium.org

Explainer https://github.com/whatwg/html/pull/10873

Specification https://github.com/whatwg/html/pull/10873

Summary

The <canvas> DOM element, like all DOM elements, accepts a `lang` attribute that is used to define language specific treatment for font selection (when fonts have locale specific glyphs). Browsers respect this attribute. However, when an OffscreenCanvas is created there is no way to set locale information, possibly resulting in a state where an offscreen canvas produces rendered results that differ from the canvas in which it's output is used. This feature adds a `lang` IDL attribute to CanvasTextDrawingStyles to give developers direct control over the language for the text drawing and metrics.



Blink component Blink>Canvas

TAG review None

TAG review status Not applicable


Is there a reason for no TAG review? I'm not sure if there's an exception that applies here.
 
Risks


Interoperability and Compatibility

None



Gecko: No signal (https://github.com/mozilla/standards-positions/issues/1150) Non official support in WHATWG meetings.

WebKit: Support (https://github.com/WebKit/standards-positions/issues/439)

Web developers: No signals

Although this seems like a small feature, having no web developer signals is a bit unfortunate. Do you know of any cases where this behavior is currently broken and would be fixed by the change?
 


Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

Pure addition of functionality.



Debuggability

None



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)? Yes

Feature is useful on all platforms and important for localization.



Is this feature fully tested by web-platform-tests? Yes

https://wpt.fyi/results/html/canvas/element/manual/text?label=master&label=experimental canvas.2d.lang.dynamic.html canvas.2d.lang.empty.canvas.html canvas.2d.lang.inherit.canvas.html canvas.2d.lang.inherit.disconnected.canvas.html canvas.2d.lang.inherit.document.disconnected.canvas.html canvas.2d.lang.inherit.document.html canvas.2d.lang.html https://wpt.fyi/results/html/canvas/offscreen/manual/text?label=master&label=experimental canvas.2d.offscreen.lang.inherit.html canvas.2d.offscreen.lang.html canvas.2d.offscreen.transferred.lang.inherit.document.html canvas.2d.offscreen.transferred.lang.inherit.html canvas.2d.offscreen.transferred.lang.html canvas.2d.offscreen.worker.lang.inherit.html canvas.2d.offscreen.worker.lang.html https://wpt.fyi/results/html/canvas/element/text?label=master&label=experimental 2d.text.lang.default.html 2d.text.lang.valid.html https://wpt.fyi/results/html/canvas/offscreen/text?label=master&label=experimental 2d.text.lang.default.html 2d.text.lang.valid.html



Flag name on about://flags Experimental Web Platform Features

Finch feature name CanvasTextLang

Non-finch justification

This is a feature addition with very very little expected impact on performance or changes in existing website functionality.



Requires code in //chrome? False

Tracking bug https://issues.chromium.org/issues/385006131

Availability expectation WebKit implementation is moving forward. There is agreement that the feature is needed and implementation is not complex. I would anticipate all browsers have implemented within 2 years.

Adoption expectation I would expect that the feature is adopted by default, in that the default value for the new attribute is likely to be by far the most common. So sites will immediately "adopt" the feature and get the benefits without taking any action.

It wasn't immediately clear: what's the default value that would be used?

Stephen Chenney

unread,
Mar 5, 2025, 9:38:46 AMMar 5
to Vladimir Levin, blink-dev, Chromestatus
Thanks Vlad. Answers inline.

On Tue, Mar 4, 2025 at 10:34 PM Vladimir Levin <vmp...@chromium.org> wrote:


On Tuesday, March 4, 2025 at 11:17:42 AM UTC-5 Chromestatus wrote:
Contact emails sche...@chromium.org

Explainer https://github.com/whatwg/html/pull/10873

Specification https://github.com/whatwg/html/pull/10873

Summary

The <canvas> DOM element, like all DOM elements, accepts a `lang` attribute that is used to define language specific treatment for font selection (when fonts have locale specific glyphs). Browsers respect this attribute. However, when an OffscreenCanvas is created there is no way to set locale information, possibly resulting in a state where an offscreen canvas produces rendered results that differ from the canvas in which it's output is used. This feature adds a `lang` IDL attribute to CanvasTextDrawingStyles to give developers direct control over the language for the text drawing and metrics.



Blink component Blink>Canvas

TAG review None

TAG review status Not applicable


Is there a reason for no TAG review? I'm not sure if there's an exception that applies here.

I didn't consider TAG review because the discussion in WHATWG viewed this as fixing an oversite in the canvas spec, and from a technical/ergonomics perspective it seems pretty straight forward. Happy to see if the TAG have any opinions though so I'll file an issue.

 
Risks


Interoperability and Compatibility

None



Gecko: No signal (https://github.com/mozilla/standards-positions/issues/1150) Non official support in WHATWG meetings.

WebKit: Support (https://github.com/WebKit/standards-positions/issues/439)

Web developers: No signals

Although this seems like a small feature, having no web developer signals is a bit unfortunate. Do you know of any cases where this behavior is currently broken and would be fixed by the change?

Finding reports of developers having problems is a bit tricky, in part because "canvas" is also a very widely used online learning framework with lots of people who care about language. Anyways, this is one report of offscreen canvas giving the wrong metrics for text due to the lack of offscreen language support (exactly what this intent is expected to fix). Hitting the problem of offscreen/DOM inconsistency that we are trying to fix here would require a localized application using a common font for multiple locales with developers/users attentive enough to notice problems and report them.

Another way of looking at Web Developer signals is that this is a prerequisite spec addition for the highly demanded Extended Text Metrics feature set. Without this we don't get better canvas text in general.

 


Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

Pure addition of functionality.



Debuggability

None



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)? Yes

Feature is useful on all platforms and important for localization.



Is this feature fully tested by web-platform-tests? Yes

https://wpt.fyi/results/html/canvas/element/manual/text?label=master&label=experimental canvas.2d.lang.dynamic.html canvas.2d.lang.empty.canvas.html canvas.2d.lang.inherit.canvas.html canvas.2d.lang.inherit.disconnected.canvas.html canvas.2d.lang.inherit.document.disconnected.canvas.html canvas.2d.lang.inherit.document.html canvas.2d.lang.html https://wpt.fyi/results/html/canvas/offscreen/manual/text?label=master&label=experimental canvas.2d.offscreen.lang.inherit.html canvas.2d.offscreen.lang.html canvas.2d.offscreen.transferred.lang.inherit.document.html canvas.2d.offscreen.transferred.lang.inherit.html canvas.2d.offscreen.transferred.lang.html canvas.2d.offscreen.worker.lang.inherit.html canvas.2d.offscreen.worker.lang.html https://wpt.fyi/results/html/canvas/element/text?label=master&label=experimental 2d.text.lang.default.html 2d.text.lang.valid.html https://wpt.fyi/results/html/canvas/offscreen/text?label=master&label=experimental 2d.text.lang.default.html 2d.text.lang.valid.html



Flag name on about://flags Experimental Web Platform Features

Finch feature name CanvasTextLang

Non-finch justification

This is a feature addition with very very little expected impact on performance or changes in existing website functionality.



Requires code in //chrome? False

Tracking bug https://issues.chromium.org/issues/385006131

Availability expectation WebKit implementation is moving forward. There is agreement that the feature is needed and implementation is not complex. I would anticipate all browsers have implemented within 2 years.

Adoption expectation I would expect that the feature is adopted by default, in that the default value for the new attribute is likely to be by far the most common. So sites will immediately "adopt" the feature and get the benefits without taking any action.

It wasn't immediately clear: what's the default value that would be used?
 
Default is "inherit", the behavior of which matches DOM canvas right now, and would make offscreen canvas match DOM canvas.

Chris Harrelson

unread,
Mar 12, 2025, 12:02:05 PMMar 12
to Stephen Chenney, Vladimir Levin, blink-dev, Chromestatus
LGTM1

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAGsbWzSYuQJfmu_MWGOCOOWufKqk6zH1miOqJ_B6E%3DOx9-2RnA%40mail.gmail.com.

Alex Russell

unread,
Mar 12, 2025, 12:47:48 PMMar 12
to blink-dev, Chris Harrelson, Vladimir Levin, blink-dev, Chromestatus, Stephen Chenney
LGTM2

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

Mike Taylor

unread,
Mar 12, 2025, 12:59:59 PMMar 12
to Alex Russell, blink-dev, Chris Harrelson, Vladimir Levin, Chromestatus, Stephen Chenney

LGTM3

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/a1d57bf1-0761-4128-95be-acc43c30c612n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages