Search code examples
grailscssfont-face

Using CSS3 @font-face in Grails web application


Can anyone shed some clarity on how to use CSS3 @font-face styling in a Grails web application. How do I get the application to include the font in the war, and how do I reference it.

I'm fairly new to Grails, and I'm not sure where exactly to put the fonts so that they can be referenced in the CSS.

Thanks!


UPDATE

Seems that putting it in the web-app directory does not work. Example, let's say the font filename is myfont.ttf. I place it in the web-app directory and then in my css do:

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

As far as I know that is correct, but it does not seem to work when I launch it from STS.


Solution

  • If you're using a font embedding service like Google's free web fonts api (http://www.google.com/webfonts) then you don't need to put fonts in your app. You just grab the generated JS includes and the generated CSS, plonk it in and use it. Easy.