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.
This commit is contained in:
Diego Borghetti 2011-02-19 13:43:22 +00:00
parent 9ee1b3930f
commit 65ce537c6c
3 changed files with 13 additions and 11 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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;