-
Notifications
You must be signed in to change notification settings - Fork 797
[css-fonts-5][editorial] Add more meta text scale examples #14019
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
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -168,10 +168,17 @@ Further, when the value of the [=text-scale=] content attribute is | |||||
|
|
||||||
| Note: | ||||||
| Authors are expected to use | ||||||
| <code><meta name="text-scale" content="scale"></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. | ||||||
| <code><meta name="text-scale" content="scale"></code> in stylesheets so that the ''font-size/medium'' font size will reflect 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'' and ''em'' throughout the page to honor the user's font preferences. | ||||||
|
|
||||||
| Note: | ||||||
|
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. Bikeshed has put this paragraph in a separate note box, but this seems like a continuation of the previous one. Do they need to be in the same note box? |
||||||
| This requires care to do correctly, given the very large font sizes some low-vision users need. | ||||||
| Consider the extreme case of an iPhone Mini set to iOS's largest font size of 53px. | ||||||
| Only ~12-15 characters fit on a line. | ||||||
|
|
||||||
|
|
||||||
| <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 | ||||||
| Assuming a page hasn't altered the '':root'' font size, content sized with ''rem'' units will be relative to the preferred text scale | ||||||
|
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. Might be better to say, "Assuming a page hasn't altered the |
||||||
| <pre class="lang-html"> | ||||||
| <!DOCTYPE html> | ||||||
| <html> <!-- leave this element's font-size as the default --> | ||||||
|
|
@@ -195,6 +202,50 @@ Authors are expected to use | |||||
| </pre> | ||||||
| </div> | ||||||
|
|
||||||
| <div class="example" id="ex-non-linear"> | ||||||
| Header text starts larger than body text, so pages should probably grow headers at a slower rate. | ||||||
|
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 think this intro needs more context. How about this:
|
||||||
| <pre class="lang-html"> | ||||||
| <meta name="text-scale" content="scale" /> | ||||||
| <style> | ||||||
| .h1 { | ||||||
| --dampen-factor: calc(0.5 + 0.5 / env(preferred-text-scale)); | ||||||
|
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. What do you think of adding a comment and a little content, then showing an example of the content at 1.x, 2x, and 3.5x? This will encourage others to test large scales.
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. Yeah, that seems good, as long as @fantasai thinks it's appropriate level of detail for the spec. (We could put it in MDN or some other article/documentation.) Also, note that you can see this PR at https://davidsgrogan.github.io/css-fonts-5/Overview.html#scale-keyword
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. It's appropriate for a spec.
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. Our specs really should have more illustrations and examples of good practices, not less. :)
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. Might be good to use parentheses around the division so that people don't get confused by BIDMAS/PEMDAS. (Because I did. 😅 I was wondering for ages why it's not just
Suggested change
|
||||||
| font-size: calc(2rem * var(--dampen-factor)); | ||||||
| /* Resulting font sizes at various text scale factors: | ||||||
| h1 body | ||||||
| 1x 32px 16px | ||||||
| 1.5x 40px 24px | ||||||
| 2x 48px 32px | ||||||
| 3x 64px 48px */ | ||||||
| } | ||||||
| </style> | ||||||
| </pre> | ||||||
| </div> | ||||||
|
|
||||||
| <div class="example" id="ex-inverse"> | ||||||
| An extreme version of the above, some text content that starts larger than body text can and should become smaller than body text as the user's font size increases. | ||||||
| In this floating button example, the button text is larger than the body text at 1x but gets smaller at ~2.5x font scale. | ||||||
| <pre class="lang-html"> | ||||||
| <meta name="text-scale" content="scale" /> | ||||||
| <style> | ||||||
| .floating-action-button { | ||||||
| position: fixed; | ||||||
| top: 30px; | ||||||
| right: 30px; | ||||||
| /* Grow slightly slower than h1 example: */ | ||||||
| --dampen-factor: calc(0.4 + 0.6 / env(preferred-text-scale)); | ||||||
| font-size: calc(1.5rem * var(--dampen-factor)); | ||||||
| /* Resulting font sizes at various text scale factors: | ||||||
| button body | ||||||
| 1x 24px 16px | ||||||
| 1.5x 28.8px 24px | ||||||
| 2x 33.6px 32px | ||||||
| 3x 43.2px 48px <-- inversion */ | ||||||
| } | ||||||
| </style> | ||||||
| <button class="floating-action-button">➕Add</button> | ||||||
| </pre> | ||||||
| </div> | ||||||
|
|
||||||
|
|
||||||
| <h2 id="basic-font-props"> | ||||||
| Basic Font Properties</h2> | ||||||
|
|
||||||

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 think this needs stronger wording so that authors know 'you must only use this if you have tested your website with scaled text'.