by swyx · 4y ago · 0 comments
some of them even come with annotations as to why they make the choices they make.
Github's font stack is
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
VS Code:
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif
probably more "native" on mobile:
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Helvetica Neue", Arial, sans-serif;
apparently all modern browsers have this new shortcut that make it as simple as:
font-family: ‘system-ui’, sans-serif;
@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.
[1]: https://github.com/StackExchange/Stacks/pull/642/files[2]: https://meta.stackexchange.com/questions/364048/we-are-switc...
It's mostly Helvetica based: San Francisco is the Apple knock off of Helvetica and Liberation Sans is a knock off of Arial which is a knock off of Helvetica. Only Segoe UI isn't Helvetica.
font-family: system-ui, -apple-system, sans-serif;
Is really all you need these days. That covers all modern browsers, and older browsers will just fall back to whatever sans-serif is.> It turns out that the value of system-ui in fact not only depends on the version of the current OS, but the language of the OS as well.
I'm pretty sure the font choosing algorithm takes into account the "lang" attribute as well. lang attribute and the system language are probably used to determine the fallback order. For example, on Windows 10+ with system font stack without system-ui: [0], [1]
For Han characters:
- lang="en" + system lang en -> "Chinese" font
- lang="en" + system lang ja -> "Japanese" font
- lang="ja" + system lang en -> "Japanese" font
For Hiragana, Katakana:
- lang="en" + system lang en -> "Japanese" font
which is reasonable enough but can be surprising I think. This can be confusing when you care enough about how the Han unified characters look but can't control the lang attribute (for example in Discord messages).
[0] https://jsfiddle.net/6gfyrpv0/
[1] https://momdo.hatenablog.jp/entry/20200802/1596376257
Side note, if the system lang is en and on Windows 10+, Japanese Github markdown text will be shown in two fonts with different "weights" [3]. It looks fine if your system lang is Japanese. I wonder if it's possible to set/guess a custom lang attribute for user/repo/markdown document.
Like if you're on a Japanese OS but your language preferences are English, the default sans-serif font is a Japanese typeface that often doesn't display Roman alphabets that nicely.
Please specify your environment. I use Japanese OS and I haven't found a single OS/browser combo would do that.
Use Windows as an example, sans-serif by default = Arial for Chrome and Firefox for English content.
And as a bonus, you can even adjust the default sans-serif font in browser setting to your like; while with these hard-coded CSS, you can't.
Using plain sans-serif, I get Hiragino Kaku Gothic ProN as my default font instead of something nice like Helvetica Neue.
So… you think your font of choice would be better than what the user had configured as the default in their user agent?