[vlc-commits] libass: match font attachments based on extension

Grigori Goronzy git at videolan.org
Mon Aug 22 15:14:11 CEST 2011


vlc | branch: master | Grigori Goronzy <greg at blackbox> | Mon Aug 22 01:40:54 2011 +0200| [ab9b56ca9562d8f73ef67e3264e500c1a5f2315f] | committer: Jean-Baptiste Kempf

libass: match font attachments based on extension

Sometimes fonts are muxed with the wrong MIME type, but we should
still be able to use them. Especially OpenType font collections are
affected by this. Match attachments by extensions .ttf, .otf and .ttc
in addition to MIME type to fix these issues.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ab9b56ca9562d8f73ef67e3264e500c1a5f2315f
---

 modules/codec/libass.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index 829e1fe..123da1f 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -187,7 +187,21 @@ static int Create( vlc_object_t *p_this )
     {
         input_attachment_t *p_attach = pp_attachments[k];
 
+        bool found = false;
+
+        /* Check mimetype*/
         if( !strcasecmp( p_attach->psz_mime, "application/x-truetype-font" ) )
+            found = true;
+        /* Then extension */
+        else if( !found && strlen( p_attach->psz_name ) > 4 )
+        {
+            char *ext = p_attach->psz_name + strlen( p_attach->psz_name ) - 4;
+
+            if( !strcasecmp( ext, ".ttf" ) || !strcasecmp( ext, ".otf" ) || !strcasecmp( ext, ".ttc" ) )
+                found = true;
+        }
+
+        if( found )
         {
             msg_Dbg( p_dec, "adding embedded font %s", p_attach->psz_name );
 



More information about the vlc-commits mailing list