From 443a64135ea25b19cb5212c99cf85444ebb782d0 Mon Sep 17 00:00:00 2001 From: Joilnen Leite Date: Mon, 30 Jul 2007 15:59:16 +0000 Subject: Font preview --- source/blender/ftfont/FTF_Api.h | 4 ++++ source/blender/ftfont/SConscript | 2 +- source/blender/ftfont/intern/FTF_Api.cpp | 32 ++++++++++++++++++++++++++++++++ source/blender/ftfont/intern/Makefile | 1 + 4 files changed, 38 insertions(+), 1 deletion(-) (limited to 'source/blender/ftfont') 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 -- cgit v1.2.3