summaryrefslogtreecommitdiff
path: root/src/strgen
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-11-24 18:53:17 +0000
committerrubidium <rubidium@openttd.org>2008-11-24 18:53:17 +0000
commitfea78fbfbb2bfe5c6ddf90adb811eb60f4ecfc50 (patch)
treeead76c1aeb888d0a95a040f598f2614ff0ad201e /src/strgen
parent6878b181c7371ecc4af39eef6b01b710cc9f088b (diff)
downloadopenttd-fea78fbfbb2bfe5c6ddf90adb811eb60f4ecfc50.tar.xz
(svn r14618) -Feature: when the chosen language isn't supported by the current font, try to find a font that does and use that instead. Thanks to glx/michi_cc for the Windows implementation.
Diffstat (limited to 'src/strgen')
-rw-r--r--src/strgen/strgen.cpp10
-rw-r--r--src/strgen/strgen.h11
2 files changed, 20 insertions, 1 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index 298597311..ba6a9bb40 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -87,6 +87,7 @@ static uint32 _hash;
static char _lang_name[32], _lang_ownname[32], _lang_isocode[16];
static byte _lang_pluralform;
static byte _lang_textdir;
+static uint16 _lang_winlangid;
#define MAX_NUM_GENDER 8
static char _genders[MAX_NUM_GENDER][16];
static int _numgenders;
@@ -649,6 +650,13 @@ static void HandlePragma(char *str)
} else {
error("Invalid textdir %s", str + 8);
}
+ } else if (!memcmp(str, "winlangid ", 10)) {
+ char *buf = str + 10;
+ long langid = strtol(buf, NULL, 16);
+ if (langid > UINT16_MAX || langid < 0) {
+ error("Invalid winlangid %s", buf);
+ }
+ _lang_winlangid = (uint16)langid;
} else if (!memcmp(str, "gender ", 7)) {
char* buf = str + 7;
@@ -912,6 +920,7 @@ static void ParseFile(const char *file, bool english)
_numgenders = 0;
_lang_name[0] = _lang_ownname[0] = _lang_isocode[0] = '\0';
_lang_textdir = TD_LTR;
+ _lang_winlangid = 0x0000; // neutral language code
// TODO:!! We can't reset the cases. In case the translated strings
// derive some strings from english....
@@ -1161,6 +1170,7 @@ static void WriteLangfile(const char *filename)
hdr.version = TO_LE32(_hash);
hdr.plural_form = _lang_pluralform;
hdr.text_dir = _lang_textdir;
+ hdr.winlangid = TO_LE16(_lang_winlangid);
strcpy(hdr.name, _lang_name);
strcpy(hdr.own_name, _lang_ownname);
strcpy(hdr.isocode, _lang_isocode);
diff --git a/src/strgen/strgen.h b/src/strgen/strgen.h
index a38b1760d..93253259f 100644
--- a/src/strgen/strgen.h
+++ b/src/strgen/strgen.h
@@ -14,7 +14,16 @@ struct LanguagePackHeader {
uint16 offsets[32]; // the offsets
byte plural_form; // plural form index
byte text_dir; // default direction of the text
- byte pad[2]; // pad header to be a multiple of 4
+ /**
+ * Windows language ID:
+ * Windows cannot and will not convert isocodes to something it can use to
+ * determine whether a font can be used for the language or not. As a result
+ * of that we need to pass the language id via strgen to OpenTTD to tell
+ * what language it is in "Windows". The ID is the 'locale identifier' on:
+ * http://msdn.microsoft.com/en-us/library/ms776294.aspx
+ */
+ uint16 winlangid; // windows language id
+ /* byte pad[0]; // pad header to be a multiple of 4 */
};
assert_compile(sizeof(LanguagePackHeader) % 4 == 0);