1

This is how I refer my css file in my index.xhtml:

<h:outputStylesheet library="css" name="vendors/fontello.css" />

And that's how I'm using #resources, which works fine:

background-image: url("#{resource['img:lang/ico-en.gif']}");

This way is how it's working in a HTML project:

@font-face {
  font-family: 'fontello';
  src: url('../font/fontello69db.eot?24671060');
  src: url('../font/fontello69db.eot?24671060#iefix') format('embedded-opentype'),
       url('../font/fontello69db.woff?24671060') format('woff'),
       url('../font/fontello69db.ttf?24671060') format('truetype'),
       url('../font/fontello69db.svg?24671060#fontello') format('svg');
  font-weight: normal;
  font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
  @font-face {
    font-family: 'fontello';
    src: url('../font/fontello.svg?24671060#fontello') format('svg');
  }
}
*/

Then as I'm moving the HTML project into JSF 2 project I would like to use #resources, right ? So I did the same thing as before but doesn't work:

@font-face {
  font-family: 'fontello';
  src: url("#{resource[css:font/fontello69db.eot?24671060']}");
/*  src: url("#{resource[css:font/fontello69db.eot?24671060');*/

  src: url("#{resource[css:font/fontello69db.eot?24671060#iefix']}") format('embedded-opentype'),
       url("#{resource[css:font/fontello69db.woff?24671060']}") format('woff'),
       url("#{resource[css:font/fontello69db.ttf?24671060']}") format('truetype'),
       url("#{resource[css:font/fontello69db.svg?24671060#fontello']}") format('svg');
  font-weight: normal;
  font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
  @font-face {
    font-family: 'fontello';
    src: url("#{resource[css:font/fontello.svg?24671060#fontello']}") format('svg');
  }
}
*/

And this is my project structure:

project

Any idea how to use #resource correctly in this case ?

Valter Silva
  • 16,446
  • 52
  • 137
  • 218

1 Answers1

2

remove url parameters from font file names. try that.

@font-face {
    font-family: 'fontello';
    src: url("#{resource[css:font/fontello69db.eot']}?24671060");

    src: url("#{resource[css:font/fontello69db.eot']}?24671060#iefix") format('embedded-opentype'),
    url("#{resource[css:font/fontello69db.woff']}?24671060") format('woff'),
    url("#{resource[css:font/fontello69db.ttf']}?24671060") format('truetype'),
    url("#{resource[css:font/fontello69db.svg']}?24671060#fontello") format('svg');
    font-weight: normal;
    font-style: normal;
}
bhdrk
  • 3,415
  • 26
  • 20
  • For some reason the `fontello.css` it's not loaded anymore with this approach. But it's without it. – Valter Silva May 31 '14 at 15:14
  • It works my friend! I combine your adive with this other topic and it's working now! Thank you! http://stackoverflow.com/questions/13567714/jsf2-image-path-in-css-as-background-image-url-is-not-working-used-on-hout – Valter Silva May 31 '14 at 15:30