From 1cbd5dfd3195eb7c802eca9771d5f1ce1c50337e Mon Sep 17 00:00:00 2001 From: eugeni Date: Sun, 26 Nov 2006 22:49:27 +0000 Subject: Move fonts-related code to a separate file. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21293 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass_cache.c | 48 +++++++----------------------------------------- 1 file changed, 7 insertions(+), 41 deletions(-) (limited to 'libass/ass_cache.c') diff --git a/libass/ass_cache.c b/libass/ass_cache.c index e4d41e45b0..e3ef630708 100644 --- a/libass/ass_cache.c +++ b/libass/ass_cache.c @@ -30,6 +30,7 @@ #include "ass_fontconfig.h" #include "ass_bitmap.h" #include "ass_cache.h" +#include "ass_font.h" #define MAX_FONT_CACHE_SIZE 100 @@ -48,24 +49,6 @@ static int font_compare(ass_font_desc_t* a, ass_font_desc_t* b) { return 1; } -/** - * Select Microfost Unicode CharMap, if the font has one. - * Otherwise, let FreeType decide. - */ -static void charmap_magic(FT_Face face) -{ - int i; - for (i = 0; i < face->num_charmaps; ++i) { - FT_CharMap cmap = face->charmaps[i]; - unsigned pid = cmap->platform_id; - unsigned eid = cmap->encoding_id; - if (pid == 3 /*microsoft*/ && (eid == 1 /*unicode bmp*/ || eid == 10 /*full unicode*/)) { - FT_Set_Charmap(face, cmap); - break; - } - } -} - /** * \brief Get a face object, either from cache or created through FreeType+FontConfig. * \param library FreeType library object @@ -75,12 +58,9 @@ static void charmap_magic(FT_Face face) */ ass_font_t* ass_new_font(FT_Library library, void* fontconfig_priv, ass_font_desc_t* desc) { - FT_Error error; int i; - char* path; - int index; ass_font_t* item; - FT_Face face; + int error; for (i=0; ifamily, desc->bold, desc->italic, &index); - - error = FT_New_Face(library, path, index, &face); - if (error) { - if (!no_more_font_messages) - mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningFont, path, index); - no_more_font_messages = 1; - return 0; - } - - charmap_magic(face); - item = font_cache + font_cache_size; - item->path = strdup(path); - item->index = index; - item->face = face; - memcpy(&(item->desc), desc, sizeof(ass_font_desc_t)); + error = ass_font_init(library, fontconfig_priv, item, desc); + if (error) // FIXME: mp_msg + return 0; font_cache_size++; + return item; } @@ -123,9 +91,7 @@ void ass_font_cache_done(void) int i; for (i = 0; i < font_cache_size; ++i) { ass_font_t* item = font_cache + i; - if (item->face) FT_Done_Face(item->face); - if (item->path) free(item->path); - // FIXME: free desc ? + ass_font_free(item); } free(font_cache); font_cache_size = 0; -- cgit v1.2.3