font-face does not display local font
I downloaded some fonts and am storing them in my src folder:
├── src
│ ├── fonts
│ │ ├── font.ttf
│ ├── components
Then I tried to add them using font-face
but I can't figure out why it's not working. Is there a specific place you're supposed to put them in your react project?
Right now I'm declaring the font in the same file where I'm trying to use it:
@font-face {
font-family: "MyFont";
src: local("MyFont"), url("path/to/font.ttf"),
format("truetype"开发者_高级运维;);
}
p {
font-family: 'MyFont'
}
When I do this it just reverts to my system's font, overriding the fonts declared in my index.scss file:
html,
body {
font-family: "Roboto", "Arial", sans-serif;
}
body {
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: "Roboto", "Arial", sans-serif;
}
Is there a specific file I need to declare the font family? Am I importing it wrong? The file path is correct, so I'm not sure what's happening. I downloaded the fonts I wanted and copied the files into my src/fonts
directory. Is that where the issue is coming from?
精彩评论