Skip to content

Commit

Permalink
Rollup merge of rust-lang#92448 - jsha:font-size-access, r=GuillaumeG…
Browse files Browse the repository at this point in the history
…omez

Set font size proportional to user's font size

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 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 rust-lang#59845. Note: this will conflict with rust-lang#92404. We should merge that first (once it's done) and I'll resolve the merge conflicts.

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/font-size-access/std/string/struct.String.html
  • Loading branch information
matthiaskrgr committed Jan 5, 2022
2 parents a0262fd + cc18120 commit 5bf321f
Showing 1 changed file with 58 additions and 53 deletions.

0 comments on commit 5bf321f

Please sign in to comment.