summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-29 13:45:41 +0100
committerwm4 <wm4@nowhere>2013-12-29 14:19:22 +0100
commit6878cf283292fe5962ed3ff53fc25ae16de8a8fc (patch)
treee5b26e23f2d93f01a7fdc8aacdd7aa5245fb95e7
parentfc583e74ec538b250ce371f06baf159c6e4b70c3 (diff)
downloadmpv-6878cf283292fe5962ed3ff53fc25ae16de8a8fc.tar.bz2
mpv-6878cf283292fe5962ed3ff53fc25ae16de8a8fc.tar.xz
player: use arrays to list font mimetypes and font file extensions
-rw-r--r--player/loadfile.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 64db70687b..f527cb852d 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -843,20 +843,26 @@ static void open_subtitles_from_resolve(struct MPContext *mpctx)
}
}
+static const char *font_mimetypes[] = {
+ "application/x-truetype-font",
+ "application/x-font",
+ NULL
+};
+
+static const char *font_exts[] = {".ttf", ".ttc", ".otf", NULL};
+
static bool attachment_is_font(struct mp_log *log, 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;
+ for (int n = 0; font_mimetypes[n]; n++) {
+ if (strcmp(font_mimetypes[n], att->type) == 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)
- {
+ char *ext = strlen(att->name) > 4 ? att->name + strlen(att->name) - 4 : "";
+ for (int n = 0; font_exts[n]; n++) {
+ if (strcasecmp(ext, font_exts[n]) == 0) {
mp_warn(log, "Loading font attachment '%s' with MIME type %s. "
"Assuming this is a broken Matroska file, which was "
"muxed without setting a correct font MIME type.\n",