FontFace.display - Web APIs 编辑

Experimental

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The display property of the FontFace interface determines how a font face is displayed based on whether and when it is downloaded and ready to use. This property is equivalent to the CSS font-display descriptor.

When this property is used, font loading has a timeline with three periods. The lengths of the first two periods depend on the value of the property and the user agent. (See below.)

block period
The browser invisibly prepares a fallback font. If the font face loads during this time, it's used to display the text and display is complete. 
swap period
If the font face is still not loaded, the fallback font will be shown. When the font face loads, the fallback will be swaped for the downloaded font.
failure period
If the font face still is not loaded, the fallback font will be shown and no swap will occur.

Syntax

var display = FontFace.display
FontFace.display = display

Value

A CSSOMString with one of the following values.

  • 'auto': Use the font display strategy provided by the user agent.
  • 'block': Gives the font face a short block period and an infinite swap period. The spec recommends 3 seconds for the block period, though this may vary from browser to browser.
  • 'fallback': Gives the font face a short block period and a short swap period. The spec recommends 100 ms or less for the block period and 3 seconds for the swap period, though these values may vary from browser to browser.
  • 'optional': Gives the font face a short block period and no swap period. The spec recommends 100 ms or less, though this may vary from browser to browser.
  • 'swap': Gives the font face a 0 second block period and an infinite swap period.

Specifications

SpecificationStatusComment
CSS Font Loading Module Level 3
The definition of 'display' in that specification.
Working DraftInitial definition.
CSS Fonts Module Level 4
The definition of 'font-display' in that specification.
Working DraftDefines the values for the display property. (They are the same as for font-display.)

Browser Compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:133 次

字数:3754

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文