github web-platform-tests/wpt merge_pr_48424

latest releases: merge_pr_49470, epochs/three_hourly/2024-12-03_06H, epochs/six_hourly/2024-12-03_06H...
4 months ago

Implement ctx.fillTextCluster()

This change creates a new API method for the CanvasRenderingContext2d
that enables the rendering of the TextCluster objects returned by the
API implemented on the previous CL in the stack.

The new method receives a TextCluster object, an x value, and a y value.
This coordinates represent by how much to shift the rendered text from
the x and y attributes of the TextCluster object. In practice, this
means that calling fillText() from a point p will have the same result
as measuring that text and calling fillTextCluster() on each cluster
passing the same point as parameter. This is true provided that the
textAlign and textBaseline values for the rendering context are set to
the same values as passed to TextMetrics::getTextClustersForRange().

The implementation required a new Font::SubRunWidth to calculate the
width and the bounds of the TextCluster object to be rendered. It runs
the bidi algorithm to get the visual runs, and once it finds the correct
one, uses GetCharacterRange() to obtain these values.

The new paths are only used when rendering a TextCluster to avoid
potential performance issues for the existing ctx.fillText() and
ctx.StrokeText() methods.

The new API was enabled under the ExtendedTextMetrics flag.

Bug: 341213359
Change-Id: I2f58b3ef958704910aedaa450923ed3751a77bdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5854270
Reviewed-by: Jean-Philippe Gravel jpgravel@chromium.org
Commit-Queue: Andres Ricardo Perez andresrperez@chromium.org
Cr-Commit-Position: refs/heads/main@{#1370047}

Don't miss a new wpt release

NewReleases is sending notifications on new releases.