Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@font-face not working on chrome

I'm using the latest version of google chrome and it won't render font face at all.

I'm running Debian Linux, and all other browsers , including Chromium , show included fonts properly.

Font face declaration I'm using is:

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

@font-face {
    font-weight: bold;
    font-family: Dejaweb;
    src: url('DejaWeb-Bold.ttf');
}
like image 800
Bojan Savic Avatar asked Mar 09 '12 21:03

Bojan Savic


People also ask

How do I fix the font problem on Google Chrome?

Go to Control Panel > Appearance and Personalization > Display > Adjust ClearType text (on the left). Check the box entitled “Turn on ClearType.” After going through a short wizard, this will fix some of the text rendering issues in Chrome.

How do I enable fonts in Chrome?

Select the Menu button in the top-right corner of the browser window or press Alt + F on your keyboard. Select Settings. Click Appearance on the left-hand side then click Customise fonts on the right. Use the drop-down menus to choose which fonts to use for the Standard, Serif, San-serif and Fixed-width styles.

Does OTF work on Chrome?

TTF/OTF - TrueType and OpenType font support is Fully Supported on Google Chrome 71.

How do I use Google Fonts face?

Google Fonts provides free fonts to use in an HTML file with the <link> tag or the @font-face property in CSS. Add local fonts to a document with @font-face and the path to the font's source. Then use the named font-family rules as you please (along with a web-safe fallback font), and you're good to go!


2 Answers

Whenever @font-face inexplicably doesn't work for me in the supposedly compliant browsers, I drop this in my .htaccess file. Supposedly some browsers won't load fonts hosted on other domains, and this bit of code troubleshoots that, but sometimes it is the only remedy to force fonts to load that are hosted on same domain as well. Generally its more of an issue with Firefox than with Chrome, but I just now used this to force fonts in Chrome while Firefox was working fine. Go figure.

<FilesMatch "\.(ttf|otf|eot)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>

Another inexplicably weird thing I have had happen with the @font-face syntax was that it wouldn't load font files properly with caps in the name. This only was an issue once, and after repeatedly banging my head against the desk troubleshooting @font-face a bunch of different ways, as a last resort I changed all font files and font-family name to lowercase characters, and it worked fine (I think that was an issue in ever-finicky IE, and only one website I was doing, exact same syntax on another website worked fine with upper and lowercase characters).

like image 129
thelindsaybutler Avatar answered Sep 20 '22 02:09

thelindsaybutler


Try this

   src:url('DejaWeb-Bold.ttf') format('truetype'), 

Also if the fonts are available in other different format from where you got them then I suggest writing all the cross browser compatibly in the following manner

    @font-face {
     font-family: "Dejaweb";
     src: url("DejaWeb-Bol.eot") format('embedded-opentype'), /* EDIT correction on this line */
     url('DejaWeb-Bol.woff') format('woff'), /* Modern Browsers */
     url('DejaWeb-Bol.ttf') format('truetype'), /* Safari, Android, iOS */
     url('DejaWeb-Bol.svg#Dejaweb') format('svg'); /* Legacy iOS; correction on this line */
     font-weight:bold;
    font-style:normal;
  }
like image 38
jmishra Avatar answered Sep 20 '22 02:09

jmishra