diff options
author | Diego Borghetti <bdiego@gmail.com> | 2011-02-19 16:43:22 +0300 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2011-02-19 16:43:22 +0300 |
commit | 65ce537c6c797fac1b750c963e9563293c17d011 (patch) | |
tree | a97d2f9e359fee8c14de25591b78432592265bcc /source/blender/blenfont | |
parent | 9ee1b3930fef6404f197a56363bee4f846bc2bb7 (diff) |
Rename global_ft_lib and make it static.
Remove the XXX code from blf_glyph.c and use the pointer
inside the FontBLF struct.
If still have problem, let me know.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 13 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 8 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_internal_types.h | 3 |
3 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index ce68df5c8b6..1b739c31f08 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -52,17 +52,17 @@ #include "blf_internal.h" -/* freetype2 handle. */ -FT_Library global_ft_lib; +/* freetype2 handle ONLY for this file!. */ +static FT_Library ft_lib; int blf_font_init(void) { - return(FT_Init_FreeType(&global_ft_lib)); + return(FT_Init_FreeType(&ft_lib)); } void blf_font_exit(void) { - FT_Done_FreeType(global_ft_lib); + FT_Done_FreeType(ft_lib); } void blf_font_size(FontBLF *font, int size, int dpi) @@ -547,6 +547,7 @@ static void blf_font_fill(FontBLF *font) font->b_col[1]= 0; font->b_col[2]= 0; font->b_col[3]= 0; + font->ft_lib= ft_lib; memset(font->glyph_ascii_table, 0, sizeof(font->glyph_ascii_table)); } @@ -558,7 +559,7 @@ FontBLF *blf_font_new(const char *name, const char *filename) char *mfile; font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new"); - err= FT_New_Face(global_ft_lib, filename, 0, &font->face); + err= FT_New_Face(ft_lib, filename, 0, &font->face); if (err) { MEM_freeN(font); return(NULL); @@ -600,7 +601,7 @@ FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_siz FT_Error err; font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem"); - err= FT_New_Memory_Face(global_ft_lib, mem, mem_size, 0, &font->face); + err= FT_New_Memory_Face(ft_lib, mem, mem_size, 0, &font->face); if (err) { MEM_freeN(font); return(NULL); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 9a3843b960d..c29017c35f3 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -51,8 +51,6 @@ #include "blf_internal_types.h" #include "blf_internal.h" -/* XXX copied from blf_font.c */ -extern FT_Library global_ft_lib; GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi) { @@ -236,9 +234,9 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) /* Convert result from 1 bit per pixel to 8 bit per pixel */ /* Accum errors for later, fine if not interested beyond "ok vs any error" */ FT_Bitmap_New(&tempbitmap); - err += FT_Bitmap_Convert(global_ft_lib, &slot->bitmap, &tempbitmap, 1); /* Does Blender use Pitch 1 always? It works so far */ - err += FT_Bitmap_Copy(global_ft_lib, &tempbitmap, &slot->bitmap); - err += FT_Bitmap_Done(global_ft_lib, &tempbitmap); + err += FT_Bitmap_Convert(font->ft_lib, &slot->bitmap, &tempbitmap, 1); /* Does Blender use Pitch 1 always? It works so far */ + err += FT_Bitmap_Copy(font->ft_lib, &tempbitmap, &slot->bitmap); + err += FT_Bitmap_Done(font->ft_lib, &tempbitmap); } else { err = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL); } diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index d7c023fc415..dd6bf3cfa7c 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -183,6 +183,9 @@ typedef struct FontBLF { /* fast ascii lookip */ GlyphBLF *glyph_ascii_table[256]; + /* freetype2 lib handle. */ + FT_Library ft_lib; + /* freetype2 face. */ FT_Face face; |