/** * \brief Create a new ASS_Font according to "desc" argument */ ASS_Font *ass_font_new(Cache *font_cache, ASS_Library *library, FT_Library ftlibrary, ASS_FontSelector *fontsel, ASS_FontDesc *desc) { int error; ASS_Font *fontp; ASS_Font font; fontp = ass_cache_get(font_cache, desc); if (fontp) return fontp; font.library = library; font.ftlibrary = ftlibrary; font.shaper_priv = NULL; font.n_faces = 0; font.desc.family = strdup(desc->family); font.desc.bold = desc->bold; font.desc.italic = desc->italic; font.desc.vertical = desc->vertical; font.scale_x = font.scale_y = 1.; font.v.x = font.v.y = 0; font.size = 0.; error = add_face(fontsel, &font, 0); if (error == -1) { free(font.desc.family); return 0; } else return ass_cache_put(font_cache, &font.desc, &font); }
/** * \brief Create a new ASS_Font according to "desc" argument */ ASS_Font *ass_font_new(Cache *font_cache, ASS_Library *library, FT_Library ftlibrary, ASS_FontSelector *fontsel, ASS_FontDesc *desc) { ASS_Font *font; if (ass_cache_get(font_cache, desc, &font)) { if (font->desc.family) return font; ass_cache_dec_ref(font); return NULL; } if (!font) return NULL; font->library = library; font->ftlibrary = ftlibrary; font->shaper_priv = NULL; font->n_faces = 0; ASS_FontDesc *new_desc = ass_cache_key(font); font->desc.family = new_desc->family; font->desc.bold = desc->bold; font->desc.italic = desc->italic; font->desc.vertical = desc->vertical; font->scale_x = font->scale_y = 1.; font->v.x = font->v.y = 0; font->size = 0.; int error = add_face(fontsel, font, 0); if (error == -1) { font->desc.family = NULL; ass_cache_commit(font, 1); ass_cache_dec_ref(font); return NULL; } ass_cache_commit(font, 1); return font; }