未验证 提交 88a6b168 编写于 作者: O openharmony_ci 提交者: Gitee

!20403 registerFont中参数新增支持Resource类型

Merge pull request !20403 from 范盼/fap_docs
......@@ -36,8 +36,8 @@ registerFont(options: FontOptions): void
| 名称 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------ |
| familyName | string | 是 | 设置注册的字体名称。 |
| familySrc | string | 是 | 设置注册字体文件的路径。 |
| familyName | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>10+</sup> | 是 | 设置注册的字体名称。 |
| familySrc | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>10+</sup> | 是 | 设置注册字体文件的路径。 |
**示例:**
......@@ -51,10 +51,23 @@ struct FontExample {
@State message: string = '你好,世界'
aboutToAppear() {
// familyName和familySrc都支持string
font.registerFont({
familyName: 'medium',
familySrc: '/font/medium.ttf'
})
// familyName和familySrc都支持系统Resource
font.registerFont({
familyName: $r('app.string.mediumFamilyName'),
familySrc: $r('app.string.mediumFamilySrc')
})
// familySrc支持RawFile
font.registerFont({
familyName: 'mediumRawFile',
familySrc: $rawfile('font/medium.ttf')
})
}
build() {
......@@ -62,7 +75,7 @@ struct FontExample {
Text(this.message)
.align(Alignment.Center)
.fontSize(20)
.fontFamily('medium') // medium:注册自定义字体的名字
.fontFamily('medium') // medium:注册自定义字体的名字($r('app.string.mediumFamilyName')、'mediumRawFile'等已注册字体也能正常使用)
.height('100%')
}.width('100%')
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册