【发布时间】:2014-06-26 05:21:15
【问题描述】:
我曾经将我的字体直接链接到 Google 的 API,效果很好。现在我发现我的字体在某些浏览器和操作系统上无法正常显示。我下载了字体并用 fontsquirrel 转换它们以供网络使用。将转换后的文件复制到我的站点目录并将@font-face CSS 粘贴到我的样式表中后,字体不会显示在任何浏览器中。请帮忙。
CSS 是这样的:
@font-face {
font-family: 'titillium_webregular';
src: url('titilliumweb-regular-webfont.eot');
src: url('titilliumweb-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('titilliumweb-regular-webfont.woff') format('woff'),
url('titilliumweb-regular-webfont.ttf') format('truetype'),
url('titilliumweb-regular-webfont.svg#titillium_webregular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'ralewaybold';
src: url('raleway-bold-webfont.eot');
src: url('raleway-bold-webfont.eot?#iefix') format('embedded-opentype'),
url('raleway-bold-webfont.woff') format('woff'),
url('raleway-bold-webfont.ttf') format('truetype'),
url('raleway-bold-webfont.svg#ralewaybold') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'ralewayregular';
src: url('raleway-regular-webfont.eot');
src: url('raleway-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('raleway-regular-webfont.woff') format('woff'),
url('raleway-regular-webfont.ttf') format('truetype'),
url('raleway-regular-webfont.svg#ralewayregular') format('svg');
font-weight: normal;
font-style: normal;
}
我的字体在主站点目录中,但我的样式表是主目录中的一个单独文件夹(我不知道这是否重要)。
【问题讨论】:
-
您的浏览器控制台是否有任何错误?我会检查字体源的 URL。正如你现在所拥有的,意味着你的 CSS 和所有文件都在同一个文件夹中。
-
@Teknotica 我只是将字体文件放入我的 css 文件夹中,但它仍然无法正常工作。
-
您能粘贴一个使用该字体的 CSS 示例吗?你的控制台有什么错误吗?
-
@Teknotica 没有错误,但我刚刚解决了这个问题(请参阅我自己的答案)。
标签: css fonts font-face webfonts google-font-api