页面加载后动态加载谷歌字体

我希望能够让用户选择他们希望页面显示的字体。 以下是Google建议您使用JavaScript执行此操作的方式。

WebFontConfig = { google: { families: ['Tangerine', 'Cantarell'] } }; (function() { var wf = document.createElement('script'); wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; wf.type = 'text/javascript'; wf.async = 'true'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wf, s); })(); 

如何修改这个以便我可以在页面加载后重新获取字体?

查看此github仓库中的WebFont.load命令:

https://github.com/typekit/webfontloader

您可以动态加载任何您想要的字体: