user3183717
user3183717

Reputation: 4667

Rails application not loading fonts

When I try to load custom fonts in my Rails app, they do not load on the page, and when I inspect them in the source, I get a 404 error. But I'm POSITIVE I've done everything correctly.

CSS:

@font-face {
    font-family: "Roboto";
    src: local(Roboto Thin), url("/assets/fonts/Roboto-Thin.eot");
    src: url("/assets/fonts/Roboto-Thin.eot?#iefix") format("embedded-opentype"), url("/assets/fonts/Roboto-Thin.woff2") format("woff2"), url("/assets/fonts/Roboto-Thin.woff") format("woff"), url("/assets/fonts/Roboto-Thin.ttf") format("truetype");
    font-weight: 200;
}

And my fonts are definitely in /assets/fonts/

Here's how my application.css is laid out:

*= require normalize.css
*= require_tree .
*= require materialize.css

Where materialize.css defines my font files

What else do I need?

Upvotes: 1

Views: 846

Answers (1)

chad_
chad_

Reputation: 3819

You'll want to use the font_url helper instead of static urls in your CSS.

Upvotes: 2

Related Questions