修复通过 fc-match 获取字体时未正确处理 TTC 文件的问题#3950
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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-matchoutput 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
resultsis generic; consider renaming it tooutputLinesor similar to clarify that it represents the lines fromfc-matchoutput.
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-matchoutputs malformed lines or where the output is not exactly two entries.
if (results.length != 2 || results[0].isEmpty() || results[1].isEmpty()) {
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.
No description provided.