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:
parent
465b15eb69
commit
136ecd4644
@ -69,7 +69,7 @@ FTF_EXPORT int FTF_GetSize(void)
|
||||
return _FTF_GetFont()->GetSize();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FTF_EXPORT int FTF_Ascender(void)
|
||||
{
|
||||
return _FTF_GetFont()->Ascender();
|
||||
@ -79,7 +79,7 @@ FTF_EXPORT int FTF_Descender(void)
|
||||
{
|
||||
return _FTF_GetFont()->Descender();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
@ -221,11 +217,23 @@ int FTF_TTFont::SetFont(const unsigned char* str, int datasize, int fontsize)
|
||||
return 0;
|
||||
} 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 = fonts->FaceSize(fontsize/2);
|
||||
// success = fontm->FaceSize(fontsize);
|
||||
// success = fontl->FaceSize(fontsize*2);
|
||||
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;
|
||||
|
||||
@ -274,13 +282,9 @@ void FTF_TTFont::SetEncoding(char* str)
|
||||
|
||||
void FTF_TTFont::SetSize(int 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);
|
||||
}
|
||||
fonts->FaceSize(size-2<8?8:size-2);
|
||||
fontm->FaceSize(size-1<8?8:size-1);
|
||||
fontl->FaceSize(size);
|
||||
|
||||
font_size = size;
|
||||
}
|
||||
@ -290,6 +294,7 @@ int FTF_TTFont::GetSize(void)
|
||||
return font_size;
|
||||
}
|
||||
|
||||
/*
|
||||
int FTF_TTFont::Ascender(void)
|
||||
{
|
||||
return (int)font->Ascender();
|
||||
@ -300,7 +305,7 @@ int FTF_TTFont::Descender(void)
|
||||
return (int)font->Descender();
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
int FTF_TTFont::TransConvString(char* str, char* ustr, unsigned int flag)
|
||||
{
|
||||
return 0;
|
||||
@ -365,7 +370,7 @@ float FTF_TTFont::GetStringWidth(char* str, unsigned int flag)
|
||||
if(mode == FTF_PIXMAPFONT) {
|
||||
return font->Advance(wstr);
|
||||
} else if(mode == FTF_TEXTUREFONT) {
|
||||
return font->Advance(wstr) * fsize;
|
||||
return font->Advance(wstr);// * fsize;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,8 @@ public:
|
||||
void SetSize(int size);
|
||||
int GetSize(void);
|
||||
|
||||
int Ascender(void);
|
||||
int Descender(void);
|
||||
// int Ascender(void);
|
||||
// int Descender(void);
|
||||
|
||||
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);
|
||||
|
||||
void BIF_RasterPos(float x, float y);
|
||||
void BIF_SetScale(float aspect);
|
||||
void refresh_interface_font(void);
|
||||
|
||||
#endif /* BIF_LANGUAGE_H */
|
||||
|
@ -258,7 +258,6 @@
|
||||
#define B_DOLANGUIFONT 316
|
||||
#define B_RESTOREFONT 317
|
||||
#define B_USETEXTUREFONT 318
|
||||
#define B_SCALETEXTUREFONT 319
|
||||
|
||||
#define B_UITHEMECHANGED 320
|
||||
#define B_UITHEMECOLORMOD 321
|
||||
|
@ -47,12 +47,6 @@
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#include "BMF_Api.h"
|
||||
#include "BIF_language.h"
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_ipo_types.h"
|
||||
|
@ -46,12 +46,6 @@
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#include "BMF_Api.h"
|
||||
#include "BIF_language.h"
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_lamp_types.h"
|
||||
|
@ -47,12 +47,6 @@
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#include "BMF_Api.h"
|
||||
#include "BIF_language.h"
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
@ -46,12 +46,6 @@
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#include "BMF_Api.h"
|
||||
#include "BIF_language.h"
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
|
@ -47,12 +47,6 @@
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#include "BMF_Api.h"
|
||||
#include "BIF_language.h"
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_lamp_types.h"
|
||||
@ -112,6 +106,7 @@
|
||||
#include "BPY_menus.h"
|
||||
|
||||
#include "blendef.h"
|
||||
#include "interface.h"
|
||||
#include "mydevice.h"
|
||||
|
||||
extern char versionstr[]; /* from blender.c */
|
||||
@ -1910,6 +1905,7 @@ void info_buttons(void)
|
||||
}
|
||||
else xco= 430;
|
||||
|
||||
BIF_SetScale(block->aspect);
|
||||
info_text(xco+24, 6);
|
||||
|
||||
uiBlockSetEmboss(block, UI_EMBOSSN);
|
||||
|
@ -47,12 +47,6 @@
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#include "BMF_Api.h"
|
||||
#include "BIF_language.h"
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_key_types.h"
|
||||
|
@ -47,12 +47,6 @@
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#include "BMF_Api.h"
|
||||
#include "BIF_language.h"
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_nla_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
@ -47,12 +47,6 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "BMF_Api.h"
|
||||
#include "BIF_language.h"
|
||||
#ifdef INTERNATIONAL
|
||||
#include "FTF_Api.h"
|
||||
#endif
|
||||
|
||||
#include "BSE_headerbuttons.h"
|
||||
|
||||
#include "DNA_ID.h"
|
||||
|
@ -173,6 +173,7 @@
|
||||
|
||||
#include "mydevice.h"
|
||||
#include "blendef.h"
|
||||
#include "interface.h"
|
||||
#include "nla.h" /* __NLA : To be removed later */
|
||||
#include "butspace.h" // test_idbutton
|
||||
|
||||
@ -1585,16 +1586,9 @@ void do_global_buttons(unsigned short event)
|
||||
break;
|
||||
|
||||
case B_RESTOREFONT: /* is button from space.c *info* */
|
||||
{
|
||||
extern float lang_texsize;
|
||||
|
||||
lang_texsize = 1.0;
|
||||
FTF_SetScale(lang_texsize);
|
||||
|
||||
U.fontsize= 0;
|
||||
start_interface_font();
|
||||
allqueue(REDRAWALL, 0);
|
||||
}
|
||||
U.fontsize= 0;
|
||||
start_interface_font();
|
||||
allqueue(REDRAWALL, 0);
|
||||
break;
|
||||
|
||||
case B_USETEXTUREFONT: /* is button from space.c *info* */
|
||||
@ -1607,15 +1601,6 @@ void do_global_buttons(unsigned short event)
|
||||
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();
|
||||
|
@ -3452,10 +3452,7 @@ static uiOverDraw *ui_draw_but_tip(uiBut *but)
|
||||
uiOverDraw *od;
|
||||
float x1, x2, y1, y2;
|
||||
|
||||
|
||||
#ifdef INTERNATIONAL
|
||||
extern float lang_texsize;
|
||||
|
||||
if(G.ui_international == TRUE) {
|
||||
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);
|
||||
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);
|
||||
@ -3528,6 +3521,8 @@ static uiOverDraw *ui_draw_but_tip(uiBut *but)
|
||||
|
||||
glColor3ub(0,0,0);
|
||||
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));
|
||||
|
||||
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);
|
||||
|
||||
BIF_RasterPos(x, y);
|
||||
BIF_SetScale(aspect);
|
||||
}
|
||||
|
||||
/* ************** generic embossed rect, for window sliders etc ************* */
|
||||
|
@ -71,7 +71,6 @@ struct _LANGMenuEntry {
|
||||
|
||||
static LANGMenuEntry *langmenu= 0;
|
||||
static int tot_lang = 0;
|
||||
float lang_texsize = 1.0;
|
||||
|
||||
#endif // INTERNATIONAL
|
||||
|
||||
@ -82,6 +81,13 @@ void BIF_RasterPos(float x, float y)
|
||||
#endif // INTERNATIONAL
|
||||
}
|
||||
|
||||
void BIF_SetScale(float aspect)
|
||||
{
|
||||
#ifdef INTERNATIONAL
|
||||
FTF_SetScale(aspect);
|
||||
#endif // INTERNATIONAL
|
||||
}
|
||||
|
||||
void refresh_interface_font(void)
|
||||
{
|
||||
#ifdef INTERNATIONAL
|
||||
|
@ -2542,15 +2542,6 @@ void drawinfospace(ScrArea *sa, void *spacedata)
|
||||
(xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth,
|
||||
&(U.transopts), 0, 0, 0, 0,
|
||||
"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 */
|
||||
|
Loading…
Reference in New Issue
Block a user