2

I can't figure out how to enforce using of my custom font with JSF. I use Glassfish 4. My filesystem looks like this:

Filesystem

Where Basic.css style is applied to BasicTemplate.xhtml and this template is used in index.xhtml. Everything works fine, every change to the Basic.css file has effect, except for the custom font.

My CSS looks exactly like this:

@font-face{
font-family: 'Conv_Champagne_Limousines';
src: url('fonts/Champagne_Limousines.eot');
src: url('fonts/Champagne_Limousines.woff') format('woff'),     url('fonts/Champagne_Limousines.ttf') format('truetype'),     url('fonts/Champagne_Limousines.svg') format('svg');
    font-weight: normal;
    font-style: normal;
}


body{
    font-family: 'Conv_Champagne_Limousines';
}

Things I've already tried:

  1. Triple check for typos
  2. Various paths. Relative, absolute ....
  3. Cleaning, rebuilding, restarting Glassfish.

2 Answers 2

4

Try this :

url('#{resource['fonts/...']}')

Instead of

url('fonts/...')
Sign up to request clarification or add additional context in comments.

1 Comment

You'll most likely see that this resolves to /javax.faces.resources/fonts/Champagne_Limousines.eot rather than the /resources/fonts/Champagne_Limousines.eot you were probably expecting. This is because JSF is attempting to parse the file before it is being served. This is why you can use the syntax in David H's answer in your CSS file.
3

@David H.'s answer caused "Unexpected token COLON found" error in my Netbeans. So I changed his code to url('#{resource["fonts/..."]}') or url("#{resource['fonts/...']}") and the error was gone.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.