Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font asset without digest in Ruby on Rails 4

I've got a problem with my font assets being served without digest in production. As soon as I do rake assets:precompile I get:

 5futurebit-webfont-c133dbefd9e1ca208741ed53c7396062.eot

I was trying to link it with font-face in scss with asset-url, asset-path, font-url and font-path but all of them end up outputting path:

 /assets/5futurebit-webfont.eot

For now I'm copying assets from /app/assets/fonts straight to /public/assets/ but it doesn't feel like that's the way to do it.

like image 436
Anton Avatar asked Oct 13 '13 17:10

Anton


2 Answers

I've been looking at a similar issue and am currently using the non-stupid-digest-assets gem: https://github.com/alexspeller/non-stupid-digest-assets

For more info on how you can use it, see here. Correct use of non-stupid-digest-assets gem

Now that being said, the link provided by Chris (specifically, https://stackoverflow.com/a/17367264/291640) seems like it may accomplish the same as the gem without the gem itself. I know I need to look into it further.

like image 59
whoughton Avatar answered Nov 01 '22 13:11

whoughton


Make sure you have the exact filename WITH extention name of the font in your font-url declaration like:

Correct:

@font-face{
  font-family: 'Sawasdee';
  src: font-url('Sawasdee.ttf') format('truetype');
}

Wrong:

@font-face{
  font-family: 'Sewasdee';
  src: font-url('Sewasdee') format('truetype');
}

My font folder:

fonts
 |_ Sewasdee.ttf
 |_ Otherfont.ttf
like image 1
Norly Canarias Avatar answered Nov 01 '22 12:11

Norly Canarias