This is a fix for bug #6100
When using international fonts, blender was assuming that the default language on the system was chinese. Now it checks to see what language code you have selected and if its chinese or japanese it converts those to utf8 and then continues to translate them. I can't fully check this so will need others to test it. This should at least be better now. Kent
This commit is contained in:
@@ -52,5 +52,15 @@ void BIF_RasterPos(float x, float y);
|
||||
void BIF_SetScale(float aspect);
|
||||
void refresh_interface_font(void);
|
||||
|
||||
struct LANGMenuEntry {
|
||||
struct LANGMenuEntry *next;
|
||||
char *line;
|
||||
char *language;
|
||||
char *code;
|
||||
int id;
|
||||
};
|
||||
|
||||
struct LANGMenuEntry *find_language(short langid);
|
||||
|
||||
#endif /* BIF_LANGUAGE_H */
|
||||
|
||||
|
||||
@@ -897,14 +897,15 @@ static void linerect(int id, int x, int y)
|
||||
}
|
||||
|
||||
#ifdef WITH_ICONV
|
||||
static void string_to_utf8(char *original, char *utf_8)
|
||||
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", "gb2312");
|
||||
cd=iconv_open("UTF-8", code);
|
||||
|
||||
if (cd == (iconv_t)(-1)) {
|
||||
printf("iconv_open Error");
|
||||
*utf_8='\0';
|
||||
@@ -970,15 +971,27 @@ static void print_line(SpaceFile *sfile, struct direntry *files, int x, int y)
|
||||
glRasterPos2i(x, y);
|
||||
#ifdef WITH_ICONV
|
||||
{
|
||||
struct LANGMenuEntry *lme;
|
||||
char utf_8[512];
|
||||
string_to_utf8(files->relname, utf_8);
|
||||
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 (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 (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));
|
||||
} else {
|
||||
BMF_DrawString(G.font, files->relname);
|
||||
}
|
||||
}
|
||||
#else
|
||||
BMF_DrawString(G.font, files->relname);
|
||||
BMF_DrawString(G.font, files->relname);
|
||||
#endif
|
||||
|
||||
|
||||
x += sfile->maxnamelen + 100;
|
||||
|
||||
glRasterPos2i(x - BMF_GetStringWidth(G.font, files->size), y);
|
||||
|
||||
@@ -55,17 +55,7 @@
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
|
||||
typedef struct _LANGMenuEntry LANGMenuEntry;
|
||||
struct _LANGMenuEntry {
|
||||
LANGMenuEntry *next;
|
||||
|
||||
char *line;
|
||||
char *language;
|
||||
char *code;
|
||||
int id;
|
||||
};
|
||||
|
||||
static LANGMenuEntry *langmenu= 0;
|
||||
static struct LANGMenuEntry *langmenu= 0;
|
||||
static int tot_lang = 0;
|
||||
|
||||
#endif // INTERNATIONAL
|
||||
@@ -172,7 +162,7 @@ char *fontsize_pup(void)
|
||||
|
||||
char *language_pup(void)
|
||||
{
|
||||
LANGMenuEntry *lme = langmenu;
|
||||
struct LANGMenuEntry *lme = langmenu;
|
||||
static char string[1024];
|
||||
static char tmp[1024];
|
||||
|
||||
@@ -191,9 +181,9 @@ char *language_pup(void)
|
||||
}
|
||||
|
||||
|
||||
static LANGMenuEntry *find_language(short langid)
|
||||
struct LANGMenuEntry *find_language(short langid)
|
||||
{
|
||||
LANGMenuEntry *lme = langmenu;
|
||||
struct LANGMenuEntry *lme = langmenu;
|
||||
|
||||
while(lme) {
|
||||
if(lme->id == langid)
|
||||
@@ -207,7 +197,7 @@ static LANGMenuEntry *find_language(short langid)
|
||||
|
||||
void lang_setlanguage(void)
|
||||
{
|
||||
LANGMenuEntry *lme;
|
||||
struct LANGMenuEntry *lme;
|
||||
|
||||
lme = find_language(U.language);
|
||||
if(lme) FTF_SetLanguage(lme->code);
|
||||
@@ -290,7 +280,7 @@ static char *first_dpointchar(char *string)
|
||||
}
|
||||
|
||||
|
||||
static void splitlangline(char *line, LANGMenuEntry *lme)
|
||||
static void splitlangline(char *line, struct LANGMenuEntry *lme)
|
||||
{
|
||||
char *dpointchar= first_dpointchar(line);
|
||||
|
||||
@@ -306,7 +296,7 @@ static void splitlangline(char *line, LANGMenuEntry *lme)
|
||||
|
||||
static void puplang_insert_entry(char *line)
|
||||
{
|
||||
LANGMenuEntry *lme, *prev;
|
||||
struct LANGMenuEntry *lme, *prev;
|
||||
int sorted = 0;
|
||||
|
||||
prev= NULL;
|
||||
@@ -393,10 +383,10 @@ int read_languagefile(void)
|
||||
|
||||
void free_languagemenu(void)
|
||||
{
|
||||
LANGMenuEntry *lme= langmenu;
|
||||
struct LANGMenuEntry *lme= langmenu;
|
||||
|
||||
while (lme) {
|
||||
LANGMenuEntry *n= lme->next;
|
||||
struct LANGMenuEntry *n= lme->next;
|
||||
|
||||
if (lme->line) MEM_freeN(lme->line);
|
||||
if (lme->language) MEM_freeN(lme->language);
|
||||
|
||||
Reference in New Issue
Block a user