diff options
author | Diego Borghetti <bdiego@gmail.com> | 2009-05-06 03:10:32 +0400 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2009-05-06 03:10:32 +0400 |
commit | 405cf80eb8dc2df8ae160aee70aef34052add24a (patch) | |
tree | f03cc27e95bdf91b25ea9d2a0dffb28ccef666be /source/blender/blenfont/intern/blf.c | |
parent | 71c38978e14ebf3522fe60fc239ad04f10ef30ab (diff) |
Big, big commit!!
1) Remove WITH_FREETYPE2 from code, so now blender always need freetype2
2) Remove the old bmfont
3) Remove ftfont and bFTGL library
4) Implement a new BLF_draw_default function for place that still need/use
the old BMF api.
I try to update both, scons and cmake, but I only can test with make, so
hope all work fine.
MSVC is broken, but I don't have Windows, things to search and fix are
any reference to WITH_FREETYPE2, FTGL and BMFONT (take in care that
blenkernel also have a BKE_bmfont.h, this don't have anything to do with bmfont).
Always have to link/include the freetype2 library
Remove any reference to libbmfont
Remove any reference to libftfont
Remove any reference to libbftgl (or libbFTGL)
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 149 |
1 files changed, 116 insertions, 33 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index e43d7905cf9..d49ca0bd0ac 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -31,15 +31,11 @@ #include <string.h> #include <math.h> -#ifdef WITH_FREETYPE2 - #include <ft2build.h> #include FT_FREETYPE_H #include FT_GLYPH_H -#endif /* WITH_FREETYPE2 */ - #include "MEM_guardedalloc.h" #include "DNA_listBase.h" @@ -75,14 +71,20 @@ int global_font_num= 0; /* Current font. */ int global_font_cur= 0; +/* Default size and dpi, for BLF_draw_default. */ +int global_font_default= -1; +int global_font_points= 11; +int global_font_dpi= 72; -int BLF_init(void) +int BLF_init(int points, int dpi) { int i; for (i= 0; i < BLF_MAX_FONT; i++) global_font[i]= NULL; + global_font_points= points; + global_font_dpi= dpi; return(blf_font_init()); } @@ -142,7 +144,6 @@ int BLF_load(char *name) return(-1); } -#ifdef WITH_FREETYPE2 font= blf_font_new(name, filename); MEM_freeN(filename); @@ -155,9 +156,6 @@ int BLF_load(char *name) i= global_font_num; global_font_num++; return(i); -#endif /* WITH_FREETYPE2 */ - - return(-1); } int BLF_load_mem(char *name, unsigned char *mem, int mem_size) @@ -181,21 +179,15 @@ int BLF_load_mem(char *name, unsigned char *mem, int mem_size) return(-1); } - font= blf_internal_new(name); - if (!font) { -#ifdef WITH_FREETYPE2 - if (!mem || !mem_size) { - printf("Can't load font: %s from memory!!\n", name); - return(-1); - } - - font= blf_font_new_from_mem(name, mem, mem_size); -#endif /* WITH_FREETYPE2 */ + if (!mem || !mem_size) { + printf("Can't load font: %s from memory!!\n", name); + return(-1); + } - if (!font) { - printf("Can't load font: %s from memory!!\n", name); - return(-1); - } + font= blf_font_new_from_mem(name, mem, mem_size); + if (!font) { + printf("Can't load font: %s from memory!!\n", name); + return(-1); } global_font[global_font_num]= font; @@ -215,16 +207,6 @@ int BLF_get(void) return(global_font_cur); } -int BLF_type_get(void) -{ - FontBLF *font; - - font= global_font[global_font_cur]; - if (font) - return(font->type); - return(-1); -} - void BLF_enable(int option) { FontBLF *font; @@ -299,6 +281,41 @@ void BLF_blur(int size) font->blur= size; } +void BLF_draw_default(float x, float y, float z, char *str) +{ + FontBLF *font; + int old_font, old_point, old_dpi; + + if (!str) + return; + + if (global_font_default == -1) + global_font_default= blf_search("default"); + + if (global_font_default == -1) { + printf("Warning: Can't found default font!!\n"); + return; + } + + font= global_font[global_font_cur]; + if (font) { + old_font= global_font_cur; + old_point= font->size; + old_dpi= font->dpi; + } + + global_font_cur= global_font_default; + BLF_size(global_font_points, global_font_dpi); + BLF_position(x, y, z); + BLF_draw(str); + + /* restore the old font. */ + if (font) { + global_font_cur= old_font; + BLF_size(old_point, old_dpi); + } +} + void BLF_draw(char *str) { FontBLF *font; @@ -363,6 +380,39 @@ float BLF_width(char *str) return(0.0f); } +float BLF_width_default(char *str) +{ + FontBLF *font; + float width; + int old_font, old_point, old_dpi; + + if (global_font_default == -1) + global_font_default= blf_search("default"); + + if (global_font_default == -1) { + printf("Error: Can't found default font!!\n"); + return(0.0f); + } + + font= global_font[global_font_cur]; + if (font) { + old_font= global_font_cur; + old_point= font->size; + old_dpi= font->dpi; + } + + global_font_cur= global_font_default; + BLF_size(global_font_points, global_font_dpi); + width= BLF_width(str); + + /* restore the old font. */ + if (font) { + global_font_cur= old_font; + BLF_size(old_point, old_dpi); + } + return(width); +} + float BLF_height(char *str) { FontBLF *font; @@ -373,6 +423,39 @@ float BLF_height(char *str) return(0.0f); } +float BLF_height_default(char *str) +{ + FontBLF *font; + float height; + int old_font, old_point, old_dpi; + + if (global_font_default == -1) + global_font_default= blf_search("default"); + + if (global_font_default == -1) { + printf("Error: Can't found default font!!\n"); + return(0.0f); + } + + font= global_font[global_font_cur]; + if (font) { + old_font= global_font_cur; + old_point= font->size; + old_dpi= font->dpi; + } + + global_font_cur= global_font_default; + BLF_size(global_font_points, global_font_dpi); + height= BLF_height(str); + + /* restore the old font. */ + if (font) { + global_font_cur= old_font; + BLF_size(old_point, old_dpi); + } + return(height); +} + void BLF_rotation(float angle) { FontBLF *font; |