5

In my rails(2.x) application. I want to use custom font in my view. So that I added the font files in public under fonts folder. When I try to get the fonts in url or via application, it through routing error. I guess rails routes not able to recognize the format/file. Correct me if I am wrong and give me solution

css code:

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

}

Note: I can able to get woff, ttf file by directly typing the path but not eot file.

Error trace:
Unknown action
No action responded to fonts. Actions: XXXXXXsomeactionsXXXXX and rescue_404

Thanks in advance, Arun.

Jak
  • 2,893
  • 3
  • 19
  • 33

1 Answers1

4

I fixed the above issue by moving the font folder under public/stylesheets/fonts. and made the above code as below.

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

Hope this will help to others.

Jak
  • 2,893
  • 3
  • 19
  • 33
  • I'm having a similar problem: Fonts are not being served via the asset pipeline locally (results in a 404 when trying the font path). The above is a workaround, but I'd love to know the actual fix. – Geoff Mar 26 '13 at 20:48