Repository navigation
Show the launcher's own text in English on non-Chinese Macs - #12
Conversation
The startup screen, shader warm-up progress, shortcut help, FPS and shader overlays and the keyboard prompt were Chinese only. They now follow the Mac's language, like the game already does (services.c desired_language): Chinese on a Chinese Mac, English otherwise. TOTK_UI_LANG=zh|en overrides it. The strings stay side by side at each call site via TOTK_UI(zh, en) from include/totk_ui_lang.h. Developer log lines and comments are unchanged; the fps_overlay probe checks both languages. iOS (frontend_ios.m) is untouched. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Tested on an M4 Pro Mac (macOS 27.0.1, TOTK 1.4.3), combined with #3 and #13. The bilingual UI works well and the Bug: in English, the shader-collection box shows only digits and punctuation. Suggested fix: use CoreText whenever any character lacks a pixel glyph, not only when the line has non-ASCII characters. This also covers any future English label. The patch adds Patch (git apply)diff --git a/games/totk/tests/fps_overlay/probe.c b/games/totk/tests/fps_overlay/probe.c
index d23c327..2eb2e1b 100644
--- a/games/totk/tests/fps_overlay/probe.c
+++ b/games/totk/tests/fps_overlay/probe.c
@@ -128,6 +128,8 @@ int main(void) {
setenv("TOTK_UI_LANG", "en", 1);
shader_overlay_text(line, sizeof line, 3, 7428, 12);
CHECK(!strcmp(line, "New shaders 3 / total 7428"), "English shader box text \"%s\"", line);
+ CHECK(!fps_overlay_line_pixel_font(line), "English shader line \"%s\" drawn with the pixel font, which lacks its lower-case letters", line);
+ CHECK(fps_overlay_line_pixel_font("FPS 60 2560x1440"), "the FPS line left the pixel font");
fps_overlay_raster(&(fps_overlay_info){97, 2560, 1440, 1, 0, 0}, 2, px, &grown, &h);
CHECK(grown > base + 40, "English MetalFX on: \" MetalFX on\" after the size (box %d, without it %d)", grown, base);
setenv("TOTK_UI_LANG", "zh", 1);
diff --git a/games/totk/third_party/d2r_gfx/gfx/nvn/fps_overlay.c b/games/totk/third_party/d2r_gfx/gfx/nvn/fps_overlay.c
index 140ad84..33e7953 100644
--- a/games/totk/third_party/d2r_gfx/gfx/nvn/fps_overlay.c
+++ b/games/totk/third_party/d2r_gfx/gfx/nvn/fps_overlay.c
@@ -120,13 +120,15 @@ static void raster_line_ct(const char *text, int highlight, int scale, uint8_t *
CGColorRelease(color); CGColorSpaceRelease(cs); CFRelease(str);
}
-static int has_non_ascii(const char *s) {
- for (; *s; s++) if ((unsigned char)*s >= 0x80) return 1;
- return 0;
+/* The 5x7 font has only the letters the original labels use: any other character (Chinese, or English words such as
+ "New shaders ... / total ...") sends the whole line to the system font instead of drawing blanks. */
+int fps_overlay_line_pixel_font(const char *s) {
+ for (; *s; s++) if (!fps_overlay_has_glyph(*s)) return 0;
+ return 1;
}
void fps_overlay_raster_line_tex(const char *text, int highlight, int scale, uint8_t *out, int tex_w, int tex_h, int *box_w, int *box_h) {
- if (has_non_ascii(text)) { raster_line_ct(text, highlight, scale, out, tex_w, tex_h, box_w, box_h); return; }
+ if (!fps_overlay_line_pixel_font(text)) { raster_line_ct(text, highlight, scale, out, tex_w, tex_h, box_w, box_h); return; }
int n = (int)strnlen(text, MAX_CHARS);
if (scale < 1) scale = 1;
if (scale > FPS_OVERLAY_MAX_SCALE) scale = FPS_OVERLAY_MAX_SCALE;
diff --git a/games/totk/third_party/d2r_gfx/gfx/nvn/fps_overlay.h b/games/totk/third_party/d2r_gfx/gfx/nvn/fps_overlay.h
index b5f21c9..1d9e4d9 100644
--- a/games/totk/third_party/d2r_gfx/gfx/nvn/fps_overlay.h
+++ b/games/totk/third_party/d2r_gfx/gfx/nvn/fps_overlay.h
@@ -28,6 +28,7 @@ void fps_overlay_raster_line_tex(const char *text, int highlight, int scale, uin
/* The bottom-right load line (totk_sysload.c) is wider than the other two: its texture. */
enum { LOAD_OVERLAY_TEX_W = 2048 }; // the widest line (every value 100%) at scale 4 (1440p)
int fps_overlay_has_glyph(char c);
+int fps_overlay_line_pixel_font(const char *text); // 0: the line has a character the pixel font lacks (drawn with CoreText)
/* TOTK automatic shader collection, bottom-left box (2026-10-16 night): "SHADER +<new>/<in the cache> PSO +<new pipelines>",
yellow for 3 s after something new was collected. TOTK_SHADER_OVERLAY=0 hides it (default on on the Mac, off on iOS). */
int shader_overlay_enabled(void);(An alternative is to keep the English text upper-case, like the old |
The English shader line "New shaders N / total M" uses lower-case letters the 5x7 pixel font lacks, so they rendered blank. Switch a line to CoreText whenever any character has no pixel glyph, not only on non-ASCII text. The probe now checks that the English shader line leaves the pixel font and that the FPS line stays in it. Reported with the fix by @RVZO6 in ly05010419#12. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
感谢贡献! |
Resolved totk_shader_rt.m against the non-fatal seed import: kept the local logic and gave its boot text, including the new "shader cache not ready" line, both languages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The launcher's own text was Chinese only. That covers the startup screen and its boot stages, the shader warm-up progress, the shortcut help, the FPS and shader-collection overlays, the test-session window title and the software-keyboard prompt. The game itself already follows the Mac's language (
services.cdesired_language), so on an English Mac the game is English but everything around it is Chinese.This PR makes that text follow the Mac's language too: Chinese on a Chinese Mac, English otherwise.
TOTK_UI_LANG=zh|enoverrides it.include/totk_ui_lang.h:totk_ui_zh()readsTOTK_UI_LANGfirst, then the current locale's language code, the same sourcedesired_languageuses.TOTK_UI(zh, en)picks a string. Both strings stay side by side at each call site, so Chinese text is unchanged and easy to edit.frontend.m,loader.c,romfs.c,swkbd_host.c,totk_shader_rt.m,nvn_mtl.m(two boot stages) andfps_overlay.c.MLOG,fprintfdiagnostics), comments, andfrontend_ios.m, which I can't build or test.totk.logfollow the UI language, because they print the same strings.Testing
probe-fps-overlay: passes (704 checks). It now pinsTOTK_UI_LANG=zhfor the existing Chinese assertions and adds English checks for the shader box text and the MetalFX label width.-Wall -Wextra -Werrorfor the runtime).Initializing game modules — Running the main game module initializers (1/3),Creating the Metal device …,Shader cache ready …), and the game reached its first frame.zhpath keeps the original strings).中文摘要:启动器自身的文字(启动画面、预热进度、快捷键说明、FPS/着色器叠层、键盘输入提示)改为跟随 Mac 系统语言:中文系统显示中文,其他显示英文;
TOTK_UI_LANG=zh|en可指定。中文原文保持不变,与英文并排写在调用处。开发日志、注释和 iOS 前端未改动。🤖 Generated with Claude Code