Skip to content

[font-metrics-api] Compatibility notes with Canvas TextMetrics API #832

@fserb

Description

@fserb

Following up with some questions from: #828

It seems that a Houdini TextMetrics API has to figure out proper use cases to track. Meanwhile, we'd like to move forward on WHATWG over the Canvas update of the TextMetrics API. And I'd really appreciate some input from folks here about some logical issues with a Canvas TextMetrics API.

The use cases for canvas are mostly caret position and character highlight.

  1. But I've been told that it's not possible to assign a 1:1 map between characters and caret position (due to bidi, in which case sometimes 2 different caret position can point to the same character). If that's so, would it still be possible to properly define a 1:1 map with: if LTR, the left-most caret position associated with this character? Would that stop being useful?

  2. If we want to assign, for a grapheme cluster a left-right bounding box (to be able to draw a background on a single character). It seems to me that it's always possible to map, for each character, a left-side (not start) position and an advance. This seems to be true to me even in bidi.

For Canvas, there's very little layout requirements (no vertical text, no multi-line for example). So we could think of it as a very simplified API, as long as it's not egregiously wrong from a layout perspective. Would something like this be possible?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions