angular2-cli include custom fonts

前端 未结 5 1213
悲&欢浪女
悲&欢浪女 2020-12-25 11:25

I am trying to include some custom fonts in my project with no success.

NOTE: I am using angular-cli: angular-cli@1.0.0-beta.21

  1. I put the fonts in

5条回答
  •  悲&欢浪女
    2020-12-25 12:18

    For the people arriving here by searching:

    Install with npm:

    npm install roboto-fontface --save

    Add to styles in .angular-cli.json (apps[0].styles):

    "styles": [
        "styles.css",
        "../node_modules/roboto-fontface/css/roboto/roboto-fontface.css"
    ],
    

    That's all!

    Edit: since Angular 6 this file is called angular.json instead of angular-cli.json. Adding fonts still works the same way as before.

提交回复
热议问题