Skip to content
121 changes: 121 additions & 0 deletions css-fonts-5/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,6 +75,126 @@ all properties defined in this specification
also accept the <a>CSS-wide keywords</a> as their property value.
For readability they have not been repeated explicitly.

<h2 id="text-scale-meta">
Text-Scale <{meta}> element</h2>

User agents must calculate the computed value of ''font-size/medium'' by multiplying 16px by
the <dfn>text scale factor</dfn>.
User agents must also apply this factor when determining the computed sizes of the other <<absolute-size>> keywords.
However, user agents should scale these other keywords non-linearly
to preserve readability.

Note: Applying a linear scale to all keywords would render large fonts excessively large. See the
<a href="https://github.com/w3c/wcag3/issues/261#issuecomment-2598860630">
WCAG discussion on minimum and maximum critical font sizes</a>.

A document with a <{meta}> tag
whose <{meta/name}> attribute
is an <a>ASCII case-insensitive</a> match for
<dfn lt="text-scale" export><code>"text-scale"</code></dfn>
is recognized as controlling the [=text scale factor=].

The value of the <{meta/content}>
attribute must be an <a>ASCII case-insensitive</a> match for one of the
recognized keywords. Otherwise the tag is ignored.

Documents without this <{meta}> tag will have an assumed default
value of <a for="text-scale">legacy</a>.

<div class="example" id="ex-text-scale">
<pre class="lang-html">&lt;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=] match 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 devices,
but 1 on desktop devices.
[=text scale factor=] incorporates UA-level font preferences but
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 for="text-scale">scale</dfn></dt>
<dd>
The ''env()/preferred-text-scale'' environment variable returns the user's OS-level font preferences.
[=text scale factor=] incorporates both UA-level and OS-level font preferences.
</dd>
</dl>

<h3 id="legacy-keyword">The <a for="text-scale">legacy</a> keyword</h3>

When the value of the [=text-scale=] content attribute is
[=text-scale/legacy=],
the [=text scale factor=] is the font scale factor
the user has chosen from any settings provided <i>only</i> by the user agent.
The ''env()/preferred-text-scale'' environment variable value must be 1 on desktop platforms.

On mobile platforms:
<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, and 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>

When the value of the [=text-scale=] content attribute is
<a for="text-scale">scale</a>,
the [=text scale factor=] matches the user's preferred paragraph text size
(as determined from a combination of OS and UA preferences)
divided by 16px.

The ''env()/preferred-text-scale'' environment variable must return the [=text scale factor=].

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
<code>&lt;meta name="text-scale" content="scale"&gt;</code> 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 class="lang-html">
&lt;!DOCTYPE html>
&lt;html> &lt;!-- leave this element's font-size as the default -->
&lt;head>
&lt;meta name="text-scale" content="scale" />
&lt;/head>
&lt;body>
&lt;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**
&lt;/div>
&lt;div style="font-size: 20px;">
This font size does NOT respect the user's font preferences.
&lt;div style="font-size: 1rem;">
But this font size does!
&lt;/div>
&lt;/div>
&lt;/body>
&lt;/html>
</pre>
</div>


<h2 id="basic-font-props">
Basic Font Properties</h2>

Expand Down