summaryrefslogtreecommitdiffstats
path: root/libass/ass_font.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@chown.ath.cx>2011-08-20 17:46:03 +0200
committerGrigori Goronzy <greg@chown.ath.cx>2015-07-10 10:42:40 +0200
commitf69ec6e0c038fe32cc5f91cc62cba52fe3934885 (patch)
tree9cc33785a996b0fe334db78941f218fef7991d77 /libass/ass_font.c
parentdef7a0c702ad1e1ecb03045acd785bd16e8a71f1 (diff)
downloadlibass-f69ec6e0c038fe32cc5f91cc62cba52fe3934885.tar.bz2
libass-f69ec6e0c038fe32cc5f91cc62cba52fe3934885.tar.xz
Memory font support
Allow memory fonts with the get_face_data callback. This feature is used for embedded fonts, but can be used by any font provider.
Diffstat (limited to 'libass/ass_font.c')
-rw-r--r--libass/ass_font.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c
index a6d1b5b..ce42781 100644
--- a/libass/ass_font.c
+++ b/libass/ass_font.c
@@ -92,18 +92,6 @@ uint32_t ass_font_index_magic(FT_Face face, uint32_t symbol)
}
}
-/**
- * \brief find a memory font by 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 void buggy_font_workaround(FT_Face face)
{
// Some fonts have zero Ascender/Descender fields in 'hhea' table.
@@ -130,14 +118,15 @@ static void buggy_font_workaround(FT_Face face)
static int add_face(ASS_FontSelector *fontsel, ASS_Font *font, uint32_t ch)
{
char *path;
- int i, index, uid;
- int error, mem_idx;
+ int i, index, uid, error;
+ ASS_Buffer mem_font = { NULL, 0 };
FT_Face face;
if (font->n_faces == ASS_FONT_MAX_FACES)
return -1;
- path = ass_font_select(fontsel, font->library, font , &index, &uid, ch);
+ path = ass_font_select(fontsel, font->library, font , &index, &uid,
+ &mem_font, ch);
if (!path)
return -1;
@@ -151,14 +140,9 @@ static int add_face(ASS_FontSelector *fontsel, ASS_Font *font, uint32_t ch)
}
}
- mem_idx = find_font(font->library, path);
- if (mem_idx >= 0) {
- error =
- FT_New_Memory_Face(font->ftlibrary,
- (unsigned char *) font->library->
- fontdata[mem_idx].data,
- font->library->fontdata[mem_idx].size, index,
- &face);
+ if (mem_font.buf) {
+ error = FT_New_Memory_Face(font->ftlibrary, mem_font.buf, mem_font.len,
+ index, &face);
if (error) {
ass_msg(font->library, MSGL_WARN,
"Error opening memory font: '%s'", path);
@@ -174,6 +158,7 @@ static int add_face(ASS_FontSelector *fontsel, ASS_Font *font, uint32_t ch)
return -1;
}
}
+
charmap_magic(font->library, face);
buggy_font_workaround(face);