Skip to content

Instantly share code, notes, and snippets.

@sharapeco
Created January 16, 2013 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharapeco/4546127 to your computer and use it in GitHub Desktop.
Save sharapeco/4546127 to your computer and use it in GitHub Desktop.
モリサワ TypeSquare が @font-face ルールを作成するときに、ウェイト情報が含まれないので、そこをいいがにする (Firefox のみ有効)
(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