mirror of
https://github.com/YuleBest/FontMM.git
synced 2026-12-04 03:11:48 +08:00
feat(emoji): 新增 Emoji 字体槽位 (emoji.ttf → FontMM-Emoji.ttf)
- fonts.xml und-Zsye 家族优先引用 FontMM-Emoji.ttf, 未设置时回退系统默认 - apply.sh 新增 emoji 复制/删除逻辑 (独立文件方案, 不覆盖补充字库) - WebUI 新增「Emoji 表情」槽位 (types/main/占位文案/应用/加载) - dev mock 补 emoji 假数据 - README 更新五槽位映射与回退规则
This commit is contained in:
1 parent
98c652e509
commit
ee5f8f6cec
11 files changed
+55
-15
No files matched your search
@@ -9,7 +9,7 @@ FontMM 是一个用于在 ColorOS 设备上一键更换系统字体的 **Magisk
|
||||
## 特性
|
||||
|
||||
- **内置 WebUI**:Material Design 3 风格的管理界面,在 KernelSU 管理器(或支持 WebUI 的 Root 管理器)中直接打开
|
||||
- **三槽位字体**:中文简体 / 中文繁体 / 英文与数字分别独立设置,另支持等宽字体
|
||||
- **五槽位字体**:中文简体 / 中文繁体 / 英文与数字 / 等宽 / Emoji 分别独立设置
|
||||
- **智能回退**:繁体、英文未设置时自动回退到简体
|
||||
- **可视化文件选择器**:浏览设备目录、仅显示 `.ttf` 文件
|
||||
- **安装自检**:刷入时自动校验 ColorOS 版本、KernelSU 元模块、FontLoader 版本
|
||||
@@ -41,7 +41,7 @@ FontMM 是一个用于在 ColorOS 设备上一键更换系统字体的 **Magisk
|
||||
选择建议:
|
||||
|
||||
- **首次安装**:用 `_preplace` 版,开箱即用;如果用 `_template` 版,刷入后需先在 WebUI 设置简体字体,否则 `apply.sh` 会因缺少 `hans.ttf` 报错。
|
||||
- **更新已安装的模块**:用 `_template` 版——更新模式会从旧模块的 `FONTS/` 目录继承 `hans.ttf` / `hant.ttf` / `en.ttf` / `mono.ttf`,无需重新设置字体,也不浪费下载预置字体。
|
||||
- **更新已安装的模块**:用 `_template` 版——更新模式会从旧模块的 `FONTS/` 目录继承 `hans.ttf` / `hant.ttf` / `en.ttf` / `mono.ttf` / `emoji.ttf`,无需重新设置字体,也不浪费下载预置字体。
|
||||
- 在线更新(KernelSU 管理器检测到新版本时)走 `update.json`,其 `zipUrl` 指向 `_template` 版,行为同上。
|
||||
|
||||
### 安装步骤
|
||||
@@ -61,6 +61,7 @@ FontMM 是一个用于在 ColorOS 设备上一键更换系统字体的 **Magisk
|
||||
- **中文繁体**——可选,未选择时自动使用简体
|
||||
- **英文 & 数字**——可选,未选择时自动使用简体
|
||||
- **等宽字体**——可选,未选择时不覆盖系统等宽字体
|
||||
- **Emoji 表情**——可选,未选择时使用系统默认 Emoji
|
||||
3. 点击「应用字体」,弹窗展示完整应用日志
|
||||
4. **重启设备**后生效
|
||||
|
||||
@@ -71,21 +72,23 @@ FontMM 是一个用于在 ColorOS 设备上一键更换系统字体的 **Magisk
|
||||
- `hant.ttf`——中文繁体(可选)
|
||||
- `en.ttf`——英文与数字(可选)
|
||||
- `mono.ttf`——等宽字体(可选)
|
||||
- `emoji.ttf`——Emoji 表情(可选)
|
||||
2. 在 Root 管理器中点击本模块的「执行」(Action),或执行 `sh /data/adb/modules/FontMM/apply.sh`
|
||||
3. 重启设备
|
||||
|
||||
## 字体映射
|
||||
|
||||
模块把 4 个用户字体槽位映射到 ColorOS 的系统字体文件:
|
||||
模块把 5 个用户字体槽位映射到 ColorOS 的系统字体文件:
|
||||
|
||||
| 槽位 | 用户文件 | 覆盖的系统字体文件 |
|
||||
| ----------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 中文简体 | `FONTS/hans.ttf` | `SysSans-Hans-Regular.ttf`、`SysFont-Static-Regular.ttf`、`SysFont-Myanmar.ttf`、`SysFont-Hans-Regular.ttf`、`SysFont-Regular.ttf` |
|
||||
| 中文繁体 | `FONTS/hant.ttf` | `SysSans-Hant-Regular.ttf`、`SysFont-Hant-Regular.ttf` |
|
||||
| 英文 & 数字 | `FONTS/en.ttf` | `SysSans-En-Regular.ttf` |
|
||||
| 等宽字体 | `FONTS/mono.ttf` | `FontMM-Mono.ttf`(monospace 家族优先引用;未设置时不存在,自动使用系统 `DroidSansMono`) |
|
||||
| 槽位 | 用户文件 | 覆盖的系统字体文件 |
|
||||
| ----------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 中文简体 | `FONTS/hans.ttf` | `SysSans-Hans-Regular.ttf`、`SysFont-Static-Regular.ttf`、`SysFont-Myanmar.ttf`、`SysFont-Hans-Regular.ttf`、`SysFont-Regular.ttf` |
|
||||
| 中文繁体 | `FONTS/hant.ttf` | `SysSans-Hant-Regular.ttf`、`SysFont-Hant-Regular.ttf` |
|
||||
| 英文 & 数字 | `FONTS/en.ttf` | `SysSans-En-Regular.ttf` |
|
||||
| 等宽字体 | `FONTS/mono.ttf` | `FontMM-Mono.ttf`(monospace 家族优先引用;未设置时不存在,自动使用系统 `DroidSansMono`) |
|
||||
| Emoji 表情 | `FONTS/emoji.ttf` | `FontMM-Emoji.ttf`(und-Zsye 家族优先引用;未设置时不存在,自动使用系统默认 Emoji) |
|
||||
|
||||
**回退规则**:`hant.ttf` / `en.ttf` 缺失时对应槽位自动使用 `hans.ttf`;`hans.ttf` 缺失时 `apply.sh` 直接报错退出(WebUI 也会禁用「应用」按钮)。`mono.ttf` 未设置时**不覆盖**系统等宽字体(`FontMM-Mono.ttf` 不存在,monospace 家族自动回退系统 `DroidSansMono`)。
|
||||
**回退规则**:`hant.ttf` / `en.ttf` 缺失时对应槽位自动使用 `hans.ttf`;`hans.ttf` 缺失时 `apply.sh` 直接报错退出(WebUI 也会禁用「应用」按钮)。`mono.ttf` 未设置时**不覆盖**系统等宽字体(`FontMM-Mono.ttf` 不存在,monospace 家族自动回退系统 `DroidSansMono`)。`emoji.ttf` 未设置时**不覆盖**系统 Emoji(`FontMM-Emoji.ttf` 不存在,und-Zsye 家族自动回退系统默认 `NotoColorEmoji`)。
|
||||
|
||||
> 注意:等宽字体若不含中文字形,等宽区域的中文会按系统机制回退到中文字体(属正常 fallback)。如需等宽中文,请使用含中文字形的等宽字体(如 Sarasa、Maple Mono 等)。
|
||||
|
||||
@@ -247,7 +250,7 @@ A:KernelSU ≥ 3.0.0 需要先安装元模块(`/data/adb/metamodule/module.p
|
||||
|
||||
**Q:更新模块会丢失我设置好的字体吗?**
|
||||
|
||||
A:不会。`customize.sh` 检测到已安装的 FontMM 时会进入更新模式,从旧模块的 `FONTS/` 目录继承 `hans.ttf` / `hant.ttf` / `en.ttf` / `mono.ttf`。
|
||||
A:不会。`customize.sh` 检测到已安装的 FontMM 时会进入更新模式,从旧模块的 `FONTS/` 目录继承 `hans.ttf` / `hant.ttf` / `en.ttf` / `mono.ttf` / `emoji.ttf`。
|
||||
|
||||
**Q:`system/fonts/` 里的字体文件为什么是 0 字节?**
|
||||
|
||||
|
||||
@@ -64,4 +64,13 @@ else
|
||||
rm -f "$SYS_FONT_DIR/FontMM-Mono.ttf"
|
||||
fi
|
||||
|
||||
echo "[*] 处理 Emoji 字体..."
|
||||
if [ -f "$FONTS_DIR/emoji.ttf" ]; then
|
||||
# 复制为模块独立文件 FontMM-Emoji.ttf (und-Zsye family 优先引用, 不覆盖补充字库 NotoColorEmoji)
|
||||
install_from "$FONTS_DIR/emoji.ttf" 'FontMM-Emoji.ttf'
|
||||
else
|
||||
echo "[-] 未设置 Emoji 字体, 使用系统默认"
|
||||
rm -f "$SYS_FONT_DIR/FontMM-Emoji.ttf"
|
||||
fi
|
||||
|
||||
echo "[*] 全部完成, 重启后生效"
|
||||
@@ -1593,6 +1593,8 @@
|
||||
<font weight="400" style="normal">NotoColorEmojiLegacy.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
<!-- 用户 Emoji 字体 (模块新建, 未设置时不存在则用补充字库 NotoColorEmoji 兜底) -->
|
||||
<font weight="400" style="normal">FontMM-Emoji.ttf</font>
|
||||
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
|
||||
@@ -1593,6 +1593,8 @@
|
||||
<font weight="400" style="normal">NotoColorEmojiLegacy.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
<!-- 用户 Emoji 字体 (模块新建, 未设置时不存在则用补充字库 NotoColorEmoji 兜底) -->
|
||||
<font weight="400" style="normal">FontMM-Emoji.ttf</font>
|
||||
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
|
||||
@@ -1593,6 +1593,8 @@
|
||||
<font weight="400" style="normal">NotoColorEmojiLegacy.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
<!-- 用户 Emoji 字体 (模块新建, 未设置时不存在则用补充字库 NotoColorEmoji 兜底) -->
|
||||
<font weight="400" style="normal">FontMM-Emoji.ttf</font>
|
||||
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
|
||||
@@ -1593,6 +1593,8 @@
|
||||
<font weight="400" style="normal">NotoColorEmojiLegacy.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
<!-- 用户 Emoji 字体 (模块新建, 未设置时不存在则用补充字库 NotoColorEmoji 兜底) -->
|
||||
<font weight="400" style="normal">FontMM-Emoji.ttf</font>
|
||||
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
|
||||
@@ -1593,6 +1593,8 @@
|
||||
<font weight="400" style="normal">NotoColorEmojiLegacy.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
<!-- 用户 Emoji 字体 (模块新建, 未设置时不存在则用补充字库 NotoColorEmoji 兜底) -->
|
||||
<font weight="400" style="normal">FontMM-Emoji.ttf</font>
|
||||
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
|
||||
@@ -1593,6 +1593,8 @@
|
||||
<font weight="400" style="normal">NotoColorEmojiLegacy.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
<!-- 用户 Emoji 字体 (模块新建, 未设置时不存在则用补充字库 NotoColorEmoji 兜底) -->
|
||||
<font weight="400" style="normal">FontMM-Emoji.ttf</font>
|
||||
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
|
||||
</family>
|
||||
<family lang="und-Zsye">
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ async function mockExec(command: string): Promise<ExecResult> {
|
||||
|
||||
// 字体测试: 模拟 FONT 字体已放入 webroot/fonts-test, 返回可用字体列表
|
||||
if (command.includes('fonts-test')) {
|
||||
return slow('hans.ttf\nhant.ttf\nen.ttf\nmono.ttf');
|
||||
return slow('hans.ttf\nhant.ttf\nen.ttf\nmono.ttf\nemoji.ttf');
|
||||
}
|
||||
|
||||
if (command.includes('rm -f')) return fake('');
|
||||
|
||||
+18
-2
@@ -25,7 +25,7 @@ enableEdgeToEdge(true);
|
||||
|
||||
const FONTS_DIR = '/data/adb/modules/FontMM/FONTS';
|
||||
|
||||
const slots: Record<'hans' | 'hant' | 'en' | 'mono', FontSlot> = {
|
||||
const slots: Record<'hans' | 'hant' | 'en' | 'mono' | 'emoji', FontSlot> = {
|
||||
hans: {
|
||||
key: 'hans',
|
||||
title: '中文简体',
|
||||
@@ -50,6 +50,12 @@ const slots: Record<'hans' | 'hant' | 'en' | 'mono', FontSlot> = {
|
||||
path: null,
|
||||
fileName: '',
|
||||
},
|
||||
emoji: {
|
||||
key: 'emoji',
|
||||
title: 'Emoji 表情',
|
||||
path: null,
|
||||
fileName: '',
|
||||
},
|
||||
};
|
||||
|
||||
const slotsEl = document.getElementById('slots')!;
|
||||
@@ -99,6 +105,7 @@ async function readFontInfo(
|
||||
'hant.ttf': { name: '源樣明體', size: '21.2 MB', variable: false },
|
||||
'en.ttf': { name: 'Inter Variable', size: '0.8 MB', variable: true },
|
||||
'mono.ttf': { name: 'JetBrains Mono', size: '1.2 MB', variable: false },
|
||||
'emoji.ttf': { name: 'Noto Color Emoji', size: '9.8 MB', variable: false },
|
||||
};
|
||||
const mock = MOCK_FONT_INFO[file];
|
||||
return mock ? { name: mock.name, sizeText: mock.size, isVariable: mock.variable } : {};
|
||||
@@ -135,7 +142,7 @@ async function refreshSlotInfo(slot: FontSlot) {
|
||||
// 打开 WebUI 时: 复制 FONT/ 到 fonts-test, 读取已有字体的名称/大小填充卡片
|
||||
async function loadExistingFonts() {
|
||||
const available = await ensureFontsCopy();
|
||||
for (const key of ['hans', 'hant', 'en', 'mono'] as const) {
|
||||
for (const key of ['hans', 'hant', 'en', 'mono', 'emoji'] as const) {
|
||||
const file = `${key}.ttf`;
|
||||
if (!available.includes(file)) continue;
|
||||
const slot = slots[key];
|
||||
@@ -154,6 +161,7 @@ function slotPlaceholder(slot: FontSlot): string {
|
||||
if (slot.key === 'hans') return '未选择字体文件';
|
||||
if (slots.hans.path) {
|
||||
if (slot.key === 'mono') return '未选择,保持系统等宽字体';
|
||||
if (slot.key === 'emoji') return '未选择,保持系统 Emoji';
|
||||
return `默认使用:${slots.hans.fileName}`;
|
||||
}
|
||||
return '未选择字体文件';
|
||||
@@ -264,6 +272,14 @@ async function apply() {
|
||||
await exec(`rm -f '${FONTS_DIR}/mono.ttf'`);
|
||||
}
|
||||
|
||||
if (slots.emoji.path) {
|
||||
if (slots.emoji.path !== `${FONTS_DIR}/emoji.ttf`) {
|
||||
await copyFont(slots.emoji.path, `${FONTS_DIR}/emoji.ttf`);
|
||||
}
|
||||
} else {
|
||||
await exec(`rm -f '${FONTS_DIR}/emoji.ttf'`);
|
||||
}
|
||||
|
||||
const { errno, stdout, stderr } = await exec('sh /data/adb/modules/FontMM/apply.sh');
|
||||
if (errno !== 0) throw new Error(stderr || 'apply.sh 执行失败');
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
export interface FontSlot {
|
||||
key: 'hans' | 'hant' | 'en' | 'mono';
|
||||
key: 'hans' | 'hant' | 'en' | 'mono' | 'emoji';
|
||||
title: string;
|
||||
path: string | null;
|
||||
fileName: string;
|
||||
|
||||
Reference in new issue
Block a user