WICG / canvas-formatted-text

Other
80 stars 17 forks source link

Suggestion: Ship polyfill that can already be used #54

Open Awendel opened 2 years ago

Awendel commented 2 years ago

As far as I understand the following thing would be very tricky to implement with the existing canvas API:

All it currently exposes if one was to parse the original paragraph is all the boundingClientRects for each line, but there is not way of telling which character / word belong to which line.

The proposed API would pretty much solve the problem, yet will probably take quite a long time before it's adopted by all major browsers.

Perhaps if possible, one could already ship a polyfill for the library that would allow to use its functionality before shipped natively in browsers, especially with the focus on that line breaking behaves identicaly to how the browser determines it.