* Cast strings to unsigned char * before handling them to our internal methods, because the chars may be cast directly to int, causing crashes with 8-bit strings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/src/FTFont/FTFont.cpp b/src/FTFont/FTFont.cpp
index 8fe1592..7889b64 100644
--- a/src/FTFont/FTFont.cpp
+++ b/src/FTFont/FTFont.cpp
@@ -302,16 +302,16 @@ inline void FTFontImpl::RenderI(const T* string, int renderMode)
}
-void FTFontImpl::Render(const wchar_t* string)
+void FTFontImpl::Render(const char * string)
{
- RenderI(string, FTGL::RENDER_FRONT | FTGL::RENDER_BACK | FTGL::RENDER_SIDE);
+ RenderI((const unsigned char *)string,
+ FTGL::RENDER_FRONT | FTGL::RENDER_BACK | FTGL::RENDER_SIDE);
}
-void FTFontImpl::Render(const char * string)
+void FTFontImpl::Render(const wchar_t* string)
{
- RenderI((const unsigned char *)string,
- FTGL::RENDER_FRONT | FTGL::RENDER_BACK | FTGL::RENDER_SIDE);
+ RenderI(string, FTGL::RENDER_FRONT | FTGL::RENDER_BACK | FTGL::RENDER_SIDE);
}
@@ -418,7 +418,9 @@ void FTFontImpl::BBox(const char* string, const int start, const int end,
float& llx, float& lly, float& llz,
float& urx, float& ury, float& urz)
{
- return BBoxI(string, start, end, llx, lly, llz, urx, ury, urz);
+ /* The chars need to be unsigned because they are cast to int later */
+ return BBoxI((const unsigned char *)string, start, end,
+ llx, lly, llz, urx, ury, urz);
}
@@ -449,15 +451,16 @@ inline float FTFontImpl::AdvanceI(const T* string)
}
-float FTFontImpl::Advance(const wchar_t* string)
+float FTFontImpl::Advance(const char* string)
{
- return AdvanceI(string);
+ /* The chars need to be unsigned because they are cast to int later */
+ return AdvanceI((const unsigned char *)string);
}
-float FTFontImpl::Advance(const char* string)
+float FTFontImpl::Advance(const wchar_t* string)
{
- return AdvanceI((const unsigned char *)string);
+ return AdvanceI(string);
}