From d1546c2e83159d97d48310a54a6b501de4109b89 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Tue, 5 Aug 2008 01:57:23 +0200 Subject: [PATCH] libass: move attachments processing before the ass_set_fonts_dir() option which enables those fonts. Set a fonts_dir for OSX. We might wanna fix that later on. --- modules/codec/libass.c | 56 +++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/modules/codec/libass.c b/modules/codec/libass.c index ddd871eeaf..b1bf84f6ee 100644 --- a/modules/codec/libass.c +++ b/modules/codec/libass.c @@ -149,31 +149,6 @@ static int Create( vlc_object_t *p_this ) vlc_mutex_init( &p_sys->lock ); p_sys->i_refcount = 1; - /* load attachments */ - input_attachment_t **pp_attachments; - int i_attachments; - - if( decoder_GetInputAttachments( p_dec, &pp_attachments, &i_attachments )) - { - i_attachments = 0; - pp_attachments = NULL; - } - for( int k = 0; k < i_attachments; k++ ) - { - input_attachment_t *p_attach = pp_attachments[k]; - - if( !strcasecmp( p_attach->psz_mime, "application/x-truetype-font" ) ) - { - msg_Dbg( p_dec, "adding embedded font %s\n", p_attach->psz_name ); - - vlc_mutex_lock( p_sys->p_ass->p_lock ); - ass_add_font( p_sys->p_ass->p_library, p_attach->psz_name, p_attach->p_data, p_attach->i_data ); - vlc_mutex_unlock( p_sys->p_ass->p_lock ); - } - vlc_input_attachment_Delete( p_attach ); - } - free( pp_attachments ); - /* Add a track */ vlc_mutex_lock( p_sys->p_ass->p_lock ); p_sys->p_track = p_track = ass_new_track( p_sys->p_ass->p_library ); @@ -706,7 +681,38 @@ static ass_handle_t *AssHandleYield( decoder_t *p_dec ) if( !p_library ) goto error; + /* load attachments */ + input_attachment_t **pp_attachments; + int i_attachments; + + if( decoder_GetInputAttachments( p_dec, &pp_attachments, &i_attachments )) + { + i_attachments = 0; + pp_attachments = NULL; + } + for( int k = 0; k < i_attachments; k++ ) + { + input_attachment_t *p_attach = pp_attachments[k]; + + if( !strcasecmp( p_attach->psz_mime, "application/x-truetype-font" ) ) + { + msg_Dbg( p_dec, "adding embedded font %s\n", p_attach->psz_name ); + + ass_add_font( p_ass->p_library, p_attach->psz_name, p_attach->p_data, p_attach->i_data ); + } + vlc_input_attachment_Delete( p_attach ); + } + free( pp_attachments ); + +#ifdef __APPLE__ + char * psz_font_dir; + if( asprintf( &psz_font_dir, "%s/Library/Fonts", config_GetHomeDir() ) != -1 ) { + ass_set_fonts_dir( p_library, psz_font_dir ); + free( psz_font_dir ); + } +#else ass_set_fonts_dir( p_library, "/usr/share/fonts" ); // FIXME +#endif ass_set_extract_fonts( p_library, true ); ass_set_style_overrides( p_library, NULL ); -- 2.39.5