Re: [w3ctag/design-reviews] Canvas Text Metrics for Editing, Art and Design (Issue #1095)

jyasskin left a comment (w3ctag/design-reviews#1095)

Hi @schenney-chromium, and thanks for your review request. We have a few questions about the proposal:

1. We're not 100% sure, but is there a bug in the "colors are fine" example? It would help to have an accompanying description as to how the example works, as even if there's not a bug, it could help a lot of readers to understand how the example is working. Our understanding is as follows:

   * The example code passes `end`=`text.length`, which is the number of code _units_, but the [algorithm](https://whatpr.org/html/11000/canvas.html#dom-textcluster-start) throws an exception if it exceeds the number of code _points_. Since the emoji each take 2 code units to represent a code point, this should throw. However, [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing) operates in terms of code units, and it's important to be consistent with that here, so you should probably update your algorithm to use code units too.

   * We see that the "fi" ligature is getting a single color. We suspect that counts as "their corresponding glyphs cannot be broken down any further" in your spec.  There are two problems here:

      1. The explainer refers to these TextClusters as "grapheme clusters" in a couple places, but ["Grapheme clusters are not the same as ligatures."](https://unicode.org/reports/tr29/#:~:text=Grapheme%20clusters%20are%20not%20the%20same%20as%20ligatures.)
      2. One of your use cases for this API is for caret positioning, but the caret has to be able to be positioned between the "f" and "i" in that ligature.

   We recommend that you get a review on this proposal from the Internationalization WG. [i18n WG has a checklist and other resources you may find helpful.](https://www.w3.org/International/i18n-drafts/techniques/shortchecklist)

2. Does `getIndexFromOffset()` accommodate vertical writing systems? Even in horizontal writing systems, are there any cases where the vertical position within a block of text will affect the index? (e.g. a _very italic 'l'_ might place the left edge of its top to the right of the right edge of its bottom)

   Again, we recommend review from the Internationalization WG.

3. We're concerned that this proposal doesn't talk about providing equivalents for the text that is placed on the canvas that would be exposed to assistive technologies. One option the platform offers is canvas fallback content, though it has its limitations. Have you considered how this barrier may be overcome, and/or what specific advice should be given to content authors?

   The [Accessible Platform Architectures WG](https://www.w3.org/WAI/about/groups/apawg/) would be happy to help advise on this, and help you write such guidance.

4. `align` and `baseline` in `TextCluster` seem to just be copied from the `getTextClusters()` input. Why bother copying them?

Thanks @dandclark for your contribution to this review.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/1095#issuecomment-2978850878
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/1095/2978850878@github.com>

Received on Tuesday, 17 June 2025 04:02:59 UTC