0

I have a css file which I included into Angular project this way:

{
  "styles" : [
        "src/assets/css/style.css"
  ],
}

Into angular.json I added:

"assets": [
              "src/favicon.ico",
              "src/assets"
            ],

But into the css file font files are loaded like:

src: url("assets/fonts/materialdesignicons-webfont.eot?v=1.4.57");
src: url("assets/fonts/materialdesignicons-webfont.eot?#iefix&v=1.4.57") format("embedded-opentype"), url("assets/fonts/materialdesignicons-webfont.woff2?v=1.4.57") format("woff2"),

I get error:

Can't resolve 'assets/fonts/glyphicons-halflings-regular.ttf'

And many more other like this. What is the proper way to solve this problem?

3
  • you have this file in your assets folder? Commented Apr 8, 2020 at 5:23
  • Yes, I do but it's not found Commented Apr 8, 2020 at 6:17
  • have you checked in dist/assets/fonts ? Commented Apr 8, 2020 at 6:18

2 Answers 2

1
+50

You can add your font as follows:

@font-face {
  font-family:"Your font";
  src: url("assets/fonts/materialdesignicons-webfont.eot?v=1.4.57"),
       url("assets/fonts/materialdesignicons-webfont.eot?#iefix&v=1.4.57") format("embedded-opentype"),
       url("assets/fonts/materialdesignicons-webfont.woff2?v=1.4.57") format("woff2");
}

Hope it help you.

Sign up to request clarification or add additional context in comments.

Comments

0

I usually include my fonts like this :

@font-face {    font-family: "Nunito Light"; font-display: swap;    src: url('../font/Nunito/Nunito-Light.ttf'); }

You should just include .ttf file of your fonts instead of including .eot, .woff2

here : Everythings fonts

you can change .woff2 font to .ttf font

3 Comments

But what if I have also src: url(assets/fonts/materialdesignicons-webfont.eot?v=1.4.57); ? with some data?
for me just the .ttf file should be enougth and I do not understand why at the end, you've wrote ?v=1.4.57
This is from the original template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.