Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@font-face working in localhost not in live server

I am using a font for my site which is stored under my project folder as fonts and i used this code in css.

my css

 @font-face
{
font-family: buddys;
src: url('/fonts/Kristen-ITC-Regular.ttf'),
     url('/fonts/Kristen-ITC-Regular.eot'); /* IE9 */
}

its working on localhost while its uploaded to live the font style not apply on my site. How to make it work on live site.

Thanks.

like image 458
Krish Avatar asked Dec 07 '25 14:12

Krish


1 Answers

As you're using Visual Studio, you need to set the Build Action for each of your webfonts to 'Content' under properties. If you don't do this, your font files do not get included in the deployment package and never make it to your server.

Also, I would suggest improving your @font-face code in your CSS to include all formats (you can use font squirrel to help with this: http://www.fontsquirrel.com/fontface/generator). Also worth a read is this article on the most compatible code to use: http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/

like image 132
Alan Shortis Avatar answered Dec 10 '25 22:12

Alan Shortis