firefox-devtools / ux

Firefox DevTools UX Community
Mozilla Public License 2.0
103 stars 21 forks source link

Typography guidelines #2

Open fvsch opened 5 years ago

fvsch commented 5 years ago

For prior art, see Photon typography guidelines.

It would be great to have typography guidelines that are specific to the DevTools, to make sure we harmonize any discrepancies when they exist, and avoid creating discrepancies in the future.

Current status

Typefaces

Currently DevTools use 2 typefaces:

  1. A sans-serif system font, which conforms to Photon guidelines: Segoe UI on Windows, San Francisco on macOS, etc.
  2. A monospace font, which can vary depending on the OS as well (Consolas on Windows, Menlo on macOS, a few others on Linux).

Scale

DevTools do not and probably will not use the Photon typography scale. DevTools are generally more compact than the rest of the Firefox UI. This can be explained by its presentation context: users will want to see both the page content and technical information about the page, at the same time. This technical information is also very rich (big DOM trees, many matches CSS rules, long files in the Style Editor and Debugger, dozens of HTTP requests in the Network monitor…), and users need to take in enough of it at a glance.

Text sizes found in the DevTools include:

Since monospace fonts have wider letters and often a bigger x-height than the system’s sans-serif font, 11px monospace tends to look like 12px sans-serif. (There are some exceptions, especially on Linux when Courier-style fallback fonts are used.)

devtools-typography-size

Line-height

Currently the line-height property is rarely used, which means that the browser uses line-height: normal, which computes to different line heights depending on the font. For instance, with 11px text on macOS, the normal line-height computes to 13.5px for Menlo and 12.8667px for Arial.

fvsch commented 5 years ago

Next, some suggestions and ideas.

Proposed changes

Typefaces

No change.

The Linux monospace font-family may need some tweaks, I’ve seen examples where it falls back to a Courier-like typeface, which makes the code text visually smaller than expected.

Scale

I’ve seen a few reports where users find the text sizes too small, especially when the system font used has a small x-height (seems to be an on-and-off problem on Linux) or when they are using a display with small system points.

For example the 13" macbook pro has a 227ppi display, that means 113 system points per inch, which is visually quite smaller than the industry reference of 96 system points per inch. And some Windows laptops have 140-150ppi screens configured at @1x by default, which makes things tiny.

It can be hard to find the sweet spot that works for the most users out of the box.

Some exploration avenues:

  1. Ban 11px sans-serif, bumping it to 12px. Pros: better readability (and even discoverability) for a lot of small features in toolbars. Cons: toolbars may accomodate fewer items before wrapping; losing some hierarchy between tabs and section headers (currently at 12px) and other UI text (currently at 11px).

  2. Bump everything by 1px. This would make the Firefox DevTools more readable than Chrome or Safari DevTools, but also fit less content which can be a deal-breaker for existing users and users switching from another browser.

  3. Offer a text size setting, separated from the zoom level. (Why not just use zoom? Well, on low-dpi displays and even to some extent on retina displays, zooming icons by 10%, 20% or 33% can result in very blurry icons. Users may also want to use slightly bigger text but keep the UI compact.)

It's likely that the third option would break the least things. It would require a bit of refactoring though.

Here’s a quick mock-up for a font-size preference:

devtools-settings-fontsize

A 2 option setting ("normal" and "bigger") might work too.

Implementation: aside from the preference UI, this could be implemented in CSS with variables:

:root {
  --theme-font-size-small: 11px;
  --theme-font-size-medium: 12px;
  font-size: var(--theme-font-size-small);
}

.theme-font-medium {
  --theme-font-size-small: 12px;
  --theme-font-size-medium: 13px;
}

Then there would be a pass to do on most tools to make them compatible when needed.

Line height

This was discussed for the Console in: https://bugzilla.mozilla.org/show_bug.cgi?id=1479750#c7 https://bugzilla.mozilla.org/show_bug.cgi?id=1479750#c9

The idea is to try to set a predictable line-height instead of relying on line-height: normal, and to try to match a whole pixel value.

For instance, for 11px code we’ve settled on a 14px line-height for now, which can be achieved with:

.code-stuff {
  font-size: 11px;
  line-height: 1.2727;
}
fvsch commented 5 years ago

Related bug: Bug 1458224 - Font size too big on Linux for breadcrumbs and search inputs.

On Linux the default font-size seems to be 14.66667px and not 11px. This base font-size is overriden in many places, so depending on the tool it may appear in just a few elements, for most content, or not at all. This creates some consistency issues and some layout issues (e.g. misaligned buttons in toolbars). The fix seems to be to explicitly set the base font size to 11px.

fvsch commented 5 years ago

More discussion happened around https://bugzilla.mozilla.org/show_bug.cgi?id=1508036 (line-height for the markup view).

So far we decided to go with font-size: 11px; line-height: 15px; for the markup view, and we would like to expand it to more places (Rules, Console, Debugger, basically everything that looks like code).

Bigger text (used in tabs and headers) should probably be font-size: 12px; line-height: 16px;.

fvsch commented 5 years ago

@violasong @mcroud Do you have an opinion on whether we may want to pursue text size options?

devtools-settings-fontsize

(...) A 2 option setting ("normal" and "bigger") might work too.

We have some users asking for it in bug 1319367, and Patrick suggested this could be an interesting community project, but do we even want this, UX-wise? I definitely want this for myself, so I'm heavily biased.

DPX-designer commented 5 years ago

My knee-jerk reaction to this was I'm all for it, I'd find it difficult to argue a reason not to offer it to users. Having thought a little more, how much different would the experience be to just zooming with Command +/- ? With the panels in particular it won't take much text increase to warrant increasing the size of the other UI elements to accomodate the larger text. Maybe we need a comparison image showing what zoom level 3 looks like compared with text size: Big ?

fvsch commented 5 years ago

The main difference is if you're on a 1x display, zooming to intermediate values (110%, 120% or 130% which is zoom level 3*) will make the icons blurry. Things are perfect at 200% zoom (ten times Ctrl+Plus), and can be passable at 150%, but often 110, 120 and 130% are blurry.

Another big difference is that sometimes you want bigger text but don't want toolbars and icons and buttons to all become 20% bigger, especially if you're not on a huge screen.

It would be interesting to:

* our zoom levels are in 10% increments, unlike web content which uses a "110-120-133-150-170-200" scale.

fvsch commented 5 years ago

Currently, the default font-size for code in VS Code is 14px. I've seen 13px, 14px and 15px in different IDEs. It feels a bit strange that DevTools (both in Firefox and Chrome) seem to use a tiny 11px, and with pixel screens getting smaller over time (even when dividing the resolution by the "device pixel ratio") we may end up in a situation where 11px is too small to be comfortable for most users.

So one advantage of having a "slightly bigger font-size" preference (in the 13-14px range for the base size maybe) and making sure in 2019 that it works well all over devtools is that we could make it the default for new users sometime in 2020. :)

violasong commented 5 years ago

Yes! Sorry for the late reply - but this does seem like a good idea to me (especially if we can also minimize a few of the other less sensible settings in the prefs panel :D).