summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontselect.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@chown.ath.cx>2015-06-12 02:04:43 +0200
committerGrigori Goronzy <greg@chown.ath.cx>2015-07-10 10:42:41 +0200
commitef707a9e7d1934c433a55b9f7f4376ca6e7956d1 (patch)
treee00160bc1d8ed0007b54d15c204cd9734b263368 /libass/ass_fontselect.c
parentb39e873342825f9640580b8237cf19ecf247e261 (diff)
downloadlibass-ef707a9e7d1934c433a55b9f7f4376ca6e7956d1.tar.bz2
libass-ef707a9e7d1934c433a55b9f7f4376ca6e7956d1.tar.xz
fontselect: simplify lookup of embedded fonts
Currently, it is not safe to change the embedded fonts (ass_add_font/ass_clear_fonts) while an ASS_Renderer exists. We can simplify how embedded fonts are looked up because of that. At some point, ASS_Library and ASS_Renderer should be merged and we can then implement a more flexible approach.
Diffstat (limited to 'libass/ass_fontselect.c')
-rw-r--r--libass/ass_fontselect.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c
index 787e3a8..95a4038 100644
--- a/libass/ass_fontselect.c
+++ b/libass/ass_fontselect.c
@@ -110,7 +110,6 @@ typedef struct font_data_ft FontDataFT;
struct font_data_ft {
ASS_Library *lib;
FT_Face face;
- char *name;
int idx;
};
@@ -129,24 +128,9 @@ static void destroy_font_ft(void *data)
FontDataFT *fd = (FontDataFT *)data;
FT_Done_Face(fd->face);
- free(fd->name);
free(fd);
}
-/**
- * \brief find a memory font by name
- * \param library ASS library
- * \param name font name
- */
-static int find_font(ASS_Library *library, char *name)
-{
- int i;
- for (i = 0; i < library->num_fontdata; ++i)
- if (strcasecmp(name, library->fontdata[i].name) == 0)
- return i;
- return -1;
-}
-
static size_t
get_data_embedded(void *data, unsigned char *buf, size_t offset, size_t len)
{
@@ -154,9 +138,6 @@ get_data_embedded(void *data, unsigned char *buf, size_t offset, size_t len)
ASS_Fontdata *fd = ft->lib->fontdata;
int i = ft->idx;
- if (ft->idx < 0)
- ft->idx = i = find_font(ft->lib, ft->name);
-
if (buf == NULL)
return fd[i].size;
@@ -792,10 +773,9 @@ static void process_fontdata(ASS_FontProvider *priv, ASS_Library *library,
continue;
}
- ft->lib = library;
- ft->face = face;
- ft->name = strdup(name);
- ft->idx = -1;
+ ft->lib = library;
+ ft->face = face;
+ ft->idx = idx;
if (ass_font_provider_add_font(priv, &info, NULL, face_index,
NULL, ft)) {