diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/ftfont/FTF_Api.h | 4 | ||||
-rw-r--r-- | source/blender/ftfont/FTF_Settings.h | 2 | ||||
-rw-r--r-- | source/blender/ftfont/intern/FTF_Api.cpp | 19 | ||||
-rw-r--r-- | source/blender/ftfont/intern/FTF_TTFont.cpp | 157 | ||||
-rw-r--r-- | source/blender/ftfont/intern/FTF_TTFont.h | 12 | ||||
-rw-r--r-- | source/blender/include/BIF_language.h | 3 | ||||
-rw-r--r-- | source/blender/include/blendef.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 1 | ||||
-rw-r--r-- | source/blender/src/header_info.c | 3 | ||||
-rw-r--r-- | source/blender/src/headerbuttons.c | 33 | ||||
-rw-r--r-- | source/blender/src/interface.c | 6 | ||||
-rw-r--r-- | source/blender/src/interface_draw.c | 2 | ||||
-rw-r--r-- | source/blender/src/language.c | 40 | ||||
-rw-r--r-- | source/blender/src/outliner.c | 1 | ||||
-rw-r--r-- | source/blender/src/space.c | 17 | ||||
-rw-r--r-- | source/blender/src/usiblender.c | 8 |
16 files changed, 252 insertions, 58 deletions
diff --git a/source/blender/ftfont/FTF_Api.h b/source/blender/ftfont/FTF_Api.h index 8f603d73ae1..15fa55c905d 100644 --- a/source/blender/ftfont/FTF_Api.h +++ b/source/blender/ftfont/FTF_Api.h @@ -148,6 +148,10 @@ FTF_EXPORT void FTF_SetLanguage(char* str); */ FTF_EXPORT void FTF_SetEncoding(char* str); +FTF_EXPORT void FTF_SetPosition(float x, float y); +FTF_EXPORT void FTF_SetMode(int mode); +FTF_EXPORT void FTF_SetScale(float fsize); + FTF_EXPORT void FTF_End(void); #ifdef __cplusplus diff --git a/source/blender/ftfont/FTF_Settings.h b/source/blender/ftfont/FTF_Settings.h index d9263baf5a2..dc325c1de41 100644 --- a/source/blender/ftfont/FTF_Settings.h +++ b/source/blender/ftfont/FTF_Settings.h @@ -43,5 +43,7 @@ #define FTF_INPUT_SYSTEM_ENCODING FTF_BIT(1) #define FTF_USE_GETTEXT FTF_BIT(2) #define FTF_INPUT_UTF8 FTF_BIT(3) +#define FTF_PIXMAPFONT 0 +#define FTF_TEXTUREFONT 1 #endif /* __FTF_SETTINGS_H */ diff --git a/source/blender/ftfont/intern/FTF_Api.cpp b/source/blender/ftfont/intern/FTF_Api.cpp index 46638d9f4eb..036e13a7e6e 100644 --- a/source/blender/ftfont/intern/FTF_Api.cpp +++ b/source/blender/ftfont/intern/FTF_Api.cpp @@ -155,11 +155,22 @@ FTF_EXPORT void FTF_SetLanguage(char* str) _FTF_GetFont()->SetLanguage(str); } -/** - * added by phase - * - */ FTF_EXPORT void FTF_SetEncoding(char* str) { _FTF_GetFont()->SetEncoding(str); } + +FTF_EXPORT void FTF_SetPosition(float x, float y) +{ + _FTF_GetFont()->SetPosition(x, y); +} + +FTF_EXPORT void FTF_SetMode(int mode) +{ + _FTF_GetFont()->SetMode(mode); +} + +FTF_EXPORT void FTF_SetScale(float fsize) +{ + _FTF_GetFont()->SetScale(fsize); +} diff --git a/source/blender/ftfont/intern/FTF_TTFont.cpp b/source/blender/ftfont/intern/FTF_TTFont.cpp index ff599e9444c..d25c60ea402 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.cpp +++ b/source/blender/ftfont/intern/FTF_TTFont.cpp @@ -51,6 +51,7 @@ #define FTF_MAX_STR_SIZE 512 + int utf8towchar(wchar_t *w, char *c) { int len=0; @@ -102,6 +103,8 @@ FTF_TTFont::FTF_TTFont(void) font=NULL; fontm= fonts= fontl= NULL; font_size=FONT_SIZE_DEFAULT; + mode = FTF_PIXMAPFONT; + fsize = 1.0; strcpy(encoding_name, SYSTEM_ENCODING_DEFAULT); //set messagepath directory @@ -153,10 +156,13 @@ FTF_TTFont::~FTF_TTFont(void) void FTF_TTFont::SetFontSize(char size) { - if(size=='s') font=fonts; - else if(size=='l') font=fontl; - else font=fontm; - + if(mode == FTF_PIXMAPFONT) { + if(size=='s') font=fonts; + else if(size=='l') font=fontl; + else font=fontm; + } else if(mode == FTF_TEXTUREFONT) { + font=fontl; + } } int FTF_TTFont::SetFont(const unsigned char* str, int datasize, int fontsize) @@ -171,34 +177,60 @@ int FTF_TTFont::SetFont(const unsigned char* str, int datasize, int fontsize) fontm= NULL; fontl= NULL; - if(datasize) font = new FTGLPixmapFont(str, datasize); - else font = new FTGLPixmapFont( (char *)str); + if(mode == FTF_PIXMAPFONT) { - err = font->Error(); + if(datasize) font = new FTGLPixmapFont(str, datasize); + else font = new FTGLPixmapFont( (char *)str); - if(err) { - printf("Failed to open font %s\n", str); - return 0; - } else { - - fontm= font; + err = font->Error(); - if(datasize) fonts = new FTGLPixmapFont(str, datasize); - else fonts = new FTGLPixmapFont((char *)str); - if(datasize) fontl = new FTGLPixmapFont(str, datasize); - else fontl = new FTGLPixmapFont((char *)str); - - success = fonts->FaceSize(fontsize-2<8?8:fontsize-2); - success = fontm->FaceSize(fontsize-1<8?8:fontsize-1); - success = fontl->FaceSize(fontsize); - if(!success) return 0; + if(err) { + printf("Failed to open font %s\n", str); + return 0; + } else { + + fontm= font; + + if(datasize) fonts = new FTGLPixmapFont(str, datasize); + else fonts = new FTGLPixmapFont((char *)str); + if(datasize) fontl = new FTGLPixmapFont(str, datasize); + else fontl = new FTGLPixmapFont((char *)str); + + success = fonts->FaceSize(fontsize-2<8?8:fontsize-2); + success = fontm->FaceSize(fontsize-1<8?8:fontsize-1); + success = fontl->FaceSize(fontsize); + if(!success) return 0; + + success = fonts->CharMap(ft_encoding_unicode); + success = fontm->CharMap(ft_encoding_unicode); + success = fontl->CharMap(ft_encoding_unicode); + if(!success) return 0; + + return 1; + } + + } else if(mode == FTF_TEXTUREFONT) { + + if(datasize) font = new FTGLTextureFont(str, datasize); + else font = new FTGLTextureFont( (char *)str); - success = fonts->CharMap(ft_encoding_unicode); - success = fontm->CharMap(ft_encoding_unicode); - success = fontl->CharMap(ft_encoding_unicode); - if(!success) return 0; + err = font->Error(); - return 1; + if(err) { + printf("Failed to open font %s\n", str); + return 0; + } else { + + fontl= font; + + success = fontl->FaceSize(fontsize); + if(!success) return 0; + + success = fontl->CharMap(ft_encoding_unicode); + if(!success) return 0; + + return 1; + } } } @@ -242,9 +274,13 @@ void FTF_TTFont::SetEncoding(char* str) void FTF_TTFont::SetSize(int size) { - fonts->FaceSize(size-2<8?8:size-2); - fontm->FaceSize(size-1<8?8:size-1); - fontl->FaceSize(size); + if(mode == FTF_PIXMAPFONT) { + fonts->FaceSize(size-2<8?8:size-2); + fontm->FaceSize(size-1<8?8:size-1); + fontl->FaceSize(size); + } else if(mode == FTF_TEXTUREFONT) { + fontl->FaceSize(size); + } font_size = size; } @@ -284,15 +320,33 @@ float FTF_TTFont::DrawString(char* str, unsigned int flag) glGetFloatv(GL_CURRENT_COLOR, color); - glPixelTransferf(GL_RED_SCALE, color[0]); - glPixelTransferf(GL_GREEN_SCALE, color[1]); - glPixelTransferf(GL_BLUE_SCALE, color[2]); - - font->Render(wstr); + if(mode == FTF_PIXMAPFONT) { + + glPixelTransferf(GL_RED_SCALE, color[0]); + glPixelTransferf(GL_GREEN_SCALE, color[1]); + glPixelTransferf(GL_BLUE_SCALE, color[2]); + + font->Render(wstr); + + glPixelTransferf(GL_RED_SCALE, 1.0); + glPixelTransferf(GL_GREEN_SCALE, 1.0); + glPixelTransferf(GL_BLUE_SCALE, 1.0); + + } else if(mode == FTF_TEXTUREFONT) { + + glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); + + glPushMatrix(); + glTranslatef(pen_x, pen_y, 0.0); + glScalef(fsize, fsize, 1.0); + + font->Render(wstr); + glPopMatrix(); - glPixelTransferf(GL_RED_SCALE, 1.0); - glPixelTransferf(GL_GREEN_SCALE, 1.0); - glPixelTransferf(GL_BLUE_SCALE, 1.0); + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + } return font->Advance(wstr); } @@ -308,7 +362,11 @@ float FTF_TTFont::GetStringWidth(char* str, unsigned int flag) else len=utf8towchar(wstr,str); - return font->Advance(wstr); + if(mode == FTF_PIXMAPFONT) { + return font->Advance(wstr); + } else if(mode == FTF_TEXTUREFONT) { + return font->Advance(wstr) * fsize; + } } @@ -324,3 +382,24 @@ void FTF_TTFont::GetBoundingBox(char* str, float *llx, float *lly, float *llz, f font->BBox(wstr, *llx, *lly, *llz, *urx, *ury, *urz); } + + +void FTF_TTFont::SetPosition(float x, float y) +{ + pen_x = x; + pen_y = y; +} + + +void FTF_TTFont::SetMode(int m) +{ + mode = m; +} + + +void FTF_TTFont::SetScale(float size) +{ + fsize = size; +} + + diff --git a/source/blender/ftfont/intern/FTF_TTFont.h b/source/blender/ftfont/intern/FTF_TTFont.h index 103a25a1a71..15682bd4fde 100644 --- a/source/blender/ftfont/intern/FTF_TTFont.h +++ b/source/blender/ftfont/intern/FTF_TTFont.h @@ -38,6 +38,7 @@ #define __FTF_TRUETYPE_FONT_H #include "FTGLPixmapFont.h" +#include "FTGLTextureFont.h" #include <stdio.h> //#include <iconv.h> @@ -91,6 +92,13 @@ public: void SetEncoding(char* str); + /** + * functions to communicate with blender ui rasterpos + */ + void SetPosition(float x, float y); + void SetMode(int mode); + void SetScale(float fsize); + protected: char messagepath[1024]; @@ -99,6 +107,10 @@ protected: char font_name[128]; int font_size; + int mode; // 0 = pixmap, 1 = texture + float pen_x, pen_y; //rasterpos + float fsize; + /** FTGL's */ FTFont* font; /* active */ diff --git a/source/blender/include/BIF_language.h b/source/blender/include/BIF_language.h index 414207c2e44..28b57aa1017 100644 --- a/source/blender/include/BIF_language.h +++ b/source/blender/include/BIF_language.h @@ -48,5 +48,8 @@ char *fontsize_pup(void); int BIF_DrawString(struct BMF_Font* font, char *str, int translate); float BIF_GetStringWidth(struct BMF_Font* font, char *str, int translate); +void BIF_RasterPos(float x, float y); +void refresh_interface_font(void); + #endif /* BIF_LANGUAGE_H */ diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h index d4d2b2eba9b..904928c65ad 100644 --- a/source/blender/include/blendef.h +++ b/source/blender/include/blendef.h @@ -257,6 +257,8 @@ #define B_SETTRANSBUTS 315 #define B_DOLANGUIFONT 316 #define B_RESTOREFONT 317 +#define B_USETEXTUREFONT 318 +#define B_SCALETEXTUREFONT 319 #define B_UITHEMECHANGED 320 #define B_UITHEMECOLORMOD 321 diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 7d35bbb7873..2b7ff9d326e 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -204,6 +204,7 @@ extern UserDef U; /* from usiblender.c !!!! */ #define USER_TR_FILESELECT 8 #define USER_TR_TEXTEDIT 16 #define USER_DOTRANSLATE 32 +#define USER_USETEXTUREFONT 64 /* dupflag */ diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 5ef7fc7a2dd..f1ec2bbe27a 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -898,6 +898,7 @@ static void do_info_filemenu(void *arg, int event) BKE_reset_undo(); BKE_write_undo("original"); /* save current state */ + refresh_interface_font(); } break; case 31: /* save default settings */ @@ -1820,11 +1821,13 @@ static void info_text(int x, int y) glColor3ub(0, 0, 0); glRasterPos2i(x, y); + BIF_RasterPos(x, y); BIF_DrawString(G.font, headerstr, (U.transopts & USER_TR_MENUS)); hsize= BIF_GetStringWidth(G.font, headerstr, (U.transopts & USER_TR_BUTTONS)); glRasterPos2i(x+hsize+10, y); + BIF_RasterPos(x+hsize+10, y); BIF_DrawString(G.font, infostr, (U.transopts & USER_TR_MENUS)); } diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index 6a2d139f17d..68194e25d8a 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -1575,6 +1575,7 @@ void do_global_buttons(unsigned short event) break; case B_SETFONTSIZE: /* is button from space.c *info* */ + refresh_interface_font(); FTF_SetSize(U.fontsize); allqueue(REDRAWALL, 0); break; @@ -1584,11 +1585,37 @@ void do_global_buttons(unsigned short event) break; case B_RESTOREFONT: /* is button from space.c *info* */ - U.fontsize= 0; - start_interface_font(); - allqueue(REDRAWALL, 0); + { + extern float lang_texsize; + + lang_texsize = 1.0; + FTF_SetScale(lang_texsize); + + U.fontsize= 0; + start_interface_font(); + allqueue(REDRAWALL, 0); + } break; + case B_USETEXTUREFONT: /* is button from space.c *info* */ + if(U.transopts & USER_USETEXTUREFONT) + FTF_SetMode(FTF_TEXTUREFONT); + else + FTF_SetMode(FTF_PIXMAPFONT); + + refresh_interface_font(); + allqueue(REDRAWALL, 0); + break; + + case B_SCALETEXTUREFONT: /* is button from space.c *info* */ + { + extern float lang_texsize; + + FTF_SetScale(lang_texsize); + allqueue(REDRAWALL, 0); + } + break; + case B_DOLANGUIFONT: /* is button from space.c *info* */ if(U.transopts & USER_DOTRANSLATE) start_interface_font(); diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index 454826c85d7..4a08b6ee983 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -3454,6 +3454,8 @@ static uiOverDraw *ui_draw_but_tip(uiBut *but) #ifdef INTERNATIONAL + extern float lang_texsize; + if(G.ui_international == TRUE) { float llx,lly,llz,urx,ury,urz; //for FTF_GetBoundingBox() @@ -3462,11 +3464,15 @@ static uiOverDraw *ui_draw_but_tip(uiBut *but) x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*FTF_GetStringWidth(but->tip, FTF_USE_GETTEXT | FTF_INPUT_UTF8); //BMF_GetStringWidth(but->font, but->tip); y1= but->y1-(ury+FTF_GetSize())-12; y2= but->y1-12; + y1 *= lang_texsize; + y2 *= lang_texsize; } else { FTF_GetBoundingBox(but->tip, &llx,&lly,&llz,&urx,&ury,&urz, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*FTF_GetStringWidth(but->tip, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); //BMF_GetStringWidth(but->font, but->tip); y1= but->y1-(ury+FTF_GetSize())-12; y2= but->y1-12; + y1 *= lang_texsize; + y2 *= lang_texsize; } } else { x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*BMF_GetStringWidth(but->font, but->tip); diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index b731615b6a9..b6bb28fbf66 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -115,6 +115,8 @@ void ui_rasterpos_safe(float x, float y, float aspect) } if(doit) glRasterPos2f(x, y); + + BIF_RasterPos(x, y); } /* ************** generic embossed rect, for window sliders etc ************* */ diff --git a/source/blender/src/language.c b/source/blender/src/language.c index 55e0b864abc..8f9c476a142 100644 --- a/source/blender/src/language.c +++ b/source/blender/src/language.c @@ -28,6 +28,10 @@ */ +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif + #include <string.h> #include <stdlib.h> @@ -40,6 +44,7 @@ #include "BLI_blenlib.h" #include "BLI_linklist.h" /* linknode */ +#include "BIF_gl.h" #include "BIF_language.h" #include "BIF_space.h" /* allqueue() */ #include "BIF_toolbox.h" /* error() */ @@ -66,20 +71,51 @@ struct _LANGMenuEntry { static LANGMenuEntry *langmenu= 0; static int tot_lang = 0; +float lang_texsize = 1.0; + #endif // INTERNATIONAL +void BIF_RasterPos(float x, float y) +{ +#ifdef INTERNATIONAL + FTF_SetPosition(x, y); +#endif // INTERNATIONAL +} + +void refresh_interface_font(void) +{ +#ifdef INTERNATIONAL + if(U.transopts & USER_DOTRANSLATE) + start_interface_font(); + else + G.ui_international = FALSE; +#else // INTERNATIONAL + G.ui_international = FALSE; +#endif +} int BIF_DrawString(BMF_Font* font, char *str, int translate) { #ifdef INTERNATIONAL - if(G.ui_international == TRUE) + if(G.ui_international == TRUE) { if(translate) return FTF_DrawString(str, FTF_USE_GETTEXT | FTF_INPUT_UTF8); else return FTF_DrawString(str, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); - else + } 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 return BMF_DrawString(font, str); #endif diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c index 3bfdfe9e548..b3c00331e2e 100644 --- a/source/blender/src/outliner.c +++ b/source/blender/src/outliner.c @@ -1992,6 +1992,7 @@ static void outliner_draw_tree_element(SpaceOops *soops, TreeElement *te, int st if(active==1) BIF_ThemeColor(TH_TEXT_HI); else BIF_ThemeColor(TH_TEXT); glRasterPos2i(startx+offsx, *starty+5); + BIF_RasterPos(startx+offsx, *starty+5); BIF_DrawString(G.font, te->name, 0); offsx+= OL_X + BIF_GetStringWidth(G.font, te->name, 0); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 54c69657d1a..cd8951a5691 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -2538,12 +2538,19 @@ void drawinfospace(ScrArea *sa, void *spacedata) (xpos+edgsp+(2.2*mpref)+(3*midsp)),y2,mpref+(0.5*mpref)+3,buth, &U.language, 0, 0, 0, 0, "Select interface language"); - /* uiDefButBitS(block, TOG, USER_TR_TEXTEDIT, B_SETTRANSBUTS, "FTF All windows", - (xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth, + uiDefButBitS(block, TOG, USER_USETEXTUREFONT, B_USETEXTUREFONT, "Use Textured Fonts", + (xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth, &(U.transopts), 0, 0, 0, 0, - "Use FTF drawing for fileselect and textwindow " - "(under construction)"); - */ + "Use Textured Fonts"); + + if(U.transopts & USER_USETEXTUREFONT) { + extern float lang_texsize; + + uiDefButF(block, NUM, B_SCALETEXTUREFONT, "Scale Factor", + (xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth, + &lang_texsize, 0.2, 2.0, 100, 2, "Tweak scaling for textured font"); + } + } /* end of INTERNATIONAL */ diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index 8f92dbb71ff..037e1e9f439 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -215,12 +215,9 @@ static void init_userdef_file(void) #ifdef INTERNATIONAL read_languagefile(); - if(U.transopts & USER_DOTRANSLATE) - start_interface_font(); - else - G.ui_international = FALSE; + refresh_interface_font(); #endif // INTERNATIONAL - + } void BIF_read_file(char *name) @@ -248,6 +245,7 @@ void BIF_read_file(char *name) undo_editmode_clear(); BKE_reset_undo(); BKE_write_undo("original"); /* save current state */ + refresh_interface_font(); } else BIF_undo_push("Import file"); } |