我想知道是否有一种方法可以,谷歌网络字体关闭了,使用这个作为字体来源?例如,我们如何进行window.jquery检查,以查看google jquery cdn是否已关闭并提供替代文件?
发布于 2013-02-27 03:13:15
您可以简单地指定安装在您自己的服务器上的web字体版本作为第二个选项,例如
<link href='https://fonts.googleapisx.com/css?family=Cantarell' rel='stylesheet'>
<style>
@font-face {
font-family: 'cantarellregular';
src: url('cantarell-regular-webfont.eot');
src: url('cantarell-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('cantarell-regular-webfont.woff') format('woff'),
url('cantarell-regular-webfont.ttf') format('truetype'),
url('cantarell-regular-webfont.svg#cantarellregular') format('svg');
font-weight: normal;
font-style: normal;
}
body { font-family: Cantarell, cantarellregular; }
</style>您的服务器中的字体系列需要一个不同的名称;在本例中,我使用了FontSquirrel @font-face generator生成的名称。
这样,浏览器将尝试首先从Google站点获取字体文件,如果由于某种原因失败,它将从您的服务器获取字体文件。
我想知道为什么你不简单地使用你自己的服务器上的字体,如果你担心谷歌网站宕机。(很少会看到它出现故障;但是从用户设备到Google站点的连接可能会断开,即使到您的站点的连接是正常的。)
发布于 2013-02-27 02:42:30
您可以列出多个字体系列,它们将按该顺序显示。例如
font-family: 'Skranji', cursive, Verdana, Geneva, sans-serif;这将使用Google webfont Skranji,如果该字体不可用,则会将其转换为Verdana,依此类推。
https://stackoverflow.com/questions/15096733
复制相似问题