1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Better handling of encoding detection for maps and campaigns

Now VCMI will use either preferred language or install language to load
maps and campaigns that are part of "core" mod, or, in other words -
placed in Maps directory of H3 data (like most of manually downloaded
maps and campaigns are)

If game data is in English, then game can safely use encoding of player-
selected language (such as Chinese) to load maps. After all, both GBK
and all Win-125X encoding are superset of ASCII, so English map will
always load up correctly.

Maps that are part of a mod still use mod language as before - it is up
to mod maker to correctly set up mod language.
This commit is contained in:
Ivan Savenko
2024-10-30 11:54:35 +00:00
parent 3a45e6dae1
commit 22f517686d
7 changed files with 43 additions and 19 deletions

View File

@@ -60,11 +60,9 @@ bool FontChain::bitmapFontsPrioritized(const std::string & bitmapFontName) const
if (!vstd::isAlmostEqual(1.0, settings["video"]["fontScalingFactor"].Float()))
return false; // If player requested non-100% scaling - use scalable fonts
std::string modName = CGI->modh->findResourceOrigin(ResourcePath("data/" + bitmapFontName, EResType::BMP_FONT));
std::string fontLanguage = CGI->modh->getModLanguage(modName);
std::string gameLanguage = CGI->generaltexth->getPreferredLanguage();
std::string fontEncoding = Languages::getLanguageOptions(fontLanguage).encoding;
std::string gameEncoding = Languages::getLanguageOptions(gameLanguage).encoding;
std::string fontEncoding = CGI->modh->findResourceEncoding(ResourcePath("data/" + bitmapFontName, EResType::BMP_FONT));
// player uses language with different encoding than his bitmap fonts
// for example, Polish language with English fonts or Chinese language which can't use H3 fonts at all