diff options
-rw-r--r-- | libass/ass_font.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c index 6f55840..68e5fe4 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -133,9 +133,6 @@ static void set_font_metrics(FT_Face face) FT_Face ass_face_open(ASS_Library *lib, FT_Library ftlib, const char *path, const char *postscript_name, int index) { - if (index < 0 && !postscript_name) - return NULL; - FT_Face face; int error = FT_New_Face(ftlib, path, index, &face); if (error) { @@ -157,6 +154,17 @@ FT_Face ass_face_open(ASS_Library *lib, FT_Library ftlib, const char *path, return NULL; } + // If there is only one face, don't bother checking the name. + // The font might not even *have* a valid PostScript name. + if (!i && face->num_faces == 1) + return face; + + // Otherwise, we really need a name to search for. + if (!postscript_name) { + FT_Done_Face(face); + return NULL; + } + const char *face_psname = FT_Get_Postscript_Name(face); if (face_psname != NULL && strcmp(face_psname, postscript_name) == 0) |