CSS3 font-face を使用する正しい方法を誰かが理解するのを手伝ってくれませんか。以下は、いくつかの font-face 宣言です。正しいのはどれで、その理由は何ですか?
/* START OF SAMPLE CODE # 1 */
@font-face {
font-family: 'WebFont';
src: url('webfont.eot');
src: url('webfont.eot?#iefix') format('embedded-opentype'),
url('webfont.woff') format('woff'),
url('webfont.ttf') format('truetype'),
url('webfont.svg#WebFont') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'WebFont';
src: url('webfont-bold.eot');
src: url('webfont-bold.eot?#iefix') format('embedded-opentype'),
url('webfont-bold.woff') format('woff'),
url('webfont-bold.ttf') format('truetype'),
url('webfont-bold.svg#WebFont-Bold') format('svg');
font-weight: bold;
font-style: normal;
}
h1 {
font-family: 'WebFont', blah, blah, blah;
font-weight: bold;
}
h2 {
font-family: 'WebFont', blah, blah, blah;
font-weight: normal;
}
/* END OF SAMPLE CODE # 1 */
=========
/* START OF SAMPLE CODE # 2 */
@font-face {
font-family: 'WebFont';
src: url('webfont.eot');
src: url('webfont.eot?#iefix') format('embedded-opentype'),
url('webfont.woff') format('woff'),
url('webfont.ttf') format('truetype'),
url('webfont.svg#WebFont') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'WebFontBold';
src: url('webfont-bold.eot');
src: url('webfont-bold.eot?#iefix') format('embedded-opentype'),
url('webfont-bold.woff') format('woff'),
url('webfont-bold.ttf') format('truetype'),
url('webfont-bold.svg#WebFont-Bold') format('svg');
font-weight: normal;
font-style: normal;
}
h1 {
font-family: 'WebFontBold', blah, blah, blah;
font-weight: normal;
}
h2 {
font-family: 'WebFont', blah, blah, blah;
font-weight: normal;
}
/* END OF SAMPLE CODE # 2 */
=========
/* START OF SAMPLE CODE # 3 */
@font-face {
font-family: 'WebFont';
src: url('webfont.eot');
src: url('webfont.eot?#iefix') format('embedded-opentype'),
url('webfont.woff') format('woff'),
url('webfont.ttf') format('truetype'),
url('webfont.svg#WebFont') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'WebFontBold';
src: url('webfont-bold.eot');
src: url('webfont-bold.eot?#iefix') format('embedded-opentype'),
url('webfont-bold.woff') format('woff'),
url('webfont-bold.ttf') format('truetype'),
url('webfont-bold.svg#WebFont-Bold') format('svg');
font-weight: bold;
font-style: normal;
}
h1 {
font-family: 'WebFontBold', blah, blah, blah;
font-weight: bold;
}
h2 {
font-family: 'WebFont', blah, blah, blah;
font-weight: normal;
}
/* END OF SAMPLE CODE # 3 */
これらのコード サンプルの違いは、"Bold" フォントの宣言方法と使用方法です。これらのうちどれが正しいか、またその理由を教えてください。
PS: 長い質問/サンプルで申し訳ありません。混乱を避けるために、できるだけ多くの情報を提供したかっただけです。
編集1:以下の回答の1つで@Jukkaが述べたように、論理的なアプローチは「コード#1」を使用することですが、Safariをチェックしたところ、太字のフォントは他のブラウザーと比較してSafariで太字になりすぎています、しかし、「コード #2」を使用すると、すべてのブラウザが同じようにレンダリングされるため、異なる font-face 宣言を使用すると、舞台裏で何かが起こっているように見えます。ですから、現時点では、「コード #2」が進むべき道のように思えます。