Search code examples
google-chromecssfontsfont-face

@font-face for custom fonts, fonts not smooth in Chrome


I have a web application that is using CSS3's @font-face to embed custom fonts. So far this has works perfectly in IE and Firefox.

With Chrome, however, the custom fonts appear pixelated and not smooth. Below is a link to a screen snippet of an example of my font in Firefox & IE (top) and Chrome (bottom): Screenshot comparison

It might be hard to see the difference in such a small sample screenshot, but when this is happening all over the page it is very noticeable.

Below is an example of how I'm using @font-face in my stylesheet:

@font-face 
{
    font-family: 'MyFont';
    src: url('../Content/fonts/MyFont.eot?') format('embedded-opentype'),
         url('../Content/fonts/MyFont.ttf') format('truetype');
}

Another thing possibly worth mentioning, is that when I pull up the site in ANY browser running on a VM, the fonts are SUPER choppy, much worse than the Chrome example. This is happening when I use any of my school computers, which are all running Win7 VMWare desktops. It also happens when I pull up the site from a Windows 7 VM running on a friend's Mac.


Solution

  • This is a known issue that Chrome devs are fixing:

    http://code.google.com/p/chromium/issues/detail?id=137692

    To work around until then first try:

    html {
        text-rendering: optimizeLegibility !important;
        -webkit-font-smoothing: antialiased !important;
    }
    

    If this does not work for you, this work-around worked for me (above did not fix windows Chrome):

    http://code.google.com/p/chromium/issues/detail?id=137692#c68

    it appears rearranging the @font-face CSS rule to allow svg's to appear 'first' fixes this problem.

    example:

    -before--------------
    
    @font-face {
    font-family: 'chunk-webfont';
    src: url('../../includes/fonts/chunk-webfont.eot');
    src: url('../../includes/fonts/chunk-webfont.eot?#iefix') format('eot'),
    url('../../includes/fonts/chunk-webfont.woff') format('woff'),
    url('../../includes/fonts/chunk-webfont.ttf') format('truetype'),
    url('../../includes/fonts/chunk-webfont.svg') format('svg');
    font-weight: normal;
    font-style: normal;
    }
    
    
    -after--------------
    
    @font-face {
    font-family: 'chunk-webfont';
    src: url('../../includes/fonts/chunk-webfont.eot');
    src: url('../../includes/fonts/chunk-webfont.eot?#iefix') format('eot'),
    url('../../includes/fonts/chunk-webfont.svg') format('svg'),
    url('../../includes/fonts/chunk-webfont.woff') format('woff'),
    url('../../includes/fonts/chunk-webfont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    }