diff --git a/source b/source index 13ac7862d0c..bb2dca9ecf1 100644 --- a/source +++ b/source @@ -4530,6 +4530,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute +
Unicode
+
+

The following terms are defined in Unicode: UNICODE

+ + +
+
Web App Manifest
@@ -65506,6 +65515,7 @@ interface mixin CanvasText { undefined fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth); undefined strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth); TextMetrics measureText(DOMString text); + undefined fillTextCluster(TextCluster textCluster, double x, double y, optional TextClusterOptions options); }; interface mixin CanvasDrawImage { @@ -65604,6 +65614,28 @@ interface TextMetrics { readonly attribute double hangingBaseline; readonly attribute double alphabeticBaseline; readonly attribute double ideographicBaseline; + + sequence<DOMRectReadOnly> getSelectionRects(unsigned long start, unsigned long end); + DOMRectReadOnly getActualBoundingBox(unsigned long start, unsigned long end); + unsigned long getIndexFromOffset(double offset); + sequence<TextCluster> getTextClusters(unsigned long start, unsigned long end, optional TextClusterOptions options); +}; + +[Exposed=(Window,Worker)] +interface TextCluster { + readonly attribute double x; + readonly attribute double y; + readonly attribute unsigned long begin; + readonly attribute unsigned long end; + readonly attribute CanvasTextAlign align; + readonly attribute CanvasTextBaseline baseline; +}; + +dictionary TextClusterOptions { + CanvasTextAlign align; + CanvasTextBaseline baseline; + double x; + double y; }; dictionary ImageDataSettings { @@ -69143,6 +69175,12 @@ try {
metrics.ideographicBaseline

Returns the measurement described below.

+
metrics.getSelectionRects(start, end)
+
metrics.getActualBoundingBox(start, end)
+
metrics.getIndexFromOffset(offset)
+
metrics.getTextClusters(start, end [, options ])
+ +
context.fillTextCluster(textCluster, x, y [, options ])
@@ -69327,6 +69365,116 @@ try { positive numbers indicating that the given baseline is below the ideographic-under baseline. (Zero if the given baseline is the ideographic-under baseline.)

+ +
getSelectionRects(start, end) method
+ +

Returns the set of rectangles that the UA would render as selection to select + a particular character range, in CSS pixels. The positions are returned + relative to the alignment point given by the textAlign and textBaseline attributes.

+ +
getActualBoundingBox(start, end) method
+ +
+

Returns the rectangle equivalent to the box described by actualBoundingBoxLeft, actualBoundingBoxRight, actualBoundingBoxAscent, actualBoundingBoxDescent, for the given + range. The positions are returned relative to the alignment point given by the textAlign and textBaseline attributes.

+ +

The bounding box can be (and usually is) different from the selection + rectangles, which are based on the advance of the text. A font that is particularly slanted or + with accents that go beyond the flow of text will have a different paint bounding box.

+
+ +
getIndexFromOffset(offset) method
+ +

Returns the string index for the character at the given offset distance from the start + position of the text run, relative to the alignment point given by the textAlign attribute, with offset always increasing left + to right (negative offsets are valid). Values to the left or right of the text bounds will return + 0 or the length of the text, depending on the writing direction.

+ +
getTextClusters(start, end, options) method
+ +
+

Splits the given range of the text into grapheme clusters, and returns the positional data + for each cluster, as a list of new TextCluster objects, with members behaving as + described in the following list: UNICODE

+ +
+
x attribute
+ +
+

The x coordinate of the cluster, on a coordinate space using CSS pixels, with its origin at the anchor point defined by the textAlign attribute (at the time measureText() was called) in relation to the text + as a whole.

+ +

The x position specified for each cluster corresponds to the aligment point given by the + align attribute of the cluster (e.g. if + this attribute is set to "left", the calculated position corresponds + to the left of each cluster). The + selection criteria for this alignment point is explained in the section for this attribute + of the cluster.

+
+ +
y attribute
+ +
+

The y coordinate of the cluster, on a coordinate space using CSS pixels, with its origin at the anchor point defined by the textBaseline attribute (at the time measureText() was called) in relation to the text + as a whole.

+ +

The y position specified for each cluster corresponds to the aligment point given by the + baseline attribute of the cluster (e.g. if + this attribute is set to "top", the calculated position corresponds + to the top of each cluster). The + selection criteria for this alignment point is explained in the section for this attribute + of the cluster.

+
+ +
begin attribute
+ +

The starting index for the range of code points that are + rendered as this cluster.

+ +
end attribute
+ +

The ending index for the range of code points that are + rendered as this cluster.

+ +
align attribute
+ +

The align for the specific point returned for the cluster. If a + TextClusterOptions options dictionary is passed, and it has a value for + options.align, this will be the assigned value. Otherwise, it will be + set as the textAlign attribute. Note that this + doesn't change the origin of the coordinate system, just which point is specified for each + cluster.

+ +
baseline attribute
+ +

The baseline for the specific point returned for the cluster. If a + TextClusterOptions options dictionary is passed, and it has a value for + options.baseline, this will be the assigned value. Otherwise, it will + be set as the textBaseline attribute. Note + that this doesn't change the origin of the coordinate system, just which point is specified + for each cluster.

+
+ +

The user agent might internally store in the TextCluster object the + complete text, as well as all the CanvasTextDrawingStyles at the time that measureText() was called, as they will be needed to + correctly render the clusters as they were measured.

+

Glyphs rendered using fillText() and @@ -69339,7 +69487,67 @@ try { documents, rendered using CSS, straight to the canvas. This would be provided in preference to a dedicated way of doing multiline layout.

+

The fillTextCluster(textCluster, x, + y, options) method renders a TextCluster object. + The cluster is rendered where it would be if the whole text that was passed to measureText() to obtain the cluster was rendered at + position (x,y), unless the positioning is modified with the options + argument. Specifically, when the methods are invoked, the user agent must run these steps:

+ +
    +
  1. If any of the arguments are infinite or NaN, then return.

  2. + +
  3. Run the text preparation algorithm, passing it the text + originally passed to measureText() to obtain + the cluster, and an object with the CanvasTextDrawingStyles values as they were + when the cluster was measured, with the exception of textAlign and textBaseline, which are taken from the align and baseline attributes of cluster. Let + glyphs be the result.

  4. + +
  5. Filter glyphs to include only glyphs that contain code points within the range cluster.begin to cluster.end.

  6. + +
  7. Move all the shapes in glyphs to the right by x + CSS pixels and down by y CSS + pixels.

  8. + +
  9. +

    If a TextClusterOptions options dictionary is passed and it has an options.x value, move all the shapes in glyphs to the right by + options.x-cluster.x.

    + +

    If a TextClusterOptions options dictionary is passed and it has an options.y value, move all the shapes in glyphs down by options.y-cluster.y.

    +
  10. + +
  11. +

    Paint the shapes given in glyphs, as transformed by the current transformation matrix, with each CSS pixel in the coordinate space of glyphs mapped to one + coordinate space unit.

    + +

    this's fill style must be applied to the + shapes and this's stroke style must be ignored. + +

    These shapes are painted without affecting the current path, and are subject to shadow effects, global + alpha, the clipping region, and the current compositing and blending + operator.

    +
  12. +
+

By setting options.x and options.y + to 0, the cluster will be rendered exactly at the position (x,y) passed to + fillTextCluster().

Drawing paths to the canvas
@@ -146080,6 +146288,7 @@ INSERT INTERFACES HERE Andreas Kling, Andrei Popescu, Andres Gomez, + Andrés Ricardo Pérez Rojas, Andres Rios, Andreu Botella, Andrew Barfield,