Skip to content

Commit

Permalink
Only convert and add the font-face when it makes sense.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred committed Feb 15, 2011
1 parent d37ea30 commit ad64db5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 15 deletions.
37 changes: 30 additions & 7 deletions dist/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ var WORF = {
VERSION: "0.1.0",

font_face: function() {
var length = arguments.length / 2;
var url, rules;
while(length--) {
url = arguments[length*2];
rules = arguments[length*2+1];
WORF._font_face(url, rules);
if (WORF.worfable()) {
var length = arguments.length / 2;
var url, rules;
while(length--) {
url = arguments[length*2];
rules = arguments[length*2+1];
WORF._font_face(url, rules);
}
WORF.Caching.cleanup();
}
WORF.Caching.cleanup();
},

_font_face: function(url, rules) {
Expand All @@ -30,6 +32,27 @@ var WORF = {
var style = document.createElement('style');
style.innerHTML = declaration;
document.head.appendChild(style);
},

worfable: function() {
var ua = navigator.userAgent, version;
if (version = ua.match(/Chrome\/(\d+\.\d+\.\d+\.\d+)/)) {
return version[1] >= '4.0.249.4' && version[1] < '5.0';
}
if (version = ua.match(/Safari\/(\d+\.\d+)/)) {
if (ua.indexOf('(iPhone') > -1 || ua.indexOf('(iPad') > -1 || ua.indexOf('(iPod') > -1) {
return version[1] >= '533.17.9';
} else {
return version[1] >= '525.13';
}
}
if (/Opera/.test({}.toString.call(window.opera))) {
return opera.version() >= '10.00' && opera.version() < '11.00';
}
if (version = ua.match(/rv:(\d+\.\d+\.\d+)[^b].*Gecko\//)) {
return parsed[1] >= '1.9.1';
}
return false;
}
}

Expand Down
Loading

0 comments on commit ad64db5

Please sign in to comment.