OpenHarmony开发者论坛
标题:
Cannot read property registerFont of undefined 无法注册字体
[打印本页]
作者:
xie
时间:
2024-1-30 13:57
标题:
Cannot read property registerFont of undefined 无法注册字体
[md]Js-Engine: ark
page: pages/DeviceHpPage.js
Error message: Cannot read property registerFont of undefined
SourceCode:
font.registerFont({
^
[/md]
作者:
xie
时间:
2024-1-30 13:59
harmony 4.0 api9
源码:
import font from '@ohos.font';
@Entry
@Component
struct DeviceHpPage {
@State message: string = 'Device Hp'
aboutToAppear(){
font.registerFont({
familyName: 'medium',
familySrc: '/font/Blender Pro Bold.ttf'
})
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.fontFamily("medium")
}
.width('100%')
}
.height('100%')
}
}
作者:
hyacinth养花人
时间:
2024-2-2 11:50
很久以前的版本是有这个问题的,我用最近的版本没复现,建议更新环境和镜像版本。
欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/)
Powered by Discuz! X3.5