Safari font-weight issue , text too bold

前端 未结 5 1994
生来不讨喜
生来不讨喜 2020-12-29 23:48

When I apply a font-weight:bold style, the look of the font is too bold in Safari when compared to other browsers. I tried below css as suggested in some site b

相关标签:
5条回答
  • 2020-12-30 00:19

    For rendering bold text consistently across browsers, your font should explicitly contain bold characters. Otherwise, browsers probably try to make bold variants of characters based on their normal variants, and results are inconsistent across browsers since they likely have different algorithms for such conversion.

    Also note that text rendering may be different on different platforms on system level (e.g. Windows, Mac OS). Such differences are OK and do not typically need to be fixed.

    See also topic about -webkit-font-smoothing property.

    0 讨论(0)
  • 2020-12-30 00:30

    None of the answers here worked for me. Possibly because I am using the windows version of Safari for testing. I had to include the bold font in my CSS to fix the problem. In the case of the original question he would need to add the following (notice it uses the same font-family name)

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

    This worked in all browsers for me.

    0 讨论(0)
  • 2020-12-30 00:37

    Use -webkit-font-smoothing: antialiased;

    The text-shadow trick doesn't work anymore.

    0 讨论(0)
  • 2020-12-30 00:44

    The -webkit solutions won't work for the strong issue for many google fonts, custom fonts and fonts that don't have preset values.

    The problem is that you need to specify the value of bold in the strong tags.

    This can be done by two ways:

    You can either include from Google Fonts or wherever your font is from in your header; it needs both the regular font and the bold font each should have a different font-weight number like 400 regular and 600 bold for example:

    <link href="https://fonts.xxx.com/css?family=XXX:400,600" rel="stylesheet">
    

    Or use the aboves source code and paste into your own css like below:

    @font-face {
      font-family: 'XXX';
      font-style: normal;
      font-weight: 600;
      src: local('XXX SemiBold'), local('XXX-SemiBold'), 
      url...
    }
    

    Use whatever your font is instead of XXX.

    Then also in strong {font-weight:600;}

    0 讨论(0)
  • 2020-12-30 00:44

    I found a solution for this particular issue. Actually any of above solutions dint work for me. So started checking the default webkit styles added by safari and found that -webkit-text-stroke-width was applied to body having value 0.5px. I set it to 0!important and solved the issue for me.

    0 讨论(0)
提交回复
热议问题