Skip to content

[Feature] Unicode support (utf8-format) - #226

Open
C-ColinTH wants to merge 37 commits into
wolfetplayer:mainfrom
C-ColinTH:unicode
Open

[Feature] Unicode support (utf8-format)#226
C-ColinTH wants to merge 37 commits into
wolfetplayer:mainfrom
C-ColinTH:unicode

Conversation

@C-ColinTH

@C-ColinTH C-ColinTH commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

It has been tested since March with 9 players and there have been no serious bug issues.

Except for console text and a few hud texts that have not yet been deployed, the vast majority of text display in games can now display Unicode characters. That is to say, the game can now support displaying almost all official languages.

QQ图片20260815175041

Changes and Usage:

Renderer part:

  1. Modify to support reading more Unicode font information. It will read the fixed name DAT file in the fonts directory: fontImage_utf8_<num>.dat, num from 0 to 3, correspond to the following:
DAT file Type
fontImage_utf8_0.dat FONT_UTF_DEFAULT
fontImage_utf8_1.dat FONT_UTF_CUSTOM1
fontImage_utf8_2.dat FONT_UTF_CUSTOM2
fontImage_utf8_3.dat FONT_UTF_CUSTOM3
  1. If no more templates for fonts are needed, only the fontImage_utf8_0.dat file and corresponding font material images are requisite.
  2. To generate the Unicode font DAT file and texture pictures, we can temporarily use this Python script: RTCW-font. Or use the generated default template:
    z_zzzz_realrtcw_utf8fonts.zip

UI part:

  1. In menudef. h, add keyword FONT_UTF_DEFAULT, FONT_UTF_CUSTOM1, FONT_UTF_CUSTOM2, and FONT_UTF_CUSTOM3 to allow game authors to choose the desired font template in the UI.
  2. Now, In order to display Unicode font in the game now, please specify the parameter after keyword textfont in the MENU script file as one of the four templates mentioned above, and then the text file needs to be stored in UTF8 format.

for example:

"example.menu"

itemDef {
  ...
  textfont  FONT_UTF_DEFAULT    // or other type, for support Unicode fonts
  textfile  "text/EnglishUSA/example.txt"    // the `example.txt` file needs to be UTF8 format
  ...
}

if use text in the MENU script file, please make sure "example.menu" stored in UTF8 format, such as:

"example.menu" (UTF8 format)

itemDef {
  ...
  textfont  FONT_UTF_DEFAULT
  text  "Hello, Привет, Bonjour, Ciao, Dobrý den, 你好。"
  ...
}

HUD part:

  1. Add cl_enableUtf8Font, cl_hudUtf8FontScale in client. In order to display Unicode fonts in cinematic video subtitle, cl_enableUtf8Font needs to be set to 1 . cl_hudUtf8FontScale is used to globally adjust the font scaling size.
  2. Add cg_enableUtf8Font, cg_hudUtf8FontScale, cg_subtitleUtf8FontScale in cgame. In order to display Unicode fonts in game hud (Including dialogue subtitles), cg_enableUtf8Font needs to be set to 1. cg_hudUtf8FontScale and cg_subtitleUtf8FontScale are used to globally adjust the font scaling size of non subtitle text and subtitle text in cgame, respectively.
  3. Unlike the UI part, as the text display in cgame is not specified through the MENU script file, they will always use the font corresponding to fontImage_utf8_0.dat.

Translation part:

  1. After understanding the above content and making changes according to translator's own need. Now the translator only needs to edit the bonus_strings.txt, pickupnames.txt, strings.txt, strings.txt and the text files under EnglishUSA in the text directory of z_rallrtcw_utalization.pk3, keyword textfont paremeter in MENU script files, and some other related text files.

Misc:

  1. In order to optimize the display effect of some special texts, such as Arabic, etc, Add FRIBIDI third party to suooprt bidirectional text.
  2. Add COM_ParseExt2 function in q_shared.c, it support escape character parse.
  3. Add printsubtitle keyword for AI, SCRIPT file. At present, only playsound can attach to subtitles display, but there are still some audios that do not use or cant use playsound, so the subtitles cannot be fully covered. Use printsubtitle could let it print subtitle. Its usage is basically the same as the original playsound:
    printsubtitle <keyname> in AI, SCRIPT file, and "<keyname>" "text" in subtitle file under text\EnglishUSA\maps.
  4. Add textlinespacing keyword for MENU script file. In MENU script file, using textlinespacing to specifiy the spacing of text lines.

C-ColinTH added 30 commits April 3, 2026 16:50
Merge main-"Skins switches CVARs for EE"-e05a14c4f5159f9651c4671e5c8c146b82c0cd8a into font
In menu script file, using "textlinespacing" to specifiy the spacing of text lines
Should display Arabic like characters text better
In fact, the strings in buffs do not end in '\n', they are actually replaced with a space.
The line break spacing should be normal now with utf8 text.
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.

1 participant