From 8346ca606f89d1a400127533303d2e5ca3bca1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 22 Nov 2018 15:28:54 +0100 Subject: [PATCH] [kandinsky] Fix Font::signedCharAsIndex --- kandinsky/include/kandinsky/font.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kandinsky/include/kandinsky/font.h b/kandinsky/include/kandinsky/font.h index 3eae2a3b1..d0031c9ba 100644 --- a/kandinsky/include/kandinsky/font.h +++ b/kandinsky/include/kandinsky/font.h @@ -40,7 +40,13 @@ private: return static_cast(c) - k_magicCharOffsetValue; } int signedCharAsIndex(char c) const { - return static_cast(c) - k_magicCharOffsetValue; + int cInt = c; + if (cInt < 0) { + /* A char casted as int takes its value between -127 and +128, but we want + * a positive value. -127 is thus 129, -126 is 130, etc. */ + cInt+=128+(cInt-(-127)+1); + } + return cInt - k_magicCharOffsetValue; } KDSize m_glyphSize;