diff options
author | woglinde <woglinde@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-08-20 11:22:56 +0000 |
---|---|---|
committer | woglinde <woglinde@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-08-20 11:22:56 +0000 |
commit | 2d0e0b5ad3430c174f6abf664b45da6e54295c94 (patch) | |
tree | ed15d1014bd52196bed0de4f092eb08d5a968c64 /navit/font | |
parent | f2c063f14e76e6882a66d4c122ca2d966b437ddb (diff) | |
download | navit-2d0e0b5ad3430c174f6abf664b45da6e54295c94.tar.gz |
Fix:font/freetype:introduce and use font_freetype_destroy to memfree freetype, cleanup freetype cachemanager, cleanup sdl using freetype
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5584 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/font')
-rw-r--r-- | navit/font/freetype/font_freetype.c | 24 | ||||
-rw-r--r-- | navit/font/freetype/font_freetype.h | 1 |
2 files changed, 19 insertions, 6 deletions
diff --git a/navit/font/freetype/font_freetype.c b/navit/font/freetype/font_freetype.c index 504cc55c0..b308f16ce 100644 --- a/navit/font/freetype/font_freetype.c +++ b/navit/font/freetype/font_freetype.c @@ -75,7 +75,8 @@ static FTC_ImageCache image_cache; static FTC_CMapCache charmap_cache; static FTC_SBitCache sbit_cache; #endif -static int library_init; +static int library_init = 0; +static int library_deinit = 0; static void @@ -129,14 +130,14 @@ font_freetype_get_text_bbox(struct graphics_priv *gr, FTC_ImageCache_LookupScaler(image_cache, &font->scaler, FT_LOAD_DEFAULT, glyph_index, &cached_glyph, &anode); #else FTC_ImageCache_Lookup(image_cache, &font->scaler, glyph_index, &cached_glyph, &anode); -#endif +#endif /* HAVE_LOOKUP_SCALER */ FT_Glyph_Copy(cached_glyph, &glyph); FT_Glyph_Transform(glyph, &matrix, &pen); #else glyph_index = FT_Get_Char_Index(font->face, g_utf8_get_char(p)); FT_Load_Glyph(font->face, glyph_index, FT_LOAD_DEFAULT); FT_Get_Glyph(font->face->glyph, &glyph); -#endif +#endif /* USE_CACHING */ FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox); glyph_bbox.xMin += x >> 6; @@ -154,11 +155,10 @@ font_freetype_get_text_bbox(struct graphics_priv *gr, if (glyph_bbox.yMax > bbox.yMax) bbox.yMax = glyph_bbox.yMax; p = g_utf8_next_char(p); -#if USE_CACHING + FT_Done_Glyph(glyph); +#if USE_CACHING FTC_Node_Unref(anode, manager); -#else - FT_Done_Glyph(glyph); #endif } if (bbox.xMin > bbox.xMax) { @@ -776,7 +776,19 @@ font_freetype_glyph_get_glyph(struct font_freetype_glyph *g, return 1; } +static void +font_freetype_destroy(void) { + if (!library_deinit) { +#if USE_CACHING + FTC_Manager_Done(manager); +#endif + FT_Done_FreeType(library); + } + library_deinit = 1; +} + static struct font_freetype_methods methods = { + font_freetype_destroy, font_freetype_font_new, font_freetype_get_text_bbox, font_freetype_text_new, diff --git a/navit/font/freetype/font_freetype.h b/navit/font/freetype/font_freetype.h index 246c47b99..26cfc558d 100644 --- a/navit/font/freetype/font_freetype.h +++ b/navit/font/freetype/font_freetype.h @@ -20,6 +20,7 @@ struct font_freetype_font; struct font_freetype_glyph; struct font_freetype_methods { + void (*destroy)(void); struct font_freetype_font *(*font_new) (struct graphics_priv * gr, struct graphics_font_methods * |