diff options
author | Adam Borowski <kilobyte@angband.pl> | 2010-12-16 21:06:12 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2010-12-17 09:59:29 +0100 |
commit | e5e08161e7e4aef95c45b8604f00f5c2034c81b1 (patch) | |
tree | c3b1620ad55e0f6f2821e8ac30995a58b4e57b6e /crawl-ref/source/fontwrapper-ft.cc | |
parent | 5600077b0b13747f1481787fe0e0d252241c09fa (diff) | |
download | crawl-ref-e5e08161e7e4aef95c45b8604f00f5c2034c81b1.tar.gz crawl-ref-e5e08161e7e4aef95c45b8604f00f5c2034c81b1.zip |
Handle fixed-width characters of width 2 in tiles.
Diffstat (limited to 'crawl-ref/source/fontwrapper-ft.cc')
-rw-r--r-- | crawl-ref/source/fontwrapper-ft.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/crawl-ref/source/fontwrapper-ft.cc b/crawl-ref/source/fontwrapper-ft.cc index ea6cfbca5f..8b9ea1285e 100644 --- a/crawl-ref/source/fontwrapper-ft.cc +++ b/crawl-ref/source/fontwrapper-ft.cc @@ -517,7 +517,9 @@ void FTFontWrapper::render_string(unsigned int px, unsigned int py, ucs_t c; for (const char *tp = text; int s = utf8towc(&c, tp); tp += s) { - cols++; // TODO: use wcwidth() + int w = wcwidth(c); + if (w != -1) + cols += w; max_cols = std::max(cols, max_cols); // NOTE: only newlines should be used for tool tips. Don't use EOL. @@ -542,8 +544,14 @@ void FTFontWrapper::render_string(unsigned int px, unsigned int py, unsigned int rows = 0; for (const char *tp = text; int s = utf8towc(&c, tp); tp += s) { - chars[cols + rows * max_cols] = c; - cols++; + int w = wcwidth(c); + if (w > 0) // FIXME: combining characters are silently ignored + { + chars[cols + rows * max_cols] = c; + cols++; + if (w == 2) + chars[cols + rows * max_cols] = ' ', cols++; + } if (c == '\n') { |