summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
Diffstat (limited to 'libass')
-rw-r--r--libass/ass.c20
-rw-r--r--libass/ass_cache.c2
-rw-r--r--libass/ass_fontconfig.c52
3 files changed, 44 insertions, 30 deletions
diff --git a/libass/ass.c b/libass/ass.c
index 5c750d6852..55a4a79b7f 100644
--- a/libass/ass.c
+++ b/libass/ass.c
@@ -163,7 +163,7 @@ static void rskip_spaces(char** str, char* limit) {
static int lookup_style(ass_track_t* track, char* name) {
int i;
if (*name == '*') ++name; // FIXME: what does '*' really mean ?
- for (i=0; i<track->n_styles; ++i) {
+ for (i = track->n_styles - 1; i >= 0; --i) {
// FIXME: mb strcasecmp ?
if (strcmp(track->styles[i].Name, name) == 0)
return i;
@@ -846,16 +846,22 @@ static char* sub_recode(char* data, size_t size, char* codepage)
char* ip;
char* op;
size_t rc;
+ int clear = 0;
- outbuf = malloc(size);
+ outbuf = malloc(osize);
ip = data;
op = outbuf;
- while (ileft) {
- rc = iconv(icdsc, &ip, &ileft, &op, &oleft);
+ while (1) {
+ if (ileft)
+ rc = iconv(icdsc, &ip, &ileft, &op, &oleft);
+ else {// clear the conversion state and leave
+ clear = 1;
+ rc = iconv(icdsc, NULL, NULL, &op, &oleft);
+ }
if (rc == (size_t)(-1)) {
if (errno == E2BIG) {
- int offset = op - outbuf;
+ size_t offset = op - outbuf;
outbuf = (char*)realloc(outbuf, osize + size);
op = outbuf + offset;
osize += size;
@@ -864,7 +870,9 @@ static char* sub_recode(char* data, size_t size, char* codepage)
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorRecodingFile);
return NULL;
}
- }
+ } else
+ if (clear)
+ break;
}
outbuf[osize - oleft - 1] = 0;
}
diff --git a/libass/ass_cache.c b/libass/ass_cache.c
index 1269d04409..41645c4a48 100644
--- a/libass/ass_cache.c
+++ b/libass/ass_cache.c
@@ -86,7 +86,7 @@ static unsigned hashmap_hash(void* buf, size_t len)
static int hashmap_key_compare(void* a, void* b, size_t size)
{
- return (memcmp(a, b, size) == 0);
+ return memcmp(a, b, size) == 0;
}
static void hashmap_item_dtor(void* key, size_t key_size, void* value, size_t value_size)
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c
index b66dad7e60..ccbb47086f 100644
--- a/libass/ass_fontconfig.c
+++ b/libass/ass_fontconfig.c
@@ -150,11 +150,13 @@ static char* _select_font(fc_instance_t* priv, const char* family, unsigned bold
if (curf >= fset->nfont)
goto error;
+#if (FC_VERSION >= 20297)
// Remove all extra family names from original pattern.
// After this, FcFontRenderPrepare will select the most relevant family
// name in case there are more than one of them.
for (; family_cnt > 1; --family_cnt)
FcPatternRemove(pat, FC_FAMILY, family_cnt - 1);
+#endif
rpat = FcFontRenderPrepare(priv->config, pat, fset->fonts[curf]);
if (!rpat)
@@ -349,35 +351,39 @@ static void process_fontdata(fc_instance_t* priv, ass_library_t* library, FT_Lib
FcPattern* pattern;
FcFontSet* fset;
FcBool res;
+ int face_index, num_faces = 1;
- rc = FT_New_Memory_Face(ftlibrary, (unsigned char*)data, data_size, 0, &face);
- if (rc) {
- mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningMemoryFont, name);
- return;
- }
+ for (face_index = 0; face_index < num_faces; ++face_index) {
+ rc = FT_New_Memory_Face(ftlibrary, (unsigned char*)data, data_size, face_index, &face);
+ if (rc) {
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningMemoryFont, name);
+ return;
+ }
+ num_faces = face->num_faces;
- pattern = FcFreeTypeQueryFace(face, (unsigned char*)name, 0, FcConfigGetBlanks(priv->config));
- if (!pattern) {
- mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcFreeTypeQueryFace");
- FT_Done_Face(face);
- return;
- }
+ pattern = FcFreeTypeQueryFace(face, (unsigned char*)name, 0, FcConfigGetBlanks(priv->config));
+ if (!pattern) {
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcFreeTypeQueryFace");
+ FT_Done_Face(face);
+ return;
+ }
- fset = FcConfigGetFonts(priv->config, FcSetSystem); // somehow it failes when asked for FcSetApplication
- if (!fset) {
- mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcConfigGetFonts");
- FT_Done_Face(face);
- return;
- }
+ fset = FcConfigGetFonts(priv->config, FcSetSystem); // somehow it failes when asked for FcSetApplication
+ if (!fset) {
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcConfigGetFonts");
+ FT_Done_Face(face);
+ return;
+ }
+
+ res = FcFontSetAdd(fset, pattern);
+ if (!res) {
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcFontSetAdd");
+ FT_Done_Face(face);
+ return;
+ }
- res = FcFontSetAdd(fset, pattern);
- if (!res) {
- mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcFontSetAdd");
FT_Done_Face(face);
- return;
}
-
- FT_Done_Face(face);
#endif
}