[FIX] fixed CJK characters rendering as □ in graphs#2768
Open
EVE-Rangeen wants to merge 1 commit into
Open
Conversation
…t display correctly on graph Configures Matplotlib font fallback stack to include available system CJK fonts. This ensures Chinese, Japanese, and Korean characters render correctly in graphs.
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.
Summary
Graph labels and legends showed tofu (□) for Chinese, Japanese, and Korean text when using localized pyfa clients. The wx UI rendered CJK text correctly, but Matplotlib defaulted to DejaVu Sans, which lacks CJK characters.




Before Fix
After Fix
This PR adds a small Matplotlib font setup module and applies it when the graph canvas initializes Matplotlib. It builds a prioritized font stack from the system GUI font and common platform CJK fonts.
Detailed fonts per platform see below:
Then assigns it to
font.familyso Matplotlib 3.6+ can fall back per glyph. Hence mixed legend text also works (e.g. Chinese shipname in Japanese/Korean GUI), see above.Changes
graphs/mpl_fonts.pywithconfigure_matplotlib_font()graphs/gui/canvasPanel.pyaftermpl.use('wxagg')##P.S.
I did some manual tests myself on windows, it looks pretty good, but I dont have any macOS or linux device, so I cant test on these platforms