Google Font not rendering correctly in Firefox

五迷三道 提交于 2019-12-06 10:48:51

问题


I'm using a google web font, Titillium Web, on my website . It renders perfectly in Google Chrome, IE, Opera and Safari but in Firefox the text looks horrible.

Google Font Link:

<link href='http://fonts.googleapis.com/css?family=Titillium+Web:200' rel='stylesheet' type='text/css'>

HTML :

<p id="main-top-text" class="txt-style">WELCOME TO <span class="site-colour">NATHAN DA SILVA,</span></p>

<p id="main-bottom-text" class="txt-style">ENJOY YOUR STAY.</p>

CSS :

.txt-style {
    font-family: 'Titillium Web', sans-serif;
    font-size: 60px;    
    line-height: 70px;
    color: #666666;
    text-align: center;
}

You can see what it looks like here: http://www.nathandasilva.co.uk/v3

I don't suppose anyone knows of any fix to make this look better in Firefox?


回答1:


I have often found that declaring the font-weight can help.

font-weight: 200;



回答2:


I had problems with all Google web fonts (particularly Roboto) and found that I needed to force Direct2d acceleration ON to fix it. My graphics card is an Intel HD4000.

Posting the solution that worked for me, in case it's relevant to you or another reader:

  1. Go to about:config
  2. Find gfx.direct2d.force-enabled
  3. Set to True and restart Firefox



回答3:


Looks fine in my end, try clearing your browser caches, and trying again.




回答4:


I have exactly the same problem! I'm using the latest version of Firefox (23), and Windows (8). I also have a discreet (onboard) AMD graphics card in my laptop, which is fairly weak.

I did not have the problem in windows 7 before I upgraded.

After doing some investigation, here's what I've discovered:

  • I seem to have the problem with cleartype generally, because when I view thin fonts (via control panel > fonts) with cleartype on, they look terribly pixelated. With cleartype off, they look smoother, but without the great sub-pixel rendering, so they're not super sharp like they could be.

  • Each of the browsers installed on my computer (IE, Opera, Chrome, Firefox), treats thin fonts differently. Opera has a similar with pixelation as Firefox. Chrome treats Titillium fine, but not Glypha LT (the title font on The Expressive Web). IE is the only browser, ironically, that treats all thin fonts perfectly as it should.




回答5:


Evidently Firefox by default blocks fonts from "cross-sites" to prevent XSS attacks.

You can tell in Firebug whether the fonts have loaded or not, as they will appear 'grey' in the style tab (when you inspect the HTML element).

Also, try checking in Firefox's built-in Developer Console (Menu > Web Developer > Web Console) and look for errors loading the font (Firebug doesn't seem to report these). This will help you identify where the problem is.

To solve the problem you can configure your site to accept external fonts eg:

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

And for other fonts (ie. not from Google), if you can host the fonts on your server, you can refer to them relatively to get around the problem too. eg.:

@font-face { 
  font-family: 'museo_sans_100regular'; 
  src: url('/wp-content/uploads/museosans_100-webfont.eot'); 
  src: local('☺'), local('museo_sans_100regular'), 
    url('/wp-content/uploads/museosans_100-webfont.woff') format('woff'), 
    url('/wp-content/uploads/museosans_100-webfont.ttf') format('truetype'), 
    url('/wp-content/uploads/museosans-100-webfont.svg#museo_sans_100regular')     format('svg');
}



回答6:


I fixed mine (also broken in Safari) by changing the http to https (guess google themselves changed how they host it). Not sure why a browser would care about whether stylesheets come from https versus http but it did clear up the problem.

<link href='http://fonts.googleapis.com/css?family=Great+Vibes' rel='stylesheet' type='text/css'>

to

<link href='https://fonts.googleapis.com/css?family=Great+Vibes' rel='stylesheet' type='text/css'>


来源:https://stackoverflow.com/questions/16031864/google-font-not-rendering-correctly-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!