Skip to content

2026 Extended Canvas Text Metrics ‐ moving it forward

Manuel Rego edited this page Jul 6, 2026 · 1 revision

WEH 2026 - Extended Canvas Text Metrics - moving it forward

(Stephen showed his slides)

Alan: HTML-in-canvas probably not sufficient for editing - particularly editing text rendered on a path

Stephen: Yes, I see the point that when we add the ability to render individual glyphs the selection related things are inadequate. Need to consider this.

Behdad: Issue with bidi editing, likely need to add affinity to the API for boundary cases

Stephen: We use the HTML getPositionFromPoint functionality. But there are lots of problems in browsers today with mixed bidi selection

Xiaoqian: We've been discussing similar use cases and challenges in the W3C Web Editing WG, and Microsoft has put together an early proposal for this. Would it be helpful to have a joint meeting to discuss this further?

Stephen: Yes, I'll follow up

Said: Why not use html text, proposal seems not sufficient to get the right clusters and apply styling information on each.

Stephen: you need to know where to create the textCluster object and give it a string, part of its state, captures font, directionality, all computing information. gettextclusters internally will take the string, apply an algorithm to get text runs in a way similar to text runs in a paragraph, the ordering in the sequence of text clusters, order obtained is the ordering after the bidi ordering of the string. Clusters in sequence would get you the same ordering in original text. Not understanding why the concern of text clusters not having all the information.

Said: Because of the context, you have to provide everything even the fonts, you cannot take part of it and apply different font.

Stephen: in canvas you would have to break up the text in runs with different fonts yourself. We should probably try to solve that problem.

Nikolas: if html text in canvas (SVG? Niko can you clarify?) would be more widely available, would we even need this? to provide things like accessitibilty to this it would be very hard while with html text you get it for free, also text editing... I wonder what's the benefit on this

Stephen: the ability to break text up and style it or position it independently would be new feature not available in html text.

Nikolas: also animations?

Alan: HTML text is heavily opinionated where as we have additional freedom in Canvas text.

Alan: svg has text on a path but IMO it does it badly, drawing text of a canvas is an escape hatch. It's ok that canvas API is more complex. You don't get all the affordances but you get more capabilities you can code yourself. There are capabilities you cannot get in html (like getting the measure of the rendered text)

Stephen: in html how you specify different fonts on a chunk of text? You need span, so you would be breaking text up manually, right?

Behdad: I need to break my text but I can specify two font families?

Said: we would break the span into pieces if the language is different and if the font doesn't support the glyph you would fall back.

Stephen: so the solution would be to carefully select the fonts to support all glyphs in the text? Trying to figure out if the situation is any worse in the canvas than in current html dom, it seems not

Behdad: canvas api a paragraph would be one line and html gives you line breaking and interaction with neighboring characters

Stephen: there's propoosal for line breaking, that's a whole other problem with previous proposals. We would have a hard time to get multi-line canvas text now we have HTML text in canvas.

Behdad/Stephen: If we did this kind of per-glyph styling in dom we could use html in canvas and cover these use cases.

Alan: Proposal with some overlap in CSS: https://github.com/w3c/csswg-drafts/issues/13689

Stephen: question then, solving that problem would we get things like character animation?

Said: Think so, need solution for multiple fonts.

Anne: it's a common situation, emoji using emoji fonts, normal text out of a normal font, etc. in the same piece of text

Stephen: if we supported multiple fonts in multiple runs and the cluster took that into account, we would address more use cases and be more ergonomic than the current proposal, is that a good summary? (general nodding) -> AP file issues

Stephen: any other general thoughts, other uses cases from canvas developers?

Anne: We have some existing issues in alignment (vertical e.g) Going through the existing issues we have for text in canvas would be good.

Stephen: alignment would be part of the text orientation feature in the proposal (orientation of glyphs too)

Anne/Stephen: text metrics seem odd and the way browsers are computing this relies a lot on heuristics, depends a lot on the font

Fred: another use case is math rendering in canvas. would be mostly solved by mathml in canvas, but I guess some JS libraries (MathJax KaTex) could be interested to do their own math layout and need more metrics.

Stephen: if you wanted a math layout , html in canvas would solve that

Fred: there is a specific OpenType MATH table for math. To be discussed offline

Clone this wiki locally