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:
parent
9ee1b3930f
commit
65ce537c6c
@ -52,17 +52,17 @@
|
|||||||
#include "blf_internal.h"
|
#include "blf_internal.h"
|
||||||
|
|
||||||
|
|
||||||
/* freetype2 handle. */
|
/* freetype2 handle ONLY for this file!. */
|
||||||
FT_Library global_ft_lib;
|
static FT_Library ft_lib;
|
||||||
|
|
||||||
int blf_font_init(void)
|
int blf_font_init(void)
|
||||||
{
|
{
|
||||||
return(FT_Init_FreeType(&global_ft_lib));
|
return(FT_Init_FreeType(&ft_lib));
|
||||||
}
|
}
|
||||||
|
|
||||||
void blf_font_exit(void)
|
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)
|
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[1]= 0;
|
||||||
font->b_col[2]= 0;
|
font->b_col[2]= 0;
|
||||||
font->b_col[3]= 0;
|
font->b_col[3]= 0;
|
||||||
|
font->ft_lib= ft_lib;
|
||||||
|
|
||||||
memset(font->glyph_ascii_table, 0, sizeof(font->glyph_ascii_table));
|
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;
|
char *mfile;
|
||||||
|
|
||||||
font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new");
|
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) {
|
if (err) {
|
||||||
MEM_freeN(font);
|
MEM_freeN(font);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -600,7 +601,7 @@ FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_siz
|
|||||||
FT_Error err;
|
FT_Error err;
|
||||||
|
|
||||||
font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem");
|
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) {
|
if (err) {
|
||||||
MEM_freeN(font);
|
MEM_freeN(font);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -51,8 +51,6 @@
|
|||||||
#include "blf_internal_types.h"
|
#include "blf_internal_types.h"
|
||||||
#include "blf_internal.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)
|
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 */
|
/* 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" */
|
/* Accum errors for later, fine if not interested beyond "ok vs any error" */
|
||||||
FT_Bitmap_New(&tempbitmap);
|
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_Convert(font->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_Copy(font->ft_lib, &tempbitmap, &slot->bitmap);
|
||||||
err += FT_Bitmap_Done(global_ft_lib, &tempbitmap);
|
err += FT_Bitmap_Done(font->ft_lib, &tempbitmap);
|
||||||
} else {
|
} else {
|
||||||
err = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
|
err = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,9 @@ typedef struct FontBLF {
|
|||||||
/* fast ascii lookip */
|
/* fast ascii lookip */
|
||||||
GlyphBLF *glyph_ascii_table[256];
|
GlyphBLF *glyph_ascii_table[256];
|
||||||
|
|
||||||
|
/* freetype2 lib handle. */
|
||||||
|
FT_Library ft_lib;
|
||||||
|
|
||||||
/* freetype2 face. */
|
/* freetype2 face. */
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user