[css-houdini-drafts] [font-metrics-api] Revised proposal of font metrics for each character

kojiishi has just created a new issue for https://github.com/w3c/css-houdini-drafts:

== [font-metrics-api] Revised proposal of font metrics for each character ==
One of the feedback to the previous proposal was about use cases. This proposal tries to solve use cases such as knowing caret positions of characters, or drawing background, text decoration effects, or selection to the text.

This proposal adds `characters` as an array of metrics for each grapheme cluster in the logical order. This change helps not to expose the details of shaping, which is sometimes complicated and may vary by platforms, as indicated by feedback.


```
interface TextMetrics {
  readonly attribute FrozenArray<TextMetricUnit> characters;
};

interface TextMetricUnit {
  readonly attribute long codeUnitIndex;
  readonly attribute double position;
  readonly attribute double advance;
  readonly attribute bool isRightToLeft;
};
```

The `codeUnitIndex` attribute provides the index of the first code unit of the base character.

When there are ligatures of multiple grapheme clusters, UA may produce one `TextMetricUnit` for a ligature, or compute metrics for each grapheme cluster in the ligature by using the information in the font, or by synthesizing.

UA may tailor UAX#29 if needed for the caret positioning purpose.

This interface supports RTL, by adding the `isRightToLeft` attribute which represents the resolved direction of the grapheme cluster, and by adding the `position` attribute which represents the start-side position of the grapheme cluster from the origin. With `position` and `advance`, this interface can represent the ambiguous caret positioning at BiDi boundaries. The `position` attribute may also help rearrangement of glyphs while shaping some scripts if it occurs across grapheme cluster boundaries.

I think this new proposal covers feedback at whatwg/html#4026 and whatwg/html#3994, applies to both the Font Metrics API and to Canvas Text Metrics API.

Appreciate feedback in advance: @litherum @FremyCompany @dbaron @jfkthame @r12a @annevk @fserb @domenic @eaenet @chrishtr @drott (Can't seem to mention @whatwg/canvas, anyone know how?)

Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/828 using your GitHub account

Received on Tuesday, 23 October 2018 13:43:35 UTC