> 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.

# '@font-face'

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

## 语法

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

## 声明取值

### `font-family`

使用字符串指定字体名称，并且指定的字体名字将会被用于 `font` 或 `font-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+)。
:::

## 示例

**下面是一个示例: text**

**Entry:** `src/font_face`
**Bundle:** `dist/font_face.lynx.bundle` | Web: `dist/font_face.web.bundle`

```tsx
import { root } from "@lynx-js/react";
import { Component } from "@lynx-js/react";

import "./index.scss";

export default class FontFaceExample extends Component {
  render() {
    return (
      <view
        style={{
          display: "flex",
          flexDirection: "column",
          alignItems: "center",
          width: "100%",
        }}
      >
        <text>Whereas recognition of the inherent dignity</text>
        <text style={{ fontFamily: "Inter" }}>Whereas recognition of the inherent dignity</text>
        <text style={{ fontFamily: "Icon" }}>&#xEA01;</text>
      </view>
    );
  }
}
root.render(<FontFaceExample />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.1



## 与 Web 的区别

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

## 兼容性

**Compatibility Table**

**Query:** `css.at-rule.font-face`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/css/at-rule/font-face.json) · [MDN](https://developer.mozilla.org/zh-CN/docs/Web/CSS/@font-face)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| font-face | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |

**`font-face`**

**Specifications:**

