[vlc-commits] freetype: add missing attachment mime types

Francois Cartegnie git at videolan.org
Thu Jul 23 10:11:18 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jun 25 19:29:14 2020 +0200| [086eb444c5d2c14f4c01458f105dfaebe8fb9056] | committer: Francois Cartegnie

freetype: add missing attachment mime types

(cherry picked from commit d0a8a9fd606c75020ae268e7c04baf03d69341a0)

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

 modules/text_renderer/freetype/freetype.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/modules/text_renderer/freetype/freetype.c b/modules/text_renderer/freetype/freetype.c
index c5d3ff8036..314e5024b6 100644
--- a/modules/text_renderer/freetype/freetype.c
+++ b/modules/text_renderer/freetype/freetype.c
@@ -290,6 +290,27 @@ static FT_Vector GetAlignedOffset( const line_desc_t *p_line,
     return offsets;
 }
 
+static bool IsSupportedAttachment( const char *psz_mime )
+{
+    static const char * fontMimeTypes[] =
+    {
+        "application/x-truetype-font", // TTF
+        "application/x-font-otf",  // OTF
+        "application/font-sfnt",
+        "font/ttf",
+        "font/otf",
+        "font/sfnt",
+    };
+
+    for( size_t i=0; i<ARRAY_SIZE(fontMimeTypes); ++i )
+    {
+        if( !strcmp( psz_mime, fontMimeTypes[i] ) )
+            return true;
+    }
+
+    return false;
+}
+
 /*****************************************************************************
  * Make any TTF/OTF fonts present in the attachments of the media file
  * and store them for later use by the FreeType Engine
@@ -320,9 +341,8 @@ static int LoadFontsFromAttachments( filter_t *p_filter )
     {
         input_attachment_t *p_attach = pp_attachments[k];
 
-        if( ( !strcmp( p_attach->psz_mime, "application/x-truetype-font" ) || // TTF
-              !strcmp( p_attach->psz_mime, "application/x-font-otf" ) ) &&    // OTF
-            p_attach->i_data > 0 && p_attach->p_data )
+        if( p_attach->i_data > 0 && p_attach->p_data &&
+            IsSupportedAttachment( p_attach->psz_mime ) )
         {
             p_sys->pp_font_attachments[ p_sys->i_font_attachments++ ] = p_attach;
 



More information about the vlc-commits mailing list