Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在一个网站上工作,该网站允许用户输入一些文本并将其拖到适当的位置等。我已经到了一个我想提供字体选择的地步。我可以动态加载字体而不是一次全部加载吗?例如,用户输入他们的文本并选择使用“通用字体 1”是否可以使用 jquery 加载该字体?这样我就可以提供一堆字体,而无需在页面加载时全部加载。我也希望使用谷歌网络字体,但不是必须的。为清楚起见,我目前正在使用几种自定义字体,它们加载得很好。
再一次,谢谢你……托德
这是我最近编写的用于动态添加 Google 网络字体的函数...
function addGoogleFont(FontName) { $("head").append("<link href='https://fonts.googleapis.com/css?family=" + FontName + "' rel='stylesheet' type='text/css'>"); } addGoogleFont("Junge"); // for example
之后,您只需font-family像往常一样应用字体。
font-family