Repository navigation
fonts: find CJK fonts on Windows, allow a GEO_FONT override - #13
Merged
Merged
Conversation
_font() only searched macOS and Linux font paths, so on Windows it fell back to ImageFont.load_default(), which has no CJK glyphs, and Chinese labels in evidence sheets and contact sheets rendered as boxes. Try the standard Windows CJK fonts too, and let GEO_FONT point at any other font. Fixes #11
Keep the font override and regression tests from #13, and include the additional Windows font candidate proposed by @mengmengma0104 in #11 and #14.
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.
What this changes
Fixes #11.
_font()(inbaidu_pano.py, used for every label and contact sheet) only searched macOS and Linux font paths. On Windows it fell back toImageFont.load_default(), which has no CJK glyphs, so Chinese labels fromevidence.pyand the other sheets rendered as boxes.It now also tries the standard Windows CJK fonts (
msyh.ttc,simhei.ttf,simsun.ttc), and aGEO_FONTenvironment variable, checked first, can point at any other font file. That follows the existingGEO_PROXY. This is the patch @mengmengma0104 suggested in the issue, minus the bold Microsoft YaHei variant.Tests: new
FontTestsintests/test_runtime.py: the Windows fonts are tried,GEO_FONTcomes first, and the first font that loads is used. On Windows 11,_font(40)now loadsC:/Windows/Fonts/msyh.ttcand draws "机位" with real glyphs.test_runtime.py: the 3 new tests pass.NetworkTests.test_model_route_overrides_ambient_variablesfails on my Windows machine both before and after this change (environment variables are case-insensitive there), so it is unrelated.Checklist
_meta(source, date, rows, licence). (n/a)uv run. (no new dependencies)README.mdchanged,README.zh-CN.mdstill matches its structure and numbers. (unchanged)