使用CSS嵌入字体系列

时间:2014-04-04 12:03:39

标签: fonts font-family

我目前正在尝试将TTF字体嵌入到我的页面中,然后显然会提供备份字体。由于某些原因它似乎没有嵌入,我使用http://browsershots.org/在多个浏览器中查看我的页面,似乎没有人拿起嵌入字体。

我的字体CSS是:

@font-face 
{
font-family: 'Tw Cen MT';
src: url('tw.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}

这包含在我的所有CSS文档中,我实现字体的示例如下:

p.toptext
{
font-size:17px;
font-family:"Tw Cen MT";
font-weight:bold;
color:#d5d3d3;
letter-spacing:0.5ex;
}

现在,链接是否需要('../tw.ttf')添加(../)才能找到字体?

另外一个与此相关的问题,我可以将我的备份字体放在font-family代码中,还是每次将font-family链接到段落和锚点时都必须手动添加它?

提前致谢,非常感谢。

3 个答案:

答案 0 :(得分:0)

试试这个所有类型的字体...

@font-face {
    font-family: 'Tw Cen MT';
    src: url('tw.eot');
    src: url('tw.eot?#iefix') format('embedded-opentype'),
         url('tw.woff') format('woff'),
         url('tw.ttf') format('truetype'),
         url('tw.svg#helveticaregular') format('svg');
    font-weight: normal;
    font-style: normal;

}

答案 1 :(得分:0)

请试试这个css

@font-face {

font-family: 'fontscorecomttwcenmt';
src: local('fontscorecomttwcenmt'),url('./fontscorecomttwcenmt.woff') format('woff'), url('./fontscorecomttwcenmt.ttf') format('truetype');

}

/* use this class to attach this font to any element i.e. <p class="fontsforweb_fontid_13141">Text with this font applied</p> */

 .fontsforweb_fontid_13141
        {
        font-family: 'fontscorecomttwcenmt' !important;
        }

/* Font downloaded from FontsForWeb.com */

答案 2 :(得分:0)

我的路径是尝试在CSS文件夹中找到Font,因为@ font-face代码放在我的CSS中,改变了字体的路径添加&#39; ../'从一开始就修复了它。

FIXED:

@font-face {
    font-family: 'Tw Cen MT';
       src: url('../tw.eot');
       src: url('../tw.eot?#iefix') format('embedded-opentype'),
            url('../tw.woff') format('woff'),
            url('../tw.ttf') format('truetype'),
            url('../tw.svg#helveticaregular') format('svg');
    font-weight: normal;
    font-style: normal;
}