How to use Apple's new San Francisco font on a webpage

前端 未结 11 958
一整个雨季
一整个雨季 2020-11-30 17:05

I\'d like to use the new San Francisco font on a site. I\'ve tried:

font: \'San Francisco\', Helvetica, Arial, san-serif;

to no avail. I ha

相关标签:
11条回答
  • 2020-11-30 17:33

    Apple is abstracting the system fonts going forward. This facility uses new generic family name -apple-system. So something like below should get you what you want.

    body 
    {
      font-family: -apple-system, "Helvetica Neue", "Lucida Grande";
    }
    
    0 讨论(0)
  • 2020-11-30 17:34

    Last time tested: March 2018


    To address the question

    How to use Apple's new San Francisco font on a webpage

    font-family: -apple-system, system-ui, BlinkMacSystemFont;
    

    or (even shorter):

    font-family: -apple-system, BlinkMacSystemFont;
    

    should suffice.

    If you want to default to system font on multiple platforms, though, I'd suggest:

    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu;
    
    • -apple-system — San Francisco in Safari (on Mac OS X and iOS); Neue Helvetica and Lucida Grande on older versions of Mac OS X.
    • system-ui — default UI font on a given platform.
    • BlinkMacSystemFont — equivalent of -apple-system, for Chrome on Mac OS X.
    • "Segoe UI" — Windows (Vista+) and Windows Phone.
    • Roboto — Android (Ice Cream Sandwich (4.0)+) and Chrome OS.
    • Ubuntu — all versions of Ubuntu.

    The idea is borrowed from the following issue on github.

    You can look up fonts for other OS or older versions of them in this article on css-tricks.

    0 讨论(0)
  • 2020-11-30 17:35

    Apple's new system font is not publicly exposed. Apple has started abstracting system font names:

    The motivation for this abstraction is so the operating system can make better choices on which face to use at a given weight. Apple is also working on font features, such as selectable “6″ and “9″ glyphs or non-monospaced numbers. It’s my guess that they’d like to bring these features to the web, as well.

    Safari and Firefox use SF for -apple-system; Chrome recognizes BlinkMacSystemFont:

    body {
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    }
    

    There are also other variations:

    font-family: -apple-system-body
    font-family: -apple-system-headline
    font-family: -apple-system-subheadline
    font-family: -apple-system-caption1
    font-family: -apple-system-caption2
    font-family: -apple-system-footnote
    font-family: -apple-system-short-body
    font-family: -apple-system-short-headline
    font-family: -apple-system-short-subheadline
    font-family: -apple-system-short-caption1
    font-family: -apple-system-short-footnote
    font-family: -apple-system-tall-body
    

    You can demo these at the following fiddle; most are not supported yet: http://jsfiddle.net/v94gw9nx/

    I got my info from Craig Hockenberry's article which has a lot of great info about using the font: http://furbo.org/2015/07/09/i-left-my-system-fonts-in-san-francisco/

    Also, some great info on the Surfin' Safari blog about using abstracted system fonts: https://www.webkit.org/blog/3709/using-the-system-font-in-web-content/

    And apparently Apple is working with the W3C to standardize using a generic "system" font name in CSS. https://lists.w3.org/Archives/Public/www-style/2015Jul/0169.html

    Download the SF font .otf files for your own personal use: https://developer.apple.com/fonts/

    0 讨论(0)
  • 2020-11-30 17:38

    If the user is running El Capitan or higher, it will work in Chrome with

    font-family: 'BlinkMacSystemFont';
    
    0 讨论(0)
  • 2020-11-30 17:41

    Basically, this is what worked for me:

    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif 
    

    P.S. This works on all systems.

    0 讨论(0)
  • 2020-11-30 17:43

    -apple-system allows you to pick San Francisco in Safari. BlinkMacSystemFont is the corresponding alternative for Chrome.

    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    

    Roboto or Helvetica Neue could be inserted as fallbacks even before sans-serif.

    https://www.smashingmagazine.com/2015/11/using-system-ui-fonts-practical-guide/#details-of-approach-a (how or previously http://furbo.org/2015/07/09/i-left-my-system-fonts-in-san-francisco/ do a great job explaining the details.

    0 讨论(0)
提交回复
热议问题