Repository navigation
feat: 支持为中日韩和英语单独设置歌词字体 - #97
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
为应用内歌词增加中、日、韩、英分语言字体配置,并通过行级 lang 属性应用对应字体。
Changes:
- 新增歌词语言检测与行级语言标记。
- 扩展字体设置、默认值及中英文文案。
- 为两套歌词渲染引擎应用分语言字体。
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/lyric/language.ts |
新增歌词语言检测 |
src/types/settings.ts |
扩展歌词字体类型 |
src/stores/settings.ts |
添加字体默认值 |
src/i18n/locales/zh-CN.json |
添加中文文案 |
src/i18n/locales/en-US.json |
添加英文文案 |
src/components/settings/custom/FontConfig.vue |
增加分语言字体配置项 |
src/components/player/Lyrics/renderer.css |
定义语言字体规则 |
src/components/player/Lyrics/engine/line-builder.ts |
为歌词行设置语言 |
src/components/player/Lyrics/AMLLLyrics.vue |
为 AMLL 歌词设置语言字体 |
src/components/player/FullPlayer/index.vue |
注入字体 CSS 变量 |
Comment on lines
+40
to
+42
| if (HAN_RE.test(lyric)) return "zh-CN"; | ||
| // 默认英语(覆盖拉丁、西里尔、阿拉伯等其余情况) | ||
| return "en"; |
MoYingJi
marked this pull request as draft
July 21, 2026 17:12
此 commit 由 AI 仿照旧的 SPlayer 项目生成并由人工审核和测试
此 commit 由 AI 仿照旧的 SPlayer 项目生成并由人工审核和测试
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/utils/lyric/language.ts:29
- 必修:这里没有“未知/歧义”结果。仅含汉字的日语行(如“君”)会被判为
zh-CN,而俄语、阿拉伯语和纯标点会被判为en;两个调用方又会直接据此设置字体和lang,因此会选错字形,并让辅助技术按错误语言朗读。建议从整首歌词中含假名/谚文的明确行推断上下文来处理纯 Han;其余无法识别的脚本返回未识别,并由调用方跳过lang。
// 中文:含汉字(简繁不区分)
if (HAN_RE.test(lyric)) return "zh-CN";
// 默认英语(覆盖拉丁、西里尔、阿拉伯等其余情况)
return "en";
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/utils/lyric/language.ts:32
- 必修:这里把字符脚本直接当成了语言,导致确定性的误分类。仅含汉字的日语行(例如「愛」)会被标成
zh-CN,西班牙语等任何拉丁字母歌词也会被标成en,从而应用错误的lang和用户字体;这也与文件首行“仅含汉字不能视为确定语言”的说明矛盾。请结合整首歌词上下文/语言元数据推断这些歧义行,或仅在能够确定语言时设置lang。
// 中文:含汉字(简繁不区分)
if (HAN_RE.test(lyric)) return "zh-CN";
// 英语:至少包含拉丁字母,避免把数字、标点和其他脚本误标为英文
if (LATIN_RE.test(lyric)) return "en";
Comment on lines
+105
to
+109
| const lyricMainLineElement = lyricLineElement.firstChild; | ||
| if (lyricMainLineElement instanceof HTMLElement) { | ||
| const language = (lyricLine as LyricLine).language; | ||
| if (language) lyricMainLineElement.lang = language; | ||
| else lyricMainLineElement.removeAttribute("lang"); |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/utils/lyric/language.ts:29
- 必修:这里把所有无法区分区域/字形体系的纯汉字歌词都标成
zh-CN,会将繁体中文歌词错误声明为中国大陆中文;浏览器又会依据lang选择 CJK 字形,因此可能恰好选到不符合歌词的简体字形。无法可靠区分 Hans/Hant 时应使用中性的zh(并同步LyricLanguage与测试),或先检测字形体系再设置对应标签。
: "zh-CN";
| if (KANA_RE.test(content)) lines[i].language = "ja"; | ||
| else if (HANGUL_RE.test(content)) lines[i].language = "ko"; | ||
| else if (HAN_RE.test(content)) lines[i].language = hanLanguage; | ||
| else if (LATIN_RE.test(content)) lines[i].language = "und-Latn"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动类型
是否包含破坏性变更
改动说明
在日本标准中某些汉字的字形与中国内地标准并不一致却有相同的 Unicode 码位,单独设置字体以获得更好的体验
按行判断歌词的语言,并为主歌词设置 html lang 属性。支持在设置中单独设置中文、日语、韩语和英语的字体
测试情况
由 AI 仿照旧的 SPlayer 项目生成并由人工审核和测试
截图 / 录屏
Details
自查清单
pnpm format,并确认pnpm typecheck、pnpm lint通过pnpm build:native验证;未手写native/*/index.d.tsdev分支提交