-
Notifications
You must be signed in to change notification settings - Fork 758
[css-fonts-5] Define behavior for <meta text-scale> from #12380 #13052
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
base: main
Are you sure you want to change the base?
Changes from all commits
8d5f5e2
18f2f8b
b729d74
0206973
c287984
f6d1a0c
3716341
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ spec:css-color-4; type:property; text:color | |
| spec:css-values; type:value; text:ex | ||
| spec:css22; type:value; for:/; text:block | ||
| spec:html; type:element; text:font | ||
| spec:html; type:element; text:meta | ||
| spec:css-fonts-4; type:property; text:font-size | ||
| spec:css-fonts-4; type:descriptor; text:font-language-override | ||
| spec:css-fonts-4; type:property; text:font-family | ||
|
|
@@ -59,7 +60,119 @@ rules defined in CSS Fonts Level 4. | |
| This specification is currently a delta to the CSS Fonts Level 4 specification. | ||
| Do not assume that if something is not here, it has been dropped. | ||
|
|
||
| <h2 id="text-scale-meta"> | ||
| Text-Scale <code class=html><meta></code> element</h2> | ||
|
|
||
| A document with a <{meta}> tag | ||
| whose <{meta/name}> attribute | ||
| is a <a>ASCII case-insensitive</a> match for | ||
| <dfn lt=text-scale><code>"text-scale"</code></dfn> | ||
| is recognized as setting the computed value | ||
| of the ''font-size/medium'' font size | ||
| and consequently scaling the computed size of the other <<absolute-size>> keywords. | ||
|
|
||
| The value of the <code>content</code> | ||
| attribute must be an <a>ASCII case-insensitive</a> match for one of the | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must -> otherwise what?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added 'Otherwise the tag is ignored.'
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering specifying the 'otherwise' case is neccessary here, because, to me, the HTML spec seems to imply it is ignored anyway. |
||
| recognized keywords. Otherwise the tag is ignored. | ||
|
|
||
| Documents without this <{meta}> tag will have an assumed default | ||
| value of <code>legacy</code>. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to add an example block here, similar to the example in the HTML spec for the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| <div class="example" id="ex-text-scale"> | ||
| <pre><meta name="text-scale" content="scale" /></pre> | ||
| </div> | ||
|
|
||
| There must not be more than one <{meta}> element with its <{meta/name}> attribute value set to an [=ASCII case-insensitive=] for [=text-scale=] per document. | ||
|
|
||
| <h3 id="text-scale-meta-keywords"> | ||
| Keywords</h3> | ||
|
|
||
| The recognized keywords in the [=text-scale=] | ||
| <{meta}> element are: | ||
|
|
||
| <dl> | ||
| <dt><dfn for="text-scale">legacy</dfn></dt> | ||
| <dd>The ''env()/preferred-text-scale'' environment variable returns the user's OS-level font factor on mobile, | ||
| but 1 on desktop. | ||
| The document's ''font-size/medium'' font size incorporates UA-level font preferences. | ||
| OS-level font preferences are ignored. | ||
|
|
||
| Note: Equivalent to omitting a [=text-scale=] <{meta}> tag or | ||
| including an unrecognized content attribute keyword. | ||
| </dd> | ||
| <dt><dfn>scale</dfn></dt> | ||
| <dd>The ''env()/preferred-text-scale'' environment variable returns the user's OS-level font preferences. | ||
| The document's ''font-size/medium'' font size incorporates both UA-level and OS-level font preferences.</dd> | ||
| </dl> | ||
|
|
||
| <h3 id="legacy-keyword">The 'legacy' keyword</h3> | ||
|
|
||
| When the value of the [=text-scale=] content attribute is | ||
| [=text-scale/legacy=] | ||
| the user agent must set the computed ''font-size/medium'' font size | ||
| to 16px multiplied by | ||
| the font scale factor | ||
| the user has chosen from any settings <i>provided by the user agent</i>. | ||
| The ''preferred-text-scale'' environment variable value must be 1 on desktop platforms. | ||
| On mobile: | ||
| <ul> | ||
| <li>if the operating system provides a text scale setting AND | ||
| the UA hasn't already applied that factor to the ''font-size/medium'' font size, | ||
| the ''env()/preferred-text-scale'' environment variable returns the multiplier | ||
| that the user has chosen in the operating system's text scale setting. | ||
|
|
||
| Note: At the time of publishing, all combinations of | ||
| Android, iOS, | ||
| Firefox, Safari, Chrome | ||
| satisfy this first condition. | ||
|
|
||
| </li> | ||
| <li>Otherwise the ''env()/preferred-text-scale'' environment variable returns 1.</li> | ||
| </ul> | ||
|
|
||
| <h3 id="scale-keyword">The 'scale' keyword</h3> | ||
|
|
||
| The <dfn for="text-scale" export><code>scale</code></dfn> property is | ||
| recognized in the [=text-scale=] content attribute value. | ||
|
|
||
| When the value of the [=text-scale=] content attribute is | ||
| <a for=text-scale>scale</a> | ||
| computed ''font-size/medium'' font size must match the user's preferred paragraph text size as determined from a combination of OS and UA preferences. | ||
|
|
||
| The ''env()/preferred-text-scale'' environment variable must return a number that, | ||
| when multiplied by 16px, | ||
| provides a <<length>> that matches that of the ''font-size/medium'' font size. | ||
|
|
||
| Further, when the value of the [=text-scale=] content attribute is | ||
| <a for=text-scale>scale</a>, the user agent should skip all font-sizing interventions it would otherwise perform in an attempt to automatically honor the user's preferences. E.g. text autosizing on mobile (See [[css-size-adjust#intro]]) and full-application zoom (<a href="https://github.com/w3c/csswg-drafts/blob/main/css-env-1/explainers/env-preferred-text-scale.md#windows-11">popular browsers do this on Windows)</a>. | ||
|
|
||
| Note: Authors are expected to use | ||
| ''<meta name="text-scale" content="scale">'' in stylesheets so that the ''font-size/medium'' font size will reflect a combination of the user's font preferences, whether those are specified at the OS level or the UA level. The author will then be able to use ''rem'' throughout the page to honor the user's font preferences. | ||
|
|
||
| <div class="example" id="ex-scaled-page"> | ||
| If authors don't alter the '':root'' font size, content sized with ''rem'' units will be relative to the preferred text scale | ||
| <pre> | ||
| <!DOCTYPE html> | ||
| <html> <!-- leave this element's font-size as the default --> | ||
| <head> | ||
| <meta name="text-scale" content="scale" /> | ||
| </head> | ||
| <body> | ||
| <div style="font-size: 1rem;"> | ||
| This font size obeys the user's font preferences, **whether | ||
| those preferences are specified at the operating system level | ||
| or the user agent level** | ||
| </div> | ||
| <div style="font-size: 20px;"> | ||
| This font size does NOT respect the user's font preferences. | ||
| <div style="font-size: 1rem;"> | ||
| But this font size does! | ||
| </div> | ||
| </div> | ||
| </body> | ||
| </html> | ||
| </pre> | ||
| </div> | ||
|
|
||
| <h3 id="values"> | ||
| Value Definitions</h3> | ||
|
|
||
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 noticed the HTML spec also mentions when a metadata name should not appear more than once in the document. Maybe you should add this line somewhere:
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