diff options
author | Joilnen Leite <joilnen.leite@gmail.com> | 2007-07-30 19:59:16 +0400 |
---|---|---|
committer | Joilnen Leite <joilnen.leite@gmail.com> | 2007-07-30 19:59:16 +0400 |
commit | 443a64135ea25b19cb5212c99cf85444ebb782d0 (patch) | |
tree | 75acf4f51b07f382b5bf81135b85b4c151e6db1f | |
parent | ecd42c43427dd9abd8371554e623b64103587e2f (diff) |
Font preview
-rw-r--r-- | config/linux2-config.py | 4 | ||||
-rw-r--r-- | projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj | 2 | ||||
-rw-r--r-- | source/blender/ftfont/FTF_Api.h | 4 | ||||
-rw-r--r-- | source/blender/ftfont/SConscript | 2 | ||||
-rw-r--r-- | source/blender/ftfont/intern/FTF_Api.cpp | 32 | ||||
-rw-r--r-- | source/blender/ftfont/intern/Makefile | 1 | ||||
-rw-r--r-- | source/blender/include/BIF_interface.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 7 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 2 | ||||
-rw-r--r-- | source/blender/src/filesel.c | 13 | ||||
-rw-r--r-- | source/blender/src/header_filesel.c | 7 | ||||
-rw-r--r-- | source/blender/src/interface_draw.c | 6 |
12 files changed, 71 insertions, 10 deletions
diff --git a/config/linux2-config.py b/config/linux2-config.py index edc7f26c690..3e442892748 100644 --- a/config/linux2-config.py +++ b/config/linux2-config.py @@ -5,7 +5,7 @@ WITH_BF_VERSE = 'false' 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 @@ BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer 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 ' diff --git a/projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj b/projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj index ad0f5d83ced..6bbd13686d4 100644 --- a/projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj +++ b/projectfiles_vc7/blender/ftfont/FTF_ftfont.vcproj @@ -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" diff --git a/source/blender/ftfont/FTF_Api.h b/source/blender/ftfont/FTF_Api.h index 15fa55c905d..b370c18f89e 100644 --- a/source/blender/ftfont/FTF_Api.h +++ b/source/blender/ftfont/FTF_Api.h @@ -154,6 +154,10 @@ FTF_EXPORT void FTF_SetScale(float fsize); 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 diff --git a/source/blender/ftfont/SConscript b/source/blender/ftfont/SConscript index cf6805d6bb3..615b274677c 100644 --- a/source/blender/ftfont/SConscript +++ b/source/blender/ftfont/SConscript @@ -4,7 +4,7 @@ Import ('env') 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'] diff --git a/source/blender/ftfont/intern/FTF_Api.cpp b/source/blender/ftfont/intern/FTF_Api.cpp index 52fc9378f00..bf6698a1cde 100644 --- a/source/blender/ftfont/intern/FTF_Api.cpp +++ b/source/blender/ftfont/intern/FTF_Api.cpp @@ -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 @@ static FTF_TTFont *_FTF_GetFont(void) { 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_EXPORT void FTF_SetScale(float fsize) { _FTF_GetFont()->SetScale(fsize); } + + diff --git a/source/blender/ftfont/intern/Makefile b/source/blender/ftfont/intern/Makefile index d3a1977994b..a9ac8067164 100644 --- a/source/blender/ftfont/intern/Makefile +++ b/source/blender/ftfont/intern/Makefile @@ -46,6 +46,7 @@ CFLAGS += $(LEVEL_1_C_WARNINGS) 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 diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h index ad2c8988343..453e4e628fe 100644 --- a/source/blender/include/BIF_interface.h +++ b/source/blender/include/BIF_interface.h @@ -166,6 +166,7 @@ struct AutoComplete; #define BUT_CURVE (32<<9) #define BUT_TOGDUAL (33<<9) #define ICONTOGN (34<<9) +#define FTPREVIEW (35<<9) #define BUTTYPE (63<<9) diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index e7839f49cae..e70c8baaa78 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -170,8 +170,10 @@ typedef struct SpaceFile { 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 @@ typedef struct SpaceImaSel { #define FILE_LOADLIB 1 #define FILE_MAIN 2 +#define FILE_LOADFONT 3 /* sfile->flag */ #define FILE_SHOWSHORT 1 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 50f2212023c..05d08e4c9fc 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -2420,7 +2420,7 @@ void do_fontbuts(unsigned short event) 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: diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index b4c090dd7fb..f3d7add8b8d 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -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 @@ void test_flags_file(SpaceFile *sfile) } } } - } 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 @@ static void activate_fileselect_(int type, char *title, char *file, short *menup 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 @@ void winqreadfilespace(ScrArea *sa, void *spacedata, BWinEvent *evt) } 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); } diff --git a/source/blender/src/header_filesel.c b/source/blender/src/header_filesel.c index 3424c4b7c3d..57bb681d185 100644 --- a/source/blender/src/header_filesel.c +++ b/source/blender/src/header_filesel.c @@ -158,6 +158,13 @@ void file_buttons(void) 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); diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index 4c6734a7be4..374cc72a59f 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -1604,7 +1604,11 @@ static void ui_draw_text_icon(uiBut *but) 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) { |