-
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
Update letterSpacing and wordSpacing to accept String #7378
Conversation
Thanks for creating this PR @yiyix. As far as I know @Kaiido does not speak for Mozilla or Firefox. @jdashg or I do (at times). Also, this change isn't sufficient. You need to invoke the CSS parser as we do for other canvas members. And we also need to serialize the value in some manner for the getters. |
cc @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.
Yes, I always speak (maybe too much) only for myself as a web-author, I don't have any affiliation with any vendor.
Regarding the changes I still find the discrepancy between font
being converted to px
and these values kept as relative <length>
a bit surprising ("2vw"
may represent two different values entirely just by resizing the window), but overall I don't have strong opinions.
Thank you for the clarification. What do you think about this change, Define letterSpacing and wordSpacing in terms of String? Or do you think it's better to keep as it is or accept doubles and strings?
I will re-write this part. Thank you |
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 this quite sketchy review, I am not sure about all my proposed changes and a review of the review is required.
@Kaiido, it'd be best if you left review to the editors :). I worry that you might end up giving advice which conflicts with our preferences, or applies to a section the editors request be done in a different way entirely, etc. This makes it harder for contributors to understand what is required for merging, and can generate unnecessary work. |
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.
Overall it looks like you have the right idea to me, and have found the most relevant algorithms for parsing and serializing. We just need to tighten up the language.
Note that this parse/serialize architecture means that
ctx.letterSpacing = "5PX";
console.assert(ctx.letterSpacing === "5px"); // lowercased!!
will hold. That seems consistent with what we've specified elsewhere, but is worth writing web platform tests for.
Good point! Tests and Changes are now made. |
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 looks great. A few style issues and one more substantial issue about the initial value, but after that this is about ready to merge. (I can do a final formatting pass.)
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.
OK, this all looks good! But I realized we forgot to update a couple other parts of the spec which currently refer to letterSpacing
/wordSpacing
to instead refer to "letter spacing"/"word spacing" (i.e., to refer to the underlying <span data-x="concept-CanvasTextDrawingStyles-letter-spacing">letter spacing</span>
private field).
I think the following two places need updating:
- https://html.spec.whatwg.org/#the-canvas-state:dom-context-2d-letterspacing
- https://html.spec.whatwg.org/#text-styles:dom-context-2d-letterspacing-3
After that I think we should be good!
This version definitely looks much better than the previous ones. Thank you so much! This should conclude our spec changes for Canvas new API |
Is it so? This section gets the "attributes" values, linking to the IDL attributes' getters sounds correct, no? Otherwise I guess this should be moved in a later item like it's done for "The current dash list". |
Yes @Kaiido, this is part of a general program to update the spec to stop relying on JavaScript-modifiable getters and instead get their backing values. |
… getters This is a follow-up on whatwg#7378. It fixes a couple of typos, and adds the current filter and the current composition operator in the list of saved values from CanvasState, since these already have their own internal value being defined.
Fix some typos in the canvas text styles section that were introduced in4d93c06fa604021b7c582940e1a419378237bf44. Use the current filter and current composition operator in the canvas state section, instead of the public getters, per #7378 (comment).
Fix some typos in the canvas text styles section that were introduced in4d93c06fa604021b7c582940e1a419378237bf44. Use the current filter and current composition operator in the canvas state section, instead of the public getters, per whatwg#7378 (comment).
Fix some typos in the canvas text styles section that were introduced in4d93c06fa604021b7c582940e1a419378237bf44. Use the current filter and current composition operator in the canvas state section, instead of the public getters, per whatwg#7378 (comment).
At least two implementers are interested (and none opposed):
Tests are written and can be reviewed and commented upon at:
Implementation bugs are filed:
(See WHATWG Working Mode: Changes for more details.)
/canvas.html ( diff )
/canvas.html ( diff )