Contact emails
dav...@chromium.org, fs...@chromium.org
Spec
https://html.spec.whatwg.org/multipage/canvas.html#textmetrics
Summary
The current canvas TextMetrics API only exposes the width of the measured text. Part of the new API was already implemented under a flag, but there were some inconsistencies and bugs, especially with RightToLeft text. We fixed the problems and implemented a new version of the spec including an array of advances per character and a dictionary returning baselines.
The feature bug (https://crbug.com/277215) has strong user support (21 stars)
Link to “Intent to Implement” blink-dev discussion
The thread was titled “Intend to ship”, but it was seen as “Intend to implement” and was never actually shipped.
Is this feature supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes
Demo link
-
Debuggability
No DevTools needed for debug. Users can console print the full TextMetrics object in one line.
Risks
Interoperability and Compatibility
Safari already has some of the metrics implemented but since the spec was recently updated some work still needs to be done (advances and getBaselines) to have full interoperability with Chrome. Firefox started development 4 years ago but never shipped. Edge is the only one that has no public signals of implementing yet.
Edge: No signals
Firefox: In development
Safari: Partially Shipped
We know this is a major feature requested by developers (as well as internal Google teams like Google Docs). This API will help developers have more control and more accurate text rendering. As of today a different way to achieve this is by using rendering text to the DOM and using getBoundingClientRect to get some measurements. This process not only requires a draw call but also doesn’t help obtaining the advances or the more granular metrics.
Activation
Enable the platform experiment ExtendedTextMetrics
Is this feature fully tested by web-platform-tests? Link to test suite results from wpt.fyi.
A set of test for each metric, prefixed by “2d.text.measure”:
https://wpt.fyi/results/2dcontext/drawing-text-to-the-canvas
Entry on the feature dashboard
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAP%3Dr99Qn-Wyd6WPVva8NapLViurY-uvRaskyZaZYH%2BAKvp-mNQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAOMQ%2Bw-%2BSTyU%2BPJTZBpbG_r%3DyQE9zd3jfvJ8JuiYGDn_hrnxzg%40mail.gmail.com.