CSS 自定义字体不工作

标签 css encoding fonts font-face custom-font

我在 Windows 中安装了新字体,现在我想在我的 Web 中使用该字体作为自定义字体。在下图中,它将描述我所有的问题 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

最佳答案

字体坏了。我用 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

在字体检查器中查看字体,我注意到这些字符被分配给私有(private)使用代码点。这样可以“工作”,但是 HTML 内容需要包含这些代码点。它显然无法工作,因为字体中的某些表格已损坏。

结论是:另找字体。

关于CSS 自定义字体不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25607833/

相关文章:

javascript - Chrome 使用 Css-element-queries 缩放图像错误

jQuery通过POST发送HTML数据

c++ - GetGlyphOutline 函数如何工作? (WinAPI)

python unicode渲染: how to know if a unicode character is missing from the font

php - 具有多个变量的 Mod_rewrite

html - Drupal:页面上的 HTML 按钮以匹配主题

html - HTML5错误验证中表格宽度边框cellspacing cellpadding全0

java - Solr 编码/解码数据

javascript - 显示编码的 PNG

html - 加粗 Lucida Sans 时 CSS 中奇怪的文本对齐问题