For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/css/at-rule/font-face.md.
Lynx
  • 简体中文
  • '@font-face'

    @font-face 指定一个用于显示文本的自定义字体,字体能从远程服务器或者用户本地安装的字体加载。

    语法

    @font-face {
      [ font-family: <string>; ] ||
      [ src: url(<string>) | local(<string>); ]
    }

    声明取值

    font-family

    使用字符串指定字体名称,并且指定的字体名字将会被用于 fontfont-family 属性。

    src

    使用逗号分割排列出所有可用的字体,可以使用 url 函数来指定远程字体和 Base64 字体,使用 local 函数来指定本地字体。

    Info

    在 Android 上可以使用 local(file://absolute/path) 来指定字体的绝对路径。 在 iOS 上可以使用类似 local(font-name)` 来指定字体名(例如 local(xxx-light))。

    Caution

    Android 支持的字体格式有 TTF,OTF,和 TTC, iOS 支持 TTF,OTF, WOFF(iOS 10+), WOFF2 (iOS 10+)。

    示例

    与 Web 的区别

    • 不支持 font-style、font-weight 和 font-variant 等取值。

    兼容性

    LCD tables only load in the browser

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。