192 points · by joshbetz · 4y ago · 121 comments
body {
font-family: -apple-system, BlinkMacSystemFont,
"Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell",
"Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
}
Stack Overflow took this approach last year with the following font stack: [1] @ff-sans:
system-ui, -apple-system, BlinkMacSystemFont, // San Francisco on macOS and iOS
"Segoe UI", // Windows
"Ubuntu", // Ubuntu
"Roboto", "Noto Sans", "Droid Sans", // Chrome OS and Android with fallbacks
sans-serif; // The final fallback for rendering in sans-serif.
@ff-serif: Georgia, Cambria, "Times New Roman", Times, serif;
@ff-mono:
ui-monospace, // San Francisco Mono on macOS and iOS
"Cascadia Mono", "Segoe UI Mono", // Newer Windows monospace fonts that are optionally installed. Most likely to be rendered in Consolas
"Ubuntu Mono", // Ubuntu
"Roboto Mono", // Chrome OS and Android
Menlo, Monaco, Consolas, // A few sensible system font choices
monospace; // The final fallback for rendering in monospace.
[1]: https://meta.stackexchange.com/questions/364048/we-are-switc...For sans-serif, I recommend at most three items: a web font, system-ui, and sans-serif. No more. I would note that system-ui is not necessarily sans-serif, but in practice it almost always is, and ui-sans-serif (along with ui-serif, ui-monospace and ui-rounded) is only implemented by Safari yet.
For serif, I recommend at most three items, possibly including one named font: a web font, Georgia, and serif. See, serif is probably a narrower serif (something like Times New Roman), but Georgia a wider one—they’re fairly different in character, so that it can be worth including if you’re doing so deliberately.
For monospace, I recommend at most four: a web font, ui-monospace (I wouldn’t, but some macOS people prefer it), Consolas, and monospace. I think Consolas is worth keeping in until Firefox updates its Windows default (https://bugzilla.mozilla.org/show_bug.cgi?id=713680), because Courier New is that bad.
Most font stacks now are just cargo culting, and are mostly mildly harmful.
And that's exactly where it causes problem [1].
It's all fallback, how can they be "not a good idea"? That's the beauty of these CSS font stacks: you can always put first the latest best practices.
> Most font stacks now are just cargo culting, and are mostly mildly harmful.
I disagree and if anything they're not complete enough (I'll write another comment).
I don’t want your idea of a suitable font, in general, because the default defaults (that is, the browser’s default value for sans-serif) are thoroughly good enough, and I changed my defaults, and by writing the likes of `…, Arial, Helvetica, sans-serif`, you didn’t change anything for most people, but prevented me from getting my chosen default sans-serif.
Long font stacks are fighting a fundamentally unwinnable battle with small potential benefits, high uncertainty, and definite costs (normally mild) to people that actually expressed preferences to their user agent.
Can you expand on why?
Also, even with `ui-sans-serif` (i.e. if it's guaranteed that it is/someone's doing something deliberate if it isn't) why's that what you want for the sans serif text on your web page, that isn't 'system UI'?
Just to note, what you posted below isn't their final version, and for good reasons. Anyone that is interested about this please check the original post with update 1,2, and 3.
On the other hand, I still failed to see the the advantage of such complex stack vs
font-family: sans-serif;
Why reinvent the wheel when you can just use this and it would use browser's default sans-serif font setting? Which users can define to whatever they want, system font or not.I've done lots of testing and very often a font stack gives better looking results than simply using the default. People who came up with these font stacks didn't do a bad job at all. I'd say it's especially noticeable on Linux (but not only): the default may really be freaking ugly compared to one of the previous font in the stack.
> Which users can define to whatever they want, system font or not.
But most users really don't bother do that. Heck, out of simplicity I don't even do it: the reason being I like to see how others are using fonts on their sites and I don't want to always turn my font overrides/default on/off. I want to know if the sites looks good "without any user intervention".
One problem with font stacks though is those who picked one then forget to update them when new, much better, fonts installed by default comes out. For example a shitload of websites on the latest OS X / M1 macs are going to fall on Helvetica first (because they use outdated font stacks) and use that even though the world as really moved on and came up with incredibly better looking screen fonts than Helvetica (I'm not saying Helvetica doesn't still have its place in print).
Not without trial-and-error. Twitter, GitHub, and Stackoverflow all got huge complaints for their font changes and had to revert/revise their font stack choices quickly due to the outcry.
In SO's case which I followed, they didn't even have anyone to test their UI on Windows at all. I don't know how that's "a good job".
>and I don't want to always turn my font overrides/default on/off
Just to clarify a little bit, by "user can define it" I'm not saying to override using custom CSS or anything. I'm saying users can choose the default sans-serif/serif/monospace fonts in all major browsers. Any specific fonts defined in CSS other than sans-serif would still override that.
They removed system-ui which, as you pointed out in the other comment, can cause problems for some OS languages:
@ff-sans:
-apple-system, BlinkMacSystemFont, // San Francisco on macOS and iOS
"Segoe UI", // Windows
"Liberation Sans", // Linux
sans-serif; // The final fallback for rendering in sans-serif.
@ff-serif: Georgia, Cambria, "Times New Roman", Times, serif;
@ff-mono:
ui-monospace, // San Francisco Mono on macOS and iOS
"Cascadia Mono", "Segoe UI Mono", // Newer Windows monospace fonts that are optionally installed. Most likely to be rendered in Consolas
"Liberation Mono", // Linux
Menlo, Monaco, Consolas, // A few sensible system font choices
monospace; // The final fallback for rendering in monospace.
https://github.com/StackExchange/Stacks/pull/642/filesIn those cases, using whatever font is usually not good enough, because many of them have different sizes (both length-wise, height-wise and line-height-wise), so if a user gets a different font loaded than what you have tested with, it could at best just have a different size (right-side of the text is now 3px away from the side rather than 6px for example) and at worst introduce line-breaks in your buttons that only expects one line of text, making everything look very fugly.
It’s a fair reason with an appropriate CSS pattern.
This seems to be developed for browsers which do not default to system-wide fonts: which ones are those today?
So: modern font stacks... Not bad, but not yet the panacea either (even for big websites who really should know better).
I make exceptions for websites that I visit regularly, where the most frequent breakage is a custom font that packs icons. On websites that I frequently read for documentation I sometimes even swap the font to something that I prefer (by injecting a @font-face src:local rule).
Designer's choice of fonts are frequently lower in legibility and/or do not have good hinting (not at the same level of most system fonts). On non-retina displays the qualitative difference is sometimes staggering.
This. Plus sometimes, for some reason, they choose hair-thin versions of fonts that are a pain to read even on (non mac) retina displays.
This made sense for me in conjunction with subsetting for a stopwatch app that only needs 10 digits and a colon.
I submit it's not so bad if you inline it with the rest of your styling, at least that's cacheable separate from the content.
Separate metrics files have already been done too (both with TeX in TFM files and Adobe/PostScript fonts in AFM/PFM files), so you wouldn't even have to invent a new file format.
Or you could simply use a regular font with no glyph curve data.
I am a bit disappointed this is not covered in the original post, and that no effort is being put in W3C to make that easy and viable.
var html = document.documentElement;
var script = document.createElement("script");
script.src = "fontfaceobserver.js";
script.async = true;
script.onload = function () {
var roboto = new FontFaceObserver("Roboto");
var sansita = new FontFaceObserver("Sansita");
var timeout = 2000;
Promise.all([
roboto.load(null, timeout),
sansita.load(null, timeout)
]).then(function () {
html.classList.add("fonts-loaded");
}).catch(function (e) {
html.classList.add("fonts-failed");
});
};
document.head.appendChild(script);I wonder why we almost never talk about the actual filesizes of different fonts and which ones take less space, for when the total size of our webpages is important and we'd like to make our font choices with that in mind, provided that we don't want to just use the system fonts for whatever reason.
For example, i described some of the specifics of serving my own fonts on my site instead of using Google Fonts in a discussion about privacy some time back: https://news.ycombinator.com/item?id=29996364
The question that i posed in that comment still hasn't really been answered and is still relevant in my eyes:
> While we're on the topic of fonts, it's a shame that we don't think more about how heavy the fonts we choose to use are, since right now serving my own fonts eats up around half of the bandwidth on my non-image-heavy site. The single article that i've found on the topic so far as been this, "Smallest (file size) Google Web Fonts": http://www.oxfordshireweb.com/smallest-file-size-google-web-...
Why doesn't Google Fonts have a field somewhere that'd show the total size of a font in any number of supported file formats? Why do we have so much effort towards optimizing the sizes of images, and yet fonts don't get the same love?
I've been keeping an eye out to see if there's been an equivalent FOSS solution but nada so far.
We used adobe fonts for a while, but I really wasn’t impressed.
Hundreds of dollars to buy a font it turned out we could only use through their hosted service.
Am I crazy or does that waterfall pretty clearly show nothing of the sort? When using http/2, a reasonable amount of preloaded assets won’t block anything else in the critical path…
And do use verdana, it's the most readable font. Admit it, you like it here
How to avoid layout shifts caused by images.
How to avoid layout shifts caused by ads.
How to avoid layout shifts caused by DOM changes.
It is funny how as many things moved to web we still have those basic issues, that would be considered show stopper errors in a desktop app.
Sometimes I would like for the browser to keep the state from 0.2 second ago when I decided to tap or click and do something like nothing did change in this time.
And it’s funny how the state of the art way to address these issues is usually some absurd hack. Like in the case of images, setting the height to 0 and using padding to achieve a stable height: https://nikitahl.com/css-aspect-ratio.
Which is supported in all modern browsers: https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-rati...
The state of the art for CSS these days is not that hacky.
Not sure this one counts as a bug, but a deliberate WONTFIX. I never intentionally click on ads, but I have been known to press one when an ad "happened" to appear in the position of some other content.
"Avoiding layout shifts caused by web fonts" is a great topic.
"Readability" would be another one.
2. There is no step 2
They just slow the web down and often make things less legible in the name of style.
Explaining them that web is not paper, helps removing a lot of this childish behaviour.
On a more serious note, screw all the font **ery. Settings → Language and Appearance → Advanced → untick Allow pages to choose their own fonts, instead of your selections above. Better to have some crappy websites glitch out a bit than get a headache from trying to read 200 different fonts in a day.
Done! Thanks for the reminder!
You can ship your own fonts. Everyone and their dog uses one of two web browser engines. People want their websites to "look right". You can offer a fully specified look!
Meh.
It takes senior engineers (with weight in the company) to lead the effort to force design to concede on certain things like this.
So to instead of dropping (or at least thinking about optimizing) the loading transition the designer (with a straight face) proposed a loading bar for the loading of the loading animation.
I was lost for words.
[Edit: typo]
The answer is most likely branding, but I don’t recall landing on a company website and going: “That’s not the font from their design guidelines. This is unacceptable, I shall take my business elsewhere”
All this tweaking and hacking font loading is a vaste of time.
I don’t know whether fonts are really that important to the total equation, but “not terrible enough to walk out the door” is generally a very low bar to meet when designing a thing.
Another example in the app space — you know enterprise apps will get the job done, but they’re downright unpleasant to use; from aesthetics to workflow efficiency, they just barely hover over “dealing with it isn’t worth the output”. But that’s generally not where you want things to sit as a design goal.
While this is a good point, i don't feel like a discussion about fonts is relevant here. For example, when working with Jira, i don't care about what font it uses, as long as it is legible (e.g. even whatever is the default sans-serif font would work), whereas what actually matters to me in such a context is the responsiveness of the UI and how well it works, UX over UI.
If Jira's interface is laggy and slow, or just cumbersome to use because their implementation of custom fields is weird, no font or logo choices will make any of that markedly better. In my eyes, how something looks is largely decoupled from how well it works - if Jira were a GTK/Win32 app with almost no styling, but worked faster than it currently does, i'd probably get more value out of it than i currently do, fancy UI or not.
(just using Jira as an example here, because their UI redesign did make things slower and got some backlash from users that was ultimately ignored, i bet the same applies to a lot of other software out there, e.g. how Flutter apps oftentimes break right click behaviour in browsers etc.)
Because typography is a means of communication.
I'll bite. What's wrong with fonts on Linux?
>and other fonts might be more suited in a different context
that is why "general use case" is my point. can you point me a specific example of where my current default "noto sans 10 pt" in kde neon is NOT suited for a specific use case? i want to see that unless i use a developer decided font, i would be totally off base, i would miss the plot, i would read garbage, etc etc.