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

# -x-auto-font-size-preset-sizes

APISummary
## 介绍

`-x-auto-font-size-preset-sizes` 属性指定了预设的字号大小数组，设置后如果需要文本字号自适应将从中选择最合适的字号，即满足宽度限制下的最大字号。

## 使用示例

**下面是一个示例: css-api**

**Entry:** `src/-x-auto-font-size-preset-sizes`
**Bundle:** `dist/-x-auto-font-size-preset-sizes.lynx.bundle`

```tsx
import { root } from "@lynx-js/react";
import "./index.scss";

const XAutoFontSizePresetSizes = () => {
  const containerStyle = {
    display: "linear" as const,
    backgroundColor: "white",
  };

  const baseTextStyle = {
    backgroundColor: "gray",
    fontSize: "20px",
    overflow: "hidden",
  };

  const autoFontStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true",
  };

  const autoFontWithSizeStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true 10px",
  };

  const autoFontWithRangeStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true 10px 50px",
  };

  const autoFontWithStepStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true 10px 50px 3px",
  };

  const presetSizesStyle = {
    ...baseTextStyle,
    XAutoFontSize: "true",
    XAutoFontSizePresetSizes: "10px 16px 25px",
  };

  const sampleText = "This is a test text for auto-sizing font This is a test text for auto-sizing font";

  return (
    <view className="intro" style={containerStyle}>
      <text text-maxline="1" style={autoFontStyle}>
        {sampleText}
      </text>

      <text text-maxline="1" style={autoFontWithSizeStyle}>
        {sampleText}
      </text>

      <text text-maxline="1" style={autoFontWithRangeStyle}>
        {sampleText}
      </text>

      <text text-maxline="1" style={autoFontWithStepStyle}>
        {sampleText}
      </text>

      <text text-maxline="1" style={presetSizesStyle}>
        {sampleText}
      </text>
    </view>
  );
};

root.render(<XAutoFontSizePresetSizes />);

```

v0.11.0



## 语法

```css
-x-auto-font-size: true;
-x-auto-font-size-preset-sizes: 10px 12px 15px;
```

### 取值

- 一个或多个以空格分隔的 [`<length>`](/next/zh/api/css/data-type/length.md) 值，用于指定预设的字号大小。

## 形式定义

| 初始值 | [] |
| 适用元素 | text |
| 是否支持继承 | no |
| 是否支持动画 | no |


## 形式语法

```
-x-auto-font-size-preset-sizes = <length>+
```

## 与 Web 的区别

- Lynx 特有的属性。

## 注意事项

- 此属性在 `-x-auto-font-size` 设置开启时才有效，同时覆盖 `-x-auto-font-size` 中的最小字号和最大字号设置。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.-x-auto-font-size-preset-sizes`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/198--x-auto-font-size-preset-sizes.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| -x-auto-font-size-preset-sizes | Yes (1.0) | No | Yes (1.0) | Yes (3.2) | Yes (3.2) | No |

**`-x-auto-font-size-preset-sizes`**

**Specifications:**

- **Web — Not supported:** This native property is not implemented by the Web style transformer.

