r21634 - in trunk/libass: ass_font.c ass_font.h
Author: eugeni Date: Sat Dec 16 20:29:33 2006 New Revision: 21634 Modified: trunk/libass/ass_font.c trunk/libass/ass_font.h Log: Avoid storing font file path and index in ass_font_t. Modified: trunk/libass/ass_font.c ============================================================================== --- trunk/libass/ass_font.c (original) +++ trunk/libass/ass_font.c Sat Dec 16 20:29:33 2006 @@ -96,8 +96,6 @@ 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 @@ } #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 @@ 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 @@ } 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 @@ 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 @@ 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); Modified: trunk/libass/ass_font.h ============================================================================== --- trunk/libass/ass_font.h (original) +++ trunk/libass/ass_font.h Sat Dec 16 20:29:33 2006 @@ -33,8 +33,6 @@ 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
participants (1)
-
eugeni