Custom font import in Angular4

前端 未结 2 792
醉话见心
醉话见心 2021-01-04 22:13

I use Angular4 and have a problem with making use of my custom font. I tried using font-face but it gives me the error that the font-file cannot be found. What do I need to

2条回答
  •  庸人自扰
    2021-01-04 22:30

    There is the src property, which can be a URL to a remote font file location or the name of a font on the user's computer. So if you serve your assets folder as static files and you have the fonts folder in there, you should be able to reference the font files relativly to your app's URL like this:

    @font-face {
      font-family: 'lcd-plain';
      src: url('/fonts/lcd-plain/lcd-plain.ttf') format('truetype'),
    }
    

提交回复
热议问题