Skip to content

Show the launcher's own text in English on non-Chinese Macs - #12

Merged
ly05010419 merged 2 commits into
ly05010419:mainfrom
joevans:english-ui
Oct 18, 2026
Merged

ly05010419 merged 2 commits into
ly05010419:mainfrom
joevans:english-ui

Conversation

@joevans

@joevans joevans commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

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.c desired_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|en overrides it.

  • New include/totk_ui_lang.h: totk_ui_zh() reads TOTK_UI_LANG first, then the current locale's language code, the same source desired_language uses. 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.
  • Call sites changed: frontend.m, loader.c, romfs.c, swkbd_host.c, totk_shader_rt.m, nvn_mtl.m (two boot stages) and fps_overlay.c.
  • Unchanged: developer log lines (MLOG, fprintf diagnostics), comments, and frontend_ios.m, which I can't build or test.
  • The boot-stage lines in totk.log follow the UI language, because they print the same strings.
  • README (both languages): a short note on the language behaviour and both overrides.

Testing

  • probe-fps-overlay: passes (704 checks). It now pins TOTK_UI_LANG=zh for the existing Chinese assertions and adds English checks for the shader box text and the MetalFX label width.
  • All changed runtime and graphics files compile with the Makefile's flags (-Wall -Wextra -Werror for the runtime).
  • Ran on macOS 27.0.1 with an English system, on top of Support the macOS 27 address-space layout #11, which is needed to start at all on macOS 27. The boot stages appear in English (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.
  • Not verified on screen: the shortcut help and keyboard prompt (I couldn't capture the screen on that machine), and a Chinese-system run (the zh path keeps the original strings).

中文摘要:启动器自身的文字(启动画面、预热进度、快捷键说明、FPS/着色器叠层、键盘输入提示)改为跟随 Mac 系统语言:中文系统显示中文,其他显示英文;TOTK_UI_LANG=zh|en 可指定。中文原文保持不变,与英文并排写在调用处。开发日志、注释和 iOS 前端未改动。

🤖 Generated with Claude Code

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]>
@RVZO6

RVZO6 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

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 TOTK_UI_LANG override behaves as described.

Bug: in English, the shader-collection box shows only digits and punctuation. New shaders %llu / total %s is drawn with the 5×7 pixel font, which only has the upper-case letters the old labels used (no lower-case e, w, h, …). fps_overlay_raster_line_tex only switches to CoreText when the line has non-ASCII characters, so this English line stays in the pixel font and the missing letters come out blank. I confirmed this in a screenshot of the running game. The existing probe checks the string but not whether it can be drawn.

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 fps_overlay_line_pixel_font() and two probe checks: the English shader line must leave the pixel font, and the FPS line must stay in it. The overlay probe passes (704 checks).

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 SHADERS +N / M, but the fallback avoids the same trap for the next label.)

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]>
@joevans

joevans commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @RVZO6, good catch. I applied your patch as is in bbacef6. The overlay probe passes with 706 checks, your two new ones included. Lines whose characters all have pixel glyphs (FPS, size) still use the 5×7 font. Any line with a character the font lacks now goes to CoreText.

@ly05010419
ly05010419 merged commit 0a23402 into ly05010419:main Oct 18, 2026
1 check passed
@ly05010419

Copy link
Copy Markdown
Owner

感谢贡献!

ly05010419 added a commit that referenced this pull request Oct 19, 2026
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]>
@joevans
joevans deleted the english-ui branch October 23, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants