mirror of
https://github.com/YuleBest/FontMM.git
synced 2026-12-04 03:11:48 +08:00
Compare commits
53
Commits
No files matched your search
@@ -1 +0,0 @@
|
||||
template/*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
@@ -0,0 +1,40 @@
|
||||
name: Build & Upload Artifacts
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 11
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
cache-dependency-path: web/pnpm-lock.yaml
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm -C web install --frozen-lockfile
|
||||
|
||||
- name: Build WebUI
|
||||
run: pnpm -C web build
|
||||
|
||||
- name: Pack module (preplace / template)
|
||||
run: bash dev/cd.sh
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fontmm-build
|
||||
path: dist/*.zip
|
||||
retention-days: 14
|
||||
@@ -1,50 +0,0 @@
|
||||
name: Release Package & Attach
|
||||
|
||||
# 触发条件:当发布(published)一个 Release 时
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
upload-assets:
|
||||
runs-on: ubuntu-latest
|
||||
# 授予写入 Release 内容的权限
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
# 1. 拉取代码并包含 LFS
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
|
||||
- name: Pull LFS objects
|
||||
run: git lfs pull
|
||||
|
||||
# 2. 准备打包环境并压缩
|
||||
- name: Cleanup and Zip
|
||||
id: pack
|
||||
run: |
|
||||
# 删除 .gitattributes
|
||||
rm -f .gitattributes
|
||||
|
||||
# 获取当前 Release 的 Tag 名字 (比如 V1.1)
|
||||
TAG_NAME="${{ github.event.release.tag_name }}"
|
||||
# 按照你的要求命名:FontMM-[Tag]-release.zip
|
||||
FILENAME="FontMM-${TAG_NAME}-release.zip"
|
||||
|
||||
# 执行最高压缩
|
||||
zip -r -9 "$FILENAME" . -x "*.git*" ".github*"
|
||||
|
||||
# 存入环境变量供下一步引用
|
||||
echo "ZIP_PATH=$FILENAME" >> $GITHUB_ENV
|
||||
|
||||
# 3. 将打包好的文件上传到当前的 Release 页面
|
||||
- name: Upload Release Asset
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
# files 指向刚才生成的压缩包路径
|
||||
files: ${{ env.ZIP_PATH }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,42 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 11
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
cache-dependency-path: web/pnpm-lock.yaml
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm -C web install --frozen-lockfile
|
||||
|
||||
- name: Build WebUI
|
||||
run: pnpm -C web build
|
||||
|
||||
- name: Pack module (preplace / template)
|
||||
run: bash dev/cd.sh
|
||||
|
||||
- name: Upload release assets
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: dist/*.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,9 @@
|
||||
node_modules/
|
||||
web/node_modules/
|
||||
dist/
|
||||
src/webroot/
|
||||
reasonix.toml
|
||||
.reasonix/
|
||||
.agent/
|
||||
|
||||
.ref/
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["oxc.oxc-vscode"]
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
// 官方推荐: https://oxc.rs/docs/guide/usage/linter/editors.html
|
||||
// https://oxc.rs/docs/guide/usage/formatter/editors.html
|
||||
// 使用 Oxc 扩展 (oxlint --lsp / oxfmt --lsp), 需本地安装 oxlint 与 oxfmt
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.oxc": "always"
|
||||
},
|
||||
// 显式指定 JavaScript/TypeScript 由 oxfmt 格式化
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode"
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Yule
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,264 @@
|
||||
# FontMM
|
||||
|
||||
FontMM 是一个用于在 ColorOS 设备上一键更换系统字体的 **Magisk / KernelSU 模块**,内置 WebUI 字体管理界面。
|
||||
|
||||
只需在 WebUI 中挑选一个 `.ttf` 字体文件,点一下「应用字体」,重启即可生效——不需要在电脑上手动解压、改名、打包模块。
|
||||
|
||||
> 当前为 v26 架构(WebUI + 统一 `apply.sh` 安装逻辑),旧版 v1.x 的「解压模板 → 放入 ttf → 运行打包脚本」流程已被取代。
|
||||
|
||||
## 特性
|
||||
|
||||
- **内置 WebUI**:Material Design 3 风格的管理界面,在 KernelSU 管理器(或支持 WebUI 的 Root 管理器)中直接打开
|
||||
- **三槽位字体**:中文简体 / 中文繁体 / 英文与数字分别独立设置,另支持等宽字体
|
||||
- **智能回退**:繁体、英文未设置时自动回退到简体
|
||||
- **可视化文件选择器**:浏览设备目录、仅显示 `.ttf` 文件
|
||||
- **安装自检**:刷入时自动校验 ColorOS 版本、KernelSU 元模块、FontLoader 版本
|
||||
- **更新模式**:覆盖安装/更新模块时自动继承旧版模块中已设置的字体
|
||||
- **补充字库**:内置 OFL/MIT 许可字体,兜底 CJK 扩展区、最新 Unicode 字符与小篆(Seal)等罕见字形
|
||||
|
||||
## 支持环境
|
||||
|
||||
| 项目 | 要求 |
|
||||
| --------- | ----------------------------------------------------------------------------------------- |
|
||||
| 系统 | ColorOS 16.0+(检测 `ro.build.version.oplus.api` 与 `ro.build.version.oplusrom.display`) |
|
||||
| Root 环境 | Magisk 20.4+ / KernelSU(KernelSU ≥ 3.0.0 需先安装元模块) |
|
||||
| 推荐组件 | [FontLoader](https://github.com/KernelSU-Modules-Repo/fontloader) v1.2.3+(提升字体显示) |
|
||||
| 字体格式 | `.ttf`(支持可变字体) |
|
||||
|
||||
> 非 ColorOS 系统、ColorOS 版本低于 16 的设备会在安装时被 `customize.sh` 直接拒绝。
|
||||
|
||||
## 安装
|
||||
|
||||
### 选择版本
|
||||
|
||||
每个 Release 提供两个压缩包,区别仅在是否预置字体:
|
||||
|
||||
| 版本 | FONT 目录 | 适用场景 |
|
||||
| ----------------------- | ------------------------------------------ | --------------------------------------------------------------------------- |
|
||||
| `FontMM_*_preplace.zip` | 含预置简体字体 `FONTS/hans.ttf`(约 20MB) | **全新安装**:刷入后立即可用默认字体,随后可再在 WebUI 更换 |
|
||||
| `FontMM_*_template.zip` | `FONTS/` 为空目录(约 3MB) | **更新已有模块**:`customize.sh` 会自动从旧模块继承已设置的字体,包体积更小 |
|
||||
|
||||
选择建议:
|
||||
|
||||
- **首次安装**:用 `_preplace` 版,开箱即用;如果用 `_template` 版,刷入后需先在 WebUI 设置简体字体,否则 `apply.sh` 会因缺少 `hans.ttf` 报错。
|
||||
- **更新已安装的模块**:用 `_template` 版——更新模式会从旧模块的 `FONTS/` 目录继承 `hans.ttf` / `hant.ttf` / `en.ttf` / `mono.ttf`,无需重新设置字体,也不浪费下载预置字体。
|
||||
- 在线更新(KernelSU 管理器检测到新版本时)走 `update.json`,其 `zipUrl` 指向 `_template` 版,行为同上。
|
||||
|
||||
### 安装步骤
|
||||
|
||||
1. 按上述说明下载对应版本(`FontMM_v*.zip`)
|
||||
2. 在 KernelSU / Magisk 管理器中刷入该 zip(无需解压)
|
||||
3. 安装脚本自动完成系统检查与字体安装,日志会给出「成功 / 失败原因」
|
||||
4. **重启设备**
|
||||
|
||||
## 使用
|
||||
|
||||
### 通过 WebUI 更换字体
|
||||
|
||||
1. 打开 KernelSU 管理器,进入 FontMM 模块,点击「打开 WebUI」
|
||||
2. 在槽位中分别选择字体:
|
||||
- **中文简体**——必选
|
||||
- **中文繁体**——可选,未选择时自动使用简体
|
||||
- **英文 & 数字**——可选,未选择时自动使用简体
|
||||
- **等宽字体**——可选,未选择时不覆盖系统等宽字体
|
||||
3. 点击「应用字体」,弹窗展示完整应用日志
|
||||
4. **重启设备**后生效
|
||||
|
||||
### 手动放置字体(可选)
|
||||
|
||||
1. 把字体放入 `/data/adb/modules/FontMM/FONTS/`,命名规则:
|
||||
- `hans.ttf`——中文简体(必选)
|
||||
- `hant.ttf`——中文繁体(可选)
|
||||
- `en.ttf`——英文与数字(可选)
|
||||
- `mono.ttf`——等宽字体(可选)
|
||||
2. 在 Root 管理器中点击本模块的「执行」(Action),或执行 `sh /data/adb/modules/FontMM/apply.sh`
|
||||
3. 重启设备
|
||||
|
||||
## 字体映射
|
||||
|
||||
模块把 4 个用户字体槽位映射到 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`) |
|
||||
|
||||
**回退规则**:`hant.ttf` / `en.ttf` 缺失时对应槽位自动使用 `hans.ttf`;`hans.ttf` 缺失时 `apply.sh` 直接报错退出(WebUI 也会禁用「应用」按钮)。`mono.ttf` 未设置时**不覆盖**系统等宽字体(`FontMM-Mono.ttf` 不存在,monospace 家族自动回退系统 `DroidSansMono`)。
|
||||
|
||||
> 注意:等宽字体若不含中文字形,等宽区域的中文会按系统机制回退到中文字体(属正常 fallback)。如需等宽中文,请使用含中文字形的等宽字体(如 Sarasa、Maple Mono 等)。
|
||||
|
||||
### 补充字库
|
||||
|
||||
模块内置一组补充字体(OFL-1.1 / MIT 许可),作为 `fonts.xml` 末尾的全局 fallback,兜底用户字体与系统字体未覆盖的字形(CJK 扩展区生僻字、最新 Unicode 字符、小篆等):
|
||||
|
||||
| 字体 | 说明 |
|
||||
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `PlangothicP1/P2.ttf` | CJK 扩展区覆盖(Ext-B、G/H、**I、J** 等生僻字与新汉字) |
|
||||
| `PlanschriftSeal-Regular.ttf` | **Seal(小篆)区块 11328 字符全覆盖**(Unicode 18 新增,子集化 34M;MIT/OFL 双许可,源自 [Planschrift_Project](https://github.com/Fitzgerald-Porthmouth-Koenigsegg/Planschrift_Project)) |
|
||||
| `NotoSansPro.otf` | 多 Noto 家族合并,覆盖广泛语言字形 |
|
||||
| `Unicode16/17/18-new.ttf` | Unicode 最新版本已定义字符覆盖 |
|
||||
| `ZUno-Number.ttf` | 保留符号 / 私用区未定义符号显示编码信息 |
|
||||
|
||||
补充字库不参与用户槽位替换(`SysFont*` / `SysSans*` 槽位规则不变),仅在缺字形时按顺序兜底。字体来源与许可详见模块内 `system/fonts/LICENSE-*` 及 [MakeFontsGreatAgain](https://github.com/Numbersf/MakeFontsGreatAgain) 的 LICENSES。
|
||||
|
||||
## 工作原理
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ KernelSU 管理器 │
|
||||
│ ┌──────────────────────────────┐ │
|
||||
│ │ WebUI (web/ 构建产物) │ ksu.exec / toast │
|
||||
│ └──────────────┬───────────────┘ │
|
||||
└───────────────────┼──────────────────────────────────────┘
|
||||
│ sh /data/adb/modules/FontMM/apply.sh
|
||||
▼
|
||||
┌───────────────────────┐ cp -f ┌──────────────────────┐
|
||||
│ FONTS/ 用户字体 │ ──────────► │ system/fonts/ │
|
||||
│ hans.ttf │ │ SysFont/SysSans 等 │
|
||||
│ hant.ttf (可选) │ └──────────────────────┘
|
||||
│ en.ttf (可选) │
|
||||
└───────────────────────┘
|
||||
```
|
||||
|
||||
1. **安装阶段**(`customize.sh`):系统检查(ColorOS 版本、KernelSU 元模块、FontLoader)→ 更新模式检测与旧字体继承 → 调用 `apply.sh` 完成首次字体安装。
|
||||
2. **换字体阶段**(WebUI):选择文件 → 复制到 `FONTS/` → 调用同一个 `apply.sh`,两条路径行为一致。
|
||||
3. **`apply.sh` 核心逻辑**:按字体映射表把 `FONTS/` 中的字体复制到 `system/fonts/` 的对应文件,缺繁体/英文时回退简体。
|
||||
4. **字体生效**:ColorOS 通过 `/system/etc/fonts.xml` 等配置引用 `SysFont*` / `SysSans*` 字体族——模块内嵌从 ColorOS 16 提取的配置(`fonts.xml` 为唯一源,开发阶段自动生成 `fonts_base.xml` / `fonts_ule.xml` / `font_fallback.xml`),替换字体文件即可全局生效。
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
FontMM/
|
||||
├── src/ # Magisk 模块源(打包时 zip 根 = 模块根)
|
||||
│ ├── module.prop # 模块元信息(id/version/updateJson)
|
||||
│ ├── customize.sh # 安装脚本:系统检查 + 更新模式 + 调用 apply.sh
|
||||
│ ├── apply.sh # 字体应用脚本(安装 & WebUI 共用)
|
||||
│ ├── FONTS/ # 用户字体目录(preplace 版含默认 hans.ttf)
|
||||
│ ├── META-INF/ # Magisk 安装入口(update-binary / updater-script)
|
||||
│ ├── system/
|
||||
│ │ ├── fonts/ # 字体槽位 + 补充字库(占位文件安装时被填充)
|
||||
│ │ └── etc/ # fonts.xml / fonts_base.xml / fonts_ule.xml / font_fallback.xml
|
||||
│ ├── system_ext/etc/ # system_ext 分区字体配置(fonts_base.xml / fonts_ule.xml)
|
||||
│ └── webroot/ # WebUI 构建产物(pnpm build 生成,不入库)
|
||||
├── web/ # WebUI 前端源码(Vite + TypeScript)
|
||||
│ ├── index.html
|
||||
│ ├── vite.config.ts # base './',产物输出到 ../src/webroot
|
||||
│ └── src/
|
||||
│ ├── main.ts # 主界面:字体槽位 + 应用 + 日志
|
||||
│ ├── fontPicker.ts # 字体文件选择器
|
||||
│ ├── ksu.ts # kernelsu API 封装(DEV 模式内置 mock)
|
||||
│ ├── theme.scss # Material Design 3 主题变量
|
||||
│ └── style.scss # 全局样式
|
||||
├── dev/ # 开发脚本
|
||||
│ ├── cd.sh # 打包模块 zip(preplace / template 两版)→ dist/
|
||||
│ ├── ci.sh # shellcheck + shfmt 检查
|
||||
│ ├── webzip.sh # 仅打包 WebUI 产物 → dist/webroot.zip
|
||||
│ ├── sync-fonts-xml.sh # 以 fonts.xml 为唯一源生成派生字体配置
|
||||
│ ├── check-unicode-coverage.py # 本地模拟字体 fallback, 统计 Unicode 区块覆盖
|
||||
│ └── empty_font.sh # 生成 0 字节占位字体
|
||||
├── package.json # pnpm workspace 根
|
||||
├── web/package.json # WebUI 依赖与脚本
|
||||
└── dist/ # 打包产物(构建时生成,不入库)
|
||||
```
|
||||
|
||||
## 开发指南
|
||||
|
||||
### 环境要求
|
||||
|
||||
- Node.js ≥ 18 + [pnpm](https://pnpm.io/)
|
||||
- `zip` / `unzip`(打包)
|
||||
- `shellcheck` + `shfmt`(仅 CI 检查需要)
|
||||
- Python 3 + fontTools(Unicode 覆盖测试)
|
||||
- Android 设备(Termux)或任意可运行 `ash` 的环境(验证 shell 脚本)
|
||||
|
||||
### 安装依赖
|
||||
|
||||
```bash
|
||||
pnpm install # 根 workspace(会联动安装 web/)
|
||||
```
|
||||
|
||||
### 本地预览 WebUI
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
`dev` 模式下 `ksu.ts` 使用内置 mock 文件系统,文件选择、槽位切换、应用字体全流程可脱离真机调试。
|
||||
|
||||
### 构建与打包
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
依次执行:
|
||||
|
||||
1. `vite build`——把 WebUI 构建到 `src/webroot/`(相对路径,适配本地 WebView 加载)
|
||||
2. `bash dev/cd.sh`——读取 `src/module.prop` 的 `version` 字段,打包出两个版本(zip 根 = 模块根):
|
||||
- `dist/FontMM_v{VERSION}_preplace.zip`——含预置字体 `FONTS/hans.ttf`
|
||||
- `dist/FontMM_v{VERSION}_template.zip`——`FONTS/` 为空目录
|
||||
|
||||
产物均校验内含 `module.prop`;template 版额外校验 `FONTS/` 下不含字体文件。打包前会自动同步派生字体 XML(`sync-fonts-xml.sh`)。
|
||||
|
||||
单独构建 WebUI 产物(调试用):
|
||||
|
||||
```bash
|
||||
pnpm build:only-web # 产出 dist/webroot.zip
|
||||
```
|
||||
|
||||
### 代码检查
|
||||
|
||||
```bash
|
||||
pnpm lint # 前端 oxlint 检查 (web/src)
|
||||
pnpm fmt # 前端 oxfmt 格式化
|
||||
pnpm fmt:check # 前端 oxfmt 格式检查
|
||||
bash dev/ci.sh # src/ 下所有 .sh 的 shellcheck + shfmt 检查
|
||||
```
|
||||
|
||||
前端 lint/format 由 [oxlint](https://oxc.rs/) 与 [oxfmt](https://oxc.rs/) 提供。
|
||||
|
||||
### Unicode 覆盖测试
|
||||
|
||||
```bash
|
||||
python3 dev/check-unicode-coverage.py # 全部区块
|
||||
python3 dev/check-unicode-coverage.py "Archaic" "Seal" # 只测指定区块
|
||||
```
|
||||
|
||||
本地模拟 `fonts.xml` 的 fallback 链(fontTools 读取 `src/system/fonts/` 各字体 cmap),对照 Unicode Blocks.txt 统计每个区块覆盖率(首次运行自动下载 Blocks.txt 缓存到 `dev/`)。
|
||||
|
||||
### 占位字体机制
|
||||
|
||||
`src/system/fonts/` 下的 `SysFont*` / `SysSans*` 是 **0 字节占位文件**,避免把大字体文件提交进仓库;安装或应用字体时由 `apply.sh` 用 `FONTS/` 里的真实字体覆盖。
|
||||
|
||||
- 开发时可用 `dev/empty_font.sh` 重新生成这些占位文件
|
||||
- `src/FONTS/hans.ttf` 是内置默认简体字体(仅 preplace 版打包)
|
||||
|
||||
## 常见问题
|
||||
|
||||
**Q:装完模块后字体没变?**
|
||||
|
||||
A:先重启设备;确认系统是 ColorOS 16+;建议安装 [FontLoader](https://github.com/KernelSU-Modules-Repo/fontloader)(v1.2.3+)。
|
||||
|
||||
**Q:KernelSU 3.0+ 装不上 / 报元模块错误?**
|
||||
|
||||
A:KernelSU ≥ 3.0.0 需要先安装元模块(`/data/adb/metamodule/module.prop`),安装日志会明确提示。
|
||||
|
||||
**Q:更新模块会丢失我设置好的字体吗?**
|
||||
|
||||
A:不会。`customize.sh` 检测到已安装的 FontMM 时会进入更新模式,从旧模块的 `FONTS/` 目录继承 `hans.ttf` / `hant.ttf` / `en.ttf` / `mono.ttf`。
|
||||
|
||||
**Q:`system/fonts/` 里的字体文件为什么是 0 字节?**
|
||||
|
||||
A:那是占位文件,安装或应用字体时会被真实字体覆盖(见「占位字体机制」)。
|
||||
|
||||
**Q:等宽字体设置了但不生效 / 显示成了简体字体?**
|
||||
|
||||
A:确认已重启;等宽字体不含中文字形时,等宽区域的中文会按系统机制回退到中文字体(正常行为),请使用含中文的等宽字体(Sarasa、Maple Mono 等)。
|
||||
|
||||
## 致谢
|
||||
|
||||
- 字体映射与配置文件参考 ColorOS 16 系统字体体系(`SysFont` / `SysSans` 字体族)
|
||||
- 补充字库与 `fonts.xml` fallback 结构参考 [MakeFontsGreatAgain](https://github.com/Numbersf/MakeFontsGreatAgain)(Unicode Latest 全覆盖思路)
|
||||
- WebUI 基于 [Material Web](https://github.com/material-components/material-web)(Material Design 3)与 [kernelsu](https://www.npmjs.com/package/kernelsu) SDK 构建
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
1. 修改 module.prop
|
||||
|
||||
2. 在 ttf 里面放入你的字体
|
||||
|
||||
ch.ttf -- 中文(简体)
|
||||
tc.ttf -- 中文(繁体)
|
||||
en.ttf -- 英文
|
||||
|
||||
你也可以只放入一个 ch.ttf
|
||||
这样的话,中文(繁体)和英文都会使用 ch.ttf
|
||||
|
||||
3. 运行 打包.sh
|
||||
@@ -0,0 +1,22 @@
|
||||
# Changelog
|
||||
|
||||
## v26.8.0-beta.2
|
||||
|
||||
- **补充字库**:内置 OFL-1.1 / MIT 许可字体,在 `fonts.xml` 末尾作为全局 fallback:
|
||||
- PlangothicP1/P2——CJK 扩展区覆盖(Ext-B、G/H、**I、J** 等生僻字与新汉字)
|
||||
- PlanschriftSeal——**Seal(小篆)区块 11328 字符 100% 覆盖**(Unicode 18 新增,子集化 34M,MIT/OFL 双许可)
|
||||
- ArchaicCuneiformNumerals、NotoUnicode、NotoColorEmoji、UnicodiaFunky、Unknown-symbol 等
|
||||
- **等宽字体修复**:改为独立文件 `FontMM-Mono.ttf`(monospace 家族优先引用),不再覆盖系统 `DroidSansMono`,解决设置等宽字体后不生效的问题
|
||||
- **单一源字体配置**:`fonts.xml` 为唯一源,`dev/sync-fonts-xml.sh` 自动生成 `fonts_base.xml` / `fonts_ule.xml` / `font_fallback.xml`
|
||||
- **Unicode 覆盖测试**:新增 `dev/check-unicode-coverage.py`,本地模拟 fallback 链统计各区块覆盖率
|
||||
- 致谢补充字库来源 [MakeFontsGreatAgain](https://github.com/Numbersf/MakeFontsGreatAgain)
|
||||
|
||||
## v26.8.0-beta.1
|
||||
|
||||
全新 v26 架构重构:
|
||||
|
||||
- **WebUI 重写**(Material Design 3 + 底部导航):字体槽位选择/应用、字体测试(字重 100–900、可变字体滑条、字号调节)、关于页、深色模式跟随系统、edge-to-edge 延伸至小白条
|
||||
- **字体名称解析**:打开 WebUI 时用 opentype.js 读取 FONT/ 内字体的真实名称并显示在卡片(如 OPPO Sans 4.0)
|
||||
- **双版本打包**:`_preplace`(含预置字体)与 `_template`(FONT 空目录)两版;新增 `build:only-web` 快速调试产物
|
||||
- **开发工具链**:oxlint / oxfmt / type-check / shellcheck 脚本化
|
||||
- 新增 MIT LICENSE
|
||||
+391
@@ -0,0 +1,391 @@
|
||||
# Blocks-18.0.0.txt
|
||||
# Date: 2026-02-03
|
||||
# © 2026 Unicode®, Inc.
|
||||
# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
|
||||
# For terms of use and license, see https://www.unicode.org/terms_of_use.html
|
||||
#
|
||||
# Unicode Character Database
|
||||
# For documentation, see https://www.unicode.org/reports/tr44/
|
||||
#
|
||||
# Format:
|
||||
# Start Code..End Code; Block Name
|
||||
|
||||
# ================================================
|
||||
|
||||
# Note: When comparing block names, casing, whitespace, hyphens,
|
||||
# and underbars are ignored.
|
||||
# For example, "Latin Extended-A" and "latin extended a" are equivalent.
|
||||
# For more information on the comparison of property values,
|
||||
# see UAX #44: https://www.unicode.org/reports/tr44/
|
||||
#
|
||||
# All block ranges start with a value where (cp MOD 16) = 0,
|
||||
# and end with a value where (cp MOD 16) = 15. In other words,
|
||||
# the last hexadecimal digit of the start of range is ...0
|
||||
# and the last hexadecimal digit of the end of range is ...F.
|
||||
# This constraint on block ranges guarantees that allocations
|
||||
# are done in terms of whole columns, and that code chart display
|
||||
# never involves splitting columns in the charts.
|
||||
#
|
||||
# All code points not explicitly listed for Block
|
||||
# have the value No_Block.
|
||||
|
||||
# Property: Block
|
||||
#
|
||||
# @missing: 0000..10FFFF; No_Block
|
||||
|
||||
0000..007F; Basic Latin
|
||||
0080..00FF; Latin-1 Supplement
|
||||
0100..017F; Latin Extended-A
|
||||
0180..024F; Latin Extended-B
|
||||
0250..02AF; IPA Extensions
|
||||
02B0..02FF; Spacing Modifier Letters
|
||||
0300..036F; Combining Diacritical Marks
|
||||
0370..03FF; Greek and Coptic
|
||||
0400..04FF; Cyrillic
|
||||
0500..052F; Cyrillic Supplement
|
||||
0530..058F; Armenian
|
||||
0590..05FF; Hebrew
|
||||
0600..06FF; Arabic
|
||||
0700..074F; Syriac
|
||||
0750..077F; Arabic Supplement
|
||||
0780..07BF; Thaana
|
||||
07C0..07FF; NKo
|
||||
0800..083F; Samaritan
|
||||
0840..085F; Mandaic
|
||||
0860..086F; Syriac Supplement
|
||||
0870..089F; Arabic Extended-B
|
||||
08A0..08FF; Arabic Extended-A
|
||||
0900..097F; Devanagari
|
||||
0980..09FF; Bengali
|
||||
0A00..0A7F; Gurmukhi
|
||||
0A80..0AFF; Gujarati
|
||||
0B00..0B7F; Oriya
|
||||
0B80..0BFF; Tamil
|
||||
0C00..0C7F; Telugu
|
||||
0C80..0CFF; Kannada
|
||||
0D00..0D7F; Malayalam
|
||||
0D80..0DFF; Sinhala
|
||||
0E00..0E7F; Thai
|
||||
0E80..0EFF; Lao
|
||||
0F00..0FFF; Tibetan
|
||||
1000..109F; Myanmar
|
||||
10A0..10FF; Georgian
|
||||
1100..11FF; Hangul Jamo
|
||||
1200..137F; Ethiopic
|
||||
1380..139F; Ethiopic Supplement
|
||||
13A0..13FF; Cherokee
|
||||
1400..167F; Unified Canadian Aboriginal Syllabics
|
||||
1680..169F; Ogham
|
||||
16A0..16FF; Runic
|
||||
1700..171F; Tagalog
|
||||
1720..173F; Hanunoo
|
||||
1740..175F; Buhid
|
||||
1760..177F; Tagbanwa
|
||||
1780..17FF; Khmer
|
||||
1800..18AF; Mongolian
|
||||
18B0..18FF; Unified Canadian Aboriginal Syllabics Extended
|
||||
1900..194F; Limbu
|
||||
1950..197F; Tai Le
|
||||
1980..19DF; New Tai Lue
|
||||
19E0..19FF; Khmer Symbols
|
||||
1A00..1A1F; Buginese
|
||||
1A20..1AAF; Tai Tham
|
||||
1AB0..1AFF; Combining Diacritical Marks Extended
|
||||
1B00..1B7F; Balinese
|
||||
1B80..1BBF; Sundanese
|
||||
1BC0..1BFF; Batak
|
||||
1C00..1C4F; Lepcha
|
||||
1C50..1C7F; Ol Chiki
|
||||
1C80..1C8F; Cyrillic Extended-C
|
||||
1C90..1CBF; Georgian Extended
|
||||
1CC0..1CCF; Sundanese Supplement
|
||||
1CD0..1CFF; Vedic Extensions
|
||||
1D00..1D7F; Phonetic Extensions
|
||||
1D80..1DBF; Phonetic Extensions Supplement
|
||||
1DC0..1DFF; Combining Diacritical Marks Supplement
|
||||
1E00..1EFF; Latin Extended Additional
|
||||
1F00..1FFF; Greek Extended
|
||||
2000..206F; General Punctuation
|
||||
2070..209F; Superscripts and Subscripts
|
||||
20A0..20CF; Currency Symbols
|
||||
20D0..20FF; Combining Diacritical Marks for Symbols
|
||||
2100..214F; Letterlike Symbols
|
||||
2150..218F; Number Forms
|
||||
2190..21FF; Arrows
|
||||
2200..22FF; Mathematical Operators
|
||||
2300..23FF; Miscellaneous Technical
|
||||
2400..243F; Control Pictures
|
||||
2440..245F; Optical Character Recognition
|
||||
2460..24FF; Enclosed Alphanumerics
|
||||
2500..257F; Box Drawing
|
||||
2580..259F; Block Elements
|
||||
25A0..25FF; Geometric Shapes
|
||||
2600..26FF; Miscellaneous Symbols
|
||||
2700..27BF; Dingbats
|
||||
27C0..27EF; Miscellaneous Mathematical Symbols-A
|
||||
27F0..27FF; Supplemental Arrows-A
|
||||
2800..28FF; Braille Patterns
|
||||
2900..297F; Supplemental Arrows-B
|
||||
2980..29FF; Miscellaneous Mathematical Symbols-B
|
||||
2A00..2AFF; Supplemental Mathematical Operators
|
||||
2B00..2BFF; Miscellaneous Symbols and Arrows
|
||||
2C00..2C5F; Glagolitic
|
||||
2C60..2C7F; Latin Extended-C
|
||||
2C80..2CFF; Coptic
|
||||
2D00..2D2F; Georgian Supplement
|
||||
2D30..2D7F; Tifinagh
|
||||
2D80..2DDF; Ethiopic Extended
|
||||
2DE0..2DFF; Cyrillic Extended-A
|
||||
2E00..2E7F; Supplemental Punctuation
|
||||
2E80..2EFF; CJK Radicals Supplement
|
||||
2F00..2FDF; Kangxi Radicals
|
||||
2FF0..2FFF; Ideographic Description Characters
|
||||
3000..303F; CJK Symbols and Punctuation
|
||||
3040..309F; Hiragana
|
||||
30A0..30FF; Katakana
|
||||
3100..312F; Bopomofo
|
||||
3130..318F; Hangul Compatibility Jamo
|
||||
3190..319F; Kanbun
|
||||
31A0..31BF; Bopomofo Extended
|
||||
31C0..31EF; CJK Strokes
|
||||
31F0..31FF; Katakana Phonetic Extensions
|
||||
3200..32FF; Enclosed CJK Letters and Months
|
||||
3300..33FF; CJK Compatibility
|
||||
3400..4DBF; CJK Unified Ideographs Extension A
|
||||
4DC0..4DFF; Yijing Hexagram Symbols
|
||||
4E00..9FFF; CJK Unified Ideographs
|
||||
A000..A48F; Yi Syllables
|
||||
A490..A4CF; Yi Radicals
|
||||
A4D0..A4FF; Lisu
|
||||
A500..A63F; Vai
|
||||
A640..A69F; Cyrillic Extended-B
|
||||
A6A0..A6FF; Bamum
|
||||
A700..A71F; Modifier Tone Letters
|
||||
A720..A7FF; Latin Extended-D
|
||||
A800..A82F; Syloti Nagri
|
||||
A830..A83F; Common Indic Number Forms
|
||||
A840..A87F; Phags-pa
|
||||
A880..A8DF; Saurashtra
|
||||
A8E0..A8FF; Devanagari Extended
|
||||
A900..A92F; Kayah Li
|
||||
A930..A95F; Rejang
|
||||
A960..A97F; Hangul Jamo Extended-A
|
||||
A980..A9DF; Javanese
|
||||
A9E0..A9FF; Myanmar Extended-B
|
||||
AA00..AA5F; Cham
|
||||
AA60..AA7F; Myanmar Extended-A
|
||||
AA80..AADF; Tai Viet
|
||||
AAE0..AAFF; Meetei Mayek Extensions
|
||||
AB00..AB2F; Ethiopic Extended-A
|
||||
AB30..AB6F; Latin Extended-E
|
||||
AB70..ABBF; Cherokee Supplement
|
||||
ABC0..ABFF; Meetei Mayek
|
||||
AC00..D7AF; Hangul Syllables
|
||||
D7B0..D7FF; Hangul Jamo Extended-B
|
||||
D800..DB7F; High Surrogates
|
||||
DB80..DBFF; High Private Use Surrogates
|
||||
DC00..DFFF; Low Surrogates
|
||||
E000..F8FF; Private Use Area
|
||||
F900..FAFF; CJK Compatibility Ideographs
|
||||
FB00..FB4F; Alphabetic Presentation Forms
|
||||
FB50..FDFF; Arabic Presentation Forms-A
|
||||
FE00..FE0F; Variation Selectors
|
||||
FE10..FE1F; Vertical Forms
|
||||
FE20..FE2F; Combining Half Marks
|
||||
FE30..FE4F; CJK Compatibility Forms
|
||||
FE50..FE6F; Small Form Variants
|
||||
FE70..FEFF; Arabic Presentation Forms-B
|
||||
FF00..FFEF; Halfwidth and Fullwidth Forms
|
||||
FFF0..FFFF; Specials
|
||||
10000..1007F; Linear B Syllabary
|
||||
10080..100FF; Linear B Ideograms
|
||||
10100..1013F; Aegean Numbers
|
||||
10140..1018F; Ancient Greek Numbers
|
||||
10190..101CF; Ancient Symbols
|
||||
101D0..101FF; Phaistos Disc
|
||||
10280..1029F; Lycian
|
||||
102A0..102DF; Carian
|
||||
102E0..102FF; Coptic Epact Numbers
|
||||
10300..1032F; Old Italic
|
||||
10330..1034F; Gothic
|
||||
10350..1037F; Old Permic
|
||||
10380..1039F; Ugaritic
|
||||
103A0..103DF; Old Persian
|
||||
10400..1044F; Deseret
|
||||
10450..1047F; Shavian
|
||||
10480..104AF; Osmanya
|
||||
104B0..104FF; Osage
|
||||
10500..1052F; Elbasan
|
||||
10530..1056F; Caucasian Albanian
|
||||
10570..105BF; Vithkuqi
|
||||
105C0..105FF; Todhri
|
||||
10600..1077F; Linear A
|
||||
10780..107BF; Latin Extended-F
|
||||
10800..1083F; Cypriot Syllabary
|
||||
10840..1085F; Imperial Aramaic
|
||||
10860..1087F; Palmyrene
|
||||
10880..108AF; Nabataean
|
||||
108E0..108FF; Hatran
|
||||
10900..1091F; Phoenician
|
||||
10920..1093F; Lydian
|
||||
10940..1095F; Sidetic
|
||||
10980..1099F; Meroitic Hieroglyphs
|
||||
109A0..109FF; Meroitic Cursive
|
||||
10A00..10A5F; Kharoshthi
|
||||
10A60..10A7F; Old South Arabian
|
||||
10A80..10A9F; Old North Arabian
|
||||
10AC0..10AFF; Manichaean
|
||||
10B00..10B3F; Avestan
|
||||
10B40..10B5F; Inscriptional Parthian
|
||||
10B60..10B7F; Inscriptional Pahlavi
|
||||
10B80..10BAF; Psalter Pahlavi
|
||||
10C00..10C4F; Old Turkic
|
||||
10C80..10CFF; Old Hungarian
|
||||
10D00..10D3F; Hanifi Rohingya
|
||||
10D40..10D8F; Garay
|
||||
10E60..10E7F; Rumi Numeral Symbols
|
||||
10E80..10EBF; Yezidi
|
||||
10EC0..10EFF; Arabic Extended-C
|
||||
10F00..10F2F; Old Sogdian
|
||||
10F30..10F6F; Sogdian
|
||||
10F70..10FAF; Old Uyghur
|
||||
10FB0..10FDF; Chorasmian
|
||||
10FE0..10FFF; Elymaic
|
||||
11000..1107F; Brahmi
|
||||
11080..110CF; Kaithi
|
||||
110D0..110FF; Sora Sompeng
|
||||
11100..1114F; Chakma
|
||||
11150..1117F; Mahajani
|
||||
11180..111DF; Sharada
|
||||
111E0..111FF; Sinhala Archaic Numbers
|
||||
11200..1124F; Khojki
|
||||
11280..112AF; Multani
|
||||
112B0..112FF; Khudawadi
|
||||
11300..1137F; Grantha
|
||||
11380..113FF; Tulu-Tigalari
|
||||
11400..1147F; Newa
|
||||
11480..114DF; Tirhuta
|
||||
11580..115FF; Siddham
|
||||
11600..1165F; Modi
|
||||
11660..1167F; Mongolian Supplement
|
||||
11680..116CF; Takri
|
||||
116D0..116FF; Myanmar Extended-C
|
||||
11700..1174F; Ahom
|
||||
11800..1184F; Dogra
|
||||
118A0..118FF; Warang Citi
|
||||
11900..1195F; Dives Akuru
|
||||
119A0..119FF; Nandinagari
|
||||
11A00..11A4F; Zanabazar Square
|
||||
11A50..11AAF; Soyombo
|
||||
11AB0..11ABF; Unified Canadian Aboriginal Syllabics Extended-A
|
||||
11AC0..11AFF; Pau Cin Hau
|
||||
11B00..11B5F; Devanagari Extended-A
|
||||
11B60..11B7F; Sharada Supplement
|
||||
11BC0..11BFF; Sunuwar
|
||||
11C00..11C6F; Bhaiksuki
|
||||
11C70..11CBF; Marchen
|
||||
11D00..11D5F; Masaram Gondi
|
||||
11D60..11DAF; Gunjala Gondi
|
||||
11DB0..11DEF; Tolong Siki
|
||||
11DF0..11DFF; Bengali Supplement
|
||||
11EE0..11EFF; Makasar
|
||||
11F00..11F5F; Kawi
|
||||
11FB0..11FBF; Lisu Supplement
|
||||
11FC0..11FFF; Tamil Supplement
|
||||
12000..123FF; Cuneiform
|
||||
12400..1247F; Cuneiform Numbers and Punctuation
|
||||
12480..1254F; Early Dynastic Cuneiform
|
||||
12550..1268F; Archaic Cuneiform Numerals
|
||||
12F90..12FFF; Cypro-Minoan
|
||||
13000..1342F; Egyptian Hieroglyphs
|
||||
13430..1345F; Egyptian Hieroglyph Format Controls
|
||||
13460..143FF; Egyptian Hieroglyphs Extended-A
|
||||
14400..1467F; Anatolian Hieroglyphs
|
||||
16100..1613F; Gurung Khema
|
||||
16800..16A3F; Bamum Supplement
|
||||
16A40..16A6F; Mro
|
||||
16A70..16ACF; Tangsa
|
||||
16AD0..16AFF; Bassa Vah
|
||||
16B00..16B8F; Pahawh Hmong
|
||||
16D40..16D7F; Kirat Rai
|
||||
16D80..16DAF; Chisoi
|
||||
16E40..16E9F; Medefaidrin
|
||||
16EA0..16EDF; Beria Erfe
|
||||
16F00..16F9F; Miao
|
||||
16FE0..16FFF; Ideographic Symbols and Punctuation
|
||||
17000..187FF; Tangut
|
||||
18800..18AFF; Tangut Components
|
||||
18B00..18CFF; Khitan Small Script
|
||||
18D00..18D7F; Tangut Supplement
|
||||
18D80..18DFF; Tangut Components Supplement
|
||||
18E00..1919F; Jurchen
|
||||
191A0..191DF; Jurchen Radicals
|
||||
1AFF0..1AFFF; Kana Extended-B
|
||||
1B000..1B0FF; Kana Supplement
|
||||
1B100..1B12F; Kana Extended-A
|
||||
1B130..1B16F; Small Kana Extension
|
||||
1B170..1B2FF; Nushu
|
||||
1BC00..1BC9F; Duployan
|
||||
1BCA0..1BCAF; Shorthand Format Controls
|
||||
1CC00..1CEBF; Symbols for Legacy Computing Supplement
|
||||
1CEC0..1CEFF; Miscellaneous Symbols Supplement
|
||||
1CF00..1CFCF; Znamenny Musical Notation
|
||||
1D000..1D0FF; Byzantine Musical Symbols
|
||||
1D100..1D1FF; Musical Symbols
|
||||
1D200..1D24F; Ancient Greek Musical Notation
|
||||
1D250..1D28F; Musical Symbols Supplement
|
||||
1D2C0..1D2DF; Kaktovik Numerals
|
||||
1D2E0..1D2FF; Mayan Numerals
|
||||
1D300..1D35F; Tai Xuan Jing Symbols
|
||||
1D360..1D37F; Counting Rod Numerals
|
||||
1D400..1D7FF; Mathematical Alphanumeric Symbols
|
||||
1D800..1DAAF; Sutton SignWriting
|
||||
1DB00..1DBFF; Miscellaneous Symbols and Arrows Extended
|
||||
1DF00..1DFFF; Latin Extended-G
|
||||
1E000..1E02F; Glagolitic Supplement
|
||||
1E030..1E08F; Cyrillic Extended-D
|
||||
1E100..1E14F; Nyiakeng Puachue Hmong
|
||||
1E290..1E2BF; Toto
|
||||
1E2C0..1E2FF; Wancho
|
||||
1E4D0..1E4FF; Nag Mundari
|
||||
1E5D0..1E5FF; Ol Onal
|
||||
1E6C0..1E6FF; Tai Yo
|
||||
1E7E0..1E7FF; Ethiopic Extended-B
|
||||
1E800..1E8DF; Mende Kikakui
|
||||
1E900..1E95F; Adlam
|
||||
1EC70..1ECBF; Indic Siyaq Numbers
|
||||
1ED00..1ED4F; Ottoman Siyaq Numbers
|
||||
1EE00..1EEFF; Arabic Mathematical Alphabetic Symbols
|
||||
1F000..1F02F; Mahjong Tiles
|
||||
1F030..1F09F; Domino Tiles
|
||||
1F0A0..1F0FF; Playing Cards
|
||||
1F100..1F1FF; Enclosed Alphanumeric Supplement
|
||||
1F200..1F2FF; Enclosed Ideographic Supplement
|
||||
1F300..1F5FF; Miscellaneous Symbols and Pictographs
|
||||
1F600..1F64F; Emoticons
|
||||
1F650..1F67F; Ornamental Dingbats
|
||||
1F680..1F6FF; Transport and Map Symbols
|
||||
1F700..1F77F; Alchemical Symbols
|
||||
1F780..1F7FF; Geometric Shapes Extended
|
||||
1F800..1F8FF; Supplemental Arrows-C
|
||||
1F900..1F9FF; Supplemental Symbols and Pictographs
|
||||
1FA00..1FA6F; Chess Symbols
|
||||
1FA70..1FAFF; Symbols and Pictographs Extended-A
|
||||
1FB00..1FBFF; Symbols for Legacy Computing
|
||||
20000..2A6DF; CJK Unified Ideographs Extension B
|
||||
2A700..2B73F; CJK Unified Ideographs Extension C
|
||||
2B740..2B81F; CJK Unified Ideographs Extension D
|
||||
2B820..2CEAF; CJK Unified Ideographs Extension E
|
||||
2CEB0..2EBEF; CJK Unified Ideographs Extension F
|
||||
2EBF0..2EE5F; CJK Unified Ideographs Extension I
|
||||
2F800..2FA1F; CJK Compatibility Ideographs Supplement
|
||||
30000..3134F; CJK Unified Ideographs Extension G
|
||||
31350..323AF; CJK Unified Ideographs Extension H
|
||||
323B0..3347F; CJK Unified Ideographs Extension J
|
||||
3D000..3FC3F; Seal
|
||||
E0000..E007F; Tags
|
||||
E0100..E01EF; Variation Selectors Supplement
|
||||
F0000..FFFFF; Supplementary Private Use Area-A
|
||||
100000..10FFFF; Supplementary Private Use Area-B
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# dev/cd.sh — 打包 FontMM 模块 (preplace / template 两版)
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SRC_DIR="$ROOT_DIR/src"
|
||||
DIST_DIR="$ROOT_DIR/dist"
|
||||
PROP_FILE="$SRC_DIR/module.prop"
|
||||
|
||||
command -v zip >/dev/null 2>&1 || {
|
||||
echo "[!] 未找到 zip 命令, 请先安装" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 1. 从 module.prop 读版本号: version=26.8.0-beta.1(260800001)
|
||||
VERSION="$(sed -n 's/^version=//p' "$PROP_FILE" 2>/dev/null | head -n 1 | tr -d '\r' || true)"
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "[!] 无法从 $PROP_FILE 读取 version 字段" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 文件名安全化: 括号 -> 点 (GitHub Release 网页上传会把括号改写为点, 导致 URL 不一致)
|
||||
# 26.8.0-beta.1(260800001) -> 26.8.0-beta.1.260800001
|
||||
FILE_VERSION="$(printf '%s' "$VERSION" | sed 's/(/./g; s/)//g')"
|
||||
|
||||
PRE_OUT="$DIST_DIR/FontMM_v${FILE_VERSION}_preplace.zip"
|
||||
TPL_OUT="$DIST_DIR/FontMM_v${FILE_VERSION}_template.zip"
|
||||
|
||||
mkdir -p "$DIST_DIR"
|
||||
rm -f "$PRE_OUT" "$TPL_OUT" # 先删旧的, 防止 zip 增量更新残留已删除的文件
|
||||
|
||||
# 0. 同步派生字体配置 (fonts.xml 为唯一源, 复制生成 fonts_base/ule/font_fallback 等)
|
||||
bash "$ROOT_DIR/dev/sync-fonts-xml.sh"
|
||||
|
||||
# 2. 打包函数: $1=输出路径, $2=额外排除模式 (可选)
|
||||
# (zip 根 = 模块根, 不含 src 这层目录)
|
||||
pack() {
|
||||
local out="$1" extra="${2:-}"
|
||||
local args=(-r -2 "$out" . -x '*.git*' -x '*.DS_Store' -x '*.swp' -x '*~' -x '*.bak')
|
||||
if [ -n "$extra" ]; then
|
||||
args+=(-x "$extra")
|
||||
fi
|
||||
(
|
||||
cd "$SRC_DIR"
|
||||
zip "${args[@]}"
|
||||
)
|
||||
}
|
||||
|
||||
echo "[*] 打包 preplace 版 (含预置字体)..."
|
||||
pack "$PRE_OUT"
|
||||
echo "[*] 打包 template 版 (FONT 目录为空)..."
|
||||
pack "$TPL_OUT" 'FONTS/*'
|
||||
# -x 'FONTS/*' 会连目录条目一起排除, 这里补回空的 FONTS/ 目录
|
||||
(
|
||||
cd "$SRC_DIR"
|
||||
zip -g "$TPL_OUT" 'FONTS/'
|
||||
)
|
||||
|
||||
# 3. 产物校验: 必须含 module.prop, 防止打包错目录
|
||||
# 注意: 不能用 grep -q, 它匹配后立即退出会使上游 unzip 收到 SIGPIPE (141),
|
||||
# 在 pipefail 下整个管道被判失败, 产生"缺少 module.prop"的偶发误报
|
||||
check() {
|
||||
local out="$1"
|
||||
if ! unzip -l "$out" | grep 'module\.prop' >/dev/null; then
|
||||
echo "[!] 打包产物缺少 module.prop: $out" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
check "$PRE_OUT"
|
||||
check "$TPL_OUT"
|
||||
|
||||
# 4. template 版校验: FONTS 目录必须不含字体文件 (保留空目录)
|
||||
if unzip -l "$TPL_OUT" | grep 'FONTS/.*\.ttf' >/dev/null; then
|
||||
echo "[!] template 版不应包含 FONTS 字体文件" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[✓] 打包完成:"
|
||||
echo " preplace: $PRE_OUT ($(du -h "$PRE_OUT" | cut -f1))"
|
||||
echo " template: $TPL_OUT ($(du -h "$TPL_OUT" | cut -f1))"
|
||||
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
"""check-unicode-coverage.py — 本地模拟 Android 字体 fallback 链, 统计 Unicode 区块覆盖率.
|
||||
|
||||
原理: 按 fonts.xml 中 family 的声明顺序构成 fallback 链, 逐字形检查覆盖;
|
||||
用 fontTools 读取各字体 cmap, 对照 Unicode Blocks.txt 统计每个区块的覆盖率.
|
||||
|
||||
用法:
|
||||
python3 dev/check-unicode-coverage.py # 全部区块 (自动获取 Blocks.txt 缓存到 dev/)
|
||||
python3 dev/check-unicode-coverage.py --blocks-file Blocks.txt
|
||||
python3 dev/check-unicode-coverage.py Hebrew "Archaic" # 只测匹配的区块名 (子串)
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
import urllib.request
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from fontTools.ttLib import TTFont
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
FONTS_DIR = os.path.join(ROOT, 'src', 'system', 'fonts')
|
||||
FONTS_XML = os.path.join(ROOT, 'src', 'system', 'etc', 'fonts.xml')
|
||||
BLOCKS_URL = 'https://www.unicode.org/Public/draft/ucd/Blocks.txt'
|
||||
|
||||
|
||||
def load_chain(xml_path):
|
||||
"""按 fonts.xml 声明顺序提取 fallback 链 (全部 font 文件名, 去重)."""
|
||||
root = ET.parse(xml_path).getroot()
|
||||
chain, seen = [], set()
|
||||
for family in root.iter('family'):
|
||||
for font in family.iter('font'):
|
||||
name = (font.text or '').strip()
|
||||
if name and name not in seen:
|
||||
seen.add(name)
|
||||
chain.append(name)
|
||||
return chain
|
||||
|
||||
|
||||
def load_cmaps(fonts_dir, chain):
|
||||
cmaps, missing = {}, []
|
||||
for name in chain:
|
||||
path = os.path.join(fonts_dir, name)
|
||||
if not os.path.exists(path):
|
||||
missing.append(name)
|
||||
continue
|
||||
try:
|
||||
cmaps[name] = TTFont(path, lazy=True).getBestCmap()
|
||||
except Exception as exc: # 解析失败 (如特殊字体) 跳过
|
||||
missing.append(f'{name} ({exc})')
|
||||
return cmaps, missing
|
||||
|
||||
|
||||
def load_blocks(path):
|
||||
blocks = []
|
||||
with open(path, encoding='utf-8') as fh:
|
||||
for line in fh:
|
||||
line = line.strip()
|
||||
if not line or line.startswith('#') or '..' not in line:
|
||||
continue
|
||||
rng, name = line.split(';')
|
||||
start, end = (int(x, 16) for x in rng.strip().split('..'))
|
||||
blocks.append((name.strip(), start, end))
|
||||
return blocks
|
||||
|
||||
|
||||
def fetch_blocks(dest):
|
||||
print(f'[i] 获取 Blocks.txt: {BLOCKS_URL}')
|
||||
urllib.request.urlretrieve(BLOCKS_URL, dest)
|
||||
return dest
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description='本地 Unicode 覆盖测试 (模拟 fonts.xml fallback 链)')
|
||||
ap.add_argument('blocks', nargs='*', help='只测试匹配的区块名 (子串, 如 Hebrew)')
|
||||
ap.add_argument('--blocks-file', help='本地 Blocks.txt 路径 (默认自动下载缓存到 dev/Blocks.txt)')
|
||||
args = ap.parse_args()
|
||||
|
||||
chain = load_chain(FONTS_XML)
|
||||
print(f'[i] fallback 链: {len(chain)} 个字体 ({FONTS_XML})')
|
||||
cmaps, missing = load_cmaps(FONTS_DIR, chain)
|
||||
if missing:
|
||||
print(f'[!] 缺失/无法解析的字体: {missing}')
|
||||
if not cmaps:
|
||||
print('[!] 无可用字体, 退出', file=os.sys.stderr)
|
||||
return 1
|
||||
|
||||
# 合并全部 cmap 为并集, 快速判字形
|
||||
union = set()
|
||||
for cm in cmaps.values():
|
||||
union.update(cm)
|
||||
print(f'[i] 可用字体 {len(cmaps)} 个, 字形码位并集 {len(union):,}')
|
||||
|
||||
blocks_file = args.blocks_file
|
||||
if not blocks_file:
|
||||
blocks_file = os.path.join(ROOT, 'dev', 'Blocks.txt')
|
||||
if not os.path.exists(blocks_file):
|
||||
fetch_blocks(blocks_file)
|
||||
blocks = load_blocks(blocks_file)
|
||||
if args.blocks:
|
||||
blocks = [b for b in blocks if any(k.lower() in b[0].lower() for k in args.blocks)]
|
||||
|
||||
print(f'\n{"Block":<42}{"Covered":>9}{"Total":>8}{"Pct":>9} Status')
|
||||
print('-' * 76)
|
||||
failed = []
|
||||
for name, start, end in blocks:
|
||||
total = end - start + 1
|
||||
covered = sum(1 for cp in range(start, end + 1) if cp in union)
|
||||
pct = covered / total * 100 if total else 0
|
||||
status = 'PASS' if covered == total else ('FAIL' if pct < 95 else '')
|
||||
if status == 'FAIL':
|
||||
failed.append(name)
|
||||
print(f'{name:<42}{covered:>9}{total:>8}{pct:>8.2f}% {status}')
|
||||
|
||||
print(f'\n[=] 共 {len(blocks)} 个区块, FAIL (<95%): {len(failed)} 个')
|
||||
for name in failed:
|
||||
print(f' - {name}')
|
||||
return 1 if failed else 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
# ---------- Termux 兼容 ----------
|
||||
# Termux 的 shellcheck / shfmt 安装在 app 私有目录, 需手动加入 PATH 与 LD_LIBRARY_PATH;
|
||||
# 其他环境 (Linux/macOS 等) 直接使用系统 PATH 中的工具
|
||||
if [ -n "${PREFIX:-}" ] && [ -d "$PREFIX/bin" ]; then
|
||||
export PATH="$PREFIX/bin:${PATH}"
|
||||
export LD_LIBRARY_PATH="$PREFIX/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
elif [ -d /data/user/0/com.termux/files/usr/bin ]; then
|
||||
export PATH="/data/user/0/com.termux/files/usr/bin:${PATH}"
|
||||
export LD_LIBRARY_PATH="/data/user/0/com.termux/files/usr/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
fi
|
||||
|
||||
# 工具可用性检查
|
||||
command -v shellcheck >/dev/null 2>&1 || {
|
||||
echo "[!] 未找到 shellcheck, 请先安装" >&2
|
||||
exit 1
|
||||
}
|
||||
command -v shfmt >/dev/null 2>&1 || {
|
||||
echo "[!] 未找到 shfmt, 请先安装" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
shopt -s nullglob globstar
|
||||
files=("$SCRIPT_DIR/src"/**/*.sh)
|
||||
|
||||
for f in "${files[@]}"; do
|
||||
echo "> Checking: $f"
|
||||
shellcheck "$f" || exit 1
|
||||
done
|
||||
|
||||
for f in "${files[@]}"; do
|
||||
echo "> Formatting: $f"
|
||||
shfmt -i 4 -w -d "$f"
|
||||
done
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
FONT_DIR="$SCRIPT_DIR/src/system/fonts"
|
||||
|
||||
# 字体清单(记得和 customize.sh 保持一致)
|
||||
all_fonts='SysSans-Hans-Regular.ttf
|
||||
SysFont-Static-Regular.ttf
|
||||
SysFont-Myanmar.ttf
|
||||
SysFont-Hans-Regular.ttf
|
||||
SysFont-Regular.ttf
|
||||
SysSans-Hant-Regular.ttf
|
||||
SysFont-Hant-Regular.ttf
|
||||
SysSans-En-Regular.ttf'
|
||||
|
||||
mkdir -p "$FONT_DIR"
|
||||
|
||||
count=0
|
||||
while IFS= read -r font; do
|
||||
[ -z "$font" ] && continue
|
||||
: > "$FONT_DIR/$font"
|
||||
echo "[*] 已生成空字体: $font"
|
||||
count=$((count + 1))
|
||||
done <<< "$all_fonts"
|
||||
|
||||
echo "[✓] 完成,共 $count 个空字体 -> $FONT_DIR"
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# dev/sync-fonts-xml.sh — 以 fonts.xml 为唯一源, 复制生成各派生字体配置
|
||||
# ColorOS 在不同场景加载 fonts.xml / fonts_base.xml / fonts_ule.xml / font_fallback.xml,
|
||||
# 参考 MakeFontsGreatAgain 的做法, 开发阶段直接复制, 避免维护多份几乎重复的 XML
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SRC="$ROOT_DIR/src/system/etc/fonts.xml"
|
||||
|
||||
[ -f "$SRC" ] || {
|
||||
echo "[!] 找不到源文件: $SRC" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
DEST=(
|
||||
"$ROOT_DIR/src/system/etc/fonts_base.xml"
|
||||
"$ROOT_DIR/src/system/etc/fonts_ule.xml"
|
||||
"$ROOT_DIR/src/system/etc/font_fallback.xml"
|
||||
"$ROOT_DIR/src/system/system_ext/etc/fonts_base.xml"
|
||||
"$ROOT_DIR/src/system/system_ext/etc/fonts_ule.xml"
|
||||
)
|
||||
|
||||
for f in "${DEST[@]}"; do
|
||||
cp -f "$SRC" "$f"
|
||||
echo "[✓] 已同步: $f"
|
||||
done
|
||||
|
||||
echo "[✓] 完成, 共 ${#DEST[@]} 个派生文件"
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# dev/webzip.sh — 仅把构建产物 src/webroot 压缩为 dist/webroot.zip (调试 WebUI 用)
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SRC="$ROOT_DIR/src/webroot"
|
||||
OUT="$ROOT_DIR/dist/webroot.zip"
|
||||
|
||||
command -v zip >/dev/null 2>&1 || {
|
||||
echo "[!] 未找到 zip 命令, 请先安装" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -d "$SRC" ] || {
|
||||
echo "[!] $SRC 不存在, 请先执行 pnpm -C web build" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
mkdir -p "$(dirname "$OUT")"
|
||||
rm -f "$OUT"
|
||||
|
||||
# zip 根 = webroot 内容 (不含 webroot 这层目录)
|
||||
(
|
||||
cd "$SRC"
|
||||
zip -r -9 "$OUT" . \
|
||||
-x '*.git*' \
|
||||
-x '*.DS_Store'
|
||||
)
|
||||
|
||||
echo "[✓] 已打包: $OUT ($(du -h "$OUT" | cut -f1))"
|
||||
@@ -1,6 +0,0 @@
|
||||
id=MyFontModule
|
||||
name=我的字体模块
|
||||
version=1.0
|
||||
versionCode=10
|
||||
author=Yule
|
||||
description=我的字体模块
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "fontmm",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "pnpm -C web dev",
|
||||
"build": "pnpm -C web build && bash dev/cd.sh",
|
||||
"build:only-web": "pnpm -C web build && bash dev/webzip.sh",
|
||||
"lint": "pnpm -C web lint",
|
||||
"fmt": "pnpm -C web fmt",
|
||||
"fmt:check": "pnpm -C web fmt:check",
|
||||
"type-check": "pnpm -C web type-check",
|
||||
"shellcheck": "find src -name '*.sh' -print0 | xargs -0 shellcheck",
|
||||
"shfmt": "find src -name '*.sh' -print0 | xargs -0 shfmt -i 4 -w -d"
|
||||
}
|
||||
}
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.: {}
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
#!/sbin/sh
|
||||
|
||||
#################
|
||||
# Initialization
|
||||
#################
|
||||
|
||||
umask 022
|
||||
|
||||
# echo before loading util_functions
|
||||
ui_print() { echo "$1"; }
|
||||
|
||||
require_new_magisk() {
|
||||
ui_print "*******************************"
|
||||
ui_print " Please install Magisk v20.4+! "
|
||||
ui_print "*******************************"
|
||||
exit 1
|
||||
}
|
||||
|
||||
#########################
|
||||
# Load util_functions.sh
|
||||
#########################
|
||||
|
||||
OUTFD=$2
|
||||
ZIPFILE=$3
|
||||
|
||||
mount /data 2>/dev/null
|
||||
|
||||
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
|
||||
. /data/adb/magisk/util_functions.sh
|
||||
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
|
||||
|
||||
install_module
|
||||
exit 0
|
||||
@@ -0,0 +1 @@
|
||||
#MAGISK
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/system/bin/sh
|
||||
# shellcheck shell=ash
|
||||
# FontMM apply.sh — 应用字体: 把 FONTS/ 里的字体安装到 system/fonts
|
||||
# 用法: apply.sh [模块目录] 默认 /data/adb/modules/FontMM
|
||||
# 回退逻辑: hant/en 缺失时回退到 hans; mono 缺失时不覆盖系统等宽字体
|
||||
MODDIR="${1:-/data/adb/modules/FontMM}"
|
||||
FONTS_DIR="$MODDIR/FONTS"
|
||||
SYS_FONT_DIR="$MODDIR/system/fonts"
|
||||
|
||||
hans_fonts='SysSans-Hans-Regular.ttf
|
||||
SysFont-Static-Regular.ttf
|
||||
SysFont-Myanmar.ttf
|
||||
SysFont-Hans-Regular.ttf
|
||||
SysFont-Regular.ttf'
|
||||
hant_fonts='SysSans-Hant-Regular.ttf
|
||||
SysFont-Hant-Regular.ttf'
|
||||
en_fonts='SysSans-En-Regular.ttf'
|
||||
|
||||
[ -f "$FONTS_DIR/hans.ttf" ] || {
|
||||
echo "[✗] FONTS/hans.ttf 不存在, 请先在 WebUI 选择字体"
|
||||
exit 1
|
||||
}
|
||||
|
||||
mkdir -p "$SYS_FONT_DIR"
|
||||
|
||||
install_from() {
|
||||
local src="$1" list="$2" line=""
|
||||
while IFS= read -r line; do
|
||||
cp -f "$src" "$SYS_FONT_DIR/$line" || {
|
||||
echo "[✗] 复制 $line 失败"
|
||||
exit 1
|
||||
}
|
||||
echo "[*] 安装: $line"
|
||||
done <<EOF
|
||||
$list
|
||||
EOF
|
||||
}
|
||||
|
||||
echo "[*] 安装简体字体..."
|
||||
install_from "$FONTS_DIR/hans.ttf" "$hans_fonts"
|
||||
|
||||
echo "[*] 处理繁体字体..."
|
||||
if [ -f "$FONTS_DIR/hant.ttf" ]; then
|
||||
install_from "$FONTS_DIR/hant.ttf" "$hant_fonts"
|
||||
else
|
||||
echo "[-] 未设置繁体, 回退使用简体"
|
||||
install_from "$FONTS_DIR/hans.ttf" "$hant_fonts"
|
||||
fi
|
||||
|
||||
echo "[*] 处理英文&数字..."
|
||||
if [ -f "$FONTS_DIR/en.ttf" ]; then
|
||||
install_from "$FONTS_DIR/en.ttf" "$en_fonts"
|
||||
else
|
||||
echo "[-] 未设置英文, 回退使用简体"
|
||||
install_from "$FONTS_DIR/hans.ttf" "$en_fonts"
|
||||
fi
|
||||
|
||||
echo "[*] 处理等宽字体..."
|
||||
if [ -f "$FONTS_DIR/mono.ttf" ]; then
|
||||
# 复制为模块独立文件 FontMM-Mono.ttf (不覆盖系统 DroidSansMono, 避免同名 overlay 失效)
|
||||
install_from "$FONTS_DIR/mono.ttf" 'FontMM-Mono.ttf'
|
||||
else
|
||||
echo "[-] 未设置等宽字体, 不覆盖系统等宽字体"
|
||||
rm -f "$SYS_FONT_DIR/FontMM-Mono.ttf"
|
||||
fi
|
||||
|
||||
echo "[*] 全部完成, 重启后生效"
|
||||
@@ -0,0 +1,187 @@
|
||||
#!/system/bin/sh
|
||||
# shellcheck shell=ash
|
||||
# shellcheck disable=SC2034
|
||||
# FontMM ColorOS 16 — 刷入脚本
|
||||
# 字体安装统一交给 apply.sh (与 WebUI 共用同一套逻辑)
|
||||
|
||||
REPLACE=""
|
||||
REMOVE=""
|
||||
|
||||
# ---------- 路径 ----------
|
||||
if [ -z "${MODPATH+x}" ]; then
|
||||
case "$0" in
|
||||
*/*) MODPATH="${0%/*}" ;;
|
||||
*) MODPATH="." ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
MOD_WORK_PATH="$MODPATH/FONTS"
|
||||
UPDATE_MODE=0
|
||||
|
||||
# ---------- 日志 ----------
|
||||
log() {
|
||||
local msg="$1"
|
||||
echo "[-] $msg"
|
||||
}
|
||||
|
||||
log_err() {
|
||||
local msg="$1"
|
||||
local code="${2:-1}"
|
||||
if command -v abort >/dev/null 2>&1; then
|
||||
abort "$msg"
|
||||
fi
|
||||
echo "[✗] $msg"
|
||||
exit "$code"
|
||||
}
|
||||
|
||||
log_succ() {
|
||||
local msg="$1"
|
||||
echo "[*] $msg"
|
||||
}
|
||||
|
||||
# ---------- 更新模式 ----------
|
||||
# 检测旧版 FontMM 是否已安装
|
||||
DETECT_UPDATE_MODE() {
|
||||
if [ -d /data/adb/modules/FontMM ]; then
|
||||
UPDATE_MODE=1
|
||||
log "检测到已安装的 FontMM, 进入更新模式"
|
||||
else
|
||||
log "全新安装"
|
||||
fi
|
||||
}
|
||||
|
||||
# 更新模式: 以旧包为主继承字体
|
||||
IMPORT_OLD_FONTS() {
|
||||
[ "$UPDATE_MODE" -eq 1 ] || return 0
|
||||
|
||||
local old_fonts="/data/adb/modules/FontMM/FONTS"
|
||||
if [ ! -d "$old_fonts" ]; then
|
||||
log "注意: 旧模块中没有 FONTS 目录, 将使用新包字体"
|
||||
return 0
|
||||
fi
|
||||
|
||||
mkdir -p "$MOD_WORK_PATH"
|
||||
local f=""
|
||||
for f in hans.ttf hant.ttf en.ttf mono.ttf; do
|
||||
if [ -f "$old_fonts/$f" ]; then
|
||||
if cp -f "$old_fonts/$f" "$MOD_WORK_PATH/$f"; then
|
||||
log_succ "已从旧模块继承字体: $f"
|
||||
else
|
||||
log_err "继承字体 $f 失败"
|
||||
fi
|
||||
else
|
||||
log "旧包没有 $f, 使用新包字体"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ---------- 系统检查 ----------
|
||||
# 仅支持 ColorOS 且版本 >= 16.0, 否则拒绝安装
|
||||
CHECK_COLOROS() {
|
||||
local oplus_api=""
|
||||
oplus_api="$(getprop ro.build.version.oplus.api 2>/dev/null || true)"
|
||||
|
||||
if [ -z "$oplus_api" ]; then
|
||||
log_err "当前系统不是 ColorOS, 本模块仅支持 ColorOS 16.0+"
|
||||
fi
|
||||
|
||||
local oplus_display=""
|
||||
oplus_display="$(getprop ro.build.version.oplusrom.display 2>/dev/null || true)"
|
||||
local major="${oplus_display%%.*}"
|
||||
|
||||
if [ "${major:-0}" -lt 16 ] 2>/dev/null; then
|
||||
log_err "ColorOS 版本过低 (${oplus_display:-未知}), 需要 16.0 及以上"
|
||||
fi
|
||||
|
||||
log_succ "ColorOS ${oplus_display}"
|
||||
}
|
||||
|
||||
# ---------- 检查元模块 ----------
|
||||
CHECK_META_MODULE() {
|
||||
if [ ! -f /data/adb/ksud ]; then
|
||||
log "非 KernelSU 环境, 跳过元模块检查"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local ksud_version=""
|
||||
ksud_version="$(/data/adb/ksud --version 2>/dev/null | tr -d '\r' || true)"
|
||||
local ver_num
|
||||
ver_num="$(printf '%s' "$ksud_version" |
|
||||
grep -o '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*' |
|
||||
head -n 1 || true)"
|
||||
log_succ "KernelSU v${ver_num}"
|
||||
local major="${ver_num%%.*}"
|
||||
|
||||
if [ "${major:-0}" -lt 3 ] 2>/dev/null; then
|
||||
log "KernelSU 版本 ${ver_num:-未知} < 3.0.0, 无需元模块"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -f /data/adb/metamodule/module.prop ]; then
|
||||
log "警告: KernelSU >= 3.0.0 需要元模块, 请先安装"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local meta_name=""
|
||||
meta_name="$(sed -n 's/^name=//p' /data/adb/metamodule/module.prop | head -n 1 || true)"
|
||||
if [ -n "$meta_name" ]; then
|
||||
log_succ "元模块已安装: $meta_name"
|
||||
else
|
||||
log "元模块已安装 (但读不到 name 字段)"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# ---------- 判断 FontLoader ----------
|
||||
CHECK_FONTLOADER() {
|
||||
local fontloader_moddir="/data/adb/modules/fontloader"
|
||||
local fontloader_github="https://github.com/KernelSU-Modules-Repo/fontloader/releases"
|
||||
|
||||
if [ ! -d "$fontloader_moddir" ]; then
|
||||
log "注意: 你还没安装 FontLoader, 如果字体显示效果不佳请安装"
|
||||
log "前往 $fontloader_github 安装 FontLoader"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local prop_file="$fontloader_moddir/module.prop"
|
||||
local version_code=""
|
||||
if [ -f "$prop_file" ]; then
|
||||
version_code="$(sed -n 's/^versionCode=//p' "$prop_file")"
|
||||
fi
|
||||
version_code="$(printf '%s' "$version_code" | tr -cd '0-9')"
|
||||
|
||||
if [ -z "$version_code" ]; then
|
||||
log "注意: 无法读取 FontLoader 版本号, 建议更新到最新版"
|
||||
log "前往 $fontloader_github 更新 FontLoader"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$version_code" -lt 33 ] 2>/dev/null; then
|
||||
log "注意: 你的 FontLoader 版本过低, 建议更新到 v1.2.3+"
|
||||
log "前往 $fontloader_github 更新 FontLoader"
|
||||
else
|
||||
log_succ "FontLoader 版本正常"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------- 主流程 ----------
|
||||
MAIN() {
|
||||
CHECK_COLOROS
|
||||
if ! CHECK_META_MODULE; then
|
||||
log_err "元模块检查不通过"
|
||||
fi
|
||||
CHECK_FONTLOADER
|
||||
|
||||
echo && log "开始准备字体..."
|
||||
DETECT_UPDATE_MODE
|
||||
IMPORT_OLD_FONTS
|
||||
|
||||
echo && log "开始安装字体..."
|
||||
if sh "$MODPATH/apply.sh" "$MODPATH"; then
|
||||
echo && log_succ "所有字体安装成功, 重启设备后生效"
|
||||
else
|
||||
echo && log_err "字体安装出现问题, 请联系开发者"
|
||||
fi
|
||||
}
|
||||
|
||||
MAIN
|
||||
@@ -0,0 +1,7 @@
|
||||
id=FontMM
|
||||
name=FontMM
|
||||
version=26.8.0-beta.2(260800002)
|
||||
versionCode=26080002
|
||||
author=Yule
|
||||
description=ColorOS 16 字体模块模板
|
||||
updateJson=https://raw.githubusercontent.com/YuleBest/FontMM/main/update.json
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018–2022 Cyano Hao
|
||||
Copyright (c) 2022 Shiroki Satsuki
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Losketch
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,94 @@
|
||||
Copyright 2025 The Noto Project Authors (https://github.com/notofonts)
|
||||
Copyright 2025 Mercury13 (https://github.com/Mercury13/unicodia)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,91 @@
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable → Regular
File renamed without changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f54da868866e46a56c39820d34f6f3c4f3d7b0922fe09d3ae938c9bd41e75f41
|
||||
size 112703062
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"versionCode": 26080002,
|
||||
"version": "v26.8.0-beta.2",
|
||||
"zipUrl": "https://github.com/YuleBest/FontMM/releases/download/v26.8.0-beta.2/FontMM_v26.8.0-beta.2.260800002_template.zip",
|
||||
"changelog": "https://raw.githubusercontent.com/YuleBest/FontMM/main/changelog.md"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||
"singleQuote": true,
|
||||
"ignorePatterns": []
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||
"plugins": ["typescript", "unicorn", "oxc"],
|
||||
"categories": {
|
||||
"correctness": "error"
|
||||
},
|
||||
"rules": {},
|
||||
"env": {
|
||||
"builtin": true
|
||||
}
|
||||
}
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover"
|
||||
/>
|
||||
<title>FontMM</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Top App Bar -->
|
||||
<header class="top-app-bar">
|
||||
<span class="top-app-bar__title">FontMM</span>
|
||||
<div class="top-app-bar__actions">
|
||||
<md-icon-button id="about-btn" aria-label="关于">
|
||||
<md-icon>info</md-icon>
|
||||
</md-icon-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 首页视图 -->
|
||||
<main id="home-view" class="view view-home active">
|
||||
<div id="slots"></div>
|
||||
</main>
|
||||
|
||||
<!-- 字体测试视图 -->
|
||||
<div id="test-view" class="view view-test">
|
||||
<div id="test-status" class="test-status">正在加载字体...</div>
|
||||
|
||||
<div id="test-content" class="test-content" hidden>
|
||||
<md-elevated-card class="test-card">
|
||||
<div class="test-section-title">
|
||||
中文简体 <span class="test-tag" id="hans-tag"></span>
|
||||
</div>
|
||||
<div class="test-sample test-sample-hans" id="test-hans">
|
||||
简体中文测试:永和九年,岁在癸丑,暮春之初,会于会稽山阴之兰亭。
|
||||
</div>
|
||||
</md-elevated-card>
|
||||
|
||||
<md-elevated-card class="test-card">
|
||||
<div class="test-section-title">
|
||||
中文繁体 <span class="test-tag" id="hant-tag"></span>
|
||||
</div>
|
||||
<div class="test-sample" id="test-hant">
|
||||
繁體中文測試:永和九年,歲在癸丑,暮春之初,會於會稽山陰之蘭亭。
|
||||
</div>
|
||||
</md-elevated-card>
|
||||
|
||||
<md-elevated-card class="test-card">
|
||||
<div class="test-section-title">
|
||||
英文 & 数字 <span class="test-tag" id="en-tag"></span>
|
||||
</div>
|
||||
<div class="test-sample" id="test-en">
|
||||
The quick brown fox jumps over the lazy dog. 0123456789
|
||||
</div>
|
||||
</md-elevated-card>
|
||||
|
||||
<md-elevated-card class="test-card">
|
||||
<div class="test-section-title">字重<span class="test-tag" id="weight-tag"></span></div>
|
||||
<div class="test-var-note">若各字重显示相同,说明字体为静态单字重或未包含对应字重。</div>
|
||||
<div class="test-w-row" style="font-weight: 100">
|
||||
<span class="test-w-text">100 - 淡体 Thin</span>
|
||||
</div>
|
||||
<div class="test-w-row" style="font-weight: 200">
|
||||
<span class="test-w-text">200 - 特细 ExtraLight</span>
|
||||
</div>
|
||||
<div class="test-w-row" style="font-weight: 300">
|
||||
<span class="test-w-text">300 - 细体 Light</span>
|
||||
</div>
|
||||
<div class="test-w-row" style="font-weight: 400">
|
||||
<span class="test-w-text">400 - 标准 Regular</span>
|
||||
</div>
|
||||
<div class="test-w-row" style="font-weight: 500">
|
||||
<span class="test-w-text">500 - 适中 Medium</span>
|
||||
</div>
|
||||
<div class="test-w-row" style="font-weight: 600">
|
||||
<span class="test-w-text">600 - 次粗 SemiBold</span>
|
||||
</div>
|
||||
<div class="test-w-row" style="font-weight: 700">
|
||||
<span class="test-w-text">700 - 粗体 Bold</span>
|
||||
</div>
|
||||
<div class="test-w-row" style="font-weight: 800">
|
||||
<span class="test-w-text">800 - 特粗 ExtraBold</span>
|
||||
</div>
|
||||
<div class="test-w-row" style="font-weight: 900">
|
||||
<span class="test-w-text">900 - 浓体 Black</span>
|
||||
</div>
|
||||
</md-elevated-card>
|
||||
|
||||
<md-elevated-card class="test-card">
|
||||
<div class="test-section-title">可变字体<span class="test-tag" id="var-tag"></span></div>
|
||||
<div class="test-var-note">
|
||||
拖动滑条调整字重,停止滑动后应用;仅对可变字体 (VF) 生效,静态字体下无变化。
|
||||
</div>
|
||||
<div class="test-wght-row">
|
||||
<span class="test-wght-label">字重</span>
|
||||
<md-slider
|
||||
id="wght-slider"
|
||||
min="100"
|
||||
max="900"
|
||||
step="1"
|
||||
value="400"
|
||||
aria-label="字重滑条"
|
||||
></md-slider>
|
||||
<span class="test-wght-value" id="wght-value">400</span>
|
||||
</div>
|
||||
<div class="test-wght-row">
|
||||
<span class="test-wght-label">字号</span>
|
||||
<md-slider
|
||||
id="size-slider"
|
||||
min="12"
|
||||
max="40"
|
||||
step="1"
|
||||
value="16"
|
||||
aria-label="字号滑条"
|
||||
></md-slider>
|
||||
<span class="test-wght-value" id="size-value">16</span>
|
||||
</div>
|
||||
<div class="test-var-preview" id="test-var-preview">400 - 标准 Regular</div>
|
||||
</md-elevated-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 关于视图 -->
|
||||
<div id="about-view" class="view view-about">
|
||||
<div class="view-topbar">
|
||||
<md-icon-button id="about-back" aria-label="返回">
|
||||
<md-icon>arrow_back</md-icon>
|
||||
</md-icon-button>
|
||||
<span class="view-topbar-title">关于</span>
|
||||
</div>
|
||||
|
||||
<md-elevated-card class="about-card">
|
||||
<div class="about-logo">FontMM</div>
|
||||
<div class="about-desc" id="about-desc">-</div>
|
||||
|
||||
<div class="about-list">
|
||||
<div class="about-row">
|
||||
<span class="about-row-label">版本</span>
|
||||
<span class="about-row-value" id="about-version">-</span>
|
||||
</div>
|
||||
<div class="about-row">
|
||||
<span class="about-row-label">versionCode</span>
|
||||
<span class="about-row-value" id="about-version-code">-</span>
|
||||
</div>
|
||||
<div class="about-row">
|
||||
<span class="about-row-label">作者</span>
|
||||
<span class="about-row-value" id="about-author">-</span>
|
||||
</div>
|
||||
<div class="about-row">
|
||||
<span class="about-row-label">模块 ID</span>
|
||||
<span class="about-row-value" id="about-id">-</span>
|
||||
</div>
|
||||
</div>
|
||||
</md-elevated-card>
|
||||
|
||||
<md-elevated-card class="about-card">
|
||||
<div class="about-section-title">开源</div>
|
||||
<p class="about-section-text">
|
||||
本项目在 GitHub 开源,遵循 MIT 许可证,欢迎 Star / Issue / PR。
|
||||
</p>
|
||||
<div class="about-link">
|
||||
<md-icon>code</md-icon>
|
||||
<span>YuleBest/FontMM</span>
|
||||
<a href="https://github.com/YuleBest/FontMM" target="_blank" rel="noopener noreferrer"
|
||||
>打开</a
|
||||
>
|
||||
</div>
|
||||
</md-elevated-card>
|
||||
|
||||
<md-elevated-card class="about-card">
|
||||
<div class="about-section-title">致谢</div>
|
||||
<p class="about-section-text">
|
||||
补充字库与字体 fallback 结构参考 MakeFontsGreatAgain; 界面基于 Material Design
|
||||
3(Material Web)构建,运行于 KernelSU WebUI; 开发工具链使用 Oxc(oxlint /
|
||||
oxfmt)。感谢所有开源贡献者。
|
||||
</p>
|
||||
</md-elevated-card>
|
||||
|
||||
<div class="about-footer">FontMM · MIT License · ColorOS 16 字体模块</div>
|
||||
</div>
|
||||
|
||||
<!-- 悬浮应用按钮 (仅首页, 向下滚动时隐藏) -->
|
||||
<button id="apply-btn" class="fab" disabled aria-label="应用字体">
|
||||
<md-icon>check_circle</md-icon>
|
||||
<span>应用</span>
|
||||
</button>
|
||||
|
||||
<!-- 日志弹窗 -->
|
||||
<md-dialog id="log-dialog">
|
||||
<div slot="headline">应用日志</div>
|
||||
<div slot="content">
|
||||
<pre
|
||||
id="log-content"
|
||||
style="white-space: pre-wrap; font-family: monospace; font-size: 0.8rem"
|
||||
></pre>
|
||||
</div>
|
||||
<div slot="actions">
|
||||
<md-text-button id="log-close">关闭</md-text-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
|
||||
<!-- 底部导航栏 -->
|
||||
<nav class="bottom-nav">
|
||||
<md-navigation-bar id="nav-bar" active-index="0">
|
||||
<md-navigation-tab label="首页">
|
||||
<md-icon slot="active-icon">home</md-icon>
|
||||
<md-icon slot="inactive-icon">home</md-icon>
|
||||
</md-navigation-tab>
|
||||
<md-navigation-tab label="字体测试">
|
||||
<md-icon slot="active-icon">text_fields</md-icon>
|
||||
<md-icon slot="inactive-icon">text_fields</md-icon>
|
||||
</md-navigation-tab>
|
||||
</md-navigation-bar>
|
||||
</nav>
|
||||
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "fontmm-webui",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"lint": "oxlint",
|
||||
"fmt": "oxfmt",
|
||||
"fmt:check": "oxfmt --check",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@material/web": "^2.4.1",
|
||||
"kernelsu": "^3.0.2",
|
||||
"material-symbols": "^0.28.0",
|
||||
"opentype.js": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"oxfmt": "^0.61.0",
|
||||
"oxlint": "^1.76.0",
|
||||
"sass": "^1.86.0",
|
||||
"typescript": "^5.8.0",
|
||||
"vite": "^6.0.11"
|
||||
}
|
||||
}
|
||||
Generated
+1402
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,3 @@
|
||||
allowBuilds:
|
||||
'@parcel/watcher': true
|
||||
esbuild: true
|
||||
@@ -0,0 +1,187 @@
|
||||
import '@material/web/dialog/dialog.js';
|
||||
import '@material/web/list/list.js';
|
||||
import '@material/web/list/list-item.js';
|
||||
import '@material/web/icon/icon.js';
|
||||
import '@material/web/iconbutton/icon-button.js';
|
||||
import '@material/web/button/text-button.js';
|
||||
import { exec } from './ksu';
|
||||
|
||||
export interface FileItem {
|
||||
name: string;
|
||||
isDir: boolean;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
export class FontFilePicker {
|
||||
private currentPath = '/storage/emulated/0';
|
||||
private dialogEl!: HTMLElement;
|
||||
private listEl!: HTMLElement;
|
||||
private pathEl!: HTMLElement;
|
||||
private onSelectCallback: (path: string, fileName: string) => void;
|
||||
|
||||
constructor(onSelect: (path: string, fileName: string) => void) {
|
||||
this.onSelectCallback = onSelect;
|
||||
this.initDialog();
|
||||
}
|
||||
|
||||
private initDialog(): void {
|
||||
if (document.getElementById('picker-dialog')) {
|
||||
this.dialogEl = document.getElementById('picker-dialog')!;
|
||||
this.listEl = document.getElementById('picker-list')!;
|
||||
this.pathEl = document.getElementById('picker-path')!;
|
||||
return;
|
||||
}
|
||||
|
||||
const dialogHTML = `
|
||||
<md-dialog id="picker-dialog" class="font-picker-dialog">
|
||||
<div slot="headline" class="picker-header">
|
||||
<div class="picker-title-bar">
|
||||
<md-icon-button id="picker-back-btn" class="picker-back" aria-label="返回上一级">
|
||||
<md-icon>arrow_back</md-icon>
|
||||
</md-icon-button>
|
||||
<div class="picker-path-group">
|
||||
<div class="picker-subtitle">选择字体文件</div>
|
||||
<div id="picker-path" class="picker-path-text">/storage/emulated/0</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div slot="content" class="picker-content">
|
||||
<md-list id="picker-list" class="picker-list"></md-list>
|
||||
</div>
|
||||
|
||||
<div slot="actions">
|
||||
<md-text-button id="picker-cancel-btn">取消</md-text-button>
|
||||
</div>
|
||||
</md-dialog>
|
||||
`;
|
||||
document.body.insertAdjacentHTML('beforeend', dialogHTML);
|
||||
|
||||
this.dialogEl = document.getElementById('picker-dialog')!;
|
||||
this.listEl = document.getElementById('picker-list')!;
|
||||
this.pathEl = document.getElementById('picker-path')!;
|
||||
|
||||
document.getElementById('picker-back-btn')?.addEventListener('click', () => this.navigateUp());
|
||||
document.getElementById('picker-cancel-btn')?.addEventListener('click', () => this.hide());
|
||||
}
|
||||
|
||||
public show(initialPath = '/storage/emulated/0'): void {
|
||||
this.currentPath = initialPath;
|
||||
(this.dialogEl as any).open = true;
|
||||
this.loadDirectory(this.currentPath);
|
||||
}
|
||||
|
||||
public hide(): void {
|
||||
(this.dialogEl as any).open = false;
|
||||
}
|
||||
|
||||
private navigateUp(): void {
|
||||
if (this.currentPath === '/' || this.currentPath === '') return;
|
||||
const parts = this.currentPath.split('/').filter(Boolean);
|
||||
parts.pop();
|
||||
this.currentPath = parts.length === 0 ? '/' : '/' + parts.join('/');
|
||||
this.loadDirectory(this.currentPath);
|
||||
}
|
||||
|
||||
private async loadDirectory(path: string): Promise<void> {
|
||||
this.pathEl.textContent = path;
|
||||
this.listEl.innerHTML = `<div class="picker-loading">正在读取目录...</div>`;
|
||||
|
||||
try {
|
||||
const { items, failed } = await this.readDir(path);
|
||||
if (failed) {
|
||||
this.listEl.innerHTML = `<div class="picker-error">无法读取该目录</div>`;
|
||||
return;
|
||||
}
|
||||
this.renderList(items);
|
||||
} catch (e) {
|
||||
this.listEl.innerHTML = `<div class="picker-error">读取目录异常: ${String(e)}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
// 用 find 列出目录与文件: 每行一个完整路径, 目录/文件分两次查询
|
||||
// (兼容 busybox 与 GNU find, 不解析 ls 的列输出, 路径含空格也安全)
|
||||
private async readDir(path: string): Promise<{ items: FileItem[]; failed: boolean }> {
|
||||
const [dirRes, fileRes] = await Promise.all([
|
||||
exec(`find "${path}" -maxdepth 1 -mindepth 1 -type d`),
|
||||
exec(`find "${path}" -maxdepth 1 -mindepth 1 -type f`),
|
||||
]);
|
||||
|
||||
if (dirRes.errno !== 0 || fileRes.errno !== 0) {
|
||||
return { items: [], failed: true };
|
||||
}
|
||||
|
||||
const dirs = this.splitLines(dirRes.stdout).map((p) => this.basename(p));
|
||||
const files = this.splitLines(fileRes.stdout)
|
||||
.map((p) => this.basename(p))
|
||||
// 仅显示扩展名为 .ttf 的文件
|
||||
.filter((name) => name.toLowerCase().endsWith('.ttf'));
|
||||
|
||||
const items: FileItem[] = [
|
||||
...dirs.map((name) => ({ name, isDir: true })),
|
||||
...files.map((name) => ({ name, isDir: false })),
|
||||
].sort((a, b) => {
|
||||
if (a.isDir && !b.isDir) return -1;
|
||||
if (!a.isDir && b.isDir) return 1;
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
|
||||
return { items, failed: false };
|
||||
}
|
||||
|
||||
private splitLines(output: string): string[] {
|
||||
return output
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
private basename(path: string): string {
|
||||
return path.slice(path.lastIndexOf('/') + 1) || path;
|
||||
}
|
||||
|
||||
private renderList(items: FileItem[]): void {
|
||||
if (items.length === 0) {
|
||||
this.listEl.innerHTML = `
|
||||
<div class="picker-empty">
|
||||
<md-icon>find_in_page</md-icon>
|
||||
<span>此目录下没有 .ttf 字体文件</span>
|
||||
</div>`;
|
||||
return;
|
||||
}
|
||||
|
||||
this.listEl.innerHTML = items
|
||||
.map(
|
||||
(item) => `
|
||||
<md-list-item class="picker-item ${item.isDir ? 'is-dir' : 'is-file'}" data-name="${item.name}" data-isdir="${item.isDir}">
|
||||
<md-icon slot="start" class="item-icon">
|
||||
${item.isDir ? 'folder' : 'font_download'}
|
||||
</md-icon>
|
||||
<div slot="headline" class="item-name">${item.name}</div>
|
||||
${
|
||||
item.isDir
|
||||
? `<md-icon slot="end" class="item-arrow">chevron_right</md-icon>`
|
||||
: `<md-text-button slot="end" class="item-select-btn">选择</md-text-button>`
|
||||
}
|
||||
</md-list-item>
|
||||
`,
|
||||
)
|
||||
.join('');
|
||||
|
||||
this.listEl.querySelectorAll('.picker-item').forEach((el) => {
|
||||
el.addEventListener('click', () => {
|
||||
const name = (el as HTMLElement).dataset.name!;
|
||||
const isDir = (el as HTMLElement).dataset.isdir === 'true';
|
||||
|
||||
if (isDir) {
|
||||
this.currentPath = this.currentPath === '/' ? `/${name}` : `${this.currentPath}/${name}`;
|
||||
this.loadDirectory(this.currentPath);
|
||||
} else {
|
||||
const fullPath = `${this.currentPath}/${name}`;
|
||||
this.onSelectCallback(fullPath, name);
|
||||
this.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
import { exec as ksuExec, toast as ksuToast, moduleInfo as ksuModuleInfo } from 'kernelsu';
|
||||
|
||||
export interface ExecResult {
|
||||
errno: number;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
}
|
||||
|
||||
// dev 模式假文件系统 (用于文件选择器, 路径结构与 Android 一致)
|
||||
const FAKE_FS: Record<string, { dirs: string[]; fonts: string[]; files: string[] }> = {
|
||||
'/': { dirs: ['storage'], fonts: [], files: [] },
|
||||
'/storage': { dirs: ['emulated'], fonts: [], files: [] },
|
||||
'/storage/emulated': { dirs: ['0'], fonts: [], files: [] },
|
||||
'/storage/emulated/0': {
|
||||
dirs: ['Download', 'Fonts', 'Documents', '字体'],
|
||||
fonts: [],
|
||||
files: ['notes.txt'],
|
||||
},
|
||||
'/storage/emulated/0/Download': {
|
||||
dirs: [],
|
||||
fonts: ['HarmonyOS_Sans.ttf', 'MiSans-Bold.ttf'],
|
||||
files: ['a.pdf'],
|
||||
},
|
||||
'/storage/emulated/0/Fonts': {
|
||||
dirs: [],
|
||||
fonts: ['OPPOSans.ttf', 'SourceHanSansCN.ttf'],
|
||||
files: [],
|
||||
},
|
||||
'/storage/emulated/0/Documents': { dirs: [], fonts: [], files: [] },
|
||||
'/storage/emulated/0/字体': { dirs: [], fonts: ['思源黑体.ttf', '霞鹜文楷.ttf'], files: [] },
|
||||
};
|
||||
|
||||
async function mockExec(command: string): Promise<ExecResult> {
|
||||
const fake = (stdout = ''): ExecResult => ({ errno: 0, stdout, stderr: '' });
|
||||
const fail = (stderr: string): ExecResult => ({ errno: 1, stdout: '', stderr });
|
||||
const slow = (stdout = '') =>
|
||||
new Promise<ExecResult>((r) => setTimeout(() => r(fake(stdout)), 200));
|
||||
const slowFail = (stderr: string) =>
|
||||
new Promise<ExecResult>((r) => setTimeout(() => r(fail(stderr)), 200));
|
||||
|
||||
// find 命令: 解析路径与类型 (d/f), 返回假目录/文件, 每行一个完整路径
|
||||
if (command.startsWith('find ')) {
|
||||
const m = command.match(/^find ['"]([^'"]*)['"] -maxdepth 1 -mindepth 1 -type ([df])$/);
|
||||
if (!m) return slow(`(mock 未定义: ${command})`);
|
||||
const dir = m[1];
|
||||
const node = FAKE_FS[dir];
|
||||
if (!node) return slowFail(`find: ${dir}: No such file or directory`);
|
||||
const full = (name: string) => (dir === '/' ? `/${name}` : `${dir}/${name}`);
|
||||
const lines = m[2] === 'd' ? node.dirs.map(full) : [...node.fonts, ...node.files].map(full);
|
||||
return slow(lines.join('\n'));
|
||||
}
|
||||
|
||||
// 字体测试: 模拟 FONT 字体已放入 webroot/fonts-test, 返回可用字体列表
|
||||
if (command.includes('fonts-test')) {
|
||||
return slow('hans.ttf\nhant.ttf\nen.ttf\nmono.ttf');
|
||||
}
|
||||
|
||||
if (command.includes('rm -f')) return fake('');
|
||||
if (command.includes('cp -f')) return fake('');
|
||||
if (command.includes('apply.sh')) {
|
||||
return fake('[*] 安装: SysSans-Hans-Regular.ttf (模拟)\n[*] 全部完成, 重启后生效 (模拟)');
|
||||
}
|
||||
|
||||
if (command.includes('ro.product.model')) return slow('Pixel 8 Pro (模拟设备)');
|
||||
return slow(`(mock 未定义: ${command})`);
|
||||
}
|
||||
|
||||
export async function exec(command: string): Promise<ExecResult> {
|
||||
if (import.meta.env.DEV) return mockExec(command);
|
||||
// KernelSU-Next 等分支的 ksu API 可能与 KernelSU 不一致, 缺失时优雅降级
|
||||
if (typeof ksuExec !== 'function') {
|
||||
return { errno: 1, stdout: '', stderr: 'kernelsu exec API 不可用' };
|
||||
}
|
||||
return ksuExec(command);
|
||||
}
|
||||
|
||||
export function toast(msg: string): void {
|
||||
if (import.meta.env.DEV) console.log('[toast]', msg);
|
||||
else if (typeof ksuToast === 'function') ksuToast(msg);
|
||||
}
|
||||
|
||||
// 模块信息 (module.prop 风格文本), dev 模式返回模拟数据
|
||||
export function moduleInfo(): string {
|
||||
if (import.meta.env.DEV) {
|
||||
return [
|
||||
'id=FontMM',
|
||||
'name=FontMM',
|
||||
'version=26.8.0-beta.1(260800001)',
|
||||
'versionCode=26080001',
|
||||
'author=Yule',
|
||||
'description=ColorOS 16 字体模块模板',
|
||||
].join('\n');
|
||||
}
|
||||
if (typeof ksuModuleInfo === 'function') return ksuModuleInfo();
|
||||
return '';
|
||||
}
|
||||
|
||||
// 全屏: 让 WebView 内容延伸到状态栏 / 底部导航栏(小白条) 下方
|
||||
export function fullScreen(enabled: boolean): void {
|
||||
if (import.meta.env.DEV) return;
|
||||
// 直接调用全局 ksu (绕过 npm 包封装), KernelSU-Next 分支缺失/命名不同时忽略
|
||||
try {
|
||||
const ksuApi = (window as any).ksu as Record<string, unknown> | undefined;
|
||||
if (ksuApi && typeof ksuApi.fullScreen === 'function') {
|
||||
(ksuApi.fullScreen as (v: boolean) => void)(enabled);
|
||||
}
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
|
||||
// edge-to-edge: 启用安全区 insets (配合 insets.css 的 --window-inset-* 变量)
|
||||
export function enableEdgeToEdge(enabled: boolean): void {
|
||||
if (import.meta.env.DEV) return;
|
||||
// 关键: 不能检查 npm 包的 import 绑定 (它始终存在, 真正的 TypeError 在包内部
|
||||
// 调用 ksu.enableEdgeToEdge 时抛出, 会中断整个脚本)。必须直接检查全局 ksu 对象。
|
||||
// KernelSU: enableEdgeToEdge; KernelSU-Next: enableInsets (命名不同)
|
||||
try {
|
||||
const ksuApi = (window as any).ksu as Record<string, unknown> | undefined;
|
||||
if (!ksuApi) return;
|
||||
const fn = (ksuApi.enableEdgeToEdge ?? ksuApi.enableInsets) as
|
||||
| ((v: boolean) => void)
|
||||
| undefined;
|
||||
if (typeof fn === 'function') fn(enabled);
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
+539
@@ -0,0 +1,539 @@
|
||||
import '@material/web/button/outlined-button.js';
|
||||
import '@material/web/button/text-button.js';
|
||||
import '@material/web/iconbutton/icon-button.js';
|
||||
import '@material/web/icon/icon.js';
|
||||
import '@material/web/dialog/dialog.js';
|
||||
import '@material/web/slider/slider.js';
|
||||
import '@material/web/labs/card/elevated-card.js';
|
||||
import '@material/web/labs/navigationbar/navigation-bar.js';
|
||||
import '@material/web/labs/navigationtab/navigation-tab.js';
|
||||
import 'material-symbols/outlined.css';
|
||||
|
||||
import './theme.scss';
|
||||
import './style.scss';
|
||||
|
||||
import { exec, enableEdgeToEdge, moduleInfo, toast } from './ksu';
|
||||
import { FontFilePicker } from './fontPicker';
|
||||
import type { FontSlot } from './types';
|
||||
import * as opentype from 'opentype.js';
|
||||
|
||||
// edge-to-edge: 启用安全区 insets, 内容延伸至状态栏/底部小白条区域,
|
||||
// insets.css 的 --window-inset-* 变量随之生效, 底栏据此避让
|
||||
enableEdgeToEdge(true);
|
||||
|
||||
const FONTS_DIR = '/data/adb/modules/FontMM/FONTS';
|
||||
|
||||
const slots: Record<'hans' | 'hant' | 'en' | 'mono', FontSlot> = {
|
||||
hans: {
|
||||
key: 'hans',
|
||||
title: '中文简体',
|
||||
path: null,
|
||||
fileName: '',
|
||||
},
|
||||
hant: {
|
||||
key: 'hant',
|
||||
title: '中文繁体',
|
||||
path: null,
|
||||
fileName: '',
|
||||
},
|
||||
en: {
|
||||
key: 'en',
|
||||
title: '英文 & 数字',
|
||||
path: null,
|
||||
fileName: '',
|
||||
},
|
||||
mono: {
|
||||
key: 'mono',
|
||||
title: '等宽字体',
|
||||
path: null,
|
||||
fileName: '',
|
||||
},
|
||||
};
|
||||
|
||||
const slotsEl = document.getElementById('slots')!;
|
||||
const applyBtn = document.getElementById('apply-btn') as HTMLButtonElement;
|
||||
const logDialog = document.getElementById('log-dialog') as any;
|
||||
const logContent = document.getElementById('log-content')!;
|
||||
|
||||
document.getElementById('log-close')?.addEventListener('click', () => {
|
||||
logDialog.open = false;
|
||||
});
|
||||
|
||||
let pickingKey: keyof typeof slots = 'hans';
|
||||
let applying = false;
|
||||
|
||||
const picker = new FontFilePicker((path, name) => {
|
||||
const slot = slots[pickingKey];
|
||||
slot.path = path;
|
||||
slot.fileName = name;
|
||||
renderSlots();
|
||||
void refreshSlotInfo(slot);
|
||||
});
|
||||
|
||||
// ---------- 字体名称解析 (opentype.js) ----------
|
||||
// 从字体名称表提取 family name, 优先中文字体名
|
||||
function extractFamilyName(font: any): string | null {
|
||||
const pick = (table: any): string | null => {
|
||||
if (!table) return null;
|
||||
const family = table.fontFamily ?? table.fullName;
|
||||
if (!family || typeof family !== 'object') return null;
|
||||
for (const lang of ['zh-CN', 'zh-Hans', 'zh', 'zh-TW', 'zh-Hant', 'en', 'en-US']) {
|
||||
if (typeof family[lang] === 'string' && family[lang]) return family[lang];
|
||||
}
|
||||
const first = Object.values(family).find((v) => typeof v === 'string' && v);
|
||||
return first ? String(first) : null;
|
||||
};
|
||||
return pick(font.names?.windows) ?? pick(font.names?.macintosh);
|
||||
}
|
||||
|
||||
// 读取 fonts-test/ 下字体文件的名称与大小 (WebView 仅能访问 webroot 内文件)
|
||||
async function readFontInfo(file: string): Promise<{ name?: string; sizeText?: string }> {
|
||||
try {
|
||||
const res = await fetch(`fonts-test/${file}`);
|
||||
if (!res.ok) return {};
|
||||
const buf = await res.arrayBuffer();
|
||||
const font = opentype.parse(buf);
|
||||
const name = extractFamilyName(font);
|
||||
const sizeText = `${(buf.byteLength / 1024 / 1024).toFixed(1)} MB`;
|
||||
return { name: name ?? undefined, sizeText };
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// 选择新字体后: 复制到 fonts-test 供解析, 更新卡片显示的名称/大小
|
||||
async function refreshSlotInfo(slot: FontSlot) {
|
||||
if (!slot.path) return;
|
||||
try {
|
||||
await exec(`cp -f '${slot.path}' '${TEST_FONT_DIR}/${slot.key}.ttf'`);
|
||||
const info = await readFontInfo(`${slot.key}.ttf`);
|
||||
if (info.name) slot.fileName = info.name;
|
||||
if (info.sizeText) slot.sizeText = info.sizeText;
|
||||
renderSlots();
|
||||
} catch {
|
||||
// 忽略解析失败, 保持选择器返回的文件名
|
||||
}
|
||||
}
|
||||
|
||||
// 打开 WebUI 时: 复制 FONT/ 到 fonts-test, 读取已有字体的名称/大小填充卡片
|
||||
async function loadExistingFonts() {
|
||||
const available = await ensureFontsCopy();
|
||||
for (const key of ['hans', 'hant', 'en', 'mono'] as const) {
|
||||
const file = `${key}.ttf`;
|
||||
if (!available.includes(file)) continue;
|
||||
const slot = slots[key];
|
||||
const info = await readFontInfo(file);
|
||||
slot.path = `${FONTS_DIR}/${file}`;
|
||||
slot.fileName = info.name ?? file;
|
||||
if (info.sizeText) slot.sizeText = info.sizeText;
|
||||
}
|
||||
renderSlots();
|
||||
}
|
||||
|
||||
// 未选择时的占位文案: 回退可视化 (WYSIWYG)
|
||||
function slotPlaceholder(slot: FontSlot): string {
|
||||
if (slot.path) return slot.fileName;
|
||||
if (slot.key === 'hans') return '未选择字体文件';
|
||||
if (slots.hans.path) {
|
||||
if (slot.key === 'mono') return '未选择,保持系统等宽字体';
|
||||
return `默认使用:${slots.hans.fileName}`;
|
||||
}
|
||||
return '未选择字体文件';
|
||||
}
|
||||
|
||||
function renderSlots() {
|
||||
slotsEl.innerHTML = Object.values(slots)
|
||||
.map((slot) => {
|
||||
// 选了其他槽位但未选简体时, 简体卡片提示"必选"
|
||||
const required =
|
||||
slot.key === 'hans' &&
|
||||
!slot.path &&
|
||||
Object.values(slots).some((s) => s.key !== 'hans' && s.path);
|
||||
const nameText = required ? '此字体为必选' : slotPlaceholder(slot);
|
||||
return `
|
||||
<md-elevated-card class="slot-card ${slot.key === 'hans' ? 'slot-hans' : ''} ${slot.path ? 'selected' : ''}">
|
||||
<div class="slot-header">
|
||||
<div class="slot-title-group">
|
||||
<span class="slot-title">${slot.title}</span>
|
||||
</div>
|
||||
<div class="slot-actions">
|
||||
<md-outlined-button class="slot-pick" data-key="${slot.key}">
|
||||
<md-icon slot="icon">folder_open</md-icon>
|
||||
${slot.path ? '更换' : '选择'}
|
||||
</md-outlined-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="slot-file">
|
||||
${
|
||||
slot.path
|
||||
? `<md-icon-button class="slot-clear" data-key="${slot.key}" aria-label="取消选择">
|
||||
<md-icon>close</md-icon>
|
||||
</md-icon-button>`
|
||||
: ''
|
||||
}
|
||||
<div class="slot-file-text">
|
||||
<div class="slot-name ${!slot.path ? 'placeholder' : ''} ${required ? 'required' : ''}">${nameText}</div>
|
||||
${slot.path ? `<div class="slot-meta">${slot.sizeText || '…'} · 字体文件</div>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
</md-elevated-card>
|
||||
`;
|
||||
})
|
||||
.join('');
|
||||
|
||||
// 绑定事件
|
||||
slotsEl.querySelectorAll<HTMLElement>('.slot-pick').forEach((btn) => {
|
||||
btn.addEventListener('click', () => {
|
||||
pickingKey = btn.dataset.key as keyof typeof slots;
|
||||
picker.show();
|
||||
});
|
||||
});
|
||||
slotsEl.querySelectorAll<HTMLElement>('.slot-clear').forEach((btn) => {
|
||||
btn.addEventListener('click', () => {
|
||||
const slot = slots[btn.dataset.key as keyof typeof slots];
|
||||
slot.path = null;
|
||||
slot.fileName = '';
|
||||
renderSlots();
|
||||
});
|
||||
});
|
||||
|
||||
if (applyBtn) {
|
||||
// 未选择简体字体时直接隐藏按钮 (不做半透明禁用)
|
||||
applyBtn.style.display = !slots.hans.path ? 'none' : '';
|
||||
applyBtn.disabled = applying;
|
||||
}
|
||||
}
|
||||
|
||||
async function copyFont(src: string, dest: string) {
|
||||
const { errno, stderr } = await exec(`cp -f '${src}' '${dest}'`);
|
||||
if (errno !== 0) throw new Error(`复制失败: ${stderr}`);
|
||||
}
|
||||
|
||||
async function apply() {
|
||||
if (!slots.hans.path) return;
|
||||
applying = true;
|
||||
renderSlots();
|
||||
try {
|
||||
// 启动加载的字体 path 即 FONT/ 内的文件, 无需再复制
|
||||
if (slots.hans.path !== `${FONTS_DIR}/hans.ttf`) {
|
||||
await copyFont(slots.hans.path, `${FONTS_DIR}/hans.ttf`);
|
||||
}
|
||||
|
||||
if (slots.hant.path) {
|
||||
if (slots.hant.path !== `${FONTS_DIR}/hant.ttf`) {
|
||||
await copyFont(slots.hant.path, `${FONTS_DIR}/hant.ttf`);
|
||||
}
|
||||
} else {
|
||||
await exec(`rm -f '${FONTS_DIR}/hant.ttf'`);
|
||||
}
|
||||
|
||||
if (slots.en.path) {
|
||||
if (slots.en.path !== `${FONTS_DIR}/en.ttf`) {
|
||||
await copyFont(slots.en.path, `${FONTS_DIR}/en.ttf`);
|
||||
}
|
||||
} else {
|
||||
await exec(`rm -f '${FONTS_DIR}/en.ttf'`);
|
||||
}
|
||||
|
||||
if (slots.mono.path) {
|
||||
if (slots.mono.path !== `${FONTS_DIR}/mono.ttf`) {
|
||||
await copyFont(slots.mono.path, `${FONTS_DIR}/mono.ttf`);
|
||||
}
|
||||
} else {
|
||||
await exec(`rm -f '${FONTS_DIR}/mono.ttf'`);
|
||||
}
|
||||
|
||||
const { errno, stdout, stderr } = await exec('sh /data/adb/modules/FontMM/apply.sh');
|
||||
if (errno !== 0) throw new Error(stderr || 'apply.sh 执行失败');
|
||||
|
||||
if (logContent && logDialog) {
|
||||
logContent.textContent = stdout;
|
||||
logDialog.open = true;
|
||||
}
|
||||
toast('字体已应用,重启后生效');
|
||||
} catch (e) {
|
||||
toast(`应用失败: ${String(e)}`);
|
||||
} finally {
|
||||
applying = false;
|
||||
renderSlots();
|
||||
}
|
||||
}
|
||||
|
||||
applyBtn?.addEventListener('click', apply);
|
||||
renderSlots();
|
||||
|
||||
// ---------------- 导航与视图切换 ----------------
|
||||
const homeView = document.getElementById('home-view')!;
|
||||
const testView = document.getElementById('test-view')!;
|
||||
const aboutView = document.getElementById('about-view')!;
|
||||
|
||||
const views = [homeView, testView, aboutView];
|
||||
const navBar = document.getElementById('nav-bar') as any;
|
||||
// 悬浮应用按钮 (与首页绑定, 仅首页显示)
|
||||
const applyFab = document.getElementById('apply-btn') as HTMLElement;
|
||||
|
||||
function showView(index: number) {
|
||||
views.forEach((v, i) => v.classList.toggle('active', i === index));
|
||||
// 悬浮应用按钮仅首页显示, 且未选简体字体时不展示
|
||||
applyFab.style.display = index === 0 && slots.hans.path ? '' : 'none';
|
||||
// 关于页隐藏顶栏 (自身带返回栏)
|
||||
document.body.classList.toggle('no-top-bar', index === 2);
|
||||
// 同步底部导航高亮 (仅首页/字体测试两个 tab)
|
||||
if (index < 2 && navBar) navBar.activeIndex = index;
|
||||
if (index === 1) loadTestFonts();
|
||||
if (index === 2) loadAbout();
|
||||
}
|
||||
|
||||
// 悬浮按钮滚动隐藏: 向下滚动移出视口, 向上滚动出现
|
||||
let lastScrollY = window.scrollY;
|
||||
window.addEventListener(
|
||||
'scroll',
|
||||
() => {
|
||||
const y = window.scrollY;
|
||||
if (y > lastScrollY + 4) applyFab.classList.add('fab-hidden');
|
||||
else if (y < lastScrollY - 4) applyFab.classList.remove('fab-hidden');
|
||||
lastScrollY = y;
|
||||
},
|
||||
{ passive: true },
|
||||
);
|
||||
|
||||
navBar?.addEventListener('navigation-bar-activated', (e: { detail: { activeIndex: number } }) => {
|
||||
showView(e.detail.activeIndex);
|
||||
});
|
||||
|
||||
// 关于入口: 顶栏按钮进入, 关于页返回栏回首页
|
||||
document.getElementById('about-btn')?.addEventListener('click', () => showView(2));
|
||||
document.getElementById('about-back')?.addEventListener('click', () => showView(0));
|
||||
|
||||
// ---------------- 关于页 ----------------
|
||||
interface ModuleProp {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
// 解析 module.prop 风格文本 (key=value 每行一个)
|
||||
function parseProp(text: string): ModuleProp {
|
||||
const out: ModuleProp = {};
|
||||
for (const line of text.split('\n')) {
|
||||
const idx = line.indexOf('=');
|
||||
if (idx > 0) {
|
||||
const key = line.slice(0, idx).trim();
|
||||
if (key) out[key] = line.slice(idx + 1).trim();
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
async function loadAbout() {
|
||||
let prop: ModuleProp = {};
|
||||
|
||||
// 1) 优先从 kernelsu WebUI API 获取模块信息
|
||||
try {
|
||||
prop = { ...prop, ...parseProp(moduleInfo()) };
|
||||
} catch {
|
||||
// dev 或 API 不可用时忽略, 走下方兜底
|
||||
}
|
||||
|
||||
// 2) 兜底: 通过 kernelsu exec 读取模块的 module.prop
|
||||
try {
|
||||
const { errno, stdout } = await exec('cat /data/adb/modules/FontMM/module.prop');
|
||||
if (errno === 0) prop = { ...prop, ...parseProp(stdout) };
|
||||
} catch {
|
||||
// 忽略读取失败
|
||||
}
|
||||
|
||||
const set = (id: string, value: string) => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.textContent = value;
|
||||
};
|
||||
set('about-version', prop.version || '未知');
|
||||
set('about-version-code', prop.versionCode || '未知');
|
||||
set('about-author', prop.author || '未知');
|
||||
set('about-id', prop.id || 'FontMM');
|
||||
set('about-desc', prop.description || 'ColorOS 16 字体模块');
|
||||
}
|
||||
|
||||
// ---------------- 字体测试页 ----------------
|
||||
const WEBROOT_DIR = '/data/adb/modules/FontMM/webroot';
|
||||
const TEST_FONT_DIR = `${WEBROOT_DIR}/fonts-test`;
|
||||
|
||||
const testStatus = document.getElementById('test-status')!;
|
||||
const testContent = document.getElementById('test-content')!;
|
||||
|
||||
type TestSlot = 'hans' | 'hant' | 'en';
|
||||
|
||||
const TEST_FONTS: { slot: TestSlot; file: string; family: string }[] = [
|
||||
{ slot: 'hans', file: 'hans.ttf', family: 'FontMM-Hans' },
|
||||
{ slot: 'hant', file: 'hant.ttf', family: 'FontMM-Hant' },
|
||||
{ slot: 'en', file: 'en.ttf', family: 'FontMM-En' },
|
||||
];
|
||||
|
||||
async function registerFont(family: string, file: string): Promise<boolean> {
|
||||
try {
|
||||
// 声明完整字重范围: 否则 FontFace 默认只覆盖 weight 400,
|
||||
// CSS font-weight 100-900 将无法匹配到该字体 (真机表现: 100-400 无变化)
|
||||
const font = new FontFace(family, `url('fonts-test/${file}')`, { weight: '100 900' });
|
||||
await font.load();
|
||||
document.fonts.add(font);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 复制 FONT/ 到 webroot/fonts-test, 供页面加载与名称解析
|
||||
// (WebView 无法直接访问模块外部目录, 符号链接在真机也不可靠, 直接复制)
|
||||
async function ensureFontsCopy(): Promise<string[]> {
|
||||
const copyCmd = [
|
||||
`rm -rf '${TEST_FONT_DIR}'`,
|
||||
`mkdir -p '${TEST_FONT_DIR}'`,
|
||||
`cp -f '${FONTS_DIR}'/*.ttf '${TEST_FONT_DIR}'/ 2>/dev/null`,
|
||||
].join('\n');
|
||||
try {
|
||||
const { errno } = await exec(copyCmd);
|
||||
if (errno !== 0) return [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
return listFontsDir();
|
||||
}
|
||||
|
||||
// 列出 fonts-test/ 下的字体文件 (每行一个完整路径)
|
||||
async function listFontsDir(): Promise<string[]> {
|
||||
try {
|
||||
const { errno, stdout } = await exec(`find '${TEST_FONT_DIR}' -maxdepth 1 -mindepth 1 -type f`);
|
||||
if (errno !== 0) return [];
|
||||
return stdout
|
||||
.split('\n')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
.map((p) => p.slice(p.lastIndexOf('/') + 1));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTestFonts(): Promise<void> {
|
||||
testStatus.hidden = false;
|
||||
testContent.hidden = true;
|
||||
testStatus.textContent = '正在加载字体...';
|
||||
|
||||
// 字体已在 WebUI 打开时复制到 fonts-test, 此处直接读取
|
||||
const available = await listFontsDir();
|
||||
|
||||
// 注册字体, 记录每个槽位是否加载成功
|
||||
const loaded = new Map<TestSlot, boolean>();
|
||||
for (const tf of TEST_FONTS) {
|
||||
loaded.set(
|
||||
tf.slot,
|
||||
available.includes(tf.file) ? await registerFont(tf.family, tf.file) : false,
|
||||
);
|
||||
}
|
||||
|
||||
// fallback 逻辑: hant/en 缺失回退 hans
|
||||
const hans = loaded.get('hans') ? 'FontMM-Hans' : 'sans-serif';
|
||||
const hant = loaded.get('hant') ? 'FontMM-Hant' : hans;
|
||||
const en = loaded.get('en') ? 'FontMM-En' : hans;
|
||||
|
||||
// 显示字体名称 (解析出的 family name; 未解析到时为文件名)
|
||||
const slotLabel = (key: TestSlot): string => slots[key].fileName;
|
||||
const hasFont = (key: TestSlot): boolean => available.includes(`${key}.ttf`);
|
||||
const hansLabel = hasFont('hans') ? slotLabel('hans') : null;
|
||||
|
||||
const setTag = (id: string, text: string) => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.textContent = text;
|
||||
};
|
||||
setTag('hans-tag', hasFont('hans') ? slotLabel('hans') : '未设置, 使用系统字体');
|
||||
setTag(
|
||||
'hant-tag',
|
||||
hasFont('hant') ? slotLabel('hant') : hansLabel ? `回退 ${hansLabel}` : '未设置, 使用系统字体',
|
||||
);
|
||||
setTag(
|
||||
'en-tag',
|
||||
hasFont('en') ? slotLabel('en') : hansLabel ? `回退 ${hansLabel}` : '未设置, 使用系统字体',
|
||||
);
|
||||
setTag('weight-tag', `使用 ${hansLabel ?? '系统字体'}`);
|
||||
setTag('var-tag', `使用 ${hansLabel ?? '系统字体'}`);
|
||||
|
||||
const setFamily = (id: string, family: string, fallback: string) => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.style.fontFamily = `'${family}', ${fallback}`;
|
||||
};
|
||||
setFamily('test-hans', hans, 'sans-serif');
|
||||
setFamily('test-hant', hant, `'${hans}', sans-serif`);
|
||||
setFamily('test-en', en, `'${hans}', sans-serif`);
|
||||
// 字重 / 可变字体测试: 用完整 fallback 链渲染 (Hans → Hant → En 按用户选择顺序,
|
||||
// 浏览器逐字形回退, 所见即所得地体现系统真实 fallback)
|
||||
const fallbackChain = [...new Set([hans, hant, en])].map((f) => `'${f}'`).join(', ');
|
||||
const fullChain = `${fallbackChain}, sans-serif`;
|
||||
document.querySelectorAll<HTMLElement>('.test-w-text').forEach((el) => {
|
||||
el.style.fontFamily = fullChain;
|
||||
});
|
||||
const vp = document.getElementById('test-var-preview');
|
||||
if (vp) vp.style.fontFamily = fullChain;
|
||||
applyWght(400); // 与滑条初始值保持一致
|
||||
|
||||
testStatus.textContent =
|
||||
available.length === 0
|
||||
? '未找到已设置的字体 (FONTS 为空), 当前使用系统字体预览'
|
||||
: '字体已加载, 下方为预览效果 (按 fallback 逻辑)';
|
||||
testContent.hidden = false;
|
||||
}
|
||||
|
||||
// 可变字体滑动条: 滑动中只更新数值显示, 停止 250ms 后才应用字重 (省性能)
|
||||
const wghtSlider = document.getElementById('wght-slider') as any;
|
||||
const wghtValue = document.getElementById('wght-value')!;
|
||||
const varPreview = document.getElementById('test-var-preview') as HTMLElement | null;
|
||||
|
||||
let wghtTimer: number | undefined;
|
||||
function applyWght(weight: number) {
|
||||
if (varPreview) varPreview.style.fontVariationSettings = `'wght' ${weight}`;
|
||||
}
|
||||
|
||||
// 字重档位名称 (与字重测试区一致)
|
||||
const WEIGHT_NAMES: Record<number, string> = {
|
||||
100: '淡体 Thin',
|
||||
200: '特细 ExtraLight',
|
||||
300: '细体 Light',
|
||||
400: '标准 Regular',
|
||||
500: '适中 Medium',
|
||||
600: '次粗 SemiBold',
|
||||
700: '粗体 Bold',
|
||||
800: '特粗 ExtraBold',
|
||||
900: '浓体 Black',
|
||||
};
|
||||
|
||||
function updateVarPreview(weight: number) {
|
||||
if (!varPreview) return;
|
||||
const key = Math.round(weight / 100) * 100;
|
||||
const name = WEIGHT_NAMES[key] ?? String(weight);
|
||||
varPreview.textContent = `${weight} - ${name}`;
|
||||
}
|
||||
|
||||
wghtSlider?.addEventListener('input', (e: Event) => {
|
||||
const value = Number((e.target as any).value);
|
||||
wghtValue.textContent = String(value);
|
||||
updateVarPreview(value);
|
||||
window.clearTimeout(wghtTimer);
|
||||
wghtTimer = window.setTimeout(() => applyWght(value), 250);
|
||||
});
|
||||
// 松手时立即应用最终值, 避免防抖延迟
|
||||
wghtSlider?.addEventListener('change', (e: Event) => {
|
||||
const value = Number((e.target as any).value);
|
||||
wghtValue.textContent = String(value);
|
||||
updateVarPreview(value);
|
||||
applyWght(value);
|
||||
});
|
||||
|
||||
// 字号滑条: 直接应用 (12-40px), 设置 style 开销小无需防抖
|
||||
const sizeSlider = document.getElementById('size-slider') as any;
|
||||
const sizeValue = document.getElementById('size-value')!;
|
||||
sizeSlider?.addEventListener('input', (e: Event) => {
|
||||
const value = Number((e.target as any).value);
|
||||
sizeValue.textContent = String(value);
|
||||
if (varPreview) varPreview.style.fontSize = `${value}px`;
|
||||
});
|
||||
|
||||
// 打开 WebUI 时读取 FONT/ 已有字体并填充卡片 (置于文件末尾, 确保常量均已初始化)
|
||||
void loadExistingFonts();
|
||||
@@ -0,0 +1,571 @@
|
||||
@use './theme.scss';
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: var(--md-sys-color-background);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
sans-serif;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
// ---------------- 1. Top App Bar ----------------
|
||||
.top-app-bar {
|
||||
// 随页面滚动 (非 fixed)
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: calc(64px + var(--top-inset, 0px));
|
||||
padding: var(--top-inset, 0px) 24px 0 24px;
|
||||
// 无边框无背景: 顶栏直接融入页面 (与内容区同底色)
|
||||
background-color: transparent;
|
||||
|
||||
.top-app-bar__title {
|
||||
font-size: var(--md-sys-typescale-title-large-size);
|
||||
font-weight: var(--md-sys-typescale-title-large-weight);
|
||||
line-height: var(--md-sys-typescale-title-large-line-height);
|
||||
letter-spacing: var(--md-sys-typescale-title-large-tracking);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.top-app-bar__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
|
||||
// 关于页隐藏顶栏 (自身带返回栏), 内容区相应缩减顶部留白
|
||||
body.no-top-bar {
|
||||
.top-app-bar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.view-about {
|
||||
padding-top: calc(var(--top-inset, 0px) + 16px);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- 2. 视图容器 ----------------
|
||||
.view {
|
||||
display: none;
|
||||
|
||||
&.active {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.view-home,
|
||||
.view-test,
|
||||
.view-about {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
// 顶栏已在文档流中占位, 顶部仅留少量呼吸间距;
|
||||
// 底部预留导航栏 + 吸底 CTA, 确保最后一张卡片能完整滑出不被遮挡
|
||||
padding: 16px 16px calc(var(--bottom-inset, 0px) + 176px) 16px;
|
||||
}
|
||||
|
||||
#slots {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
// ---------------- 3. 首页槽位卡片 ----------------
|
||||
md-elevated-card.slot-card {
|
||||
display: block;
|
||||
padding: 16px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
transition:
|
||||
border-color var(--md-duration-standard) var(--md-easing-standard),
|
||||
border-width var(--md-duration-standard) var(--md-easing-standard);
|
||||
--md-elevated-card-container-color: var(--md-sys-color-surface-container-low);
|
||||
--md-elevated-card-container-shape: var(--md-shape-corner-medium);
|
||||
--md-elevated-card-container-elevation: 1;
|
||||
|
||||
// 已选择状态: 仅通过边框高亮区分 (不再使用 Badge / 图标)
|
||||
&.selected {
|
||||
border-color: var(--md-sys-color-primary);
|
||||
border-width: 1.5px;
|
||||
}
|
||||
|
||||
// 中文简体为必选: 边框恒用强调色 (tertiary)
|
||||
&.slot-hans {
|
||||
border-color: var(--md-sys-color-tertiary);
|
||||
border-width: 1.5px;
|
||||
}
|
||||
|
||||
.slot-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
|
||||
.slot-title-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.slot-title {
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
font-weight: var(--md-sys-typescale-title-medium-weight);
|
||||
line-height: var(--md-sys-typescale-title-medium-line-height);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
// 选择/更换按钮位于卡片右上角
|
||||
.slot-actions {
|
||||
flex-shrink: 0;
|
||||
|
||||
md-outlined-button {
|
||||
--md-outlined-button-container-shape: var(--md-shape-corner-small);
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 取消 Card-in-Card: 文件名区域直接作为卡片内容, 不再嵌套浅色容器
|
||||
.slot-file {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
|
||||
// 清除按钮位于字体名称左侧
|
||||
.slot-clear {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.slot-file-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.slot-name {
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
&.placeholder {
|
||||
font-weight: 400;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
opacity: 0.75; // 半透明: 直观表达"回退/继承"状态
|
||||
}
|
||||
|
||||
// 简体必选提醒: 强调色
|
||||
&.required {
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-tertiary);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.slot-meta {
|
||||
margin-top: 2px;
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
color: var(--md-sys-color-outline);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- 4. 悬浮应用按钮 (Extended FAB) ----------------
|
||||
.fab {
|
||||
position: fixed;
|
||||
right: 16px;
|
||||
bottom: calc(var(--bottom-inset, 0px) + 96px); // 位于底部导航栏上方
|
||||
z-index: 9;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
height: 56px;
|
||||
padding: 0 20px;
|
||||
border: none;
|
||||
border-radius: var(--md-shape-corner-large);
|
||||
background-color: var(--md-sys-color-primary-container);
|
||||
color: var(--md-sys-color-on-primary-container);
|
||||
box-shadow:
|
||||
0 2px 6px rgba(0, 0, 0, 0.25),
|
||||
0 6px 12px rgba(0, 0, 0, 0.2);
|
||||
font-size: var(--md-sys-typescale-label-large-size);
|
||||
font-weight: var(--md-sys-typescale-label-large-weight);
|
||||
cursor: pointer;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
transition:
|
||||
transform var(--md-duration-standard) var(--md-easing-standard),
|
||||
opacity var(--md-duration-standard) var(--md-easing-standard),
|
||||
box-shadow var(--md-duration-standard) var(--md-easing-standard);
|
||||
|
||||
// 向下滚动时移出视口
|
||||
&.fab-hidden {
|
||||
transform: translateY(calc(100% + 24px));
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
// 应用进行中短暂禁用: 保持不透明外观, 仅禁止点击
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&:not(:disabled):active {
|
||||
box-shadow:
|
||||
0 1px 3px rgba(0, 0, 0, 0.3),
|
||||
0 3px 6px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- 5. 底部导航栏 ----------------
|
||||
.bottom-nav {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 11;
|
||||
background-color: var(--md-sys-color-surface-container);
|
||||
border-top: 1px solid var(--md-sys-color-outline-variant);
|
||||
padding-bottom: var(--bottom-inset, 0px);
|
||||
|
||||
md-navigation-bar {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
--md-navigation-bar-container-color: var(--md-sys-color-surface-container);
|
||||
// 去掉底栏阴影, 与页面融为一体
|
||||
--md-navigation-bar-container-elevation: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- 6. 对话框 ----------------
|
||||
md-dialog {
|
||||
--md-dialog-container-shape: var(--md-shape-corner-extra-large);
|
||||
}
|
||||
|
||||
// ---------------- 7. 通用信息卡片 (关于 / 测试共用) ----------------
|
||||
.about-card,
|
||||
.test-card {
|
||||
display: block;
|
||||
padding: 20px;
|
||||
border: 1px solid var(--md-sys-color-outline-variant);
|
||||
--md-elevated-card-container-color: var(--md-sys-color-surface-container-low);
|
||||
--md-elevated-card-container-shape: var(--md-shape-corner-medium);
|
||||
}
|
||||
|
||||
// ---------------- 8. 关于视图 ----------------
|
||||
.view-topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
.view-topbar-title {
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
font-weight: var(--md-sys-typescale-title-medium-weight);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
}
|
||||
|
||||
.view-about {
|
||||
gap: 16px;
|
||||
|
||||
&.active {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.about-logo {
|
||||
font-size: var(--md-sys-typescale-title-large-size);
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.about-desc {
|
||||
margin-top: 4px;
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.about-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
margin-top: 16px;
|
||||
|
||||
.about-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.about-row-label {
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.about-row-value {
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
font-weight: 600;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.about-section-title {
|
||||
margin-bottom: 8px;
|
||||
font-size: var(--md-sys-typescale-title-small-size);
|
||||
font-weight: var(--md-sys-typescale-title-small-weight);
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
.about-section-text {
|
||||
margin: 0 0 12px 0;
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: 1.6;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.about-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
border-radius: var(--md-shape-corner-medium);
|
||||
background: var(--md-sys-color-surface-container-low);
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
|
||||
md-icon {
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
a {
|
||||
margin-left: auto;
|
||||
color: var(--md-sys-color-primary);
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.about-footer {
|
||||
margin-top: 4px;
|
||||
text-align: center;
|
||||
font-size: var(--md-sys-typescale-label-small-size);
|
||||
color: var(--md-sys-color-outline);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- 9. 字体测试视图 ----------------
|
||||
.view-test {
|
||||
gap: 16px;
|
||||
|
||||
&.active {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.test-status {
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
.test-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.test-section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
font-size: var(--md-sys-typescale-title-small-size);
|
||||
font-weight: var(--md-sys-typescale-title-small-weight);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.test-tag {
|
||||
padding: 1px 8px;
|
||||
border-radius: var(--md-shape-corner-extra-small);
|
||||
background: var(--md-sys-color-secondary-container);
|
||||
color: var(--md-sys-color-on-secondary-container);
|
||||
font-size: var(--md-sys-typescale-label-small-size);
|
||||
font-weight: var(--md-sys-typescale-label-small-weight);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.test-sample {
|
||||
font-size: var(--md-sys-typescale-body-large-size);
|
||||
line-height: 1.7;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
.test-var-note {
|
||||
margin-bottom: 10px;
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
color: var(--md-sys-color-outline);
|
||||
}
|
||||
|
||||
.test-w-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 6px 0;
|
||||
border-bottom: 1px dashed var(--md-sys-color-outline-variant);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.test-w-text {
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
}
|
||||
|
||||
.test-wght-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
|
||||
.test-wght-label {
|
||||
flex-shrink: 0;
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
md-slider {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.test-wght-value {
|
||||
flex-shrink: 0;
|
||||
min-width: 3ch;
|
||||
text-align: right;
|
||||
font-size: var(--md-sys-typescale-label-large-size);
|
||||
font-weight: var(--md-sys-typescale-label-large-weight);
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.test-var-preview {
|
||||
font-size: var(--md-sys-typescale-body-large-size);
|
||||
line-height: 1.7;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- 10. 文件选择器 Dialog ----------------
|
||||
.font-picker-dialog {
|
||||
--md-dialog-container-shape: var(--md-shape-corner-extra-large);
|
||||
--md-dialog-container-color: var(--md-sys-color-surface);
|
||||
max-width: 560px;
|
||||
width: 90vw;
|
||||
|
||||
&::part(headline) {
|
||||
padding: 20px 24px 12px 24px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.picker-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
|
||||
.picker-title-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
|
||||
.picker-back {
|
||||
margin-left: -8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.picker-path-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
|
||||
.picker-subtitle {
|
||||
font-size: var(--md-sys-typescale-label-medium-size);
|
||||
color: var(--md-sys-color-primary);
|
||||
font-weight: var(--md-sys-typescale-label-medium-weight);
|
||||
}
|
||||
|
||||
.picker-path-text {
|
||||
width: 100%;
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
font-weight: 700;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.picker-content {
|
||||
padding: 8px 0;
|
||||
max-height: 50vh;
|
||||
overflow-y: auto;
|
||||
|
||||
.picker-list {
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
|
||||
.picker-item {
|
||||
border-radius: var(--md-shape-corner-medium);
|
||||
margin-bottom: 4px;
|
||||
cursor: pointer;
|
||||
|
||||
.item-icon {
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
&.is-file .item-icon {
|
||||
color: var(--md-sys-color-tertiary);
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.picker-empty,
|
||||
.picker-loading,
|
||||
.picker-error {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 32px 16px;
|
||||
gap: 8px;
|
||||
color: var(--md-sys-color-outline);
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
@import url('https://mui.kernelsu.org/internal/insets.css');
|
||||
@import url('https://mui.kernelsu.org/internal/colors.css');
|
||||
|
||||
:root {
|
||||
--top-inset: var(--window-inset-top, 0px);
|
||||
--bottom-inset: var(--window-inset-bottom, 0px);
|
||||
|
||||
--md-focus-ring-color: transparent;
|
||||
|
||||
// ============ MD3 形状 tokens ============
|
||||
--md-shape-corner-none: 0px;
|
||||
--md-shape-corner-extra-small: 4px;
|
||||
--md-shape-corner-small: 8px;
|
||||
--md-shape-corner-medium: 12px;
|
||||
--md-shape-corner-large: 16px;
|
||||
--md-shape-corner-extra-large: 28px;
|
||||
--md-shape-corner-full: 9999px;
|
||||
|
||||
// ============ MD3 动效 tokens ============
|
||||
--md-duration-standard: 300ms;
|
||||
--md-duration-standard-decelerate: 250ms;
|
||||
--md-duration-standard-accelerate: 200ms;
|
||||
--md-duration-emphasized: 500ms;
|
||||
--md-easing-standard: cubic-bezier(0.2, 0, 0, 1);
|
||||
--md-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
|
||||
--md-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
|
||||
--md-easing-emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
|
||||
|
||||
// ============ MD3 字阶 tokens ============
|
||||
--md-sys-typescale-title-large-size: 1.375rem; // 22sp
|
||||
--md-sys-typescale-title-large-weight: 400;
|
||||
--md-sys-typescale-title-large-line-height: 1.75rem; // 28sp
|
||||
--md-sys-typescale-title-large-tracking: 0em;
|
||||
|
||||
--md-sys-typescale-title-medium-size: 1rem; // 16sp
|
||||
--md-sys-typescale-title-medium-weight: 500;
|
||||
--md-sys-typescale-title-medium-line-height: 1.5rem; // 24sp
|
||||
--md-sys-typescale-title-medium-tracking: 0.0094em;
|
||||
|
||||
--md-sys-typescale-title-small-size: 0.875rem; // 14sp
|
||||
--md-sys-typescale-title-small-weight: 500;
|
||||
--md-sys-typescale-title-small-line-height: 1.25rem; // 20sp
|
||||
--md-sys-typescale-title-small-tracking: 0.0063em;
|
||||
|
||||
--md-sys-typescale-body-large-size: 1rem; // 16sp
|
||||
--md-sys-typescale-body-large-weight: 400;
|
||||
--md-sys-typescale-body-large-line-height: 1.5rem; // 24sp
|
||||
--md-sys-typescale-body-large-tracking: 0.0313em;
|
||||
|
||||
--md-sys-typescale-body-medium-size: 0.875rem; // 14sp
|
||||
--md-sys-typescale-body-medium-weight: 400;
|
||||
--md-sys-typescale-body-medium-line-height: 1.25rem; // 20sp
|
||||
--md-sys-typescale-body-medium-tracking: 0.0156em;
|
||||
|
||||
--md-sys-typescale-body-small-size: 0.75rem; // 12sp
|
||||
--md-sys-typescale-body-small-weight: 400;
|
||||
--md-sys-typescale-body-small-line-height: 1rem; // 16sp
|
||||
--md-sys-typescale-body-small-tracking: 0.025em;
|
||||
|
||||
--md-sys-typescale-label-large-size: 0.875rem; // 14sp
|
||||
--md-sys-typescale-label-large-weight: 500;
|
||||
--md-sys-typescale-label-large-line-height: 1.25rem; // 20sp
|
||||
--md-sys-typescale-label-large-tracking: 0.0063em;
|
||||
|
||||
--md-sys-typescale-label-medium-size: 0.75rem; // 12sp
|
||||
--md-sys-typescale-label-medium-weight: 500;
|
||||
--md-sys-typescale-label-medium-line-height: 1rem; // 16sp
|
||||
--md-sys-typescale-label-medium-tracking: 0.0313em;
|
||||
|
||||
--md-sys-typescale-label-small-size: 0.6875rem; // 11sp
|
||||
--md-sys-typescale-label-small-weight: 500;
|
||||
--md-sys-typescale-label-small-line-height: 1rem; // 16sp
|
||||
--md-sys-typescale-label-small-tracking: 0.0313em;
|
||||
|
||||
// ============ MD3 颜色 tokens - Light ============
|
||||
--md-sys-color-primary: var(--primary, #6750a4);
|
||||
--md-sys-color-on-primary: var(--onPrimary, #ffffff);
|
||||
--md-sys-color-primary-container: var(--primaryContainer, #eaddff);
|
||||
--md-sys-color-on-primary-container: var(--onPrimaryContainer, #21005d);
|
||||
|
||||
--md-sys-color-secondary: var(--secondary, #625b71);
|
||||
--md-sys-color-on-secondary: var(--onSecondary, #ffffff);
|
||||
--md-sys-color-secondary-container: var(--secondaryContainer, #e8def8);
|
||||
--md-sys-color-on-secondary-container: var(--onSecondaryContainer, #1d192b);
|
||||
|
||||
--md-sys-color-tertiary: var(--tertiary, #7d5260);
|
||||
--md-sys-color-on-tertiary: var(--onTertiary, #ffffff);
|
||||
--md-sys-color-tertiary-container: var(--tertiaryContainer, #ffd8e4);
|
||||
--md-sys-color-on-tertiary-container: var(--onTertiaryContainer, #31111d);
|
||||
|
||||
--md-sys-color-error: #b3261e;
|
||||
--md-sys-color-on-error: #ffffff;
|
||||
--md-sys-color-error-container: #f9dedc;
|
||||
--md-sys-color-on-error-container: #410e0b;
|
||||
|
||||
--md-sys-color-background: var(--background, #fef7ff);
|
||||
--md-sys-color-on-background: var(--onBackground, #1d1b20);
|
||||
|
||||
--md-sys-color-surface: var(--surface, #fef7ff);
|
||||
--md-sys-color-on-surface: var(--onSurface, #1d1b20);
|
||||
--md-sys-color-surface-variant: var(--surfaceVariant, #e7e0ec);
|
||||
--md-sys-color-on-surface-variant: var(--onSurfaceVariant, #49454f);
|
||||
|
||||
--md-sys-color-surface-dim: #ded8e1;
|
||||
--md-sys-color-surface-bright: #fef7ff;
|
||||
--md-sys-color-surface-container-lowest: #ffffff;
|
||||
--md-sys-color-surface-container-low: var(--surfaceContainerLow, #f7f2fa);
|
||||
--md-sys-color-surface-container: var(--surfaceContainer, #f3edf7);
|
||||
--md-sys-color-surface-container-high: var(--surfaceContainerHigh, #ece6f0);
|
||||
--md-sys-color-surface-container-highest: #e6e0e9;
|
||||
|
||||
--md-sys-color-inverse-surface: #322f35;
|
||||
--md-sys-color-inverse-on-surface: #f5eff7;
|
||||
--md-sys-color-inverse-primary: #d0bcff;
|
||||
|
||||
--md-sys-color-outline: var(--outline, #79747e);
|
||||
--md-sys-color-outline-variant: var(--outlineVariant, #cac4d0);
|
||||
--md-sys-color-shadow: #000000;
|
||||
--md-sys-color-scrim: #000000;
|
||||
}
|
||||
|
||||
// ============ MD3 深色颜色 tokens ============
|
||||
// 跟随 KernelSU 注入的壁纸动态色 (Material You 取色)
|
||||
@mixin dark-tokens {
|
||||
--md-sys-color-primary: var(--primary, #d0bcff);
|
||||
--md-sys-color-on-primary: var(--onPrimary, #381e72);
|
||||
--md-sys-color-primary-container: var(--primaryContainer, #4f378b);
|
||||
--md-sys-color-on-primary-container: var(--onPrimaryContainer, #eaddff);
|
||||
|
||||
--md-sys-color-secondary: var(--secondary, #ccc2dc);
|
||||
--md-sys-color-on-secondary: var(--onSecondary, #332d41);
|
||||
--md-sys-color-secondary-container: var(--secondaryContainer, #4a4458);
|
||||
--md-sys-color-on-secondary-container: var(--onSecondaryContainer, #e8def8);
|
||||
|
||||
--md-sys-color-tertiary: var(--tertiary, #efb8c8);
|
||||
--md-sys-color-on-tertiary: var(--onTertiary, #492532);
|
||||
--md-sys-color-tertiary-container: var(--tertiaryContainer, #633b48);
|
||||
--md-sys-color-on-tertiary-container: var(--onTertiaryContainer, #ffd8e4);
|
||||
|
||||
--md-sys-color-error: #f2b8b5;
|
||||
--md-sys-color-on-error: #601410;
|
||||
--md-sys-color-error-container: #8c1d18;
|
||||
--md-sys-color-on-error-container: #f9dedc;
|
||||
|
||||
--md-sys-color-background: var(--background, #141218);
|
||||
--md-sys-color-on-background: var(--onBackground, #e6e0e9);
|
||||
|
||||
--md-sys-color-surface: var(--surface, #141218);
|
||||
--md-sys-color-on-surface: var(--onSurface, #e6e0e9);
|
||||
--md-sys-color-surface-variant: var(--surfaceVariant, #49454f);
|
||||
--md-sys-color-on-surface-variant: var(--onSurfaceVariant, #cac4d0);
|
||||
|
||||
--md-sys-color-surface-dim: #141218;
|
||||
--md-sys-color-surface-bright: #3b383e;
|
||||
--md-sys-color-surface-container-lowest: #0f0d13;
|
||||
--md-sys-color-surface-container-low: var(--surfaceContainerLow, #1d1b20);
|
||||
--md-sys-color-surface-container: var(--surfaceContainer, #211f26);
|
||||
--md-sys-color-surface-container-high: var(--surfaceContainerHigh, #2b2930);
|
||||
--md-sys-color-surface-container-highest: #36343b;
|
||||
|
||||
--md-sys-color-inverse-surface: #e6e0e9;
|
||||
--md-sys-color-inverse-on-surface: #322f35;
|
||||
--md-sys-color-inverse-primary: #6750a4;
|
||||
|
||||
--md-sys-color-outline: var(--outline, #938f99);
|
||||
--md-sys-color-outline-variant: var(--outlineVariant, #49454f);
|
||||
--md-sys-color-shadow: #000000;
|
||||
--md-sys-color-scrim: #000000;
|
||||
}
|
||||
|
||||
// 跟随系统深浅色
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
@include dark-tokens;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export interface FontSlot {
|
||||
key: 'hans' | 'hant' | 'en' | 'mono';
|
||||
title: string;
|
||||
path: string | null;
|
||||
fileName: string;
|
||||
/** 字体大小展示文本 (如 "12.5 MB"), 异步获取 */
|
||||
sizeText?: string;
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare module 'opentype.js' {
|
||||
/** 解析字体二进制, 返回字体对象 (名称表: names.windows/macintosh) */
|
||||
export function parse(buffer: ArrayBuffer): any;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"]
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.vue"]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
// WebView 从本地加载 webroot, 资源必须相对路径
|
||||
base: './',
|
||||
build: {
|
||||
// 构建产物直接进模块的 webroot
|
||||
outDir: '../src/webroot',
|
||||
// outDir 在项目根之外, 必须显式开启清空
|
||||
emptyOutDir: true,
|
||||
},
|
||||
});
|
||||
@@ -1,144 +0,0 @@
|
||||
#!/bin/bash
|
||||
# FontMM - ColorOS 16 打包脚本
|
||||
# By Yule
|
||||
|
||||
# --- 配置 ---
|
||||
COMP_LEVEL="9"
|
||||
SCRIPT_DIR="$(dirname $(readlink -f $0))"
|
||||
TEMP_DIR="$SCRIPT_DIR/template"
|
||||
TTF_DIR="$SCRIPT_DIR/ttf"
|
||||
BUILD_DIR="$SCRIPT_DIR/.build"
|
||||
MODULE_FILE="$SCRIPT_DIR/MODULE.zip"
|
||||
|
||||
# --- 颜色定义 ---
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
PURPLE='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
|
||||
# --- 计时开始 ---
|
||||
START_TIME=$(date +%s.%N)
|
||||
|
||||
# --- 辅助函数 ---
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_succ() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WAIT]${NC} $1"; }
|
||||
log_err() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
CHECK_ENVIRONMENT() {
|
||||
echo -e "${CYAN}>>${NC} 检查运行环境..."
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
log_err "请授权 Root 权限后运行"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v zip >/dev/null 2>&1; then
|
||||
log_err "未找到 zip 工具,请运行 pkg install zip"
|
||||
exit 1
|
||||
fi
|
||||
log_succ "环境就绪"
|
||||
}
|
||||
|
||||
WELCOME() {
|
||||
clear
|
||||
echo -e "${PURPLE}${BOLD}======================================"
|
||||
echo -e " FontMM - ColorOS 16 打包脚本"
|
||||
echo -e " Author: 于乐 Yule"
|
||||
echo -e "======================================"${NC}
|
||||
echo ""
|
||||
}
|
||||
|
||||
SETUP_BUILD_ENV() {
|
||||
log_warn "清理并准备构建目录..."
|
||||
rm -rf "$BUILD_DIR"
|
||||
rm -f "$MODULE_FILE"
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cp "$TEMP_DIR/template.zip" "$BUILD_DIR/" >/dev/null
|
||||
log_succ "构建环境已初始化"
|
||||
}
|
||||
|
||||
SHOW_MODULE_INFO() {
|
||||
local PROP_FILE="$SCRIPT_DIR/module.prop"
|
||||
|
||||
if [ ! -f "$PROP_FILE" ]; then
|
||||
log_err "未找到 module.prop,跳过信息展示"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo -e "${YELLOW}${BOLD}------------- 模块信息预览 ------------${NC}"
|
||||
|
||||
# 逐行读取 module.prop
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
# 跳过空行和注释
|
||||
[[ -z "$line" || "$line" =~ ^# ]] && continue
|
||||
|
||||
# 以第一个等号为界分割 Key 和 Value
|
||||
local key="${line%%=*}"
|
||||
local value="${line#*=}"
|
||||
|
||||
# 渲染输出:Key 用灰色,Value 用高亮青色
|
||||
# %-12s 是为了让等号左边对齐,看起来更整齐
|
||||
printf "\033[0;90m%-12s\033[0m = \033[1;36m%s\033[0m\n" "$key" "$value"
|
||||
|
||||
done < "$PROP_FILE"
|
||||
|
||||
echo -e "${YELLOW}${BOLD}----------------------------------------${NC}"
|
||||
echo
|
||||
}
|
||||
|
||||
PACKER() {
|
||||
local TARGET_ZIP="$BUILD_DIR/template.zip"
|
||||
|
||||
# 字体检查
|
||||
if [ ! -f "$TTF_DIR/ch.ttf" ]; then
|
||||
echo ""
|
||||
log_err "致命错误: 缺少核心字体 ch.ttf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_warn "正在同步字体文件..."
|
||||
mkdir -p "$BUILD_DIR/ttf"
|
||||
cp "$TTF_DIR/ch.ttf" "$BUILD_DIR/ttf/"
|
||||
[ -f "$TTF_DIR/tc.ttf" ] && cp "$TTF_DIR/tc.ttf" "$BUILD_DIR/ttf/"
|
||||
[ -f "$TTF_DIR/en.ttf" ] && cp "$TTF_DIR/en.ttf" "$BUILD_DIR/ttf/"
|
||||
|
||||
log_warn "正在封包 (Level: $COMP_LEVEL)..."
|
||||
(
|
||||
cd "$BUILD_DIR" || exit
|
||||
zip -"${COMP_LEVEL}"urq "template.zip" "ttf"
|
||||
zip -"${COMP_LEVEL}"ujq "template.zip" "$SCRIPT_DIR/module.prop"
|
||||
)
|
||||
|
||||
rm -rf "$BUILD_DIR/ttf"
|
||||
mv "$TARGET_ZIP" "$SCRIPT_DIR/MODULE.zip"
|
||||
log_succ "资源已成功注入压缩包"
|
||||
}
|
||||
|
||||
CALC_TIME() {
|
||||
local END_TIME=$(date +%s.%N)
|
||||
# 计算差值并保留两位小数
|
||||
local DURATION=$(echo "$END_TIME - $START_TIME" | bc 2>/dev/null || echo "0")
|
||||
|
||||
echo ""
|
||||
echo -e "${PURPLE}--------------------------------------${NC}"
|
||||
echo -e "${GREEN}${BOLD}打包完成!${NC}"
|
||||
echo -e "${CYAN}累计耗时: ${NC}${DURATION}s"
|
||||
echo -e "${CYAN}输出路径: ${NC}${BOLD}$SCRIPT_DIR/MODULE.zip${NC}"
|
||||
echo -e "${PURPLE}--------------------------------------${NC}"
|
||||
}
|
||||
|
||||
MAIN() {
|
||||
WELCOME
|
||||
CHECK_ENVIRONMENT
|
||||
SETUP_BUILD_ENV
|
||||
SHOW_MODULE_INFO
|
||||
PACKER
|
||||
CALC_TIME
|
||||
}
|
||||
|
||||
MAIN
|
||||
Reference in new issue
Block a user