[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11429] trunk/blender: Font preview

Joilnen Leite vma_bad_list at yahoo.com
Mon Jul 30 17:59:16 CEST 2007


Revision: 11429
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11429
Author:   pidhash
Date:     2007-07-30 17:59:16 +0200 (Mon, 30 Jul 2007)

Log Message:
-----------
Font preview

Modified Paths:
--------------
    trunk/blender/config/linux2-config.py
    trunk/blender/projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj
    trunk/blender/source/blender/ftfont/FTF_Api.h
    trunk/blender/source/blender/ftfont/SConscript
    trunk/blender/source/blender/ftfont/intern/FTF_Api.cpp
    trunk/blender/source/blender/ftfont/intern/Makefile
    trunk/blender/source/blender/include/BIF_interface.h
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/filesel.c
    trunk/blender/source/blender/src/header_filesel.c
    trunk/blender/source/blender/src/interface_draw.c

Modified: trunk/blender/config/linux2-config.py
===================================================================
--- trunk/blender/config/linux2-config.py	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/config/linux2-config.py	2007-07-30 15:59:16 UTC (rev 11429)
@@ -5,7 +5,7 @@
 BF_VERSE_INCLUDE = "#extern/verse/dist"
 
 BF_PYTHON = '/usr'
-BF_PYTHON_VERSION = '2.5'
+BF_PYTHON_VERSION = '2.4'
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}'
 BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}' #BF_PYTHON+'/lib/python'+BF_PYTHON_VERSION+'/config/libpython'+BF_PYTHON_VERSION+'.a'
@@ -27,7 +27,7 @@
 WITH_BF_FMOD = 'false'
 BF_FMOD = LIBDIR + '/fmod'
 
-WITH_BF_OPENEXR = 'true'
+WITH_BF_OPENEXR = 'false'
 BF_OPENEXR = '/usr'
 BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR'
 BF_OPENEXR_LIB = 'Half IlmImf Iex Imath '

Modified: trunk/blender/projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj
===================================================================
--- trunk/blender/projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj	2007-07-30 15:59:16 UTC (rev 11429)
@@ -21,7 +21,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\..\..\lib\windows\freetype\include;..\..\..\..\build\msvc_7\extern\ftgl\include;..\..\..\..\lib\windows\gettext\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna"
+				AdditionalIncludeDirectories="..\..\..\..\lib\windows\freetype\include;..\..\..\..\build\msvc_7\extern\ftgl\include;..\..\..\..\lib\windows\gettext\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;WCHAR_T16;HAVE_LC_MESSAGES;FTGL_LIBRARY_STATIC"
 				StringPooling="TRUE"
 				RuntimeLibrary="0"

Modified: trunk/blender/source/blender/ftfont/FTF_Api.h
===================================================================
--- trunk/blender/source/blender/ftfont/FTF_Api.h	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/ftfont/FTF_Api.h	2007-07-30 15:59:16 UTC (rev 11429)
@@ -154,6 +154,10 @@
 
 FTF_EXPORT void FTF_End(void);
 
+/* Font preview functions */
+FTF_EXPORT int FTF_GetNewFont (const unsigned char *str, int datasize, int fontsize);
+FTF_EXPORT float FTF_DrawNewFontString(char* str, unsigned int flag);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/blender/source/blender/ftfont/SConscript
===================================================================
--- trunk/blender/source/blender/ftfont/SConscript	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/ftfont/SConscript	2007-07-30 15:59:16 UTC (rev 11429)
@@ -4,7 +4,7 @@
 
 sources = env.Glob('intern/*.cpp')
 
-incs = '. intern ../blenkernel ../blenlib ../makesdna'
+incs = '. intern ../blenkernel ../blenlib ../makesdna ../include'
 incs += ' ' + env['BF_FTGL_INC']
 incs += ' ' + env['BF_FREETYPE_INC']
 incs += ' ' + env['BF_GETTEXT_INC']

Modified: trunk/blender/source/blender/ftfont/intern/FTF_Api.cpp
===================================================================
--- trunk/blender/source/blender/ftfont/intern/FTF_Api.cpp	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/ftfont/intern/FTF_Api.cpp	2007-07-30 15:59:16 UTC (rev 11429)
@@ -43,8 +43,18 @@
 #include "../FTF_Api.h"
 #include "FTF_TTFont.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+	#include "datatoc.h"
+#ifdef __cplusplus
+}
+#endif
+
 #define FTF_EXPORT
 
+FTF_TTFont *newfont= 0; // preview font
+
 static FTF_TTFont *_FTF_GetFont(void) { 
 	static FTF_TTFont *theFont = NULL; 
 	
@@ -55,8 +65,28 @@
 	return theFont; 
 }
 
+FTF_EXPORT int FTF_GetNewFont (const unsigned char *str, int datasize, int fontsize) {
+
+	if (newfont) delete newfont;
+	newfont= new FTF_TTFont(); 
+
+	if (!(newfont->SetFont((unsigned char*)str, datasize, fontsize))) {
+		newfont->SetFont((unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size, fontsize);
+		return 0;
+	}
+	return 1;
+}
+
+FTF_EXPORT float FTF_DrawNewFontString(char* str, unsigned int flag)
+{
+	if (newfont)
+		return newfont->DrawString(str, flag);
+	return 0.0f;
+}
+
 FTF_EXPORT void FTF_End(void) { 
 	delete _FTF_GetFont(); 
+	delete newfont;
 }
 
 FTF_EXPORT void FTF_SetSize(int size)
@@ -174,3 +204,5 @@
 {
   _FTF_GetFont()->SetScale(fsize);
 }
+
+

Modified: trunk/blender/source/blender/ftfont/intern/Makefile
===================================================================
--- trunk/blender/source/blender/ftfont/intern/Makefile	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/ftfont/intern/Makefile	2007-07-30 15:59:16 UTC (rev 11429)
@@ -46,6 +46,7 @@
 CPPFLAGS += -I../../makesdna
 CPPFLAGS += -I../../blenkernel
 CPPFLAGS += -I../../blenlib
+CPPFLAGS += -I../../include
 CPPFLAGS += -I$(NAN_FTGL)/include
 CPPFLAGS += -I$(NAN_FTGL)/include/FTGL
 CPPFLAGS += -I$(NAN_GETTEXT)/include

Modified: trunk/blender/source/blender/include/BIF_interface.h
===================================================================
--- trunk/blender/source/blender/include/BIF_interface.h	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/include/BIF_interface.h	2007-07-30 15:59:16 UTC (rev 11429)
@@ -166,6 +166,7 @@
 #define BUT_CURVE (32<<9)
 #define BUT_TOGDUAL (33<<9)
 #define ICONTOGN (34<<9)
+#define FTPREVIEW (35<<9)
 #define BUTTYPE	(63<<9)
 
 

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h	2007-07-30 15:59:16 UTC (rev 11429)
@@ -170,8 +170,10 @@
 	char file[80];
 	
 	short type, ofs, flag, sort;
-	short maxnamelen, collums;
-	
+	short maxnamelen, collums, f_fp, pad1;
+	int pad2;
+	char fp_str[8];
+
 	struct BlendHandle *libfiledata;
 	
 	unsigned short retval;		/* event */
@@ -443,6 +445,7 @@
 
 #define FILE_LOADLIB		1
 #define FILE_MAIN			2
+#define FILE_LOADFONT		3
 
 /* sfile->flag */
 #define FILE_SHOWSHORT		1

Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/src/buttons_editing.c	2007-07-30 15:59:16 UTC (rev 11429)
@@ -2420,7 +2420,7 @@
 		sa= closest_bigger_area();
 		areawinset(sa->win);
 
-		activate_fileselect(FILE_SPECIAL, "SELECT FONT", str, load_buts_vfont);
+		activate_fileselect(FILE_LOADFONT, "SELECT FONT", str, load_buts_vfont);
 
 		break;
 	case B_PACKFONT:

Modified: trunk/blender/source/blender/src/filesel.c
===================================================================
--- trunk/blender/source/blender/src/filesel.c	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/src/filesel.c	2007-07-30 15:59:16 UTC (rev 11429)
@@ -111,6 +111,8 @@
 
 #include "BIF_fsmenu.h"  /* include ourselves */
 
+#include "FTF_Api.h"
+
 #if defined WIN32 || defined __BeOS
 int fnmatch(const char *pattern, const char *string, int flags)
 {
@@ -507,7 +509,7 @@
 					}
 				}
 			}
-		} else if (sfile->type==FILE_SPECIAL){
+		} else if (sfile->type==FILE_SPECIAL || sfile->type==FILE_LOADFONT){
 			if(BLI_testextensie(file->relname, ".py")) {
 				file->flags |= PYSCRIPTFILE;			
 			} else if( BLI_testextensie(file->relname, ".ttf")
@@ -1368,7 +1370,7 @@
 			sfile->libfiledata= NULL;
 		}
 	}
-	else {	/* FILE_BLENDER */
+	else {	/* FILE_BLENDER or FILE_LOADFONT */
 		split_sfile(sfile, name);	/* test filelist too */
 		BLI_cleanup_dir(G.sce, sfile->dir);
 
@@ -2019,8 +2021,15 @@
 					}
 					else {
 						if( strcmp(sfile->file, sfile->filelist[act].relname)) {
+							char tmpstr[240];
 							do_draw= 1;
 							BLI_strncpy(sfile->file, sfile->filelist[act].relname, sizeof(sfile->file));
+							if (sfile->f_fp) {
+								sprintf (tmpstr, "%s%s", sfile->dir, sfile->file);
+								/* printf ("%s\n", tmpstr); */
+								if (!FTF_GetNewFont ((const unsigned char *)tmpstr, 0, U.fontsize))
+									error ("No font file");
+							}
 						}
 						if(event==MIDDLEMOUSE && sfile->type) filesel_execute(sfile);
 					}

Modified: trunk/blender/source/blender/src/header_filesel.c
===================================================================
--- trunk/blender/source/blender/src/header_filesel.c	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/src/header_filesel.c	2007-07-30 15:59:16 UTC (rev 11429)
@@ -158,6 +158,13 @@
 	
 		xco+= 100;	// scroll
 	}
+	else if(sfile->type==FILE_LOADFONT) {
+		uiDefIconButBitS(block, ICONTOG, FILE_SHOWSHORT, B_SORTFILELIST, ICON_BLANK3, xco+= XIC, 0, XIC, YIC, &sfile->f_fp, 0, 0, 0, 0, "Activate font preview");
+		if (sfile->f_fp)
+			uiDefButC(block, FTPREVIEW, 0, "Font preview", xco+= XIC, 0, 100, YIC, sfile->fp_str, (float)0, (float)16, 0, 0, "Font preview");
+	
+		xco+= 100;	// scroll
+	}
 
 	uiDrawBlock(block);
 	

Modified: trunk/blender/source/blender/src/interface_draw.c
===================================================================
--- trunk/blender/source/blender/src/interface_draw.c	2007-07-30 15:19:42 UTC (rev 11428)
+++ trunk/blender/source/blender/src/interface_draw.c	2007-07-30 15:59:16 UTC (rev 11429)
@@ -1604,8 +1604,12 @@
 			ui_rasterpos_safe(x, (but->y1+but->y2- 9.0)/2.0, but->aspect);
 			if(but->type==IDPOIN) transopts= 0;	// no translation, of course!
 			else transopts= (U.transopts & USER_TR_BUTTONS);
-			BIF_DrawString(but->font, but->drawstr+but->ofs, transopts);
 
+			if (but->type == FTPREVIEW)
+				FTF_DrawNewFontString (but->drawstr+but->ofs, FTF_INPUT_UTF8);
+			else
+				BIF_DrawString(but->font, but->drawstr+but->ofs, transopts);
+
 			/* part text right aligned */
 			if(cpoin) {
 				len= BIF_GetStringWidth(but->font, cpoin+1, (U.transopts & USER_TR_BUTTONS));





More information about the Bf-blender-cvs mailing list