Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Mein <mein@cs.umn.edu>2007-07-10 19:10:32 +0400
committerKent Mein <mein@cs.umn.edu>2007-07-10 19:10:32 +0400
commit8198ea61beeb62c4ad86cc6bd1b91f4b756928ef (patch)
treeccd2b51c14973468f9b9a07672f51326a16d4bb2 /source/blender
parent9a07d9cd98d0dd09ce4a6837d27ce352d76f727d (diff)
Update to the translation code. Patch provided by dripstone.
Basically move stuff out of filesel.c and into language.c and changes when exactly it does the conversion. It was doing it when not needed for some machines. It probably still needs work but its slowly getting better. I also removed some commented out code. Kent
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/ftfont/intern/FTF_TTFont.cpp8
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h1
-rw-r--r--source/blender/src/filesel.c55
-rw-r--r--source/blender/src/language.c59
4 files changed, 65 insertions, 58 deletions
diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp
index a4d81fe0133..34b22e5c9d2 100644
--- a/source/blender/ftfont/intern/FTF_TTFont.cpp
+++ b/source/blender/ftfont/intern/FTF_TTFont.cpp
@@ -335,6 +335,8 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag)
removes special characters completely. So, for now we just skip that then. (ton) */
if (FTF_USE_GETTEXT & flag)
utf8towchar(wstr, gettext(str));
+ else if (FTF_INPUT_UTF8 & flag)
+ utf8towchar(wstr, str);
glGetFloatv(GL_CURRENT_COLOR, color);
@@ -344,7 +346,7 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag)
glPixelTransferf(GL_GREEN_SCALE, color[1]);
glPixelTransferf(GL_BLUE_SCALE, color[2]);
- if (FTF_USE_GETTEXT & flag)
+ if ((FTF_USE_GETTEXT | FTF_INPUT_UTF8) & flag)
font->Render(wstr);
else
font->Render(str);
@@ -362,7 +364,7 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag)
glTranslatef(pen_x, pen_y, 0.0);
glScalef(fsize, fsize, 1.0);
- if (FTF_USE_GETTEXT & flag)
+ if ((FTF_USE_GETTEXT | FTF_INPUT_UTF8) & flag)
font->Render(wstr);
else
font->Render(str);
@@ -373,7 +375,7 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag)
glDisable(GL_TEXTURE_2D);
}
- if (FTF_USE_GETTEXT & flag)
+ if ((FTF_USE_GETTEXT | FTF_INPUT_UTF8) & flag)
return font->Advance(wstr);
else
return font->Advance(str);
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 27c9bc16e4a..2e83e773ce8 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -243,6 +243,7 @@ extern UserDef U; /* from usiblender.c !!!! */
#define USER_TR_TEXTEDIT 16
#define USER_DOTRANSLATE 32
#define USER_USETEXTUREFONT 64
+#define CONVERT_TO_UTF8 128
/* dupflag */
diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c
index 59543861348..b4c090dd7fb 100644
--- a/source/blender/src/filesel.c
+++ b/source/blender/src/filesel.c
@@ -111,10 +111,6 @@
#include "BIF_fsmenu.h" /* include ourselves */
-#if defined WITH_ICONV
- #include "iconv.h"
-#endif
-
#if defined WIN32 || defined __BeOS
int fnmatch(const char *pattern, const char *string, int flags)
{
@@ -902,32 +898,6 @@ static void linerect(int id, int x, int y)
}
-#ifdef WITH_ICONV
-static void string_to_utf8(char *original, char *utf_8, char *code)
-{
- size_t inbytesleft=strlen(original);
- size_t outbytesleft=512;
- size_t rv=0;
- iconv_t cd;
-
- cd=iconv_open("UTF-8", code);
-
- if (cd == (iconv_t)(-1)) {
- printf("iconv_open Error");
- *utf_8='\0';
- return ;
- }
- rv=iconv(cd, &original, &inbytesleft, &utf_8, &outbytesleft);
- if (rv == (size_t) -1) {
- printf("iconv Error\n");
- return ;
- }
- *utf_8 = '\0';
- iconv_close(cd);
-}
-#endif
-
-
static void print_line(SpaceFile *sfile, struct direntry *files, int x, int y)
{
int boxcol=0;
@@ -978,25 +948,24 @@ static void print_line(SpaceFile *sfile, struct direntry *files, int x, int y)
#ifdef WITH_ICONV
{
struct LANGMenuEntry *lme;
- char utf_8[512];
-
- lme = find_language(U.language);
-
- if (!strcmp(lme->code, "ja_JP")) { /* japanese */
- string_to_utf8(files->relname, utf_8, "Shift_JIS");
- BIF_RasterPos((float)x, (float)y); /* texture fonts */
- BIF_DrawString(G.font, utf_8, (U.transopts & USER_TR_MENUS));
- } else if (!strcmp(lme->code, "zh_CN")) { /* chinese */
- string_to_utf8(files->relname, utf_8, "gb2312");
- BIF_RasterPos((float)x, (float)y); /* texture fonts */
- BIF_DrawString(G.font, utf_8, (U.transopts & USER_TR_MENUS));
+ lme = find_language(U.language);
+
+ if (!strcmp(lme->code, "ja_JP") ||
+ !strcmp(lme->code, "zh_CN"))
+ {
+ BIF_RasterPos((float)x, (float)y);
+#ifdef WIN32
+ BIF_DrawString(G.font, files->relname, ((U.transopts & USER_TR_MENUS) | CONVERT_TO_UTF8));
+#else
+ BIF_DrawString(G.font, files->relname, (U.transopts & USER_TR_MENUS));
+#endif
} else {
BMF_DrawString(G.font, files->relname);
}
}
#else
BMF_DrawString(G.font, files->relname);
-#endif
+#endif /* WITH_ICONV */
x += sfile->maxnamelen + 100;
diff --git a/source/blender/src/language.c b/source/blender/src/language.c
index 4c485bad8d3..bdf0dfa3baf 100644
--- a/source/blender/src/language.c
+++ b/source/blender/src/language.c
@@ -52,6 +52,33 @@
#include "BMF_Api.h"
+#ifdef WITH_ICONV
+#include "iconv.h"
+
+void string_to_utf8(char *original, char *utf_8, char *code)
+{
+ size_t inbytesleft=strlen(original);
+ size_t outbytesleft=512;
+ size_t rv=0;
+ iconv_t cd;
+
+ cd=iconv_open("UTF-8", code);
+
+ if (cd == (iconv_t)(-1)) {
+ printf("iconv_open Error");
+ *utf_8='\0';
+ return ;
+ }
+ rv=iconv(cd, &original, &inbytesleft, &utf_8, &outbytesleft);
+ if (rv == (size_t) -1) {
+ printf("iconv Error\n");
+ return ;
+ }
+ *utf_8 = '\0';
+ iconv_close(cd);
+}
+#endif // WITH_ICONV
+
#ifdef INTERNATIONAL
#include "FTF_Api.h"
@@ -92,23 +119,31 @@ int BIF_DrawString(BMF_Font* font, char *str, int translate)
#ifdef INTERNATIONAL
if(G.ui_international == TRUE) {
if(translate)
- return FTF_DrawString(str, FTF_USE_GETTEXT | FTF_INPUT_UTF8);
+ {
+#ifdef WITH_ICONV
+ if(translate & CONVERT_TO_UTF8) {
+ char utf_8[512];
+
+ struct LANGMenuEntry *lme;
+ lme = find_language(U.language);
+
+ if (!strcmp(lme->code, "ja_JP"))
+ string_to_utf8(str, utf_8, "Shift_JIS"); /* Japanese */
+ else if (!strcmp(lme->code, "zh_CN"))
+ string_to_utf8(str, utf_8, "GB2312"); /* Chinese */
+
+ return FTF_DrawString(utf_8, FTF_INPUT_UTF8);
+ }
+ else
+#endif // WITH_ICONV
+ return FTF_DrawString(str, FTF_USE_GETTEXT | FTF_INPUT_UTF8);
+ }
else
return FTF_DrawString(str, FTF_NO_TRANSCONV | FTF_INPUT_UTF8);
} else {
return BMF_DrawString(font, str);
-/*
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
- BMF_GetFontTexture(font);??
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- BMF_DrawStringTexture(font, str, pen_x, pen_y, 0.0);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
- return 0;
-*/
}
-#else
+#else // INTERNATIONAL
return BMF_DrawString(font, str);
#endif