diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2011-06-02 23:27:47 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2011-06-02 23:27:47 +0200 |
commit | 34273deb566046cf5958365a67ab31bfc946d037 (patch) | |
tree | 902db59e383a0f1a2419b91f4aeb94284269cfc1 /glcdgraphics/bitmap.c | |
parent | e2afe569e07bbe393bb307a860b1a895660ba371 (diff) | |
download | graphlcd-base-34273deb566046cf5958365a67ab31bfc946d037.tar.gz graphlcd-base-34273deb566046cf5958365a67ab31bfc946d037.tar.bz2 |
utf8 improvements; TODO: still bug when scrolling (jumping characters)
Diffstat (limited to 'glcdgraphics/bitmap.c')
-rw-r--r-- | glcdgraphics/bitmap.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/glcdgraphics/bitmap.c b/glcdgraphics/bitmap.c index d352639..a1ca735 100644 --- a/glcdgraphics/bitmap.c +++ b/glcdgraphics/bitmap.c @@ -563,7 +563,7 @@ int cBitmap::DrawText(int x, int y, int xmax, const std::string & text, const cF int yt; unsigned int i; uint32_t c; - int start; + unsigned int start; color = cColor::AlignAlpha(color); bgcolor = cColor::AlignAlpha(bgcolor); @@ -595,17 +595,24 @@ int cBitmap::DrawText(int x, int y, int xmax, const std::string & text, const cF if (skipPixels >= font->Width(text)) start = text.length(); else - while (skipPixels > font->Width(text[start])) + { + unsigned int tmp = start; + cFont::EncodedCharAdjustCounter(font->IsUTF8(), text, c, tmp); + while (skipPixels > font->Width(c /*text[start]*/)) { - skipPixels -= font->Width(text[start]); + cFont::EncodedCharAdjustCounter(font->IsUTF8(), text, c, start); + skipPixels -= font->Width(c/*text[start]*/); skipPixels -= font->SpaceBetween(); start++; } + } } } - for (i = start; i < (unsigned int)text.length(); i++) + + i = start; + while ( i < (unsigned int)text.length() ) { - cFont::Utf8CodeAdjustCounter(text, c, i); + cFont::EncodedCharAdjustCounter(font->IsUTF8(), text, c, i); if (xt > xmax) { @@ -644,6 +651,7 @@ int cBitmap::DrawText(int x, int y, int xmax, const std::string & text, const cF } } } + i++; } } return xt; |