locally installed TTF overrides Google fonts

前端 未结 1 424
暖寄归人
暖寄归人 2020-12-31 13:14

I\'m using the Ubuntu font from Google Fonts:



        
相关标签:
1条回答
  • 2020-12-31 13:33

    The answer lies not in your code, but in Google's.

    Here's part of the CSS you are requesting:

    @font-face {
      font-family: 'Ubuntu';
      font-style: normal;
      font-weight: bold;
      src: local('Ubuntu Bold'), local('Ubuntu-Bold'), url('http://themes.googleusercontent.com/static/fonts/ubuntu/v4/0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff') format('woff');
    }
    

    Key line here is local('Ubuntu Bold'), which asks to load local file if possible. The simplest solution is to copy all the Google's CSS, paste it in your own CSS, and modify this local name to be, for example, local('Ubuntu Bold NonExisting Name or Something Else'). Such font does not exist and will not replace font loaded by CSS.

    P.S. I have not tested this myself. If 0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff URL is expiring, then you are in a tough spot. Try to see font's licence and consider hosting the font yourself, if preventing local override is a priority.

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