Skip to content

feat: 支持为中日韩和英语单独设置歌词字体 - #97

Merged
imsyy merged 5 commits into
SPlayer-Dev:devfrom
MoYingJi:pr/feat/lang
Jul 22, 2026
Merged

imsyy merged 5 commits into
SPlayer-Dev:devfrom
MoYingJi:pr/feat/lang

Conversation

@MoYingJi

Copy link
Copy Markdown
Collaborator

改动类型

  • 新功能(feat)
  • 缺陷修复(fix)
  • 重构 / 优化(不改变对外行为)
  • 文档(docs)
  • 其他(请在「改动说明」中注明)

是否包含破坏性变更

  • 是(请在「改动说明」中详细描述)
  • 否

改动说明

在日本标准中某些汉字的字形与中国内地标准并不一致却有相同的 Unicode 码位,单独设置字体以获得更好的体验

按行判断歌词的语言,并为主歌词设置 html lang 属性。支持在设置中单独设置中文、日语、韩语和英语的字体

测试情况

由 AI 仿照旧的 SPlayer 项目生成并由人工审核和测试

截图 / 录屏

Details 图片

自查清单

  • 本 PR 只包含一个主要功能 / 修复,没有夹带无关改动
  • 已在本地完整测试通过;AI 生成的代码同样自行测试并审阅过,未做未经验证的提交
  • 已运行 pnpm format,并确认 pnpm typecheck、pnpm lint 通过
  • 改动涉及原生模块时已 pnpm build:native 验证;未手写 native/*/index.d.ts
  • 已向 dev 分支提交

Copilot AI review requested due to automatic review settings July 21, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/utils/lyric/language.ts Outdated
Comment on lines +40 to +42
if (HAN_RE.test(lyric)) return "zh-CN";
// 默认英语(覆盖拉丁、西里尔、阿拉伯等其余情况)
return "en";
Comment thread src/utils/lyric/language.ts Resolved
@MoYingJi
MoYingJi marked this pull request as draft July 21, 2026 17:12
MoYingJi added 2 commits July 22, 2026 01:16
此 commit 由 AI 仿照旧的 SPlayer 项目生成并由人工审核和测试
此 commit 由 AI 仿照旧的 SPlayer 项目生成并由人工审核和测试
Copilot AI review requested due to automatic review settings July 21, 2026 17:18
@MoYingJi
MoYingJi marked this pull request as ready for review July 21, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";

Copilot AI review requested due to automatic review settings July 22, 2026 06:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";

Copilot AI review requested due to automatic review settings July 22, 2026 06:25
@imsyy
imsyy merged commit 89fdb8c into SPlayer-Dev:dev Jul 22, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

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");
Copilot AI review requested due to automatic review settings July 22, 2026 06:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";
@MoYingJi
MoYingJi deleted the pr/feat/lang branch July 22, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants