-
Notifications
You must be signed in to change notification settings - Fork 730
[css-fonts-5]: define text-scale, legacy/scale keywords, env(preferred-text-scale) #12469
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?
[css-fonts-5]: define text-scale, legacy/scale keywords, env(preferred-text-scale) #12469
Conversation
When the value of the [=text-scale=] content attribute is | ||
<a for="text-scale">legacy</a> the user agent should set the initial font size | ||
to 16px. The user agent may chose a different initial value, such as one based | ||
on a user preference. The ''env()/preferred-text-scale'' value must be 1. |
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 value is always 1 on desktop, but not necessarily on mobile.
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.
Yeah, as in the Explainer, the env(preferred-text-scale)
is the OS text scale on mobile. So if the user doubles their text scale, the value is 2, for example.
https://github.com/w3c/csswg-drafts/blob/main/css-env-1/explainers/env-preferred-text-scale.md#proposal
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.
Does this mean in the legacy
mode that env(preferred-text-scale)
may not be congruent with the font-size? As in font-size: medium
will resolve to 16px
even though the rest of the user's OS is at 24px because they have a text-scale 1.5? So an author cannot rely on calc(16px * env(preferred-text-scale))
resolving to the same CSS pixels as 1rem
?
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.
That's correct, and is what happens in today's pre-<meta name="text-scale">
world.
We expect/hope that <meta name="text-scale" content="scale">
becomes best practice so that authors don't have to deal with today's inconsistencies, one of which is what you pointed out.
|
||
Note: It is expected that authors will use |
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.
@JoshTumath I'm interested to hear your thoughts on this paragraph :) As a non-author, I don't have a good sense of what authors are expected to do.
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.
If the meta tag is set to scale
, authors would have no need to use calc(16px * env())
. They can just use font-size: medium
, since medium
/the initial font size is now effectively that.
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.
font-size: medium
will work for font sizes but presumably this also impacts ems & rems, such that 1rem
will scale in proportion?
I think here I am simply trying to illustrate that authors might expect 16px
to be the browsers font size and 16px * env()
should (ideally?) resolve to the equivalent px units that 1rem * env()
would.
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.
Oh I think I see what you mean. Yeah if the meta tag is set to the scale
keyword, provided that the author doesn't change the root font-size, 1rem
will always be equivalent to 16px * env()
. I think I was confused by the phrasing of 'authors are expected to use it' since I wouldn't expect anyone to practically need to do that.
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 so much for writing this!
Not sure if you already saw https://drafts.csswg.org/css-env-1/#text-zoom , which was the earlier iteration of the env() definition and pem
.
Text Scale {#text-scale-envs} | ||
------------------------------------------------------------------ | ||
|
||
<table dfn-type=value dfn-for="env()"> |
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.
Did you already crib everything appropriate from https://drafts.csswg.org/css-env-1/#text-zoom ?
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.
Didn’t even spot this, I’ll make sure everything is moved over and update this tomorrow.
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.
That was a remarkably quick turnaround!
At some point, you may need to add something to the Privacy Considerations section regarding concerns around how exposing the user's OS text scale could be used for fingerprinting.
When the value of the [=text-scale=] content attribute is | ||
<a for="text-scale">legacy</a> the user agent should set the initial font size | ||
to 16px. The user agent may chose a different initial value, such as one based | ||
on a user preference. The ''env()/preferred-text-scale'' value must be 1. |
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.
Does 'initial font size' need to be formally defined somewhere? My understanding is that the initial font size is the font-size: medium
keyword. Maybe the definition of medium
needs updating to formally define it as the UA setting by default in legacy
mode and the UA setting * the OS text scale in scale
mode.
|
||
Note: It is expected that authors will use |
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.
If the meta tag is set to scale
, authors would have no need to use calc(16px * env())
. They can just use font-size: medium
, since medium
/the initial font size is now effectively that.
This is an attempt at resolving #12380 by defining the
<meta name="text-scale">
tag, how the UA responds to it (with thelegacy
andscale
keywords) and defines theenv(preferred-text-scale)
value and its relation to this.