diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-04-02 16:25:03 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-04-02 16:25:03 +0200 |
commit | e895bf9c16fd1ba5112b59532f5fce6b3634d3d9 (patch) | |
tree | f364c8674f87da5ca676f497f76c618864e795cd /crawl-ref/source/lang-fake.cc | |
parent | 8eebffc28e2049213d5f35bba2880cf4a633891d (diff) | |
download | crawl-ref-e895bf9c16fd1ba5112b59532f5fce6b3634d3d9.tar.gz crawl-ref-e895bf9c16fd1ba5112b59532f5fce6b3634d3d9.zip |
A new fake language, "wide", to test CJK wrapping.
Note that it works only on console and webtiles, not local tiles -- which is
a bug that needs to be fixed before any real translations come. Polish letters
are already screwed up there.
Diffstat (limited to 'crawl-ref/source/lang-fake.cc')
-rw-r--r-- | crawl-ref/source/lang-fake.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crawl-ref/source/lang-fake.cc b/crawl-ref/source/lang-fake.cc index cba58b96c2..a06012aac9 100644 --- a/crawl-ref/source/lang-fake.cc +++ b/crawl-ref/source/lang-fake.cc @@ -9,6 +9,7 @@ #include "debug.h" #include "libutil.h" #include "options.h" +#include "unicode.h" #define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define LOWER "abcdefghijklmnopqrstuvwxyz" @@ -327,6 +328,28 @@ static const char* german[][4] = {0} }; +static void _wide(std::string &txt) +{ + std::string out; + + for (size_t i = 0; i < txt.length(); i++) + { + if (txt[i] == ' ') + out += " "; // U+3000 rather than U+FF00 + else if (txt[i] > 32 && txt[i] < 127) + { + char buf[4]; + int r = wctoutf8(buf, txt[i] + 0xFF00 - 32); + for (int j = 0; j < r; j++) + out.push_back(buf[j]); + } + else + out.push_back(txt[i]); + } + + txt = out; +} + void filter_lang(std::string &str) { if (!Options.lang) @@ -342,6 +365,8 @@ void filter_lang(std::string &str) repl = lisp; else if (!strcmp(Options.lang, "de")) _german(str), repl = german; + else if (!strcmp(Options.lang, "wide")) + return _wide(str); else return; |