45

I created a fiddle trying to use Open Sans font with font-weight 300:

HTML

<span class="demo">example</span>

CSS

.demo {
  font-weight: 400 !important;
  font-family: 'Open Sans' !important;
  font-style: normal;
  font-variant: normal;
}

I use Google fonts to define the CSS

I can see a difference in Firefox (Ubuntu 13.10) when rendering at font-weight: 300 (light) and at font-weight: 400 (normal) but none in Chrome (Version 33.0.1750.117 ), where everything looks like it's rendered at font-weight:400. Am I doing something wrong or is there a bug in Chrome? Is there any known workaround?

Update:

There is definitely something wrong with chrome I have two instances of the same page open in 2 different windows in Chrome. One is rendering the font ok (300 weight corresponds to the light variant) and one is not (300 weight is the same as the Normal variant). Any clues? I've made sure to refresh the page in each tab so they are actually the same page.

Update 2: Attached screenshot: of the bug: Chrome font rendering bug

Update 3 This is not a duplicate of this. In that question the problem is that "Arial Black" and "Arial" are different fonts actually. In my case Open Sans is the only font and the problem is Chrome picking up the incorrect weight some times. As you can see from the screenshots, Chrome is not consistent with the font rendered even between two instances.

8
  • 1
    If you whack the font-size up to 7.5em, you'll notice that there is a slight difference in the font-weight (I am using Chrome). If you add -webkit-font-smoothing: antialiased; you'll see the difference even more.
    – adaam
    Commented Feb 24, 2014 at 23:10
  • Instead of having all of those css calls, why not just use the google font import, i.e. @import url(http://fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,700,700italic,800); Commented Feb 24, 2014 at 23:16
  • 1
    @adaam I notice no difference both at 7.5em and using -webkit-font-smoothing: antialiased.
    – vseguip
    Commented Feb 25, 2014 at 7:42
  • 3
    Do you happen to have Open Sans installed locally on your system? I've had some issues with the font weight before and after I deleted it from the system, everything worked fine.
    – Léo Lam
    Commented Mar 19, 2014 at 12:15
  • 1
    @LéoLam Thanks! Worked the second I deleted it locally.
    – MiKo
    Commented Dec 30, 2014 at 11:05

9 Answers 9

41

Add this to your CSS:

* {-webkit-font-smoothing: antialiased;}
2
15

This seems to be a Chrome/Chromium bug, caused by having the font installed locally on your system. Other browsers don't seem to suffer from this issue.

So far, it seems to occur on Linux and Windows (confirmed).

For some reason, it will just load your local font and ignore any of your font-weight rules, even if they're !important. It won't even be consistent with itself: the font weight can change randomly between tabs and page reloads.

The simplest workaround is to remove the font, but that could be an issue if you need it for something else.

You might also try renaming the font to something else in order to force Chrome to use your web font and honour your CSS font rules.

6
  • the problem is "what if the user has the font installed"? And "try renaming the font to something else" for Google's Open Sans is not so trivial.
    – Niccolò
    Commented Feb 11, 2016 at 10:50
  • You'd have to get Chromium to fix this issue. (I don't know if it's been fixed recently.) As for renaming the font, it's as trivial as downloading the font and changing the font name when you reference it in your CSS. It's not as easy as simply adding a <link> to Google's CSS but it's not that complicated either.
    – Léo Lam
    Commented Feb 11, 2016 at 18:07
  • Renaming the font reference won't work on Chrome 56.0.2924.87
    – Dan
    Commented Mar 1, 2017 at 21:45
  • Ahh, yes. That's it. It renders perfectly on other browsers and devices, and the font-weight is set to 400 yet it's rendering as 700. Thanks!
    – Daniel
    Commented Apr 7, 2017 at 2:34
  • I ran across this as well. The solution for it to work well in Chrome is to not use @import but instead include the file css in the <head> section. Also see my answer.
    – bas
    Commented Apr 20, 2020 at 7:34
9

I was having this issue with a variable font. It was solved by defining a font-weight range in the font-face definition.

@font-face {
  font-family: …;
  font-weight: 1 999;
  src: …;
}
2
  • 2
    wow, could not find this anywhere else. saved me, thank you!
    – switz
    Commented Aug 20, 2022 at 9:26
  • 1
    This was the only solution that worked for me
    – nth-child
    Commented Jan 6, 2023 at 21:55
3

Try changing the font family to 'Open Sans Light', sans-serif;. I had the same problem and this worked for me.

1
  • This makes the Google font not working on any browser for me: 'Open Sans Light' is not recognized and all browsers fall back to the installed sans-serif I believe.
    – Niccolò
    Commented Feb 11, 2016 at 10:54
1

i overlaid them on top of each other and they look good on osx chrome.

font-weight: 400 !important;

beneath

font-weight: 300 !important;

http://jsfiddle.net/gpmXe/22/

2
  • 3
    The still look the same to me on Linux.
    – vseguip
    Commented Feb 25, 2014 at 8:09
  • 1
    On Win Chrome as well for me
    – Niccolò
    Commented Feb 11, 2016 at 10:56
1

For me the solution was to include the CSS in the head-section instead of using @import inside the stylesheet.

<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,700;1,400&display=swap" rel="stylesheet">
1

In HTML use this instead of using it in CSS. Best Solution 👍

<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,700;1,400&display=swap" rel="stylesheet">

Doc for ital & wght

3
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 15, 2022 at 7:30
  • 1
    Wouldn't recommend this if your site needs to be GDPR compliant Commented Jan 9, 2023 at 14:36
  • This is definitely not the best solution and, moreover, cannot be used within the EU or countries that protect users' data.
    – rank
    Commented Jan 25, 2023 at 12:19
0

My solution is download and install all the weight types of the font on your machine, or don't install it at all. That's odd solution, but works for me.

0

This is probably obvious to most of you, but I was having this issue and in my case it turned out I was simply overriding it with the font attribute in the same selector:

    selector {
        font-weight: bold;
        ...
        font: inherit;
    }

Moving the font-weight to below the font attribute fixed it. I guess that's basic css, but I didn't remember that the font attribute overrides the font-weight attribute like that. I think I meant to use font-family instead of font, and that caused the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.