add support for the new 'system-ui' generic font family
Categories
(Core :: CSS Parsing and Computation, enhancement)
Tracking
()
People
(Reporter: jtd, Assigned: emilio)
References
(Depends on 1 open bug, Blocks 2 open bugs)
Details
(Keywords: dev-doc-complete, parity-chrome, parity-safari)
Attachments
(2 files)
Comment 3•8 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
Updated•7 years ago
|
Comment 4•6 years ago
|
||
Comment 5•6 years ago
|
||
Should this block the result of https://github.com/w3c/csswg-drafts/issues/1586 it would be nice to not expose to the webside what the chosen system font is.
Comment 6•5 years ago
|
||
Note that coda.io uses this on their page, which causes Firefox to select Arial on Windows 10 where Chrome selects Segoe UI. This doesn't seem to break anything in their layout, but it's still an interop difference worth noting.
Comment 7•5 years ago
|
||
Is this implemented and done? Looking at twitter.com in the inspector, it looks like the font chosen is "system-ui" in FF 70. (Only seems to be used if I'm logged in to twitter and using the new UI.)
Comment 8•5 years ago
|
||
shows system-ui as underlined
Comment 9•5 years ago
|
||
:grover I have seen that before, I think this is a devtools issue with how they select what is underlined for native fonts.
Comment 10•5 years ago
|
||
The implementation is definitely buggy. The selected font is Cantarell. I'm on Linux, KDE, with Noto Sans as default font. I don't even know how Cantarell ended up on my system. Could be through a Lutris/Wine package.
Chromium defaults to Noto as expected. How FF sniffs out Cantarell is beyond me. I tried grep
-ing through my ~/.config
and got nothing of relevance. Rather than system-ui
resolving incorrectly, I'd prefer it failed and skipped to the second entry in the font stack.
Tl;dr this resolves into Cantarell being used which is not my configured system font:
font-family: system-ui, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
FF: 70.0.1
Linux/KDE all pretty much latest because it's Arch.
Comment 11•5 years ago
|
||
(In reply to Jonathan Kingston [:jkt] from comment #9)
:grover I have seen that before, I think this is a devtools issue with how they select what is underlined for native fonts.
Right, that's bug 1545745. Firefox does not currently support system-ui
at all.
Comment 12•5 years ago
|
||
While implementing this be ware to retrieve 'system-ui' per language/script not once for entire scripts, for example on macOS San Francisco is the Latin font for system-ui but .Arabic UI Text is for Arabic scripts, Safari is OK on this regard, filed the issue against Chrome's current system-ui support https://crbug.com/1036695 so, just make sure data:text/html;charset=utf8,<div lang="ar" style="font-family: system-ui, arial; font-size: 300%;">%D8%B3%D9%84%D8%A7%D9%85! renders exactly similar with Safari if a correct implementation is considered.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 13•4 years ago
|
||
(In reply to andrej from comment #10)
The implementation is definitely buggy. The selected font is Cantarell. I'm on Linux, KDE, with Noto Sans as default font. I don't even know how Cantarell ended up on my system. Could be through a Lutris/Wine package.
Chromium defaults to Noto as expected. How FF sniffs out Cantarell is beyond me. I tried
grep
-ing through my~/.config
and got nothing of relevance. Rather thansystem-ui
resolving incorrectly, I'd prefer it failed and skipped to the second entry in the font stack.Tl;dr this resolves into Cantarell being used which is not my configured system font:
font-family: system-ui, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
FF: 70.0.1
Linux/KDE all pretty much latest because it's Arch.
fontconfig has supported system-ui
since 2.13.91:
https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/dba84600e1485000f358d8259b92721cf7066034
Comment 14•4 years ago
|
||
Firefox doesn't support system-ui
. (That's why this bug is open.)
If you run fc-match :family=system-ui
in a terminal, what does that return? From what I see in https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/dba84600e1485000f358d8259b92721cf7066034#189a3e6149b0632ddea0bc7bd3cb46492675e52e, it looks like this could well be resolving to Cantarell if it's installed.
Comment 15•4 years ago
|
||
I believe this should be given priority, as I'm seeing more and more sites default to system fonts and not web fonts.
Basically anyone who isn't using web fonts or custom fonts wants to use system-ui.
Leaving aside Firefox, all major browsers make correct use of the feature. Firefox needs to be verbose:
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji";
vs
font-family: system-ui;
Any plans for this? Since the bug has been open for 6 years now.
Assignee | ||
Comment 16•4 years ago
|
||
There's no concrete plan for this. I guess I can keep it on my list of things to do, now that I have some free time coming up.
The CSS bits for this are not hard to implement (it's a matter of adding a SystemUi
variant here, and that'd take care of all the parsing / serialization / etc).
I'm not too familiar with the font selection bits, but I suspect that's a matter of making sure we look at the right prefs and add a bunch of per-platform values like we do for the emoji font here for example...
Jonathan does that sound right? Or am I missing other complications?
Assignee | ||
Comment 17•4 years ago
|
||
(I guess I can take this, assuming the above is true. We should do a bit of research on whether the font resolves to different things based on the language on other browsers or what not, but that should not be too hard either)
Comment 18•4 years ago
|
||
We really shouldn't be implementing this by adding more font-list prefs that we then need to maintain as platforms evolve and change what they ship. That's a maintenance headache we can do without.
What system-ui
maps to may not be a single font or simple list at all -- it may be a collection of fonts for various languages/scripts and/or dependent on the system locale (and just listing all possibilities in a pref doesn't work, because of prioritization), it may be configurable by the user via OS-level preferences/themes/etc. We can't properly reflect things like this via the current font.name-list.* prefs mechanism.
E.g. on macOS, we should be using CTFontCreateUIFontForLanguage
to implement system-ui
, not simply mapping it to ".SFNS Text" or whatever. This will give the appropriate UI font for the language. So for instance we might get the ".Arabic UI Text" font, which is currently inaccessible -- see bug 1605605 -- if that's appropriate for the language. The result might also depend on the requested size (e.g. if there are separate Text and Display optical-size faces). We put some basic support for that into gfxMacPlatformFontList for -apple-system
when Apple started using a size-dependent system font, a few OS versions ago, but it really was just a crude hack for the one specific case, it's not generalized over languages, multiple-sized faces, etc.
(Along with system-ui
, we should also deal with the other recently-added generics like ui-serif
, ui-sans-serif
, ui-monospace
, etc.; again, this should be based on OS APIs wherever possible rather than font lists that we attempt to maintain.)
Comment 19•4 years ago
•
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #18)
What
system-ui
maps to may not be a single font or simple list at all -- it may be a collection of fonts for various languages/scripts and/or dependent on the system locale (and just listing all possibilities in a pref doesn't work, because of prioritization), it may be configurable by the user via OS-level preferences/themes/etc. We can't properly reflect things like this via the current font.name-list.* prefs mechanism.E.g. on macOS, we should be using
CTFontCreateUIFontForLanguage
to implementsystem-ui
, not simply mapping it to ".SFNS Text" or whatever. This will give the appropriate UI font for the language. So for instance we might get the ".Arabic UI Text" font, which is currently inaccessible -- see bug 1605605 -- if that's appropriate for the language. The result might also depend on the requested size (e.g. if there are separate Text and Display optical-size faces). We put some basic support for that into gfxMacPlatformFontList for-apple-system
when Apple started using a size-dependent system font, a few OS versions ago, but it really was just a crude hack for the one specific case, it's not generalized over languages, multiple-sized faces, etc.
Does Chromium all this perfectly? In other words: Isn't this an issue of "Perfect is the enemy of Good" ?
(Along with
system-ui
, we should also deal with the other recently-added generics likeui-serif
,ui-sans-serif
,ui-monospace
, etc.;
system-ui
is much more urgent for web-compat.
Comment 20•4 years ago
|
||
Here’s a code sample from Google I/O Workshop (video, codelab)
body {
font-family: system-ui, sans-serif;
}
Since system-ui
value is supported by Chrome and Safari, there’s no reason for most of the people to bother with a huge list of system fallback fonts mentioned in comments above. And because of that Firefox users get some old-school sans-serif fallback. In macOS case it’s Helvetica instead if San Francisco, but it could be much worse.
Comment 21•4 years ago
|
||
Is there any reason to delay this feature? The only reason I cannot use system-ui is because of Firefox, and for seemingly no reason Firefox doesn't support this feature whereas all other browers support it.
Updated•4 years ago
|
Assignee | ||
Comment 22•4 years ago
|
||
Making the macOS font selection language-dependent is a nice
improvement (which we should probably make to all system fonts in
general), but I don't think it should block this.
system-ui behaves like -apple-system right now, which a bunch of pages
use instead. So I think this is a strict improvement even on macOS.
Assignee | ||
Updated•4 years ago
|
Comment 23•4 years ago
|
||
Comment 24•4 years ago
|
||
bugherder |
Updated•4 years ago
|
Comment 25•3 years ago
|
||
Added to BCD and release notes https://github.com/mdn/content/issues/7751
Description
•