I've been facing this strange issue on SAFARI Browser of iPad and Mac Machine with my application(deployed on IIS). Though, whenever I try editing the CSS in Resources
tab of Developer Tools
, the font suddenly loads itself and then stays. Even a single space edit in the CSS would load the fonts. Everything works fine on Safari for Windows.
Apart from that, If I keep working on pages of my Application on Safari, the fonts get loaded on pages after a random time(time varies from 10 seconds to 10 minutes or more) and then stay there until the cache is wiped off.
I've tried several things to fix this:
- Removing the quotes from
@font-face
declaration as I've read somewhere that Safari won't load fonts with quotes. No success, albeit, firefox stopped rendering the fonts as quotes are necessary there. - Checked
MIME-Type
on IIS for.svg
file types. No Success. - Verified ID in
.svg
declaration from the font file. No Success. - Extracted
@font-face
declarations of all the fonts into separate file and included it as the top most CSS declaration in<head>
tag. - Tried removing and pushing the
CSS
tag after the browser is detected as SAFARI. This thing worked but is a nasty hack. The code is quoted below
CODE:
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
if (isSafari) {
if ($('#fontCss').length) {
$('#fontCss').remove();
$('head').append("<link rel='stylesheet' href='assets/css/fontAwesome/font-awesome.css'>");
alert('This is Safari');
}
}
Can you guys please suggest things which I can try to fix this issue. I've tried making test pages and fiddles with same fonts and tested them on same devices, everything works fine on demo pages but not with my application.