Contact emailssche...@chromium.org,
fma...@chromium.orgExplainerhttps://github.com/fserb/canvas2D/blob/master/spec/enhanced-textmetrics.mdhttps://github.com/Igalia/explainers/blob/main/canvas-formatted-text/text-metrics-additions.mdhttps://github.com/whatwg/html/issues/10677Specificationhttps://github.com/whatwg/html/pull/11000SummaryExpand the TextMetrics Canvas API to support selection rectangles, bounding box queries, and grapheme cluster-based operations.
This new functionality should enable complex text editing applications with accurate selection, caret positioning, and hit testing. Additionally, cluster-based rendering facilitates sophisticated text effects such as independent character animations and styling.
Blink componentBlink>Canvas
MotivationThe existing TextMetrics API provides measurements for atomic text, but offers no facilities to break down that information to a more granular level.
Sophisticated text applications (editors in particular) require such granular information in order to support accurate selection, caret positioning and hit testing at a grapheme level. Currently they are resorting to various inaccurate approximations to work around API limitations.
Another complex use case involves rendering fragments of pre-shaped text with different attributes - e.g. different colors or different transforms. This is of particular interest to animation frameworks which allow characters to be animated independently. Such functionality is not directly supported in existing APIs, and implementers must again resort to approximate workarounds.
The enhanced TextMetrics proposal aims to address the current API shortcomings and to offer first class support for the above use cases.
Initial public proposalhttps://github.com/whatwg/html/pull/11000TAG reviewhttps://github.com/w3ctag/design-reviews/issues/1095TAG review statusPending
RisksInteroperability and CompatibilityThese are new features and we will get vendor agreement at WHATWG before shipping. So minimal interop risks beyond platform-specific metrics differences.
Gecko: No signal (
https://github.com/mozilla/standards-positions/issues/1144)
WebKit: No signal (
https://github.com/WebKit/standards-positions/issues/436)
Web developers: Positive Developers want the ability to animate glyphs independently (such as exploding sentences) and the ability to do e.g. selection on canvas text. The proposed APIs support these use cases and more.
Other signals:
ErgonomicsNone.
ActivationNone.
SecurityThere is always a fingerprinting concern with HTML canvas. THe new features expose no novel fingerprinting surface (text metrics are already a fingerprinting concern).
WebView application risksDoes this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?
None
DebuggabilityDevTools supports querying the APIs by default.
Is this feature fully tested by web-platform-tests?Yes
html/canvas/[element|offscreen]/text...
2d.text.measure.index-from-offset*
2d.text.measure.selection-rects*
2d.text.measure.text-clusters*
Flag name on about://flagsExperimental Web Platform Features
Finch feature nameExtendedTextMetrics
Requires code in //chrome?False
MeasurementUMA counters will be added for the new APIs.
Estimated milestonesNo milestones specified
Link to entry on the Chrome Platform Statushttps://chromestatus.com/feature/5075532483657728?gate=5122812490285056This intent message was generated by Chrome Platform Status.