CSS自定义字体不起作用

时间:2014-09-01 14:19:16

标签: css encoding fonts font-face custom-font

我在Windows中安装了新字体,现在我想在我的网站中使用该字体作为自定义字体。在下面的图片中,它将描述我的所有问题http://i.imgur.com/hkbfA6O.png

enter image description here

这是我的代码

<html>
    <head>
        <meta charset='uft-8' />
        <style type="text/css">
            @font-face {
                font-family: urdu;
                src: url(font/urdu/NOORIN01.TTF);
            }
            @font-face {
                font-family: eng;
                src: url(font/sansation_light.woff);
            }

            body{
                font-size:30px;
            }
            .urdu{font-family:'urdu';}
            .eng{font-family:'eng';}
        </style>
    </head>
    <body>
        <div class='urdu'>میں نے آپ کے مسئلے کو قتل کرنے جا رہا ہوں</div>
        <div>میں نے آپ کے مسئلے کو قتل کرنے جا رہا ہوں</div>
        <div class="eng">The quick and brown fox jump over the lazy dog.</div>
    </body>
</html>

这里是字体文件
http://speedy.sh/WdxpP/sansation-light.woff
http://speedy.sh/wEzZ6/NOORIN01.TTF

1 个答案:

答案 0 :(得分:1)

字体坏了。我使用指定地址提供的NOORIN01.TTF字体进行测试,并使用问题中的代码进行测试。这是我在Firefox控制台中看到的(在Win 7上):

downloadable font: hdmx: Table discarded (font-family: "urdu" style:normal weight:normal stretch:normal src index:0)
source: [...]
downloadable font: not usable by platform (font-family: "urdu" style:normal weight:normal stretch:normal src index:0)
source: file:///C:/Users/Jukka/Documents/Fonts/NOORIN01.TTF

查看字体检查器中的字体,我注意到字符已分配给专用代码点。这样可以“工作”,但HTML内容需要包含这些代码点。它显然无法工作,因为字体中的某些表被破坏了。

结论是:找另一种字体。

相关问题