Modified interface texture font support, which should work nicely with the freshly...
authorRob Haarsma <phaseIV@zonnet.nl>
Fri, 21 Jan 2005 14:48:03 +0000 (14:48 +0000)
committerRob Haarsma <phaseIV@zonnet.nl>
Fri, 21 Jan 2005 14:48:03 +0000 (14:48 +0000)
Also removed some redundant #include's on some files.

18 files changed:
source/blender/ftfont/intern/FTF_Api.cpp
source/blender/ftfont/intern/FTF_TTFont.cpp
source/blender/ftfont/intern/FTF_TTFont.h
source/blender/include/BIF_language.h
source/blender/include/blendef.h
source/blender/src/header_action.c
source/blender/src/header_buttonswin.c
source/blender/src/header_filesel.c
source/blender/src/header_image.c
source/blender/src/header_info.c
source/blender/src/header_ipo.c
source/blender/src/header_nla.c
source/blender/src/header_script.c
source/blender/src/headerbuttons.c
source/blender/src/interface.c
source/blender/src/interface_draw.c
source/blender/src/language.c
source/blender/src/space.c

index 036e13a7e6edd54d46fcd88b69ef4a0e7fe9d61b..52fc9378f004ba79021e2e130e992a6d84497b68 100644 (file)
@@ -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)
 {
index d25c60ea4028fb596760eea9a3a256f5e124b93d..0c979ea5a9437a16122a0642a4160580e366ff95 100644 (file)
@@ -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;
        }
 }
 
index 15682bd4fde6acd11b8b53728bc5500d340c8a8b..c4dee93c5dc3fb01e46db222779a16189af2b7bd 100644 (file)
@@ -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);
 
index 28b57aa1017d7ed6c1dd219f30592e8e17531009..762407f5b247a492e1fe6d56f5eeb4366e43fd8f 100644 (file)
@@ -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 */
index 904928c65adfc8c684b5878109655af0491ff31a..3a26dae9a316ec246aeba9dce5f524922c21c667 100644 (file)
 #define B_DOLANGUIFONT         316
 #define B_RESTOREFONT          317
 #define B_USETEXTUREFONT       318
-#define B_SCALETEXTUREFONT     319
 
 #define B_UITHEMECHANGED       320
 #define B_UITHEMECOLORMOD      321
index 2d86f7a44e25c7cbbfb532862c6faaabe2edd37f..4dbe00ad0d88eba116276ce9cc01801ca39814c3 100644 (file)
 #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"
index d0375a0163e2bf79eb906890394e95b1f3160d59..0186683df31c0357c3ce3c69acd35b94a7edf45c 100644 (file)
 #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"
index 42f3b931ecf0bac5b1fb391e1fda4bae903ebb28..5177770d5c20f774b840f1aa0744f60354169173 100644 (file)
 #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"
index 2987ca7e53fc0db6ffa7c458540dd7a7f79cc570..80f8ea4121fb57290965d24ffbded8513b45449e 100644 (file)
 #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"
index f1ec2bbe27adac1b4d4725257983c6a4d50f2d8f..6c98fa0b5be3ee339b0b59b41a93949ad20749ca 100644 (file)
 #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"
 #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);
index 0b9fa56281bc442a24ec6a6df6a310a62b51c50e..0e5210e668c501e9dc9b1125862b4a1bad17ca81 100644 (file)
 #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"
index 1e821a14271efb330db0dfbdf5579b803403213c..5747ac77fc7b5778de7dbaf655b6632754475231 100644 (file)
 #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"
index 7a6b04e320c5d24fd7ea4176c7019a03a1b21c4c..27755aafd2125e10e23d37555b50697ec1ef438e 100644 (file)
 
 #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"
index 68194e25d8ab179969c7d7679eedc33b6e586804..73f0504ef1c491c3146ee68243b9b9aaf761d8c2 100644 (file)
 
 #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();
index 4a08b6ee98331b91f2a3864193269fc136423d37..df60ea61a3800073abe25e809f464ccde505d3c1 100644 (file)
@@ -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 */
index b6bb28fbf669fd46f2fa19a06f0b97d8af5173b5..f420a903de0e47cef26cac7f3f3d7c58c788059e 100644 (file)
@@ -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 ************* */
index 8f9c476a1424d5996d5452217d3c65b0451e3cdb..750483bf789b4c37eded1b9bb720c23d53e44bd0 100644 (file)
@@ -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
index cd8951a5691b7d88acf43db4e9b478e288e6ec21..6663b4b63dfac4563fd3a7748920dee1eef1cd25 100644 (file)
@@ -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 */