necolas / normalize.css

A modern alternative to CSS resets
http://necolas.github.io/normalize.css/
MIT License
52.5k stars 10.66k forks source link

font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif #665

Closed DoronBrayer closed 7 years ago

DoronBrayer commented 7 years ago

It's time to add: font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif

This solution is harmless and very useful. It is used by GitHub, Wordpress, Bootstrap, Medium, Ghost, etc.

The main reason for using "system" fonts is performance. Fonts are typically one of the largest/heaviest resources loaded on a website. If we can use a font already available on the user’s machine, we can completely eliminate the need to fetch this resource, making load times noticeably faster. The beauty of system fonts is that it matches what the current OS uses, so it can be a comfortable look.

The bottom line: It's truly the ultimate solution for any website/webapp in any OS.

More info

kevinvanrijn commented 7 years ago

Didn't normalize.css just get rid of opinionated defaults? I don't see how this would be less opinionated then the old font-family: sans-serif; rule.

russmaxdesign commented 7 years ago

This is opinionated. See this thread #664

DoronBrayer commented 7 years ago

Using system fonts is not "opinionated". System fonts are just system fonts. If you insist, use: font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto [Removing the "Helvetica Neue",Arial,sans-serif part] This is normalization, not reset. Again- this solution is used by GitHub, Wordpress, Bootstrap, Medium, Ghost, etc.

miquelfire commented 7 years ago

What browser is using ANY of these fonts by default?

DoronBrayer commented 7 years ago

Read: Font stack in 2017

thierryk commented 7 years ago

@DoronBrayer that does not answer @miquelfire's question:

What browser is using ANY of these fonts by default?

Normalize relates to default styling and—as far as I know—browsers do not use system fonts out-of-the-box.

DoronBrayer commented 7 years ago

If 99% of the websites uses sans-serif as default, why go with the other 1%?! - Go with the majority, go with the 99%! In addition - sans-serif is used by any framework out there, and there's a reason for that. Not setting a font-family (in body or html) is so 2007. It's time to move on, really.

jonathantneal commented 7 years ago

@DoronBrayer, I get what you are saying, but what you are describing is less the use case for bugs and common browser inconsistencies and more the use case for common developer expectations and preferences, like box-sizing: border-box, etc..

At least one project needs to hold the fort so to speak so that there may be a reliable base for your own projects, or bootstrap, or sanitize.css, etc.

bardiharborow commented 7 years ago

Noting for further reference, that we've had to back out system-ui over at Bootstrap due to a number of issues with faulty Chinese fonts on Windows.

mvasilkov commented 7 years ago

Since this feature isn't going to be added here, a shameless plug: https://github.com/mvasilkov/systematize It's basically normalize.css with some improvements to typography, coming from this repo's pull requests mostly. WIP.

uaoleg commented 4 years ago

BlinkMacSystemFont is causing issue while printing on Chrome for Mac https://bugs.chromium.org/p/chromium/issues/detail?id=1018581

UPD it's fixed in Chrome 81

ShikiSuen commented 4 years ago

Please do not use "system-ui".

On Windows (i forgot in FireFox or Edge Chromium, but it must be at least one of them), it makes the browser unable to choose correct CJK fallback font, regardless the language code written in the HTML tag.

Please only use "-apple-system, BlinkMacSystemFont," in this case. For Windows font fallback, simply use "Segoe UI" or "Calibri" (depending on the taste of bigger size or smaller size).

Michaelsy commented 4 years ago

@ShikiSuen Did I get it right? Your plea is only relevant if there are Chinese, Japanese or Korean (or similar?) characters on the webpage?

Or in other words: When exactly is this a problem?

ShikiSuen commented 4 years ago

@Michaelsy If you think this is not a problem to you but you are not part of the team for this repo, then please shut up. Your hostility to East-Asian language users smells.

Ideograph glyph standards vary among Mainland PRC, HK, Taiwan, Korea, Japan. In Japan there are even two variants (industrial and educational variants). There are lots of political correctness matters regarding these standards. Not to mention that on Windows the default system UI fonts for CJK languages are having different amount of supported glyphs. Suppose that a Simplified Chinese webpage on Windows get fallbacked to a JIS standard font, one will see something similar to a mix-typed paragraph in two different fonts, a typographic disaster.

Read through the book ISBN 978-0596514471 written by a retired US marine, if you have further curiosities.

ShikiSuen commented 4 years ago

The reason I wrote my initial complaints above in this thread is to concern that some ideas in the font fallback sequence provided in the beginning post (of this thread) may trigger issues to CJK users.

(Swear comments removed because they are not useful anymore.)

Michaelsy commented 4 years ago

If you think this is not a problem to you ...

I apologise for the fact that I seem to have formulated my question in such a misleading way.

No, I don't think that is not a problem. Rather, I want to understand the problem so that I can take the right action if necessary.

Michaelsy commented 4 years ago

@ShikiSuen My question more concrete: I write websites exclusively in English and German (with German umlauts like ä Ä ü Ü and for example the "ß")

Can it lead to display errors on Asian screens if I refer to "system-ui"?

ShikiSuen commented 4 years ago

@ShikiSuen My question more concrete: I write websites exclusively in English and German (with German umlauts like ä Ä ü Ü and for example the "ß")

Can it lead to display errors on Asian screens if I refer to "system-ui"?

Back to your personal case: as long as no one puts East-Asian language contents on your website, no problem to you (personally).

Your case closed.

P.S.: I repeated the same issue with FireFox on macOS. If this really is a FireFox issue then I think I have to ticket it to their bugzilla.

tedw commented 3 years ago

What about adding color emoji support as well? https://www.client9.com/css-color-emoji-stack/

FWIW GitHub adds "Apple Color Emoji", "Segoe UI Emoji" to the end of their font stack 😄

Michaelsy commented 3 years ago

What about adding color emoji support as well?

IMHO not a good idea because it misses the point of normalize.css. It makes no sense to include all the possible features that anyone might want. Normalize.css is not a universal stylesheet for all possible purposes. It is a universal stylesheet to accommodate differences between browsers.

- Michael Sy.

tedw commented 3 years ago

@Michaelsy I agree with you, which is why I think normalizing emoji display is a good idea if normalize.css is going to include a default font stack. Not sure the font stack is necessary, though.

Anyway, just wanted to add a comment about it in the hopes it helps others in the future 👍

webia1 commented 3 years ago

Today like that, isn't it?

font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
ShikiSuen commented 3 years ago

Today like that, isn't it?

font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

Please put the sans-serif at the final stack.

chrislachance commented 3 years ago

System font as a default is clearly a localization issue. It's also an accessibility one.

For example, a user with dyslexia may choose "Open Dyslexic" or "Lexend" as their default sans-serif font for legibility. The system font stack would block this.

dangelion commented 2 years ago

BlinkMacSystemFont is causing issue while printing on Chrome for Mac https://bugs.chromium.org/p/chromium/issues/detail?id=1018581

UPD it's fixed in Chrome 81

This font BlinkMacSystemFont wastes me near 2 days, yes 2 days. It was the causes for a jerky/slow/unusable resizing in Chrome Dev Simulator. Destroy it, if possible.

jeffatoptics commented 2 years ago

put "Segoe UI Emoji" before "Segoe UI Symbol". otherwise, chrome/edge in windows will only display the emoji in white/black color.

tedw commented 2 years ago

FWIW here’s the current CSS I’m using to normalize emojis:

// Custom emoji font-family to standardize appearance across platforms
// https://www.client9.com/css-color-emoji-stack/
// https://nolanlawson.com/2022/04/08/the-struggle-of-using-native-emoji-on-the-web/
@font-face {
  font-family: "color-emoji";
  src: local("Apple Color Emoji"),
       local("Twemoji Mozilla"),
       local("Segoe UI Emoji"),
       local("Segoe UI Symbol"),
       local("Noto Color Emoji"),
       local("EmojiOne Color"),
       local("Android Emoji");
}

Then you can append color-emoji to the end of your font stack:

body {
  font-family: system-ui, Segoe UI, sans-serif, color-emoji;
}
HNazmul-IV commented 1 year ago

But My question is How a font become heaviest , largest, painful resource for a website ? ?

ticoeteco23gb commented 3 months ago

But My question is How a font become heaviest , largest, painful resource for a website ? ?

There are many glyphs in a font for each character, those glyphs are basically vector graphics united together. A typeface has multiple styles of glyphs... Yeah, it depends on how complex the font is.