From dcdfea55f1c8043d89caaad4b089280bbf7b38ab Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Sun, 20 Oct 2013 22:14:38 +0200 Subject: [PATCH] Bitmap: Make 'Bitmap::textSize()' work with multibyte characters --- src/bitmap.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bitmap.cpp b/src/bitmap.cpp index a8eb0b8a..c624b12b 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -28,6 +28,9 @@ #include "pixman.h" +#include +#include + #include "gl-util.h" #include "quad.h" #include "quadarray.h" @@ -949,9 +952,10 @@ IntRect Bitmap::textSize(const char *str) int w, h; TTF_SizeUTF8(font, str, &w, &h); - // FIXME: This doesn't detect multibyte glyphs correctly - if (p->font->getItalic() && strlen(str) == 1) - TTF_GlyphMetrics(font, *str, 0, 0, 0, 0, &w); + QString qstr = QString::fromUtf8(str); + + if (p->font->getItalic() && qstr.length() == 1) + TTF_GlyphMetrics(font, qstr.at(0).unicode(), 0, 0, 0, 0, &w); return IntRect(0, 0, w, h); }