简体   繁体   中英

Import font library to angular project

I want to import https://www.cufonfonts.com/font/helvetica-neue-lt-pro-2 this font to my project. I'm using scss on my project. I downloaded font files there are a lot of woff files. How should I do?

You should be able to do something like:

@font-face {
  font-family: 'xyz';
  src: url(assets/fonts/xyz.woff) format("woff");
}

Then use it like so:

div {
  font-family: 'xyz';
}

Download the font file and extract in the assets/fonts folder. the extracted folder itself contains style.css file and you need to import the style file in angular.json .

"styles": [
     "src/styles.css",
     "src/assets/fonts/helvetica-neue-lt-pro-2-cufonfonts-webfont/style.css"
 ]

And it will be applied globally. you just use font-family where you need use

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM