Skip to content

修复通过 fc-match 获取字体时未正确处理 TTC 文件的问题#3950

Merged
Glavo merged 3 commits into
HMCL-dev:mainfrom
Glavo:ttc
May 30, 2025
Merged

修复通过 fc-match 获取字体时未正确处理 TTC 文件的问题#3950
Glavo merged 3 commits into
HMCL-dev:mainfrom
Glavo:ttc

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented May 30, 2025

No description provided.

@Glavo Glavo requested a review from Copilot May 30, 2025 14:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes incorrect handling of TrueType Collection (TTC) font files when discovering fonts via fc-match by parsing the font family and loading all faces on Java 9+.

  • Parse fc-match output into separate family and file path values.
  • Add reflection-based loading of multiple fonts (Font.loadFonts) on Java 9+ to pick the correct family from TTC collections.
  • Include validation and warning logs for malformed output or loading failures.
Comments suppressed due to low confidence (2)

HMCL/src/main/java/org/jackhuang/hmcl/setting/FontManager.java:131

  • [nitpick] The variable name results is generic; consider renaming it to outputLines or similar to clarify that it represents the lines from fc-match output.
String[] results = result.split("\\n");

HMCL/src/main/java/org/jackhuang/hmcl/setting/FontManager.java:132

  • Add unit tests for the new parsing logic, including cases where fc-match outputs malformed lines or where the output is not exactly two entries.
if (results.length != 2 || results[0].isEmpty() || results[1].isEmpty()) {

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/setting/FontManager.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/setting/FontManager.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/setting/FontManager.java
@Glavo Glavo merged commit 4a75f1d into HMCL-dev:main May 30, 2025
2 checks passed
@Glavo Glavo deleted the ttc branch May 30, 2025 14:33
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.

2 participants