Skip to content

Conversation

ioiotor
Copy link
Contributor

@ioiotor ioiotor commented Jul 27, 2025

Add Simplified Chinese language support

@ducalex ducalex force-pushed the dev branch 2 times, most recently from 35ca41d to 832b20d Compare July 27, 2025 01:43
@ducalex
Copy link
Owner

ducalex commented Aug 18, 2025

Right now retro-go doesn't have the fonts to cover Chinese so it cannot work...

Do you know what UTF-8 ranges are needed by your translations? I can probably update our fonts with them included.

@ioiotor
Copy link
Contributor Author

ioiotor commented Aug 18, 2025

I used the font "fusion-pixel-font-12px-monospaced-ttf-v2025.08.11.zip" to generate "FusionPixel12.c" based on "font_converter.py". After compiling the firmware, I tested it on the device and encountered no issues.
"translation_zh.txt" contains the Chinese vocabulary used in the Chinese translation, while "translations_zh_unicode_Dec.txt" is the converted Unicode in decimal code.
translations_zh_unicode_Dec.txt
translation_zh.txt
FusionPixel12.c

194

@ioiotor
Copy link
Contributor Author

ioiotor commented Aug 18, 2025

The game file names appear as garbled characters. If all Chinese characters are included, the compiled firmware would be too large. I think we should add the basic Level 1 Chinese character list of commonly used characters, totaling 3,755.
mixed_3818_dec.txt
mixed_3818.txt
3755.txt
FusionPixel12.c
3755.txt is the Chinese National Standard Level 1 character set.
mixed_3818.txt is a combined file of the Chinese National Standard Level 1 characters and the characters used in Chinese translations.
mixed_3818_dec.txt is the Unicode decimal file after combining the characters.
FusionPixel12.c is the converted font file.

@ducalex
Copy link
Owner

ducalex commented Aug 19, 2025

Thanks for your work! 92542 added bytes per app is a lot. I'd like to add Chinese support, but we'll have to either:

  • Make Chinese support optional at build time (individual targets could opt into it, plus maybe an option in rg_tool.py)
  • Or find a way to share fonts between apps. A shared data partition maybe.

The game file names appear as garbled characters.

My understanding is that we need to enable dynamic codepage and UTF-8 support in FATFS. However it says that it adds 480KB per app which is a lot...

image

@ioiotor
Copy link
Contributor Author

ioiotor commented Aug 21, 2025

Only enabling the Dynamic (all code pages supported) option will occupy 480KB, while a single codepage will not take up such a large amount of space. After enabling CONFIG_FATFS_API_ENCODING_UTF_8=y, the codepage—whether cp437 or cp936—will correctly display Chinese characters. After selecting codepage as CP437 and enabling CONFIG_FATFS_API_ENCODING_UTF_8=y, I tested using the word "hello" in various languages as filenames. The squares (□) shown in the image are because the FusionPixel font only includes specific languages. Characters included in the font will display normally.
514c2d8be9c8e02b26125f220cba0eb9

The following shows the scenarios with and without CONFIG_FATFS_API_ENCODING_UTF_8=y enabled.

4849664 Aug 21 08:52 retro-go_1.45-51-g73e79-dirty_rachel-esp32.img


ESP-IDF Partition Table

Name, Type, SubType, Offset, Size, Flags

nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
launcher,app,ota_0,0x10000,1088K,
retro-core,app,ota_1,0x120000,1M,
prboom-go,app,ota_2,0x220000,832K,
gwenesis,app,ota_3,0x2f0000,1M,
fmsx,app,ota_4,0x3f0000,704K,


4849664 Aug 21 08:49 retro-go_1.45-51-g73e79-dirty_rachel-esp32.img


ESP-IDF Partition Table

Name, Type, SubType, Offset, Size, Flags

nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
launcher,app,ota_0,0x10000,1088K,
retro-core,app,ota_1,0x120000,1M,
prboom-go,app,ota_2,0x220000,832K,
gwenesis,app,ota_3,0x2f0000,1M,
fmsx,app,ota_4,0x3f0000,704K,


@ioiotor ioiotor reopened this Aug 21, 2025
@ioiotor
Copy link
Contributor Author

ioiotor commented Aug 21, 2025

Sorry, I accidentally closed the PR... But I’ve now updated the code to the latest version and changed [RG_LANG_CHS] = "中文" to [RG_LANG_CHS] = "简体中文". Using just "中文" was too vague and might have caused confusion, as someone might want to submit a PR related to Traditional Chinese.

@KD-MM2
Copy link
Contributor

KD-MM2 commented Aug 22, 2025

  • Make Chinese support optional at build time (individual targets could opt into it, plus maybe an option in rg_tool.py)

+1

@ducalex
Copy link
Owner

ducalex commented Aug 23, 2025

After enabling CONFIG_FATFS_API_ENCODING_UTF_8=y, the codepage—whether cp437 or cp936—will correctly display Chinese characters.

Thanks for testing, I confirm that it works and it doesn't increase binary size so I've added it to all targets. So that's one problem solved.

Because of the translations.h format, it would be a bit difficult to make Chinese support optional there. We'd have to add an #ifdef to each string which is absurd. It's probably simpler to have Chinese strings always be compiled, I haven't checked but I suppose it's not too big increase, 2-3KB/app?

So what needs to be conditional at compile time is only the inclusion of Chinese glyphs in fonts.

@ducalex
Copy link
Owner

ducalex commented Aug 23, 2025

Can you add the font to the PR? Both .c and .ttf in case we ever need to regenerate it.

Added the fusion-pixel-12px-monospaced-zh_hans font and the converted font, which includes the first-level Chinese characters of the Chinese National Standard and the characters used in the Chinese translation.
@ioiotor
Copy link
Contributor Author

ioiotor commented Aug 25, 2025

The font and the converted font files have been committed.
They include the characters required for Chinese translation and a total of 3950 Chinese characters from the Level 1 set of the Chinese National Standard.

Modify [RG_LANG_DE] = "German" to [RG_LANG_DE] = "Deutsch" to resolve the merge conflict.
@ducalex
Copy link
Owner

ducalex commented Sep 9, 2025

Sorry for the long delay! I've tested the changes and it seems to work fine, though my ability to test is very limited.

The big glyph table certainly slows down text drawing, glyph lookup will need to be optimized eventually, but for now it seems to still be perfectly usable.

I'd like to add flags to selectively enable Chinese support before merging the PR, may I commit to your branch?

I'd likely add a flag that can be defined in the target's config.h to enable Chinese support, and maybe a flag for rg_tool.py like --with-chinese-support to force enable it for any target. Also maybe add code to force the Fusion font when Chinese language is selected in the menu.

@ioiotor
Copy link
Contributor Author

ioiotor commented Sep 10, 2025

Thank you for taking the time to test. You are welcome to commit to my branch anytime. Additionally, I tested it on the esp32-p4, and the performance is much smoother.

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