How to set different font-weight for fallback font?

前端 未结 2 1115
情书的邮戳
情书的邮戳 2021-02-15 13:53

I\'ve came across a problem with custom font i use for my website.

So i use following CSS for text.

font-family: \"Open Sans\",Helvetica,Arial;
font-wei         


        
2条回答
  •  情书的邮戳
    2021-02-15 14:15

    You could define a new @font-face for each font you want.

    @font-face {
          font-family: 'mainFont';
          src: url(/*Link to Open Sans*/);
          font-weight: 600;
    }
    
    @font-face {
          font-family: 'secondaryFont';
          src: local('Helvetica');
          font-weight: 400;
    }
    
    @font-face {
          font-family: 'tertiaryFont';
          src: local('Arial');
          font-weight: 600;
    }
    

    Then you'll end up with font-family: 'mainFont', 'secondaryFont', 'tertiaryFont'; which should get the desired results.

提交回复
热议问题