Adam Perfect

Programming

fonts.com self-hosted files and Rails asset pipeline

This one has had me scratching my head for a while. If you use self-hosted web fonts from fonts.com then you'll get a bunch of files with names like 3c939d59-70e4-4060-b2a5-fbd8fd636a5c.woff.

At least in development mode on my Rails app, the fonts were all failing to load, throwing a Rails routing 'no route matches' error, which was odd. After trying all sorts of things, I renamed one file to something simpler (fontname.woff) and hey presto, it loads fine!

It seems Sprockets doesn't like hyphens in file names as it confuses them with its fingerprinting. This Rails issue two years ago mentions it and it still hasn't been fixed in Sprockets, so for the time-being I'm working around by swapping hyphens for underscores in the font filenames.

Not a great workaround, but hope it helps someone.

Written by Adam on

Adam is a Director of User Experience by day and photographer as time allows.

You may also like…