@font-face declarations don't work in Android 4.3 Internet browser?

♀尐吖头ヾ 提交于 2019-11-28 17:37:29

I have the same issue here how i solve it.

I only use svg on mobile with media queries.

@media only screen and (max-width: 320px) {
@font-face {
    font-family: 'open_sansbold';
    src: url('OpenSans-Bold-webfont.svg#open_sansbold') format('svg');
    font-weight: normal;
    font-style: normal;
}
}
@media only screen and (max-device-width: 720px) and (orientation:portrait) {
    @font-face {
        font-family: 'open_sansbold';
        src: url('OpenSans-Bold-webfont.svg#open_sansbold') format('svg');
        font-weight: normal;
        font-style: normal;
    }

}
@media only screen and (max-device-width: 1280px) and (orientation:landscape) {
    @font-face {
        font-family: 'open_sansbold';
        src: url('OpenSans-Bold-webfont.svg#open_sansbold') format('svg');
        font-weight: normal;
        font-style: normal;
    }
}

Hope it's help you.

We were running into a similar issue, and it was caused by our use of text-rendering: optimizeLegibility - removing that from our CSS made our fonts start working on 4.3 again.

I create jsfiddle with only svg and woff fonts and test it on my Android 4.3 device in default browser. All works.

I just remove all unnecessary fonts for mobile. All mobile supports svg fonts, FF and IE10 needs woff. So you can use media queries for separate font-face defenition: for mobile and for desktop.

If you need all types of fonts check your Content-Type header for font files, it's always text/plain which is wrong:

  • eot has application/vnd.ms-fontobject type
  • otf and ttf have application/octet-stream type
  • woff has application/font-woff type
  • svg has image/svg+xml type

Also check this page to read known common problems with font face.

I had a similar problem before and I solved it by adding font-weight: normal !important;to the elements/text that was using the font. I believe the problem was that the font weight was being inherited by the elements and this caused the font to fail. Hope it works :)

So in your code:

h2 {
    font-family: 'OpenSansSemibold', Arial, sans-serif;
    font-weight: normal !important;
    /* ... */
}

You could also maybe use Beacouron's solution of the media query targeting mobile, but this may be difficult if you have various Android tablet resolutions to target to.

Another idea maybe to use a media-query targetting webkit browsers like so:

@media screen and (-webkit-min-device-pixel-ratio:0) {
    @font-face {
        font-family: 'open_sansbold';
        src: url('OpenSans-Bold-webfont.svg#open_sansbold') format('svg');
        font-weight: normal;
        font-style: normal;
    }
}

As of 2017, one can use the @import query provided by fonts.google.com for the font you like. Just search for the desired font(s), select it, then in the minimized bar at the bottom of the screen, you'll have to pick @import in the 'embed' section. I've attached a screenshot for reference: https://gyazo.com/f959b6ef973d4b0df467a7a336cc3698

I've had the same problem in the mobile's default browser, but after I used that syntax, problem was solved. Don't know why, but it worked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!