font-language-override

font-language-override CSS属性控制在指定的语言中使用特定的字形。

/* 关键字作为值 */
font-language-override: normal;

/* 字符串作为值 */
font-language-override: "ENG";  /* Use English glyphs */
font-language-override: "TRK";  /* Use Turkish glyphs */

/* 使用全局值 */
font-language-override: initial;
font-language-override: inherit;
font-language-override: unset;

默认情况下,HTML的 lang 属性告诉浏览器使用语言的特定字形。例如,很多字体都有针对合成符 fi 的字形(i 上的点会被合并进 f 里)。而当使用土耳其语时,字体就不会使用合成字形。因为土耳其语有两个版本的i: 一个带点 (i) 一个不带点 (ı)。这种情况下如果使用连写会把带点的 i 不正确地渲染成不带点的 ı

font-language-override属性可以使你重载针对特定语言的字体行为。 当你使用的字体缺少对某种语言的正确支持时,这很有用。 例如,如果一种字体没有针对阿塞拜疆语的适当规则,你可以强制字体使用遵循类似规则的土耳其语字形。

初始值normal
适用元素all elements. It also applies to ::first-letter and ::first-line.
是否是继承属性yes
计算值as specified
Animation typediscrete

语法

font-language-override 属性被指定为关键词 normal 或者一个字符串 <string>

normal
指示浏览器使用适合 lang 属性指定的语言的字体字形。这是默认值。
string
指示浏览器使用适合该字符串指定的语言的字体字形。该字符串必须与 OpenType 语言系统中的语言标签相匹配。例如,"ENG "是英语,"KOR "是韩语。

正式语法

normal | <string>

示例

使用丹麦文字形

HTML

<p class="para1">Default language setting.</p>
<p class="para2">This is a string with the <code>font-language-override</code> set to Danish.</p>

CSS

p.para1 {
  font-language-override: normal;
}

p.para2 {
  font-language-override: "DAN";
}

Result

规范

规范 状态 注释
CSS Fonts Module Level 4
font-language-override
Working Draft 初始定义

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
font-language-overrideChrome No support NoEdge No support NoFirefox Full support 34
Full support 34
No support 24 — 34
Disabled
Disabled From version 24 until version 34 (exclusive): this feature is behind the layout.css.font-features.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Full support 4
Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android Full support 34
Full support 34
No support 24 — 34
Disabled
Disabled From version 24 until version 34 (exclusive): this feature is behind the layout.css.font-features.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Full support 4
Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
User must explicitly enable this feature.
User must explicitly enable this feature.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

另请参阅