2017-10-18 4 views
0

インターネットでもスタックオーバーフローでも調べましたが、多くの人がこのトピックをカバーしていたとしても、効果的な方法はわかりません。CSS3 font-face古いブラウザの互換性+ローカルフォント

可能な限り最大限の互換性範囲でCSS3フォントフェースを使用し、使用しているウェブフォントがすでにデバイスにインストールされているかどうかを確認します。そうであれば、それをダウンロードする代わりにブラウザで使用してください。

これは私の試みです。もちろん、期待どおりに動作していません。 たとえば、Firefoxは私のwebfontのwoff2バージョンをダウンロードします。

@font-face{ 
    font-family: mplus-1c; 
    src: local('M+ 1c regular'), 
     local ('mplus-1c-regular'); 
    src: url('../fonts/mplus-1c-regular-webfont.eot'); 
    src: url('../fonts/mplus-1c-regular-webfont.eot?#iefix') format('embedded-opentype'), 
     url('../fonts/mplus-1c-regular-webfont.woff2') format('woff2'), 
     url('../fonts/mplus-1c-regular-webfont.woff') format('woff'), 
     url('../fonts/mplus-1c-regular-webfont.ttf') format('truetype'), 
     url('../fonts/mplus-1c-regular-webfont.svg#m_1cregular') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 
+0

ブラウザは一つだけ 'src'プロパティを使用していますので、それはあなたの例では最初の2を無視します:「これをまとめると 、ここで正しいコードです。代わりにそれらを組み合わせる: 'src:local(font)、url(webfont);'を使う。また、[@ font-face src:local - ユーザーが既にローカルフォントを使用している場合はどうすればいいですか?](https://stackoverflow.com/q/3837249/1016716) –

+0

?#iefixの部分は? – matteobin

+0

IEの変種の落とし穴に精通しているわけではありませんが、動作を確認したい場合は、#iffixedを最初に置いてから、ローカルフォーマットと新しいフォーマットを指定することをお勧めします。そうすれば、古いIEはローカルフォントが存在してもeotをロードしますが、少なくともそれは壊れません。 –

答えて

0

Mr Listerはまさに正しいです! はまた、私が働いてからの彼の提案を防ぐ非常に愚かな構文エラーが見つかりました:

local ('mplus-1c-regular'); 

local('mplus-1c-regular'); 

愚かな私にされている必要があります。

ありがとう、リスターさん!

@font-face{ 
    font-family: mplus-1c; 
    src: url('../fonts/mplus-1c-regular-webfont.eot'); 
    src: url('../fonts/mplus-1c-regular-webfont.eot?#iefix') format('embedded-opentype'), 
     local('M+ 1c regular'), 
     local('mplus-1c-regular'), 
     url('../fonts/mplus-1c-regular-webfont.woff2') format('woff2'), 
     url('../fonts/mplus-1c-regular-webfont.woff') format('woff'), 
     url('../fonts/mplus-1c-regular-webfont.ttf') format('truetype'), 
     url('../fonts/mplus-1c-regular-webfont.svg#m_1cregular') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 
関連する問題