0

I used to link my fonts directly to Google's API, which worked fine. Now I see that my fonts don't display properly on certain browsers and operating systems. I downloaded the fonts and converted them with fontsquirrel for web usage. After copying the converted files into my site's directory and pasting the @font-face CSS into my style sheet, the fonts don't show up in any browser. Please help.

The CSS is like this:

@font-face {
font-family: 'titillium_webregular';
src: url('titilliumweb-regular-webfont.eot');
src: url('titilliumweb-regular-webfont.eot?#iefix') format('embedded-opentype'),
     url('titilliumweb-regular-webfont.woff') format('woff'),
     url('titilliumweb-regular-webfont.ttf') format('truetype'),
     url('titilliumweb-regular-webfont.svg#titillium_webregular') format('svg');
font-weight: normal;
font-style: normal;

}

@font-face {
font-family: 'ralewaybold';
src: url('raleway-bold-webfont.eot');
src: url('raleway-bold-webfont.eot?#iefix') format('embedded-opentype'),
     url('raleway-bold-webfont.woff') format('woff'),
     url('raleway-bold-webfont.ttf') format('truetype'),
     url('raleway-bold-webfont.svg#ralewaybold') format('svg');
font-weight: normal;
font-style: normal;

}

@font-face {
font-family: 'ralewayregular';
src: url('raleway-regular-webfont.eot');
src: url('raleway-regular-webfont.eot?#iefix') format('embedded-opentype'),
     url('raleway-regular-webfont.woff') format('woff'),
     url('raleway-regular-webfont.ttf') format('truetype'),
     url('raleway-regular-webfont.svg#ralewayregular') format('svg');
font-weight: normal;
font-style: normal;

} 

My fonts are in the main site directory, but my stylesheet is a seperate folder within the main directory (I don't know if this matters at all).

user3361043
  • 361
  • 3
  • 10
  • 23

4 Answers4

1

See what the "Network" tab and "Console" tab says in your Developer Tools (Chrome and Firefox).

Try to load using absolute paths. And you can define the faces a bit differently, something like this:

@font-face {
  font-family: 'titillium';
  src: url('/titilliumweb-regular-webfont.eot');
  src: url('/titilliumweb-regular-webfont.eot?#iefix') format('embedded-opentype'),
       url('/titilliumweb-regular-webfont.woff') format('woff'),
       url('/titilliumweb-regular-webfont.ttf') format('truetype'),
       url('/titilliumweb-regular-webfont.svg#titillium_webregular') format('svg');
  font-weight: normal;
  font-style: normal;

}

@font-face {
  font-family: 'raleway';
  src: url('/raleway-bold-webfont.eot');
  src: url('/raleway-bold-webfont.eot?#iefix') format('embedded-opentype'),
       url('/raleway-bold-webfont.woff') format('woff'),
       url('/raleway-bold-webfont.ttf') format('truetype'),
       url('/raleway-bold-webfont.svg#ralewaybold') format('svg');
  font-weight: bold; /* SEE HERE. SAME NAME, BUT WE JUST CHANGED THE WEIGHT TYPE */
  font-style: normal;
}

@font-face {
  font-family: 'raleway';
  src: url('/raleway-regular-webfont.eot');
  src: url('/raleway-regular-webfont.eot?#iefix') format('embedded-opentype'),
       url('/raleway-regular-webfont.woff') format('woff'),
       url('/raleway-regular-webfont.ttf') format('truetype'),
       url('/raleway-regular-webfont.svg#ralewayregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

And to use them:

.RalewayBoldTest {
  font-family: raleway;
  font-weight : bold;
}
.RalewayRegularTest {
  font-family: raleway;
}
.TitilliumRegularTest {
  font-family: titillium;
}
andersevenrud
  • 419
  • 4
  • 11
1

Looks like a filepath error to me. The url(); should be relative to the stylesheet - so you're going to want to go up some levels, depending where your stylesheet is. To go up a level, merely use 2 dots:

url('../font.woff');
/* will take you up one level from the stylesheet and select the file called 'font.woff'. */

Hope this helps.

ArtOfCode
  • 5,702
  • 5
  • 37
  • 56
1

it matters! you need to go up a folder in the structure:

src: url('../titilliumweb-regular-webfont.eot');
MilkyTech
  • 1,919
  • 2
  • 15
  • 39
1

This was indeed a file path issue. Also I didn't change the names from Google Font defaults (Titillium Web) to converted ones (titillium-webregular). Thanks for all the help.

user3361043
  • 361
  • 3
  • 10
  • 23