@expo-oh/expo-font 14.0.12 → 14.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -28
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,51 +1,89 @@
|
|
|
1
1
|
# @expo-oh/expo-font
|
|
2
2
|
|
|
3
|
-
HarmonyOS
|
|
3
|
+
Expo Font 的 HarmonyOS 适配版本,通过 RNOH 字体注册接口加载字体,并用于 React Native 文本渲染。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
上游基线:`expo-font@14.0.12`。本包由 [expo-harmony-cli](https://github.com/stonehill-2345/expo-harmony-cli) 项目维护,非 Expo 官方发行版本。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[鸿蒙快速开始](https://github.com/stonehill-2345/expo-harmony-cli/blob/main/docs/harmony/getting-started.md) · [适配源码](https://github.com/stonehill-2345/expo-harmony-cli/tree/main/packages/expo-font) · [验收记录](https://github.com/stonehill-2345/expo-harmony-cli/blob/main/docs/releases/2026-10-09-sdk54-expo-oh-candidate.md) · [问题反馈](https://github.com/stonehill-2345/expo-harmony-cli/issues)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## 安装
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
<a href="https://docs.expo.dev/versions/latest/sdk/font/">
|
|
13
|
-
<img
|
|
14
|
-
src="../../.github/resources/expo-font.svg"
|
|
15
|
-
alt="expo-font"
|
|
16
|
-
height="64" />
|
|
17
|
-
</a>
|
|
18
|
-
</p>
|
|
11
|
+
以下命令适用于已经配置好 `@expo-oh` SDK54 依赖组合的项目。普通 Expo 项目请先阅读[鸿蒙快速开始](https://github.com/stonehill-2345/expo-harmony-cli/blob/main/docs/harmony/getting-started.md);仅安装此包不会自动完成 RNOH 和原生工程配置。
|
|
19
12
|
|
|
20
|
-
|
|
13
|
+
```bash
|
|
14
|
+
# npm
|
|
15
|
+
npm install --save-exact expo-font@npm:@expo-oh/expo-font@14.0.13
|
|
21
16
|
|
|
22
|
-
#
|
|
17
|
+
# pnpm
|
|
18
|
+
pnpm add --save-exact expo-font@npm:@expo-oh/expo-font@14.0.13
|
|
19
|
+
```
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
- [Documentation for the main branch](https://docs.expo.dev/versions/unversioned/sdk/font/)
|
|
21
|
+
保留原依赖键:
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"expo-font": "npm:@expo-oh/expo-font@14.0.13"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
本包的鸿蒙适配已包含在 npm 产物中,无需额外应用本包的本地 patch。使用完整依赖组合及 overrides,保留锁文件;不要混装另一组 SDK 版本。
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
## 使用方式
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
将有效 TTF 字体放入 `assets/fonts/Example.ttf`:
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
```tsx
|
|
38
|
+
import { useFonts } from "expo-font";
|
|
39
|
+
import { Text } from "react-native";
|
|
36
40
|
|
|
41
|
+
export default function App() {
|
|
42
|
+
const [loaded, error] = useFonts({
|
|
43
|
+
Example: require("./assets/fonts/Example.ttf"),
|
|
44
|
+
});
|
|
45
|
+
if (error) return <Text>{error.message}</Text>;
|
|
46
|
+
if (!loaded) return null;
|
|
47
|
+
return <Text style={{ fontFamily: "Example" }}>鸿蒙字体示例</Text>;
|
|
48
|
+
}
|
|
37
49
|
```
|
|
38
|
-
|
|
50
|
+
|
|
51
|
+
也可使用 `loadAsync`。资源先由 Asset 解析为本地文件,再交给原生字体加载器。
|
|
52
|
+
|
|
53
|
+
## 鸿蒙支持范围
|
|
54
|
+
|
|
55
|
+
| 能力 | HarmonyOS 实现与限制 |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| 运行时字体加载 | 校验非空本地 file:// 文件、TTF/OTF 头和表目录后注册字体 |
|
|
58
|
+
| getLoadedFonts / isLoaded | 成功注册后才能报告加载完成 |
|
|
59
|
+
| 字体集合 TTC | 当前不支持 ttcf 字体集合 |
|
|
60
|
+
| renderToImageAsync | 当前 Harmony 后端未实现 |
|
|
61
|
+
| Web 卸载接口 | 不作为 Harmony 能力提供 |
|
|
62
|
+
| 静态字体插件 | 本文示例采用运行时加载,不承诺上游 config plugin 的字体嵌入流程在鸿蒙等价可用 |
|
|
63
|
+
|
|
64
|
+
## 生成和运行原生工程
|
|
65
|
+
|
|
66
|
+
从已配置项目根目录执行:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx expo prebuild --platform harmony
|
|
70
|
+
npx expo run:harmony
|
|
39
71
|
```
|
|
40
72
|
|
|
41
|
-
|
|
73
|
+
日常开发启动 Metro:`npx expo start`。安装或更新原生依赖、应用配置后,需要重新生成并构建;重启 Metro 不能替代原生构建。
|
|
74
|
+
|
|
75
|
+
兼容基线为 Expo SDK54、React 19.1.1、React Native 0.82.1、RNOH 0.82.30。设备、DevEco、签名要求见[快速开始](https://github.com/stonehill-2345/expo-harmony-cli/blob/main/docs/harmony/getting-started.md)。普通 Expo Go 不能作为本组合的鸿蒙运行容器。
|
|
42
76
|
|
|
43
|
-
|
|
77
|
+
## 排查与反馈
|
|
44
78
|
|
|
45
|
-
|
|
79
|
+
- 安装后版本或功能不符:检查 package.json alias、overrides 和锁文件,使用 `npx expo install --check` 核对受管组合。
|
|
80
|
+
- 原生模块缺失或更新无效:确认使用同组合的 Core/Autolinking,重新 prebuild、构建并安装。
|
|
81
|
+
- 旧 patch 项目不会自动迁移;保留原项目,按指南新建项目后迁移业务代码,不叠加旧补丁。
|
|
46
82
|
|
|
47
|
-
|
|
83
|
+
请在[本仓库 Issues](https://github.com/stonehill-2345/expo-harmony-cli/issues) 提供包版本、RNOH/系统版本、设备类型、最小复现及日志。已记录的模板运行结果不代表全部 API 或所有设备均已验证。
|
|
48
84
|
|
|
49
|
-
|
|
85
|
+
## 上游与许可证
|
|
50
86
|
|
|
51
|
-
|
|
87
|
+
- [上游参考](https://docs.expo.dev/versions/v54.0.0/sdk/font/):用于通用 API 或原始包说明;HarmonyOS 支持以本文为准。
|
|
88
|
+
- 原始来源:[Expo 源码](https://github.com/expo/expo/tree/main/packages/expo-font)。
|
|
89
|
+
- 保留上游许可证和来源声明,详见包内 `LICENSE`。遵循 Expo 上游 MIT 许可证。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo-oh/expo-font",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Load fonts at runtime and use them in React Native components.",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"author": "650 Industries, Inc.",
|
|
43
43
|
"license": "MIT",
|
|
44
|
-
"homepage": "https://github.com/stonehill-2345/expo-harmony-cli
|
|
44
|
+
"homepage": "https://github.com/stonehill-2345/expo-harmony-cli/blob/main/packages/expo-font/README.md",
|
|
45
45
|
"jest": {
|
|
46
46
|
"preset": "expo-module-scripts"
|
|
47
47
|
},
|