Modified interface texture font support, which should work nicely with the freshly added bFTGL library.

Also removed some redundant #include's on some files.
This commit is contained in:
Rob Haarsma 2005-01-21 14:48:03 +00:00
parent 465b15eb69
commit 136ecd4644
18 changed files with 40 additions and 103 deletions

@ -69,7 +69,7 @@ FTF_EXPORT int FTF_GetSize(void)
return _FTF_GetFont()->GetSize(); return _FTF_GetFont()->GetSize();
} }
/*
FTF_EXPORT int FTF_Ascender(void) FTF_EXPORT int FTF_Ascender(void)
{ {
return _FTF_GetFont()->Ascender(); return _FTF_GetFont()->Ascender();
@ -79,7 +79,7 @@ FTF_EXPORT int FTF_Descender(void)
{ {
return _FTF_GetFont()->Descender(); return _FTF_GetFont()->Descender();
} }
*/
FTF_EXPORT void FTF_TransConvString(char* str, char* ustr, unsigned int flag) FTF_EXPORT void FTF_TransConvString(char* str, char* ustr, unsigned int flag)
{ {

@ -156,13 +156,9 @@ FTF_TTFont::~FTF_TTFont(void)
void FTF_TTFont::SetFontSize(char size) void FTF_TTFont::SetFontSize(char size)
{ {
if(mode == FTF_PIXMAPFONT) {
if(size=='s') font=fonts; if(size=='s') font=fonts;
else if(size=='l') font=fontl; else if(size=='l') font=fontl;
else font=fontm; else font=fontm;
} else if(mode == FTF_TEXTUREFONT) {
font=fontl;
}
} }
int FTF_TTFont::SetFont(const unsigned char* str, int datasize, int fontsize) int FTF_TTFont::SetFont(const unsigned char* str, int datasize, int fontsize)
@ -221,11 +217,23 @@ int FTF_TTFont::SetFont(const unsigned char* str, int datasize, int fontsize)
return 0; return 0;
} else { } else {
fontl= font; fontm= font;
if(datasize) fonts = new FTGLTextureFont(str, datasize);
else fonts = new FTGLTextureFont((char *)str);
if(datasize) fontl = new FTGLTextureFont(str, datasize);
else fontl = new FTGLTextureFont((char *)str);
success = fonts->FaceSize(fontsize-2<8?8:fontsize-2);
success = fontm->FaceSize(fontsize-1<8?8:fontsize-1);
success = fontl->FaceSize(fontsize); success = fontl->FaceSize(fontsize);
// success = fonts->FaceSize(fontsize/2);
// success = fontm->FaceSize(fontsize);
// success = fontl->FaceSize(fontsize*2);
if(!success) return 0; if(!success) return 0;
success = fonts->CharMap(ft_encoding_unicode);
success = fontm->CharMap(ft_encoding_unicode);
success = fontl->CharMap(ft_encoding_unicode); success = fontl->CharMap(ft_encoding_unicode);
if(!success) return 0; if(!success) return 0;
@ -274,13 +282,9 @@ void FTF_TTFont::SetEncoding(char* str)
void FTF_TTFont::SetSize(int size) void FTF_TTFont::SetSize(int size)
{ {
if(mode == FTF_PIXMAPFONT) { fonts->FaceSize(size-2<8?8:size-2);
fonts->FaceSize(size-2<8?8:size-2); fontm->FaceSize(size-1<8?8:size-1);
fontm->FaceSize(size-1<8?8:size-1); fontl->FaceSize(size);
fontl->FaceSize(size);
} else if(mode == FTF_TEXTUREFONT) {
fontl->FaceSize(size);
}
font_size = size; font_size = size;
} }
@ -290,6 +294,7 @@ int FTF_TTFont::GetSize(void)
return font_size; return font_size;
} }
/*
int FTF_TTFont::Ascender(void) int FTF_TTFont::Ascender(void)
{ {
return (int)font->Ascender(); return (int)font->Ascender();
@ -300,7 +305,7 @@ int FTF_TTFont::Descender(void)
return (int)font->Descender(); return (int)font->Descender();
} }
*/
int FTF_TTFont::TransConvString(char* str, char* ustr, unsigned int flag) int FTF_TTFont::TransConvString(char* str, char* ustr, unsigned int flag)
{ {
return 0; return 0;
@ -365,7 +370,7 @@ float FTF_TTFont::GetStringWidth(char* str, unsigned int flag)
if(mode == FTF_PIXMAPFONT) { if(mode == FTF_PIXMAPFONT) {
return font->Advance(wstr); return font->Advance(wstr);
} else if(mode == FTF_TEXTUREFONT) { } else if(mode == FTF_TEXTUREFONT) {
return font->Advance(wstr) * fsize; return font->Advance(wstr);// * fsize;
} }
} }

@ -64,8 +64,8 @@ public:
void SetSize(int size); void SetSize(int size);
int GetSize(void); int GetSize(void);
int Ascender(void); // int Ascender(void);
int Descender(void); // int Descender(void);
int TransConvString(char* str, char* ustr, unsigned int flag); int TransConvString(char* str, char* ustr, unsigned int flag);

@ -49,6 +49,7 @@ int BIF_DrawString(struct BMF_Font* font, char *str, int translate);
float BIF_GetStringWidth(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 BIF_RasterPos(float x, float y);
void BIF_SetScale(float aspect);
void refresh_interface_font(void); void refresh_interface_font(void);
#endif /* BIF_LANGUAGE_H */ #endif /* BIF_LANGUAGE_H */

@ -258,7 +258,6 @@
#define B_DOLANGUIFONT 316 #define B_DOLANGUIFONT 316
#define B_RESTOREFONT 317 #define B_RESTOREFONT 317
#define B_USETEXTUREFONT 318 #define B_USETEXTUREFONT 318
#define B_SCALETEXTUREFONT 319
#define B_UITHEMECHANGED 320 #define B_UITHEMECHANGED 320
#define B_UITHEMECOLORMOD 321 #define B_UITHEMECOLORMOD 321

@ -47,12 +47,6 @@
#include "BLI_winstuff.h" #include "BLI_winstuff.h"
#endif #endif
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_action_types.h" #include "DNA_action_types.h"
#include "DNA_ipo_types.h" #include "DNA_ipo_types.h"

@ -46,12 +46,6 @@
#include "BLI_winstuff.h" #include "BLI_winstuff.h"
#endif #endif
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_armature_types.h" #include "DNA_armature_types.h"
#include "DNA_lamp_types.h" #include "DNA_lamp_types.h"

@ -47,12 +47,6 @@
#include "BLI_winstuff.h" #include "BLI_winstuff.h"
#endif #endif
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"
#include "DNA_screen_types.h" #include "DNA_screen_types.h"

@ -46,12 +46,6 @@
#include "BLI_winstuff.h" #include "BLI_winstuff.h"
#endif #endif
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_image_types.h" #include "DNA_image_types.h"
#include "DNA_mesh_types.h" #include "DNA_mesh_types.h"

@ -47,12 +47,6 @@
#include "BLI_winstuff.h" #include "BLI_winstuff.h"
#endif #endif
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_image_types.h" #include "DNA_image_types.h"
#include "DNA_lamp_types.h" #include "DNA_lamp_types.h"
@ -112,6 +106,7 @@
#include "BPY_menus.h" #include "BPY_menus.h"
#include "blendef.h" #include "blendef.h"
#include "interface.h"
#include "mydevice.h" #include "mydevice.h"
extern char versionstr[]; /* from blender.c */ extern char versionstr[]; /* from blender.c */
@ -1910,6 +1905,7 @@ void info_buttons(void)
} }
else xco= 430; else xco= 430;
BIF_SetScale(block->aspect);
info_text(xco+24, 6); info_text(xco+24, 6);
uiBlockSetEmboss(block, UI_EMBOSSN); uiBlockSetEmboss(block, UI_EMBOSSN);

@ -47,12 +47,6 @@
#include "BLI_winstuff.h" #include "BLI_winstuff.h"
#endif #endif
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_curve_types.h" #include "DNA_curve_types.h"
#include "DNA_key_types.h" #include "DNA_key_types.h"

@ -47,12 +47,6 @@
#include "BLI_winstuff.h" #include "BLI_winstuff.h"
#endif #endif
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_nla_types.h" #include "DNA_nla_types.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"

@ -47,12 +47,6 @@
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "BMF_Api.h"
#include "BIF_language.h"
#ifdef INTERNATIONAL
#include "FTF_Api.h"
#endif
#include "BSE_headerbuttons.h" #include "BSE_headerbuttons.h"
#include "DNA_ID.h" #include "DNA_ID.h"

@ -173,6 +173,7 @@
#include "mydevice.h" #include "mydevice.h"
#include "blendef.h" #include "blendef.h"
#include "interface.h"
#include "nla.h" /* __NLA : To be removed later */ #include "nla.h" /* __NLA : To be removed later */
#include "butspace.h" // test_idbutton #include "butspace.h" // test_idbutton
@ -1585,16 +1586,9 @@ void do_global_buttons(unsigned short event)
break; break;
case B_RESTOREFONT: /* is button from space.c *info* */ case B_RESTOREFONT: /* is button from space.c *info* */
{ U.fontsize= 0;
extern float lang_texsize; start_interface_font();
allqueue(REDRAWALL, 0);
lang_texsize = 1.0;
FTF_SetScale(lang_texsize);
U.fontsize= 0;
start_interface_font();
allqueue(REDRAWALL, 0);
}
break; break;
case B_USETEXTUREFONT: /* is button from space.c *info* */ case B_USETEXTUREFONT: /* is button from space.c *info* */
@ -1607,15 +1601,6 @@ void do_global_buttons(unsigned short event)
allqueue(REDRAWALL, 0); allqueue(REDRAWALL, 0);
break; 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* */ case B_DOLANGUIFONT: /* is button from space.c *info* */
if(U.transopts & USER_DOTRANSLATE) if(U.transopts & USER_DOTRANSLATE)
start_interface_font(); start_interface_font();

@ -3452,10 +3452,7 @@ static uiOverDraw *ui_draw_but_tip(uiBut *but)
uiOverDraw *od; uiOverDraw *od;
float x1, x2, y1, y2; float x1, x2, y1, y2;
#ifdef INTERNATIONAL #ifdef INTERNATIONAL
extern float lang_texsize;
if(G.ui_international == TRUE) { if(G.ui_international == TRUE) {
float llx,lly,llz,urx,ury,urz; //for FTF_GetBoundingBox() float llx,lly,llz,urx,ury,urz; //for FTF_GetBoundingBox()
@ -3464,15 +3461,11 @@ 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); 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= but->y1-(ury+FTF_GetSize())-12; y2= but->y1-12;
y1 *= lang_texsize;
y2 *= lang_texsize;
} else { } else {
FTF_GetBoundingBox(but->tip, &llx,&lly,&llz,&urx,&ury,&urz, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); 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); 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= but->y1-(ury+FTF_GetSize())-12; y2= but->y1-12;
y1 *= lang_texsize;
y2 *= lang_texsize;
} }
} else { } else {
x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*BMF_GetStringWidth(but->font, but->tip); x1= (but->x1+but->x2)/2; x2= 10+x1+ but->aspect*BMF_GetStringWidth(but->font, but->tip);
@ -3528,6 +3521,8 @@ static uiOverDraw *ui_draw_but_tip(uiBut *but)
glColor3ub(0,0,0); glColor3ub(0,0,0);
ui_rasterpos_safe( x1+3, y1+5.0/but->aspect, but->aspect); ui_rasterpos_safe( x1+3, y1+5.0/but->aspect, but->aspect);
BIF_SetScale(1.0);
BIF_DrawString(but->font, but->tip, (U.transopts & USER_TR_TOOLTIPS)); BIF_DrawString(but->font, but->tip, (U.transopts & USER_TR_TOOLTIPS));
ui_flush_overdraw(od); /* to show it in the frontbuffer */ ui_flush_overdraw(od); /* to show it in the frontbuffer */

@ -117,6 +117,7 @@ void ui_rasterpos_safe(float x, float y, float aspect)
if(doit) glRasterPos2f(x, y); if(doit) glRasterPos2f(x, y);
BIF_RasterPos(x, y); BIF_RasterPos(x, y);
BIF_SetScale(aspect);
} }
/* ************** generic embossed rect, for window sliders etc ************* */ /* ************** generic embossed rect, for window sliders etc ************* */

@ -71,7 +71,6 @@ struct _LANGMenuEntry {
static LANGMenuEntry *langmenu= 0; static LANGMenuEntry *langmenu= 0;
static int tot_lang = 0; static int tot_lang = 0;
float lang_texsize = 1.0;
#endif // INTERNATIONAL #endif // INTERNATIONAL
@ -82,6 +81,13 @@ void BIF_RasterPos(float x, float y)
#endif // INTERNATIONAL #endif // INTERNATIONAL
} }
void BIF_SetScale(float aspect)
{
#ifdef INTERNATIONAL
FTF_SetScale(aspect);
#endif // INTERNATIONAL
}
void refresh_interface_font(void) void refresh_interface_font(void)
{ {
#ifdef INTERNATIONAL #ifdef INTERNATIONAL

@ -2542,15 +2542,6 @@ void drawinfospace(ScrArea *sa, void *spacedata)
(xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth, (xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth,
&(U.transopts), 0, 0, 0, 0, &(U.transopts), 0, 0, 0, 0,
"Use Textured Fonts"); "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 */ /* end of INTERNATIONAL */