Search code examples
ruby-on-railscssfont-face

Can't get @font-face working within a rails app


Is there a default location for where I should be storing the fonts? Within rails I can't get the font to load, whereas with the 'font kit' downloaded from fontsquirrel.com where the font,css and sample html in the same folder will work.

this is my css

@font-face {
font-family: 'RalewayThin';
src: url('fonts/raleway_thin.eot');
src: url('fonts/raleway_thin.ttf') format('truetype');

}

the fonts folder is in /public


Solution

  • For my style sheets I almost always have to have urls start with ../ to get the correct path. You might want to try

    @font-face {
      font-family: 'RalewayThin';
      src: url('../fonts/raleway_thin.eot');
      src: url('../fonts/raleway_thin.ttf') format('truetype');
    }
    

    If that doesn't work, you might want to use the developer tools in your browser to see if and what url the browse is using to get the font files.