Skip to content

Conversation

@Demitry235
Copy link

This PR addresses the long-standing issue where custom localization strings containing non-ASCII characters (Cyrillic, Polish, Turkish, etc.) are not rendered or are rendered incorrectly when the game is running on the English Frostbite engine client.

Title:
Fix: Localization rendering and "Character not supported" errors on English client

Description:
This PR completely rewrites the LocalizationHandler to fix issues with non-ASCII characters (Cyrillic, etc.) that caused invisible text and "Character not supported" warnings in the Kyber logs.

Key Fixes & Improvements:

  1. Dynamic Histogram Injection:

    • Old behavior: The handler only read the existing character table. If a character (like 'Ж') wasn't already in the English game's histogram, it was skipped, logging a "Character not supported" error.
    • New behavior: The handler now scans all modded strings, identifies missing characters, and injects them into the UITextDatabase histogram. This allows for full support of any language on any game region.
  2. Frostbite English Client Workaround (Offset -2):

    • Discovered that the English Frostbite engine ignores indices 0x80 and 0x81 in the character table.
    • The new logic starts custom character mapping from index 130 and applies a -2 byte correction during encoding. This bypasses the engine's "blind spot" and ensures characters render correctly.
  3. Performance Optimization:

    • Replaced the nested std::find loop (which was $O(N^2)$) with a std::map lookup. This prevents micro-stutters and long loading times when mods have large localization files.
  4. Robustness:

    • Added dynamic detection of the histogram table offset, replacing hardcoded pointer arithmetic that could fail on different game updates.

Linked Issue:
Fixes https://feedback.kyber.gg/p/kyber-does-not-support-cyrillic-characters-in-mods

Testing:
Verified on the English client with Cyrillic characters. Text now renders perfectly with the correct glyphs.

After:

Star Wars  Battlefront II (2017) Screenshot 2026 01 26 - 22 33 03 66 Star Wars  Battlefront II (2017) Screenshot 2026 01 26 - 22 32 51 14

Before:

1000145727
1000145728

Copy link
Contributor

@MagixGames MagixGames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of issues present in this PR. You do a lot of c-style casts, don't put open brackets on a newline, don't use the game's memory arenas, and various other things in STANDARDS.md. Please fix them along with the specific comments in the code I left.

@Demitry235
Copy link
Author

I have updated the code to follow the standards: used FB_GLOBAL_ARENA, replaced C-style casts, and fixed formatting. I hope everything is correct now!

@Demitry235 Demitry235 requested a review from MagixGames January 26, 2026 22:44
@Demitry235
Copy link
Author

I was able to test it with the Polish translation. As the author of the Polish translation of Battlefront Plus told me, it works correctly

Star Wars  Battlefront II (2017) Screenshot 2026 01 27 - 01 54 16 18

@Demitry235
Copy link
Author

@MagixGames Hi again!
Sorry to bother you once more. I was concerned that you might not have received a notification about the fixes I made based on your comments, so I decided to mention you again just in case.
I really appreciate the Kyber Team's work and the decision to go open-source; that's why I'm so eager to contribute, and perhaps I'm being a bit too persistent.
If you simply haven't had the time yet, I apologize for the trouble! 🙏

@Demitry235
Copy link
Author

I don't know if I'm doing the right thing by accepting these mergers

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.

2 participants