Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web font in Chrome

I have a webfont that looks amazing on Firefox, not so much on Chrome. I've tried playing with the text-rendering property, with less-than-spectacular results. My CSS is something like this:

@font-face {
    font-family: 'TextFont';
    src: url('[my font file url]') format('truetype');
    font-weight: normal;
    font-style: normal;
}
body {
    font-family: TextFont, Tahoma, Geneva, sans-serif;
    text-rendering: auto;
}

Changing text-rendering doesn't seem to do anything in Firefox, so I'm posting a single screenshot for it.

Results:

  • Firefox (a.k.a. "what it should look like")

    enter image description here

  • Chrome - text-rendering: auto

    enter image description here

  • Chrome - text-rendering: optimizeLegibility

    enter image description here

  • Chrome - text-rendering: optimizeSpeed

    enter image description here

  • Chrome - text-rendering: geometricPrecision

    enter image description here

All of the Chrome screenshots look really bad compared to the Firefox one. Is there something I'm missing in the CSS?

I'm using Windows 7, Firefox 8.0, and Chrome 15.0.

like image 791
cambraca Avatar asked Dec 15 '11 00:12

cambraca


People also ask

Can I change the font 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.

What is the font that Chrome uses?

You will see that Standard font is Times New Roman, Serif Font is Times New Roman, sans-serif font is Arial and Fixed width font is Consolas. You can change any one or all of these right there. Which font format has the strongest browser support?


2 Answers

Not sure if this is what you're seeing, but Chrome has an issue with anti-aliasing and truetype fonts. As per http://www.fontspring.com/blog/smoother-web-font-rendering-chrome, you can instead specify the SVG font before the TrueType in your font-face, e.g.:

@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); 
src: url('webfont.eot?#iefix') format('embedded-opentype'),
    url('webfont.svg#svgFontName') format('svg'),
    url('webfont.woff') format('woff'),
    url('webfont.ttf')  format('truetype');
}

The biggest downside is that Safari will download both the svg and the woff.

like image 183
Nils Avatar answered Nov 15 '22 17:11

Nils


Try this:

 -webkit-text-stroke: .5px

The .5 is kind of arbitrary - some pixel value between 0 and 1 is the key. This forces sub-pixel hinting of the font.

A demo can be seen here: http://dabblet.com/gist/4154587

like image 23
Barney Avatar answered Nov 15 '22 16:11

Barney