diff --git a/include/vlc_text_style.h b/include/vlc_text_style.h index 6d9280e781..dcb38e8756 100644 --- a/include/vlc_text_style.h +++ b/include/vlc_text_style.h @@ -139,6 +139,16 @@ VLC_API void text_style_Delete( text_style_t * ); */ VLC_API text_segment_t *text_segment_New( const char * ); +/** + * This function will create a new text segment and duplicates the style passed as argument + * + * You should use text_segment_ChainDelete to destroy it, to clean all + * the linked segments, or text_segment_Delete to free a specic one + * + * This doesn't initialize the text. + */ +VLC_API text_segment_t *text_segment_NewInheritStyle( const text_style_t* p_style ); + /** * Delete a text segment and its content. * diff --git a/src/libvlccore.sym b/src/libvlccore.sym index 3749a5bd45..d62d9ac32b 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -419,6 +419,7 @@ subpicture_region_Copy subpicture_region_Delete subpicture_region_New text_segment_New +text_segment_NewInheritStyle text_segment_Delete text_segment_ChainDelete text_segment_Copy diff --git a/src/misc/text_style.c b/src/misc/text_style.c index 8e7e8a2950..2241938397 100644 --- a/src/misc/text_style.c +++ b/src/misc/text_style.c @@ -105,6 +105,22 @@ text_segment_t *text_segment_New( const char *psz_text ) return segment; } +text_segment_t *text_segment_NewInheritStyle( const text_style_t* p_style ) +{ + if ( !p_style ) + return NULL; //FIXME: Allow this, even if it is an alias to text_segment_New( NULL ) ? + text_segment_t* p_segment = text_segment_New( NULL ); + if ( unlikely( !p_segment ) ) + return NULL; + p_segment->style = text_style_Duplicate( p_style ); + if ( unlikely( !p_segment->style ) ) + { + text_segment_Delete( p_segment ); + return NULL; + } + return p_segment; +} + void text_segment_Delete( text_segment_t* segment ) { if ( segment != NULL )