-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Clarification needed in step 5 of the text preparation algorithm #8103
Comments
As a web-dev I think I'd kind of prefer that the behavior of the 2D context matches the CSS one as much as possible. Would it be an option to add the missing longhands ( Ps: cc @whatwg/canvas and particularly @yiyix |
Just FYI, the Firefox bug pointed out in your jsfiddle example (exposing an illegal "shorthand" that includes |
…eftests. The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1778910 gecko-commit: d59f1e7c17c5e7a5f12a69fa4ce384bd2a31264f gecko-reviewers: gfx-reviewers, lsalzman
… and add WPT reftests. r=gfx-reviewers,lsalzman The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567
…eftests. The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1778910 gecko-commit: def0a0be81f9f1d6b63720a27b69b34ebe15b4e2 gecko-reviewers: gfx-reviewers, lsalzman
… and add WPT reftests. r=gfx-reviewers,lsalzman The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567
…eftests. The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1778910 gecko-commit: def0a0be81f9f1d6b63720a27b69b34ebe15b4e2 gecko-reviewers: gfx-reviewers, lsalzman
… and add WPT reftests. r=gfx-reviewers,lsalzman The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567
… and add WPT reftests. r=gfx-reviewers,lsalzman The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567
… and add WPT reftests. r=gfx-reviewers,lsalzman The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567 UltraBlame original commit: def0a0be81f9f1d6b63720a27b69b34ebe15b4e2
… and add WPT reftests. r=gfx-reviewers,lsalzman The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567 UltraBlame original commit: def0a0be81f9f1d6b63720a27b69b34ebe15b4e2
… and add WPT reftests. r=gfx-reviewers,lsalzman The behavior in some of these cases is open to debate, as the spec is quite unclear; see whatwg/html#8103. What I've implemented here gives the same rendering result as Chrome for these tests, so hopefully we can get this clarified in the spec as well. Differential Revision: https://phabricator.services.mozilla.com/D182567 UltraBlame original commit: def0a0be81f9f1d6b63720a27b69b34ebe15b4e2
The text preparation algorithm described in §4.12.5.1.4 of https://html.spec.whatwg.org/multipage/canvas.html#text-styles says:
However, this fails to make it clear how the target's
fontStretch
andfontVariantCaps
attributes relate to itsfont
, which (being parsed as a CSSfont
value) includesfont-stretch-css3
andfont-variant-css2
components.Given
ctx.font = "condensed 50px Bahnschrift"
andctx.fontStretch = "normal"
, what is the expected result?Given
ctx.font = "small-caps 50px serif"
andctx.fontVariantCaps = "all-small-caps"
, what is the expected result?Given
ctx.font = "small-caps 50px serif"
, does this automatically setctx.fontVariantCaps
to"small-caps"
?Given
ctx.font = "50px serif"; ctx.fontVariantCaps = "small-caps"
, does the value ofctx.font
automatically become"small-caps 50px serif"
?Some possible approaches:
(1)
font
takes precedence: if a stretch and/or caps value is included in thefont
attribute, it is a fixed part of the font style, and the corresponding separatefontStretch
orfontVariantCaps
attribute is ignored. So those attributes are only used if thefont
attribute did not explicitly set a non-normal value.(2)
fontStretch
andfontVariantCaps
take precedence: these attributes always override whatever may have been set in thefont
attribute. To avoid breaking existing content that uses e.g.ctx.font = "small-caps 20px serif"
and does not mentionfontVariantCaps
at all, we'll need to define an initial value other than"normal"
for these attributes -- something like"unset"
or even just an empty string -- so that thefont
attribute can specify a value and not simply have it overridden by the other attribute's initial value.(3) Behavior is order-dependent: when the stretch and/or caps value differs between the
font
attribute and the individual attributes, whichever was set most recently wins. This has two sub-options:(3a) The context must store the order of setting these attributes, in addition to the current set of values, and save/restore the order along with the values when saving state; or
(3b) Whenever one of these attributes is set, it also automatically updates the other(s) to reflect the new setting, so that the values are consistent with each other. However, the
font
attribute does not support all the values offontVariantCaps
, so it is unclear to me how this would be managed; there would be some weird asymmetry in the relationship.Personally, I think either (1) or (2) (or another option not yet proposed...) should be specified The order of setting attributes on the context (3) should not affect the resulting behavior, and neither (3a) nor (3b) are attractive implementation options.
As far as I am aware, currently only the Blink engine implements the
fontStretch
andfontVariantCaps
attributes, and its implementation seems incomplete and confusing (see https://crbug.com/1343549). I think, therefore, that we should not regard this as a model to be adopted, but try to come to a clear resolution that all engines can implement consistently.The text was updated successfully, but these errors were encountered: