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 +
The following terms are defined in Unicode: UNICODE
+ +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 ])
getSelectionRects(start, end)
methodReturns 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)
methodReturns 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)
methodReturns 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)
methodSplits 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
attributeThe 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
attributeThe 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
attributeThe starting index for the range of code points that are + rendered as this cluster.
end
attributeThe ending index for the range of code points that are + rendered as this cluster.
align
attributeThe 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
attributeThe 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:
If any of the arguments are infinite or NaN, then return.
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.
Filter glyphs to include only glyphs that contain code points within the range cluster.begin
to cluster.end
.
Move all the shapes in glyphs to the right by x + CSS pixels and down by y CSS + pixels.
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
.
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.
+By setting options.x
and options.y
+ to 0, the cluster will be rendered exactly at the position (x,y) passed to
+ fillTextCluster()
.