Skip to content
Browse files

Create a TLKEncodingStruct to hold encoding specifics

zeroSpace is now defined by language
  • Loading branch information...
1 parent 5545240 commit 5c17c848efe288f962c3c129e6c17a4d4e036dbc @bradallred bradallred committed
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
2 gemrb/plugins/TTFImporter/TTFFont.cpp
@@ -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

0 comments on commit 5c17c84

Please sign in to comment.
Something went wrong with that request. Please try again.