font-synthesis
CSS 属性控制浏览器可以合成(synthesize)哪些缺失的字体,粗体或斜体。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
大多数标准西方字体包含斜体和粗体变体,但许多新颖(novelty)的字体不包括这些。用于中文、日文、韩文和其他语标文字(logographic script)的字体往往不含这些变体,同时,从默认字体中生成、合成这些变体可能会妨碍文本的易读性。在这些情况下,可能最好关闭浏览器默认的 font-synthesis 字体合成特性。
初始值 | weight style |
---|---|
适用元素 | all elements. It also applies to ::first-letter and ::first-line . |
是否是继承属性 | yes |
适用媒体 | visual |
计算值 | as specified |
Animation type | discrete |
正规顺序 | order of appearance in the formal grammar of the values |
语法
此属性(的值)可采用下列任意一种形式:
- 关键词
none
- 关键词
weight
或style
- 关键词
weight
和style
。
属性值
none
- 此关键词表示不合成粗体字型(typeface)或斜体字型。
weight
- 此关键词表示,如果需要的话,可以合成粗体字型。
style
- 此关键词表示,如果需要的话,可以合成斜体字型。
形式化语法
none | [ weight || style ]
例子
HTML
<em class="syn">Synthesize me! 站直。</em> <br/> <em class="no-syn">Don't synthesize me! 站直。</em>
CSS
em { font-weight: bold; } .syn { font-synthesis: style weight; } .no-syn { font-synthesis: none; }
结果
规范
规范 | 状态 | 备注 |
---|---|---|
CSS Fonts Module Level 3 font-synthesis |
Candidate Recommendation | Initial definition |
浏览器兼容性
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
font-synthesis | Chrome No support No | Edge No support No | Firefox
Full support
34
| IE No support No | Opera No support No | Safari Full support 9 | WebView Android No support No | Chrome Android No support No | Firefox Android Full support 34 | Opera Android No support No | Safari iOS Full support 9 | Samsung Internet Android No support No |
Legend
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- User must explicitly enable this feature.
- User must explicitly enable this feature.