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