-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Set font size proportional to user's font size #92448
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some changes occurred in HTML/CSS/JS. |
rustbot
added
the
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
label
Dec 30, 2021
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Dec 30, 2021
This comment has been minimized.
This comment has been minimized.
Looks reasonable, and https://caniuse.com/rem looks like it's sufficiently widely supported. |
According to MDN (https://developer.mozilla.org/en-US/docs/Web/CSS/font-size), > To maximize accessibility, it is generally best to use values that > are relative to the user's default font size. > Defining font sizes in px is not accessible, because the user cannot > change the font size in some browsers. Note that changing font size (in browser or OS settings) is distinct from the zoom functionality triggered with Ctrl/Cmd-+. Zoom functionality increases the size of everything on the page, effectively applying a multiplier to all pixel sizes. Font size changes apply to just text. For relative font sizes, we could use `em`, as we do in several places already. However that has a problem of "compounding" (see MDN article for details). The compounding problem is nicely solved by `rem`, which make font sizes relative to the root element, not the parent element. Since we were using a hodge-podge of pixel sizes, em, rem, and percentage sizes before, this change switching everything to rem, while keeping the same size relative to our old default of 16px. 16px is still the default on most browsers, for users that haven't set a larger or smaller font size.
11 tasks
Thanks! @bors: r+ |
📌 Commit cc18120 has been approved by |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Jan 5, 2022
GuillaumeGomez
approved these changes
Jan 5, 2022
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 5, 2022
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#92182 (Label more build steps) - rust-lang#92188 (rustdoc: Clean up NestedAttributesExt trait/implementation) - rust-lang#92322 (Add another implementation example to Debug trait) - rust-lang#92448 (Set font size proportional to user's font size) - rust-lang#92517 (Explicitly pass `PATH` to the Windows exe resolver) - rust-lang#92545 (Extract init_env_logger to crate) - rust-lang#92579 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-rustdoc-ui
Area: Rustdoc UI (generated HTML)
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to MDN (https://developer.mozilla.org/en-US/docs/Web/CSS/font-size),
Note that changing font size (in browser or OS settings) is distinct from the zoom functionality triggered with Ctrl/Cmd-+. Zoom
functionality increases the size of everything on the page, effectively applying a multiplier to all pixel sizes. Font size changes apply to just text.
For relative font sizes, we could use
em
, as we do in several places already. However that has a problem of "compounding" (see MDN article for details). The compounding problem is nicely solved byrem
, which make font sizes relative to the root element, not the parent element.Since we were using a hodge-podge of pixel sizes, em, rem, and percentage sizes before, this change switches everything to rem, while keeping the same size relative to our old default of 16px.
16px is still the default on most browsers, for users that haven't set a larger or smaller font size.
Part of #59845. Note: this will conflict with #92404.
r? @GuillaumeGomez
Demo: https://rustdoc.crud.net/jsha/font-size-access/std/string/struct.String.html