[Android] libvlc: Add a freetype patch to fix subtitle files parsing

Hugo Beauzée-Luyssen git at videolan.org
Fri Dec 3 10:25:15 UTC 2021


vlc-android | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Dec  3 11:01:13 2021 +0100| [054116c5655ed8e5d6cb3742a27db8cabcdbd952] | committer: Hugo Beauzée-Luyssen

libvlc: Add a freetype patch to fix subtitle files parsing

refs #2252

> https://code.videolan.org/videolan/vlc-android/commit/054116c5655ed8e5d6cb3742a27db8cabcdbd952
---

 ...type-android-process-formatted-text-nodes.patch | 54 ++++++++++++++++++++++
 ...type-android-process-formatted-text-nodes.patch | 54 ++++++++++++++++++++++
 2 files changed, 108 insertions(+)

diff --git a/libvlc/patches/vlc3/0001-freetype-android-process-formatted-text-nodes.patch b/libvlc/patches/vlc3/0001-freetype-android-process-formatted-text-nodes.patch
new file mode 100644
index 000000000..f3da5ee37
--- /dev/null
+++ b/libvlc/patches/vlc3/0001-freetype-android-process-formatted-text-nodes.patch
@@ -0,0 +1,54 @@
+From c53d7f0295a1eba02a24794891ef2579e556793c Mon Sep 17 00:00:00 2001
+Message-Id: <c53d7f0295a1eba02a24794891ef2579e556793c.1638525624.git.hugo at beauzee.fr>
+From: Francois Cartegnie <fcvlcdev at free.fr>
+Date: Thu, 2 Dec 2021 10:06:28 +0100
+Subject: [PATCH] freetype: android: process formatted text nodes
+
+Trims filenames as they are not stored as attributes.
+
+Also removes incorrect asprintf 0 return value handling
+---
+ .../text_renderer/freetype/fonts/android.c    | 26 +++++++++++++++++--
+ 1 file changed, 24 insertions(+), 2 deletions(-)
+
+diff --git a/modules/text_renderer/freetype/fonts/android.c b/modules/text_renderer/freetype/fonts/android.c
+index 08e7007c48..ab77d5acf5 100644
+--- a/modules/text_renderer/freetype/fonts/android.c
++++ b/modules/text_renderer/freetype/fonts/android.c
+@@ -84,9 +84,31 @@ static int Android_ParseFont( filter_t *p_filter, xml_reader_t *p_xml,
+      * We don't need all font weights. Only 400 (regular) and 700 (bold)
+      */
+     if( i_weight == 400 || i_weight == 700 )
+-        if( asprintf( &psz_fontfile, "%s/%s", ANDROID_FONT_PATH, psz_val ) < 0
+-         || !NewFont( psz_fontfile, 0, b_bold, b_italic, p_family ) )
++    {
++        /* left trim */
++        while( *psz_val && *psz_val <= ' ' )
++            psz_val++;
++        /* right trim */
++        size_t len = strlen( psz_val );
++        if( len > 1 )
++        {
++            const char *psz_end = psz_val + len;
++            while( psz_end > psz_val + 1 && psz_end[-1] <= ' ' )
++                psz_end--;
++            len = psz_end - psz_val;
++        }
++
++        psz_fontfile = malloc( sizeof(ANDROID_FONT_PATH) + 1 + len );
++        if( !psz_fontfile )
+             return VLC_ENOMEM;
++        psz_fontfile[0] = '\0';
++        strcat( psz_fontfile, ANDROID_FONT_PATH );
++        strcat( psz_fontfile, "/" );
++        strncat( psz_fontfile, psz_val, len );
++
++        if( !NewFont( psz_fontfile, 0, b_bold, b_italic, p_family ) )
++            return VLC_ENOMEM;
++    }
+ 
+     return VLC_SUCCESS;
+ }
+-- 
+2.33.0
+
diff --git a/libvlc/patches/vlc4/0001-freetype-android-process-formatted-text-nodes.patch b/libvlc/patches/vlc4/0001-freetype-android-process-formatted-text-nodes.patch
new file mode 100644
index 000000000..9aa821a5c
--- /dev/null
+++ b/libvlc/patches/vlc4/0001-freetype-android-process-formatted-text-nodes.patch
@@ -0,0 +1,54 @@
+From 4218d5fca526010c8cfd412c55f53cc367e76bd5 Mon Sep 17 00:00:00 2001
+Message-Id: <4218d5fca526010c8cfd412c55f53cc367e76bd5.1638525655.git.hugo at beauzee.fr>
+From: Francois Cartegnie <fcvlcdev at free.fr>
+Date: Thu, 2 Dec 2021 10:06:28 +0100
+Subject: [PATCH] freetype: android: process formatted text nodes
+
+Trims filenames as they are not stored as attributes.
+
+Also removes incorrect asprintf 0 return value handling
+---
+ .../text_renderer/freetype/fonts/android.c    | 26 +++++++++++++++++--
+ 1 file changed, 24 insertions(+), 2 deletions(-)
+
+diff --git a/modules/text_renderer/freetype/fonts/android.c b/modules/text_renderer/freetype/fonts/android.c
+index 6712640d48..c395bb2626 100644
+--- a/modules/text_renderer/freetype/fonts/android.c
++++ b/modules/text_renderer/freetype/fonts/android.c
+@@ -84,9 +84,31 @@ static int Android_ParseFont( vlc_font_select_t *fs, xml_reader_t *p_xml,
+      * We don't need all font weights. Only 400 (regular) and 700 (bold)
+      */
+     if( i_weight == 400 || i_weight == 700 )
+-        if( asprintf( &psz_fontfile, "%s/%s", SYSTEM_FONT_PATH, psz_val ) < 0
+-         || !NewFont( psz_fontfile, 0, i_flags, p_family ) )
++    {
++        /* left trim */
++        psz_val += strspn( psz_val, " \t\r\n" );
++        /* right trim */
++        size_t len = strlen( psz_val );
++        const char *psz_end = psz_val + len;
++        while( psz_end > psz_val &&
++               ( psz_end[-1] == ' ' ||
++                 psz_end[-1] == '\t' ||
++                 psz_end[-1] == '\r' ||
++                 psz_end[-1] == '\n' ) )
++            psz_end--;
++        len = psz_end - psz_val;
++
++        psz_fontfile = malloc( sizeof(SYSTEM_FONT_PATH) + 1 + len );
++        if( !psz_fontfile )
++            return VLC_ENOMEM;
++        memcpy( psz_fontfile, SYSTEM_FONT_PATH, sizeof(SYSTEM_FONT_PATH) - 1 );
++        psz_fontfile[sizeof(SYSTEM_FONT_PATH) - 1] = '/';
++        memcpy( &psz_fontfile[sizeof(SYSTEM_FONT_PATH)], psz_val, len );
++        psz_fontfile[sizeof(SYSTEM_FONT_PATH) + len] = '\0';
++
++        if( !NewFont( psz_fontfile, 0, i_flags, p_family ) )
+             return VLC_ENOMEM;
++    }
+ 
+     return VLC_SUCCESS;
+ }
+-- 
+2.33.0
+



More information about the Android mailing list