How to import a new font into a project - Angular 5

前端 未结 3 651
陌清茗
陌清茗 2020-12-02 19:51

I want to import a new font to my Angular 5 project.

I have tried:

1) Copying the file to assets/fonts/

2) adding it to .angular-cli.json

3条回答
  •  醉酒成梦
    2020-12-02 20:09

    the answer is already exist above, but I would like to add some thing.. you can specify the following in your @font-face

    @font-face {
      font-family: 'Name You Font';
      src: url('assets/font/xxyourfontxxx.eot');
      src: local('Cera Pro Medium'), local('CeraPro-Medium'),
      url('assets/font/xxyourfontxxx.eot?#iefix') format('embedded-opentype'),
      url('assets/font/xxyourfontxxx.woff') format('woff'),
      url('assets/font/xxyourfontxxx.ttf') format('truetype');
      font-weight: 500;
      font-style: normal;
    }
    

    So you can just indicate your fontfamily name that you already choosed

    NOTE: the font-weight and font-style depend on your .woff .ttf ... files

提交回复
热议问题