@font-face: bold in FF is bolder than in Chrome

21,558

Solution 1

The Problem here is that FF takes the font and applies the bold font-weight to it (So basically it doubles the effect). Chrome doesn't seem to change the font-weight and just uses the right font. I think this happens because you declare two different font-families. The right CSS for this case would be:

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

Notice that I changed the font-family to "DroidSans" not "DroidSansRegular" and "DroidSansBold".

Solution 2

FireFox posted a resolution to this today on their bug forum. It was just finalized today so won't be in use for a while, but we should all put

-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

in our body tag to reset this for all browsers. FINALLY!! man, that made my day! This should come out in the next FF release.

thread here https://bugzilla.mozilla.org/show_bug.cgi?id=857142

Solution 3

The issue is that Firefox tries to add the bold affect to text even for custom fonts that are already bold. I've just had the exact same situation, and resolved it by setting font-weight: normal; on the @font-face declaration.

Example:

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

You'll also need to use font-weight:normal; on any element (e.g. h1, h2, etc) that would otherwise have font-weight:bold; set otherwise Firefox will still add bold to the custom font.

Solution 4

You have specified two faces in two different families. You have defined a regular face in a family called “DroidSansRegular” and you have defined a bold face in a family called “DroidSansBold”. The design of CSS expects you to define those as two weights of one family. If you make both say font-family: "DroidSans";, then you can use a font family called “DroidSans” and when you ask for bold, you get the bold face from that family.

(Oops. The chosen answer already gave the correct solution but didn’t quite explain what was wrong.)

Share:
21,558
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I used this code:

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

    and when I using font-weight: bold; then bold text in Chrome is ok, but in Firefox is too much bolder.

    How to solve this?

    PS: I have to use the fonts from local files.

  • Jake Hoffner
    Jake Hoffner about 10 years
    This just made my day. I had lost hope a long time ago and then just came across this now.
  • Jargs
    Jargs over 9 years
    Mind blown. I had no idea I was allowed to change the font-family name. I always just copied and pasted the exact code that the font provider gave me. (Still works as of Sept 2014)
  • Engineeroholic
    Engineeroholic over 8 years
    what if I am using google fonts? any solution for that?
  • Florian Rachor
    Florian Rachor over 8 years
    Should work out of the box, Google adds the fonts in the "correct" way by defining one family and adding the according font weights. That's one of their stylesheets: fonts.googleapis.com/css?family=Open+Sans:400,700,300 As you can see the define the weight's 300/400/700, you might have to use the number instead of "bold" or "light" though, like this: font-weight: 300; Hope that helps.