From 18a8479931d56bef403871f5b2542198388c1c2b Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 11 Apr 2006 12:27:50 +0000 Subject: Bugfix #3665 Using "International Fonts" (silly name, it's pixmap fonts) the special characters (values above 127) were disregarded completely. This was caused with the extremely confusing unicode conversion call, which actually only was needed when translations were set. Disabling the unicode conversion then gives correct text drawing. However, I suspect that this code will give issues for translations too... that I cannot judge nor fix. --- source/blender/ftfont/intern/FTF_TTFont.cpp | 49 ++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'source/blender/ftfont') diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp index e6bfb33e339..4b6843cfcd4 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.cpp +++ b/source/blender/ftfont/intern/FTF_TTFont.cpp @@ -317,12 +317,11 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag) { float color[4]; wchar_t wstr[FTF_MAX_STR_SIZE-1]={'\0'}; - int len=0; + /* note; this utf8towchar() function I totally don't understand... without using translations it + removes special characters completely. So, for now we just skip that then. (ton) */ if (FTF_USE_GETTEXT & flag) - len=utf8towchar(wstr,gettext(str)); - else - len=utf8towchar(wstr,str); + utf8towchar(wstr, gettext(str)); glGetFloatv(GL_CURRENT_COLOR, color); @@ -332,7 +331,10 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag) glPixelTransferf(GL_GREEN_SCALE, color[1]); glPixelTransferf(GL_BLUE_SCALE, color[2]); - font->Render(wstr); + if (FTF_USE_GETTEXT & flag) + font->Render(wstr); + else + font->Render(str); glPixelTransferf(GL_RED_SCALE, 1.0); glPixelTransferf(GL_GREEN_SCALE, 1.0); @@ -347,14 +349,21 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag) glTranslatef(pen_x, pen_y, 0.0); glScalef(fsize, fsize, 1.0); - font->Render(wstr); + if (FTF_USE_GETTEXT & flag) + font->Render(wstr); + else + font->Render(str); + glPopMatrix(); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); } - return font->Advance(wstr); + if (FTF_USE_GETTEXT & flag) + return font->Advance(wstr); + else + return font->Advance(str); } @@ -363,16 +372,26 @@ float FTF_TTFont::GetStringWidth(char* str, unsigned int flag) wchar_t wstr[FTF_MAX_STR_SIZE-1]={'\0'}; int len=0; - if (FTF_USE_GETTEXT & flag) - len=utf8towchar(wstr,gettext(str)); - else - len=utf8towchar(wstr,str); + /* note; this utf8towchar() function I totally don't understand... without using translations it + removes special characters completely. So, for now we just skip that then. (ton) */ - if(mode == FTF_PIXMAPFONT) { - return font->Advance(wstr); - } else if(mode == FTF_TEXTUREFONT) { - return font->Advance(wstr);// * fsize; + if (FTF_USE_GETTEXT & flag) { + len=utf8towchar(wstr, gettext(str)); + + if(mode == FTF_PIXMAPFONT) { + return font->Advance(wstr); + } else if(mode == FTF_TEXTUREFONT) { + return font->Advance(wstr);// * fsize; + } + } + else { + if(mode == FTF_PIXMAPFONT) { + return font->Advance(str); + } else if(mode == FTF_TEXTUREFONT) { + return font->Advance(str);// * fsize; + } } + return 0.0; } -- cgit v1.2.3