Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
31 gemrb/core/Font.cpp
@@ -41,33 +41,14 @@ Font::Font()
: resRefs(NULL), numResRefs(0), palette(NULL), maxHeight(0)
{
name[0] = '\0';
- multibyte = false;
+ multibyte = core->TLKEncoding.multibyte;
utf8 = false;
- zeroSpace = false;
- // TODO: list incomplete
- // maybe want to externalize this
- // list compiled form wiki: http://www.gemrb.org/wiki/doku.php?id=engine:encodings
- const char* multibyteEncodings[] = {
- // Chinese
- "GBK", "BIG5",
- // Korean
- "EUCKR",
- // Japanese
- "SJIS"
- };
- const size_t listSize = sizeof(multibyteEncodings) / sizeof(multibyteEncodings[0]);
- const char* encoding = core->TLKEncoding.c_str();
-
- for (size_t i = 0; i < listSize; i++) {
- if (stricmp(encoding, "UTF-8") == 0) {
- utf8 = true;
- break;
- }
- if (stricmp(encoding, multibyteEncodings[i]) == 0) {
- multibyte = true;
- break;
- }
+
+ if (stricmp(core->TLKEncoding.encoding.c_str(), "UTF-8") == 0) {
+ utf8 = true;
}
+ // utf8 & multibyte are mutually exclusive
+ assert(utf8 == false || multibyte == false);
}
Font::~Font(void)
View
2 gemrb/core/Font.h
@@ -70,7 +70,6 @@ class GEM_EXPORT Font {
bool multibyte;
bool utf8;
- bool zeroSpace;
public:
int maxHeight;
@@ -90,7 +89,6 @@ class GEM_EXPORT Font {
virtual ieWord GetPointSize() const {return 0;};
virtual FontStyle GetStyle() const {return NORMAL;};
- void SetIgnoreSpaceWidth(bool ignore) { zeroSpace = ignore; };
Palette* GetPalette() const;
void SetPalette(Palette* pal);
View
26 gemrb/core/Interface.cpp
@@ -258,7 +258,7 @@ Interface::Interface()
SpecialSpellsCount = -1;
SpecialSpells = NULL;
Encoding = "default";
- TLKEncoding = "ISO-8859-1";
+ TLKEncoding.encoding = "ISO-8859-1";
gamedata = new GameData();
}
@@ -1413,7 +1413,6 @@ int Interface::LoadSprites()
fnt->AddResRef(ResRef);
fnt->SetName(font_name);
- fnt->SetIgnoreSpaceWidth(zero_space);
fonts.push_back(fnt);
}
@@ -2511,7 +2510,28 @@ bool Interface::LoadEncoding()
PluginHolder<DataFileMgr> ini(IE_INI_CLASS_ID);
ini->Open(inifile);
- TLKEncoding = ini->GetKeyAsString("encoding", "TLKEncoding", TLKEncoding.c_str());
+ TLKEncoding.encoding = ini->GetKeyAsString("encoding", "TLKEncoding", TLKEncoding.encoding.c_str());
+ TLKEncoding.zerospace = ini->GetKeyAsBool("encoding", "NoSpaces", 0);
+
+ // TODO: list incomplete
+ // maybe want to externalize this
+ // list compiled form wiki: http://www.gemrb.org/wiki/doku.php?id=engine:encodings
+ const char* multibyteEncodings[] = {
+ // Chinese
+ "GBK", "BIG5",
+ // Korean
+ "EUCKR",
+ // Japanese
+ "SJIS"
+ };
+ const size_t listSize = sizeof(multibyteEncodings) / sizeof(multibyteEncodings[0]);
+
+ for (size_t i = 0; i < listSize; i++) {
+ if (stricmp(TLKEncoding.encoding.c_str(), multibyteEncodings[i]) == 0) {
+ TLKEncoding.multibyte = true;
+ break;
+ }
+ }
const char *s;
unsigned int i = (unsigned int) ini->GetKeyAsInt ("charset", "CharCount", 0);
View
9 gemrb/core/Interface.h
@@ -139,6 +139,13 @@ struct TimeStruct {
unsigned int attack_round_size;
};
+struct TLKEncodingStruct
+{
+ std::string encoding;
+ bool multibyte = false;
+ bool zerospace = false;
+};
+
struct SpellDescType {
ieResRef resref;
ieStrRef value;
@@ -371,7 +378,7 @@ class GEM_EXPORT Interface
KeyMap *keymap;
std::string Encoding;
public:
- std::string TLKEncoding;
+ TLKEncodingStruct TLKEncoding;
Holder<StringMgr> strings;
GlobalTimer * timer;
Palette *InfoTextPalette;
View
2 gemrb/plugins/BAMImporter/BAMFont.cpp
@@ -77,7 +77,7 @@ const Sprite2D* BAMFont::GetCharSprite(ieWord chr) const
spr = factory->GetFrameWithoutCycle(chr - '0');
}
if (!spr) {
- Log(ERROR, "BAMFont", "%s missing glyph for character '%x' using %s encoding.", name, chr, core->TLKEncoding.c_str());
+ Log(ERROR, "BAMFont", "%s missing glyph for character '%x' using %s encoding.", name, chr, core->TLKEncoding.encoding.c_str());
spr = blank;
} else {
spr->release();
View
38 gemrb/plugins/TTFImporter/TTFFont.cpp
@@ -40,24 +40,24 @@ const Sprite2D* TTFFont::GetCharSprite(ieWord chr) const
{
#if HAVE_ICONV
if (!utf8) {
- char* oldchar = (char*)&chr;
- ieWord unicodeChr = 0;
- char* newchar = (char*)&unicodeChr;
- size_t in = (multibyte) ? 2 : 1, out = 2;
-
- // TODO: make this work on BE systems
- // TODO: maybe we want to work witn non-unicode fonts?
- iconv_t cd = iconv_open("UTF-16LE", core->TLKEncoding.c_str());
-#if __FreeBSD__
- int ret = iconv(cd, (const char **)&oldchar, &in, &newchar, &out);
-#else
- int ret = iconv(cd, &oldchar, &in, &newchar, &out);
-#endif
- if (ret != GEM_OK) {
- Log(ERROR, "FONT", "iconv error: %d", errno);
- }
- iconv_close(cd);
- chr = unicodeChr;
+ char* oldchar = (char*)&chr;
+ ieWord unicodeChr = 0;
+ char* newchar = (char*)&unicodeChr;
+ size_t in = (multibyte) ? 2 : 1, out = 2;
+
+ // TODO: make this work on BE systems
+ // TODO: maybe we want to work witn non-unicode fonts?
+ iconv_t cd = iconv_open("UTF-16LE", core->TLKEncoding.encoding.c_str());
+ #if __FreeBSD__
+ int ret = iconv(cd, (const char **)&oldchar, &in, &newchar, &out);
+ #else
+ int ret = iconv(cd, &oldchar, &in, &newchar, &out);
+ #endif
+ if (ret != GEM_OK) {
+ Log(ERROR, "FONT", "iconv error: %d", errno);
+ }
+ iconv_close(cd);
+ chr = unicodeChr;
}
#endif
const Holder<Sprite2D>* sprCache = glyphCache->get(chr);
@@ -268,7 +268,7 @@ TTFFont::TTFFont(FT_Face face, ieWord ptSize, FontStyle style, Palette* pal)
// TODO: ttf fonts have a "box" glyph they use for this
blank = core->GetVideoDriver()->CreateSprite8(0, 0, 8, NULL, palette->col);
// ttf fonts dont produce glyphs for whitespace
- int SpaceWidth = zeroSpace? 1 : (ptSize * 0.25);
+ int SpaceWidth = core->TLKEncoding.zerospace ? 1 : (ptSize * 0.25);
Sprite2D* space = core->GetVideoDriver()->CreateSprite8(SpaceWidth, 0, 8, NULL, palette->col);;
Sprite2D* tab = core->GetVideoDriver()->CreateSprite8((space->Width)*4, 0, 8, NULL, palette->col);
View
3 gemrb/unhardcoded/shared/chinese.ini
@@ -1,3 +1,6 @@
[encoding]
TLKEncoding = GBK
#TLKEncoding = BIG5
+#TLKEncoding = UTF-8
+
+NoSpaces = 1
View
2 gemrb/unhardcoded/shared/japanese.ini
@@ -1,2 +1,4 @@
[encoding]
TLKEncoding = SJIS
+
+NoSpaces = 1
View
2 gemrb/unhardcoded/shared/korean.ini
@@ -1,2 +1,4 @@
[encoding]
TLKEncoding = EUCKR
+
+NoSpaces = 1

No commit comments for this range

Something went wrong with that request. Please try again.