css - 嵌入字体的@font-face 不起作用

标签 css fonts font-face

我有网站:http://kuvaklubi.fi我在哪里尝试使用字体 "Century Gothic" .

此字体在我的计算机上不存在 "Installed fonts" ,我想通过 @font-face 将此字体嵌入到 css 中.

我在 http://www.fontsquirrel.com/ 生成了一些字体文件和 css 但是我仍然有问题。我看不到"Century Gothic" IE9、FF4 浏览器中的字体

CSS:

@font-face {
    font-family: 'CenturyGothicRegular';
    src: url('gothic-webfont.eot');
    src: url('gothic-webfont.eot?#iefix') format('embedded-opentype'),
         url('gothic-webfont.woff') format('woff'),
         url('gothic-webfont.ttf') format('truetype'),
         url('gothic-webfont.svg#CenturyGothicRegular') format('svg');
    font-weight: normal;
    font-style: normal;    
}

@font-face {
    font-family: 'CenturyGothicRegular';
    src: url('gothicbi-webfont.eot');
    src: url('gothicbi-webfont.eot?#iefix') format('embedded-opentype'),
         url('gothicbi-webfont.woff') format('woff'),
         url('gothicbi-webfont.ttf') format('truetype'),
         url('gothicbi-webfont.svg#CenturyGothicBoldItalic') format('svg');
    font-weight: bold;
    font-style: italic;
}

@font-face {
    font-family: 'CenturyGothicRegular';
    src: url('gothici-webfont.eot');
    src: url('gothici-webfont.eot?#iefix') format('embedded-opentype'),
         url('gothici-webfont.woff') format('woff'),
         url('gothici-webfont.ttf') format('truetype'),
         url('gothici-webfont.svg#CenturyGothicItalic') format('svg');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'CenturyGothicRegular';
    src: url('gothicb-webfont.eot');
    src: url('gothicb-webfont.eot?#iefix') format('embedded-opentype'),
         url('gothicb-webfont.woff') format('woff'),
         url('gothicb-webfont.ttf') format('truetype'),
         url('gothicb-webfont.svg#CenturyGothicBold') format('svg');
    font-weight: bold;
    font-style: normal;
}

body {
    font-family: "Century Gothic", CenturyGothicRegular, Verdana, Tahoma, Helvetica, sans-serif;
...
}

我正在使用 normal/bold/italic 的所有组合网站上的字体。

谁能帮我看看发生了什么,为什么会发生,以及如何解决这个问题?

谢谢。

最佳答案

您上传的字体的字体系列名称标题为“CenturyGothicRegular”,因此您需要像使用 Century Gothic 一样在引号中引用它:

body {
    font-family: "Century Gothic", "CenturyGothicRegular", Verdana, Tahoma, Helvetica, sans-serif;
...
}

您还需要确保字体文件与 CSS 文件位于同一位置,或者更改文件名的相对 URL。

关于css - 嵌入字体的@font-face 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6238737/

相关文章:

javascript - 使用图像映射时鼠标悬停时图像闪烁javascript

css - CKeditor 内容样式为前端设计

jquery - 在不重置滚动位置的情况下将 css 位置更改为固定

css - Google Chrome + FireFox 不加载自定义字体 (access-control-allow-origin)

css - Twitter Bootstrap 和优雅的图标呈现双图标

css - 如何载入大量Google Web Fonts?

css - @font-face 仅在 Chrome 浏览器中不起作用

css - 字体渲染问题(MAC 与 Windows)

javascript - 什么可以抵消我的表格工作

fonts - 如何在Yii2中的AppAsset中引入字体?