Created
August 14, 2011 00:41
-
-
Save pamelafox/1144441 to your computer and use it in GitHub Desktop.
Loading fonts CSS
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
var fontNum = 0; | |
var maxCharacters = 1730; | |
var cssBaseUrl = 'http://fonts.googleapis.com/css?family='; | |
function addCss() { | |
var cssUrl = cssBaseUrl; | |
while ((cssUrl.length + allFontNames[fontNum].length) < maxCharacters && (fontNum < (allFontNames.length-1))) { | |
// dont load khmer, no point | |
if (fonts[allFontNames[fontNum]].subsets[0] != 'khmer') { | |
cssUrl += escape(allFontNames[fontNum]) + '|'; | |
} | |
fontNum++; | |
} | |
var link = document.createElement('link'); | |
link.rel = 'stylesheet'; | |
link.type = 'text/css'; | |
link.href = cssUrl; | |
document.getElementsByTagName('head')[0].appendChild(link); | |
} | |
while (fontNum < (allFontNames.length-1)) { | |
addCss(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment