Created
January 16, 2013 10:16
-
-
Save sharapeco/4546127 to your computer and use it in GitHub Desktop.
モリサワ TypeSquare が @font-face ルールを作成するときに、ウェイト情報が含まれないので、そこをいいがにする (Firefox のみ有効)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var fl = document.styleSheets.length | |
, timer = setInterval(watch, 100) | |
; | |
function watch() { | |
if (fl === document.styleSheets.length) return; | |
clearInterval(timer); | |
iiganisuru(); | |
} | |
function iiganisuru() { | |
var ss = document.styleSheets[document.styleSheets.length - 1] | |
, rules = ss.cssRules | |
, rewrited = [] | |
; | |
for (var i = rules.length - 1; i >= 0; i--) { | |
var rule = rules[i]; | |
if (rule.cssText.indexOf("@font-face") >= 0 && | |
/\b(?:Bold|ExtraBold|Heavy|ExtraHeavy|Ultra|MB1|MB31)\b/.test(rule.cssText)) { | |
rewrited.push(rule.cssText.replace(/font-family/, "font-weight: bold; font-style: normal; font-family")); | |
ss.deleteRule(i); | |
} | |
} | |
for (i = rewrited.length - 1; i >= 0; i--) { | |
ss.insertRule(rewrited[i], rules.length); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment