OpenTTD/OpenTTD

[Bug]: Game switches to fallback font when refreshing

Opened this issue · 2 comments

Version of OpenTTD

20240511-master-g721cd2b8ad, Windows 11 Home (Simplified Chinese)

Expected result

When changing the font via the font command, the game will automatically use the requested font and will not change it after refreshing the game, restarting, or abandoning a game.

Actual result

After changing the font via the font command, the text does use the glyphs in the requested font; however after restarting or abandoning a game an error message saying "switch to fallback font" appears and the text starts to use the fallback, which, on my system is 微软雅黑(YaHei).

Tested with Unifont, Unifont-JP and 寒蝉全圆体 (ChillRound)
fonts.zip

Steps to reproduce

  1. (May be unnecessary) switch system language to Simplified Chinese;
  2. Change game language to Simplified Chinese
  3. start the console and type the following commands:
font medium "" 0 aa
font medium (font) 0 aa // font == Unifont-JP, Unifont or "寒蝉全圆体"
  1. Start a new game, or open the game options menu
  2. close the game options menu, or abandon the game
  3. notice that the font changes

I can reproduce this problem on 13.4, so it might be the probelm with my system or the font itself. However I think there should be a force option to force use the requested font. It is very strange when the game says "the current font is missing some glyphs" while the font developer says "100% common CJKV glyph coverage."

I'm afraid that the game automatically determines that the requested font is unuseable when there is only one or two glyphs missing, while the rest are present. A research shows that ~3500 characters are enough to cover over 99% of common text. The required character count might be higher for Traditional Chinese, but will only be lower for Japanese and Korean.

Problem as it stands is that the game is checking all font sizes, not just the "Normal" font. If any one of those is missing glyphs, it will use the fallback.

If you set all of them to "Unifont" via the config (I suspect if you do it in game it will try to fallback after each one, resetting it...) then it will work.

My font cache changes should make this work better in future :-)