Skip to content

fix(issue-144): clean re-apply of macOS Cyrillic text fix#153

Open
fbraz3 wants to merge 10 commits into
mainfrom
fix/issue-144-clean
Open

fix(issue-144): clean re-apply of macOS Cyrillic text fix#153
fbraz3 wants to merge 10 commits into
mainfrom
fix/issue-144-clean

Conversation

@fbraz3
Copy link
Copy Markdown
Owner

@fbraz3 fbraz3 commented Jun 5, 2026

Description

Clean re-application of the Issue #144 macOS Cyrillic text fix, started from a fresh main (a7279e6) and cherry-picking only the font/caption related commits. The previous branch fix/issue-144-macos-cyrillic-text had accumulated upstream sync, CI work, diagnostic instrumentation, and a critical Drawable::calcPhysicsXformWheels regression (broken roll clamp (unclampedRoll > 0.5f && unclampedRoll < -0.5f) + autolevel branch + wheel consolidation) that broke the macOS replay-CI CRC at frames 1700/6900.

Approach

  • Branched from clean main (a7279e682).
  • Cherry-picked 9 Issue macOS: Cyrillic text labels not rendered (numbers work, English labels work) #144 commits in dependency order (see commits).
  • For commit 6b1c77e72 fix(localization): harden drawable caption fallback, manually extracted the safe font/caption work and dropped the physics changes from Drawable::calcPhysicsXformWheels (autolevel branch, broken roll clamp, wheel offset consolidation, commented-out roll-height block, cosmetic edits in drawEnthusiastic/drawBombed). Verified the resulting diff has zero matches for m_totalRoll|unclampedRoll|Autolevel|m_pitchRate|m_rollRate|m_wheelInfo|REAL_TO_INT|rasing up|calcPhysics.
  • Used main's .github/ folder as-is, then applied the 3 echo "$OUTPUT" changes from 0bc3a40d0 feat(ci): show full debug (replaces filtered grep with full output for replay debugging).
  • Skipped e38c00a2f perf(headless): skip drawable caption + alternate-unicode chain (locally verified: does not fix CRC, not the actual root cause).
  • Skipped 15e669dcf fix(macos-fontconfig): prefer system Arial fallback (deploy-script only, not on the user's list).
  • Skipped 5b8b43697 (blog) and 4e9387ae7 (branch analysis report) — both refer to the old branch structure.

Commits

  • 4d7e6e841 fix(fonts): add unicode fallback for cyrillic
  • 292bb8c51 fix(localization): add csf label fallback
  • f28e9ef19 fix(localization): harden drawable caption fallback (cleaned: physics hunks removed)
  • 00f0d56a7 fix(issue-144): add stderr diagnostics traces
  • 45dd89b21 fix(language-ini): implement fallback chain to restore Cyrillic font descriptors (Issue macOS: Cyrillic text labels not rendered (numbers work, English labels work) #144)
  • 6f4534f7a fix(fonts): break circular unicode fallback
  • 68f79fd26 fix(unicode-format): allow Cyrillic in vswprintf on macOS
  • 7f6cb7558 fix(unicode-format): make locale.h include portable for Linux
  • 62b25e736 fix(language): only fall back to English when UnicodeFontName is missing
  • 2e74fee81 feat(ci): show full debug

Diff size

  • 12 code files (was 86 in the old branch)
  • +795 / -62 lines of code (was +2338 / -1853 in the old branch)
  • 0 physics-related changes (was 90 lines of physics in the old branch)

Local validation

  • macos_2p_vanilla_map.rep — exit 0 (was CRC mismatch at frame 6900)
  • macos_6p_custom_map.rep — exit 0 (was CRC mismatch at frame 1700)
  • macos_2p_custom_map.rep — exit 0 (was already passing)

What was confirmed

  • The vswprintf uselocale(newlocale(LC_CTYPE_MASK, "UTF-8", 0)) wrap is the root cause fix for the 3D construction caption Строительство: 57% not rendering on macOS.
  • The font fallback chain (LoadUnicodeFallbackFont + circular fallback break) ensures the localized Arial resolves to a Unicode-capable font on macOS.
  • The Drawable::calcPhysicsXformWheels change in 6b1c77e72 was the regression source for the replay CI CRC mismatch and has been removed.

Why not just fix the old branch?

The old branch had grown to 86 changed code files and 2,338 / 1,853 line changes, much of it upstream sync from thesuperhackers, CI infrastructure, and diagnostic instrumentation. A clean re-apply is simpler to review and bisect than surgical fixes on the old branch.

Related

image

fbraz3 added 10 commits June 4, 2026 21:08
Improve AlternateUnicodeFont resolution on macOS/Linux by trying configured Unicode font first and then a deterministic fallback list of common system fonts.

Also update the May 2026 dev diary before commit as required by project workflow.

Fixes #144

(cherry picked from commit d8fd346)
Add GX-ISSUE144 instrumentation using sprintf + fprintf(stderr, ...) across font resolution, language loading, drawable caption paths, and control bar tooltip/cost rendering.

Include a 2026-05-26 DEV_BLOG entry describing the diagnostics scope.

(cherry picked from commit 9df81a3)
…descriptors (Issue #144)

When russifier mod (00RussianZH.big) loads an incomplete Language.ini with
UnicodeFontName=\"Arial\", it permanently overrides the stock \"Arial Unicode MS\"
which supports Cyrillic. Since Arial lacks Cyrillic, construction captions
render blank on macOS.

Now when registryLanguage != \"English\", load stock English/Language with
INI_LOAD_MULTIFILE mode to fill missing keys. This restores UnicodeFontName
to \"Arial Unicode MS\" while preserving legitimate russifier overrides.

Mirrors existing CSF fallback pattern (commit 3a28555).

Fixes #144
Affects GeneralsXZH only (Language.ini path pattern)

- GlobalLanguage::init() now loads stock Language.ini as fallback
- Updated stderr diagnostics to show primary + fallback resolution
- Expected fix: construction captions \"Строительство: XX%\" now render

(cherry picked from commit 38f0e49)
…deFont from reusing the same base family\nwhen unicode font config resolves to the same name (e.g., Arial),\nforcing fallback to continue into Unicode-capable candidates.\n\nThis targets Issue #144 macOS Cyrillic caption rendering path.

(cherry picked from commit 8de42b1)
vswprintf on macOS returns -1 when the wide-char format string
contains any non-ASCII code point under the default C locale.
This silently truncated every UnicodeString::format() call whose
template included Cyrillic, producing an empty buffer and a
width=0 caption.

Root cause confirmed via stderr instrumentation showing
'vswprintf FAILED result=-1 fmt=Строительство: %.0f%%'.

Fix wraps vswprintf in uselocale(newlocale(LC_CTYPE_MASK, UTF-8))
for the duration of the call, then restores the previous thread
locale. Static locale_t, no per-call allocation.

Validation:
- Russian test: 'Строительство: 57%' renders in 3D caption.
- English test: construction text unaffected.
- Tooltip path unaffected (2D UnicodeString::format used here too).

Also includes Cyrillic font pipeline and tooltip work from this
session, plus diagnostic logs the user wants to keep until
reporter validation is fully complete.

Fixes #144

(cherry picked from commit 70fcb1f)
xlocale.h is macOS-only; on Linux it does not exist. uselocale and
newlocale are exposed via <locale.h> when _GNU_SOURCE is defined.

The previous Cyrillic vswprintf fix broke the Linux Flatpak CI build
with:
  fatal error: xlocale.h: No such file or directory

Guard the macOS-only include behind __APPLE__ and define _GNU_SOURCE
on other POSIX systems so the locale_t APIs remain visible.

(cherry picked from commit 135b1b6)
The 2026-05-27 fallback chain forced a reload of
Data\\English\\Language.ini whenever the primary language was
not English. This regressed in two ways:

1. Deploys without English (e.g. brazilian-only test data)
   caused INI::loadFileDirectory to throw INI_CANT_OPEN_FILE
   because it cannot find any file in the fallback directory.

2. When the primary language already set UnicodeFontName, the
   fallback ran with INI_LOAD_MULTIFILE semantics (overwrite)
   and clobbered the primary value with English's value, which
   is wrong for any official localization that has its own
   font descriptor.

Gate the fallback on m_unicodeFontName.isEmpty() so it only
activates for the russifier case (mod overrides the field with
a Cyrillic-unfriendly font and leaves it broken). Also probe
the file with doesFileExist first so a missing English file in
the deploy is a no-op rather than a fatal throw.

Fixes the macOS replay CI which is now run against a brazilian
deploy.

(cherry picked from commit ab2268e)
(cherry picked from commit 0bc3a40)
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.

macOS: Cyrillic text labels not rendered (numbers work, English labels work)

1 participant