summaryrefslogtreecommitdiffstats
path: root/mpcommon.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2010-06-01 22:49:22 +0200
committerGrigori Goronzy <greg@blackbox>2010-06-01 23:15:41 +0200
commitb784346e789814362e196e513a8988cd02d96bac (patch)
treee9d9665f9bf5c26d3b04ec52b73e5b89a25324d9 /mpcommon.c
parent2fcd4cf73e1a06119e5c3284abe05942967ce3ad (diff)
downloadmpv-b784346e789814362e196e513a8988cd02d96bac.tar.bz2
mpv-b784346e789814362e196e513a8988cd02d96bac.tar.xz
libass: match font attachments based on extension
Instead of only relying on the MIME type, use the file extension as a fallback for deciding which attachments are fonts and should be fed to libass. This also refactors the check into a separate function in mpcommon.
Diffstat (limited to 'mpcommon.c')
-rw-r--r--mpcommon.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/mpcommon.c b/mpcommon.c
index 61d61c743c..5756b8ad6a 100644
--- a/mpcommon.c
+++ b/mpcommon.c
@@ -297,6 +297,24 @@ int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang)
return demuxer->audio->id;
}
+bool attachment_is_font(struct demux_attachment *att)
+{
+ if (!att->name || !att->type || !att->data || !att->data_size)
+ return false;
+ // match against MIME types
+ if (strcmp(att->type, "application/x-truetype-font") == 0
+ || strcmp(att->type, "application/x-font") == 0)
+ return true;
+ // fallback: match against file extension
+ if (strlen(att->name) > 4) {
+ char *ext = att->name + strlen(att->name) - 4;
+ if (strcasecmp(ext, ".ttf") == 0 || strcasecmp(ext, ".ttc") == 0
+ || strcasecmp(ext, ".otf") == 0)
+ return true;
+ }
+ return false;
+}
+
/* Parse -noconfig common to both programs */
int disable_system_conf=0;
int disable_user_conf=0;