mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-18 20:15:56 +00:00
Ask fontconfig for the menu's CJK font instead of hard-coding five paths
plat_font_path stats five absolute paths for NotoSansCJK-Regular.ttc and takes the first that exists. That covers SteamOS and the usual distributions, but misses any system where the font lives elsewhere, and fails outright in a sandbox: under Flatpak /usr is the runtime and ships no CJK font, the app may only write /app, and the host's fonts appear at /run/host/fonts. All five paths miss, fonts_up merges 0 fonts, and every Chinese character in the settings menu renders as '?' while English stays correct. Asking fontconfig fixes all of these at once. It is the same database Tk/Xft and every other Linux toolkit reads; it knows /app/share/fonts, the XDG data dirs, /run/host/fonts and the per-user directories, so installing the font where the system looks is enough and no packaging can leave the menu stranded. libfontconfig is dlopen'd, not linked: a host without it (headless, a bare container) still builds and runs and takes the fallback, so this adds no build dependency, and the runtime already links -ldl for the NVIDIA libraries. The result is checked against the character before it is used, because fontconfig returns the closest pattern even when nothing covers a character -- without that a Latin-only system hands back DejaVu Sans and the menu believes it merged glyphs when it did not. The pattern names zh-cn and zh-tw rather than zh-hans and zh-hant, which is how Noto CJK and fontconfig tag the faces. menu_font_fontconfig defaults to 1 and 0 goes back to the five fixed paths, for a player whose fontconfig resolves to a font the menu's parser cannot read. TOTK_MENU_FONT names a file directly and wins over both. A system with the font where the old paths expect it sees no change, and Windows, whose font names are fixed, is untouched. Verified against the real fontconfig with the host having no CJK font, with fontconfig pointed at a directory holding only NotoSansCJK-Regular.ttc (the Flatpak case, now resolved), with TOTK_MENU_FONT set and pointing at a missing file, with menu_font_fontconfig=0, and with libfontconfig made unloadable (falls back quietly, no crash).
This commit is contained in:
1 parent
d8a1d14104
commit
00a0ffc197
4 files changed
+147
-5
No files matched your search
@@ -93,6 +93,7 @@ Many rows below are developer tools that only act together with another setting
|
||||
| --- | --- | --- | --- |
|
||||
| `amiibo_dir` | Folder the Amiibo tab starts in; the tab saves the folder you last browsed here. | Only changes which folder the tab lists first. | Safe |
|
||||
| `exefs` | Folder of the game's ExeFS (with `main.npdm`); a relative path is relative to `totk.exe`'s folder. | Without it, an `exefs` folder next to `totk.exe` is used, else the path set at build time. The game code is compiled into `totk.exe`, and the loader checks the files here by SHA-256, so files from another build or game version stop the start with a message. | Caution |
|
||||
| `menu_font_fontconfig` (default `1`) | On Linux, `1` asks fontconfig which font file draws each menu language's name, and `0` keeps the fixed distribution paths (`/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc` and four more). The menu merges that file into its font atlas. | `0` is for a system whose fontconfig resolves to a font the menu's parser cannot read; the log then says `menu: system font ... left out`. Has no effect on Windows, where the file names are fixed, and none on a language the ASCII font already draws. The atlas is rebuilt when the window size or the menu language changes. `TOTK_MENU_FONT` names a file directly and wins over both. | Safe |
|
||||
| `mods_dir` (default `mods`) | Folder that holds one subfolder per player mod, beside `totk.exe`. | Mods found there replace game files; see `docs/mods.md`. | Caution |
|
||||
| `mods_disabled` | Names of mods that are switched off, separated by `\|`. | Listed mods are not applied; the Mods tab writes this line. | Safe |
|
||||
| `mods_order` | Mod names, top first, separated by `\|`; the top mod wins a file that two mods replace. | Changes which mod's file the game gets; unlisted mods go below the listed ones, by name. | Safe |
|
||||
|
||||
Reference in new issue
Block a user