0

私はWebフォントサーバーで作業しており、正しいMIMEタイプでcssを吐き出すAPIを取得しました。それらはページにもリンクされています。

@font-face {
    font-family: 'Pagul';
    src: url('http://localhost:5000/api/webfonts/static/Pagul.eot');
    src: local('☺'), url('http://localhost:5000/api/webfonts/static/Pagul.woff')   format('woff'),
         url('http://localhost:5000/api/webfonts/static/Pagul.ttf') format('truetype'),
    font-weight: normal; 
    font-style: normal;
}

ttf,eot ファイルは、リンクを使用して手動でダウンロードできます。何らかの理由で、これらのフォントがブラウザによって読み込まれません。ここで何が間違っていますか? フォント ファイルに適切な MIME タイプがありません。

font-squirells 構文も試しましたが、うまくいきません。PS: Css は動的に生成され、ヘッドに追加されますか?

4

1 に答える 1

0

絶対パスではなく相対パスを使用してください。たとえば、CSS が site/css/style.css にあり、フォントが site/api/webfonts/static/ ディレクトリにある場合:

@font-face {
  font-family: Pagul;
  src: url('../api/webfonts/static/Pagul.eot');
  src: url('../api/webfonts/static/Pagul.woff') format('woff'),
     url('../api/webfonts/static/Pagul.ttf') format('truetype'),
  font-weight: normal; 
  font-style: normal;
}

または、Google Fonts などのサービスを使用して、その CSS を HTML にリンクするか、CSS に直接インポートします。

于 2013-07-12T11:17:45.733 に答える