-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend Canvas TextMetrics for editing and text styling #11000
base: main
Are you sure you want to change the base?
Conversation
Tagging: @whatwg/canvas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for leaving some comments out of the review.
source
Outdated
|
||
<dt><dfn attribute for="TextCluster"><code data-x="dom-TextCluster-end">end</code></dfn> attribute</dt> | ||
|
||
<dd><p>The ending index for the range of <span data-x="code point">code points</span> that are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the index one past the end? Range APIs seem to behave that way but I'm not sure how conventional it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is one past the end. I hadn't realized I didn't clarify it in the spec. I'll add it explicitly as I don't know how conventional it is either.
source
Outdated
<p class="note">The user agent might internally store in the <code>TextCluster</code> object the | ||
complete text, as well as all the <code>CanvasTextDrawingStyles</code> at the time that <code | ||
data-x="dom-context-2d-measureText">measureText()</code> was called, as they will be needed to | ||
correctly render the clusters as they were measured.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a requirement that the drawing command uses the same parameters as the measurement? If so I would say that directly here, because right now it seems suggestive but not prescribed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is specified in the section for fillTextCluster()
. The idea when I first wrote it was to just mention the behavior expected, even if the implementation would most likely be to store the parameters in the cluster (as is implemented right now in Chrome).
But, following a suggestion by @Kaiido in another comment, I changed the phrasing of that requirement by using TextCluster
as an opaque object that stores those parameters in cluster when they are created. Hopefully this is more clear. Let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
A couple of questions that came to mind:
- Should there be a
strokeTextCluster()
method akin tostrokeText()
? - Should the
TextCluster
be serializable? (so that we can send it to/from a Worker).
Also, I didn't receive the @whatwg/canvas notification from your previous comment. Hopefully this one will work better.
source
Outdated
The cluster is rendered where it would be if the whole text that was passed to <code | ||
data-x="dom-context-2d-measureText">measureText()</code> to obtain the cluster was rendered at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disclaimer: I'm not an editor, so take this with a grain of salt.
I feel this would be a lot clearer if the TextMetrics
interface had an internal value to store the original text for each instance and reuse it where needed, instead of this tedious "the text that was passed to measureText()
to obtain the cluster".
See for instance how CanvasPattern
objects have a transformation matrix that isn't exposed:
Patterns have a transformation matrix, which controls how the pattern is used when it is painted. Initially, a pattern's transformation matrix must be the identity matrix.
It might even be needed to have a clear relationship established between the TextCluster
and the TextMetrics
from where it's been created, so that you can do something like the cluster's textmetrics's text, or, given that when the TextCluster
is created text
is available, and TextMetrics
may not need it otherwise, you could maybe store it directly along the TextCluster
(still in an internal value).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't noticed that objects like CanvasPattern
were defined in this way as opaque. I like that concept and I feel it applies well to this use case. Thank you so much for the suggestion!
I have updated it to reflect this. For now I went with the second approach you mentioned (storing the text and the CanvasTextDrawingStyles
directly in the cluster as internal values). Hopefully this provides more clarity. Let me know what you think!
source
Outdated
<li><p>Run the <span>text preparation algorithm</span>, passing it the <var>text</var> | ||
originally passed to <code data-x="dom-context-2d-measureText">measureText()</code> to obtain | ||
the cluster, and an object with the <code>CanvasTextDrawingStyles</code> values as they were | ||
when the cluster was measured, with the exception of <code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This object should probably be created explicitly sooner, in the getTextClusters()
method. However I'm not sure how this should be done since we want the computed values at that time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the use of the internal values of the opaque object, hopefully the relationship is clearer now. Passing the exact object from the cluster won't always be possible due to the possibility of passing align
and baseline
to to fillTextCluster()
when rendering, but most of the values now come from the internally stored value.
Thank you both for your comments! I have addressed them and uploaded the changes. Please let me know what you think. Answering some of the open questions:
I have added it to the PR. I agree that it makes sense to have both.
We feel that for now, it's simpler to not make it serializable. Once we merge this and we know exactly what clusters look like and what values they are storing internally that would require serialization, we can look into it.
Thanks! I'm not fully sure how the tags work, so I really appreciate it! |
@@ -4165,6 +4165,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute | |||
<dfn data-x="DOMPointInit-x" data-xref="https://drafts.fxtf.org/geometry/#dom-dompointinit-x">x</dfn> and | |||
<dfn data-x="DOMPointInit-y" data-xref="https://drafts.fxtf.org/geometry/#dom-dompointinit-y">y</dfn> members</li> | |||
<li><dfn data-x-href="https://drafts.fxtf.org/geometry/#matrix-multiply">Matrix multiplication</dfn></li> | |||
<li><dfn data-x-href="https://www.w3.org/TR/geometry-1/#DOMRect">DOMRectReadOnly and DOMRect</dfn></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each needs its own reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added both since the section on W3C is named DOMRect
, but since I’m only using DOMRectReadOnly
I will just leave that one pointing to its definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use TR links; use https://drafts.fxtf.org/geometry/ .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And objects should have <code>
as well.
source
Outdated
<p>The <dfn method for="CanvasText"><code | ||
data-x="dom-context-2d-fillTextCluster">fillTextCluster(<var>cluster</var>, <var>x</var>, | ||
<var>y</var>, <var>options</var>)</code></dfn> and <dfn method for="CanvasText"><code | ||
data-x="dom-context-2d-strokeTextCluster">strokeTextCluster(<var>cluster</var>, <var>x</var>, | ||
<var>y</var>, <var>options</var>)</code></dfn> methods render a <code>TextCluster</code> object. | ||
The cluster is rendered where it would be if the whole text that was passed to <code | ||
data-x="dom-context-2d-measureText">measureText()</code> to obtain the cluster was rendered at | ||
position (<var>x</var>,<var>y</var>), unless the positioning is modified with the options | ||
argument. Specifically, when the method is invoked, the user agent must run these steps:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These need to be rephrased to use the modern way of defining methods. "The X method steps are ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, although I kept the structure of bundling the fill and stroke version together.
If this version is what is desired, I can create a PR moving fillText()
and strokeText()
to this modern format once this PR lands.
source
Outdated
<ol> | ||
<li><p>If any of the arguments are infinite or NaN, then return.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation and formatting here doesn't appear to follow the guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for pointing it out!
@@ -69327,6 +69456,125 @@ try { | |||
positive numbers indicating that the given baseline is below the <span>ideographic-under | |||
baseline</span>. (Zero if the given baseline is the <span>ideographic-under | |||
baseline</span>.)</p></dd> | |||
|
|||
<dt><dfn method for="TextMetrics"><code data-x="dom-textmetrics-getSelectionRects">getSelectionRects(<var>start</var>, <var>end</var>)</code></dfn> method</dt> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not follow the bad precedent set of the current set of attributes. Please define these as modern methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to assign some variables from the result of the text preparation algorithm being run when measureText()
was called. Let me know what you think of this please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this relates to the concern?
// opaque object | ||
readonly attribute double <span data-x="dom-TextCluster-x">x</span>; | ||
readonly attribute double <span data-x="dom-TextCluster-y">y</span>; | ||
readonly attribute unsigned long <span data-x="dom-TextCluster-begin">begin</span>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes you use "begin" and sometimes "start". That should be made consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I settled with start. Thanks for pointing it out!
|
||
[Exposed=(Window,Worker)] | ||
interface <dfn interface>TextCluster</dfn> { | ||
// opaque object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this comment buys us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to show that TextCluster
objects have hidden valued stored inside that are defined when creating the cluster, and used when rendering it. I added that comment since I saw it on CanvasGradient
and CanvasPattern
, that have this kind of hidden attributes. Should I express this in a different way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, if it's consistent with CanvasPattern
we can keep it I suppose.
This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec
This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec
This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperez@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Cr-Commit-Position: refs/heads/main@{#1425171}
This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperez@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Cr-Commit-Position: refs/heads/main@{#1425171}
This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperez@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Cr-Commit-Position: refs/heads/main@{#1425171}
…tonly Automatic update from web-platform-tests Implement ctx.strokeTextCluster() This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperez@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Cr-Commit-Position: refs/heads/main@{#1425171} -- wpt-commits: e515834325719ce9e2a15e2d41bfce49f020db7a wpt-pr: 50942
…tonly Automatic update from web-platform-tests Implement ctx.strokeTextCluster() This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperez@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Cr-Commit-Position: refs/heads/main@{#1425171} -- wpt-commits: e515834325719ce9e2a15e2d41bfce49f020db7a wpt-pr: 50942
…tonly Automatic update from web-platform-tests Implement ctx.strokeTextCluster() This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperezchromium.org> Reviewed-by: Fernando Serboncini <fserbchromium.org> Reviewed-by: Stephen Chenney <schenneychromium.org> Cr-Commit-Position: refs/heads/main{#1425171} -- wpt-commits: e515834325719ce9e2a15e2d41bfce49f020db7a wpt-pr: 50942 UltraBlame original commit: c4d5d718989db2d1c940af46af2b61bd0b938b97
…tonly Automatic update from web-platform-tests Implement ctx.strokeTextCluster() This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperezchromium.org> Reviewed-by: Fernando Serboncini <fserbchromium.org> Reviewed-by: Stephen Chenney <schenneychromium.org> Cr-Commit-Position: refs/heads/main{#1425171} -- wpt-commits: e515834325719ce9e2a15e2d41bfce49f020db7a wpt-pr: 50942 UltraBlame original commit: c4d5d718989db2d1c940af46af2b61bd0b938b97
…tonly Automatic update from web-platform-tests Implement ctx.strokeTextCluster() This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperezchromium.org> Reviewed-by: Fernando Serboncini <fserbchromium.org> Reviewed-by: Stephen Chenney <schenneychromium.org> Cr-Commit-Position: refs/heads/main{#1425171} -- wpt-commits: e515834325719ce9e2a15e2d41bfce49f020db7a wpt-pr: 50942 UltraBlame original commit: c4d5d718989db2d1c940af46af2b61bd0b938b97
…tonly Automatic update from web-platform-tests Implement ctx.strokeTextCluster() This CL creates a new method for CanvasRenderingContext2d that strokes a TextCluster object. Its fill counterpart, ctx.fillTextCluster(), was merged in https://crrev.com/c/5854270. This new method came to be from the discussion around the spec for the TextMetrics additions: whatwg/html#11000 The existing tests for fillTextCluster() were renamed to include the method name in the title, since before only "rendering" was mentioned. The new tests are explicitly named using strokeTextCluster(). A line that was duplicated on the tests for fillTextCluster() was also removed. Bug: 341213359 Change-Id: Icd792b56e48f3ea5091e958671c19fcefe67fdec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6282180 Commit-Queue: Andres Ricardo Perez <andresrperez@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Reviewed-by: Stephen Chenney <schenney@chromium.org> Cr-Commit-Position: refs/heads/main@{#1425171} -- wpt-commits: e515834325719ce9e2a15e2d41bfce49f020db7a wpt-pr: 50942
|
||
[Exposed=(Window,Worker)] | ||
interface <dfn interface>TextCluster</dfn> { | ||
// opaque object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, if it's consistent with CanvasPattern
we can keep it I suppose.
<span>CanvasTextAlign</span> align; | ||
<span>CanvasTextBaseline</span> baseline; | ||
double x; | ||
double y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These members should probably be <dfn>
so they can be referenced from prose.
data-x="dom-context-2d-fillTextCluster">fillTextCluster(<var>cluster</var>, <var>x</var>, | ||
<var>y</var>, <var>options</var>)</code></dfn> and <dfn method for="CanvasText"><code | ||
data-x="dom-context-2d-strokeTextCluster">strokeTextCluster(<var>cluster</var>, <var>x</var>, | ||
<var>y</var>, <var>options</var>)</code></dfn> methods, when invoked, must run these steps:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The X method steps are:" is the modern style.
<var>y</var>, <var>options</var>)</code></dfn> methods, when invoked, must run these steps:</p> | ||
|
||
<ol> | ||
<li><p>If any of the arguments are infinite or NaN, then return.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that these also take a dictionary, I think we should be more explicit here.
|
||
<li><p>Run the <span>text preparation algorithm</span>, passing it the complete text and the | ||
<code>CanvasTextDrawingStyles</code> from the opaque <code>TextCluster</code> | ||
<var>cluster</var>, with the exception of <code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception also refers to the cluster. So I don't really follow this.
This is also talking about public API whereas we shouldn't be touching that here.
interface mixin <dfn interface>CanvasText</dfn> { | ||
// text (see also the <span>CanvasPathDrawingStyles</span> and <span>CanvasTextDrawingStyles</span> interfaces) | ||
undefined <span data-x="dom-context-2d-fillText">fillText</span>(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth); | ||
undefined <span data-x="dom-context-2d-strokeText">strokeText</span>(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth); | ||
undefined <span data-x="dom-context-2d-fillTextCluster">fillTextCluster</span>(<span>TextCluster</span> cluster, double x, double y, optional <span>TextClusterOptions</span> options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional dictionaries must default to = {}
<li> | ||
<p>If a <code>TextClusterOptions</code> options dictionary is passed and it has an <code | ||
data-x="">options["x"]</code> value, move all the shapes in <var>glyphs</var> to the right by | ||
<code data-x="">options["x"] − cluster["x"]</code>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dictionary is always passed (see other comment). But this language and markup needs updating. I recommend looking at something recent, such as TogglePopoverOptions
.
style</span> must be applied to the result of <span data-x="trace a path">tracing</span> the | ||
shapes using the object implementing the <code>CanvasText</code> interface for the line | ||
styles, and <span>this</span>'s <span data-x="concept-CanvasFillStrokeStyles-fill-style">fill | ||
style</span> must be ignored.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner if there was a shared algorithm that was passed either "fill" or "stroke" or some such as an internal enum value that you could branch on here.
@@ -69327,6 +69456,125 @@ try { | |||
positive numbers indicating that the given baseline is below the <span>ideographic-under | |||
baseline</span>. (Zero if the given baseline is the <span>ideographic-under | |||
baseline</span>.)</p></dd> | |||
|
|||
<dt><dfn method for="TextMetrics"><code data-x="dom-textmetrics-getSelectionRects">getSelectionRects(<var>start</var>, <var>end</var>)</code></dfn> method</dt> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this relates to the concern?
@@ -69339,8 +69609,6 @@ try { | |||
documents, rendered using CSS, straight to the canvas. This would be provided in preference to a | |||
dedicated way of doing multiline layout.</p> | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably best not to remove those here.
This change adds the following functionalities to TextMetrics objects:
Additionally, a new method is added to the Canvas 2D rendering context to render these clusters. When rendering, all relevant CanvasTextDrawingStyles are used as they were when the text was measured.
See the discussion in the issue: #10677
2d.text.measure.selection-rects*
,2d.text.measure.getActualBoundingBox*
,2d.text.measure.index-from-offset*
, and2d.text.measure.text-clusters*
.(See WHATWG Working Mode: Changes for more details.)
/acknowledgements.html ( diff )
/canvas.html ( diff )
/infrastructure.html ( diff )