2

I am having trouble in loading fonts from local and I am pointing to the directory. Can someone help me with it ?

Here is my code

@font-face {
  font-family: 'My font';
  src: url('./fonts/Myfonts-webfont.eot');
  src: url('./fonts/Myfonts-webfont.eot?#iefix') format('embedded-opentype'),
    url('./fonts/Myfonts-webfont.woff') format('woff'),
    url('./fonts/Myfonts-webfont.ttf') format('truetype'),
    url('./fonts/Myfonts-webfont.svg#my_fonts_otbook') format('svg');
  font-weight: normal;
  font-style: normal;
}

and using it as 
.btn {
  font-family: 'My font', sans-serif;
  max-width: 100%;
  width: 20%;
  height: 8%;
}

3 Answers3

0

I suggest having a look at this

Also depending where you have them stored i.e. assets/fonts you must be pointing towards the directory.

font-face syntax

Example

@font-face {
  font-family: 'Graublau Web';
  src: url('GraublauWeb.eot');
  src: local('☺︎'),
    url("GraublauWeb.woff") format("woff"),
    url("GraublauWeb.otf") format("opentype"),
    url("GraublauWeb.svg#grablau") format("svg");
}
Cameron Shearer
  • 142
  • 1
  • 10
0

I tried different things and finally able to find the issue. its the storybook web-pack config causing the issue. Instead of pushing module.rules to storybook default webpack config I overwrote rules and it worked.

0

Have you use webpack file-loader to load a path, you dont have to specify where you font files reside. As long as you include your font files inside src/assets/fonts, file-loader will find it for you.

Brendon
  • 461
  • 1
  • 5
  • 10