diff options
author | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-12-16 19:29:33 +0000 |
---|---|---|
committer | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-12-16 19:29:33 +0000 |
commit | eba0f2e158ee1740c9cc76bd952aa335eb29c6ac (patch) | |
tree | 563430939d18a37d8f38c401c281d37641057fcc | |
parent | 4eb3c3173e7dec0786f86a98c09ec0b84f13dbfb (diff) |
Avoid storing font file path and index in ass_font_t.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21634 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libass/ass_font.c | 20 | ||||
-rw-r--r-- | libass/ass_font.h | 2 |
2 files changed, 8 insertions, 14 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c index 84ec686923..2c17e8eceb 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -96,8 +96,6 @@ ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_ font = calloc(1, sizeof(ass_font_t)); font->ftlibrary = ftlibrary; - font->path = strdup(path); - font->index = index; font->face = face; font->desc.family = strdup(desc->family); font->desc.bold = desc->bold; @@ -137,7 +135,7 @@ void ass_font_set_size(ass_font_t* font, int size) } #ifdef HAVE_FONTCONFIG -static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font) +static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font, uint32_t ch) { char* path; int index; @@ -146,10 +144,6 @@ static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font) path = fontconfig_select_with_charset(fontconfig_priv, font->desc.family, font->desc.bold, font->desc.italic, &index, font->charset); - if (strcasecmp(path, font->path) == 0 && index == font->index) { - free(path); - return; - } error = FT_New_Face(font->ftlibrary, path, index, &face); if (error) { @@ -158,12 +152,15 @@ static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font) } charmap_magic(face); + error = FT_Get_Char_Index(face, ch); + if (error == 0) { // the new font face is not better then the old one + FT_Done_Face(face); + return; + } + if (font->face) FT_Done_Face(font->face); - free(font->path); font->face = face; - font->path = strdup(path); - font->index = index; FT_Set_Transform(font->face, &font->m, &font->v); FT_Set_Pixel_Sizes(font->face, 0, font->size); @@ -203,7 +200,7 @@ FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch if (index == 0) { mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_GlyphNotFoundReselectingFont, ch, font->desc.family, font->desc.bold, font->desc.italic); - ass_font_reselect(fontconfig_priv, font); + ass_font_reselect(fontconfig_priv, font, ch); index = FT_Get_Char_Index(font->face, ch); if (index == 0) { mp_msg(MSGT_ASS, MSGL_ERR, MSGTR_LIBASS_GlyphNotFound, @@ -253,7 +250,6 @@ FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2) void ass_font_free(ass_font_t* font) { if (font->face) FT_Done_Face(font->face); - if (font->path) free(font->path); if (font->desc.family) free(font->desc.family); #ifdef HAVE_FONTCONFIG if (font->charset) FcCharSetDestroy(font->charset); diff --git a/libass/ass_font.h b/libass/ass_font.h index f549f30c19..7c3a50d347 100644 --- a/libass/ass_font.h +++ b/libass/ass_font.h @@ -33,8 +33,6 @@ typedef struct ass_font_desc_s { typedef struct ass_font_s { ass_font_desc_t desc; - char* path; - int index; FT_Library ftlibrary; FT_Face face; FT_Matrix m; // current transformation |