Skip to content
Snippets Groups Projects
Commit 63c36318 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Nicolas Pomepuy
Browse files

libvlc: Add a freetype patch to fix subtitle files parsing

refs #2252


(cherry picked from commit 054116c5)
parent 5b243733
No related branches found
No related tags found
1 merge request!1508Fix the video information legend attribute and crash
From c53d7f0295a1eba02a24794891ef2579e556793c Mon Sep 17 00:00:00 2001
Message-Id: <c53d7f0295a1eba02a24794891ef2579e556793c.1638525624.git.hugo@beauzee.fr>
From: Francois Cartegnie <fcvlcdev@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
From 4218d5fca526010c8cfd412c55f53cc367e76bd5 Mon Sep 17 00:00:00 2001
Message-Id: <4218d5fca526010c8cfd412c55f53cc367e76bd5.1638525655.git.hugo@beauzee.fr>
From: Francois Cartegnie <fcvlcdev@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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment