/*****************************************************************************
* SSA/ASS subtitle decoder using libass.
*****************************************************************************
- * Copyright (C) 2008-2009 the VideoLAN team
+ * Copyright (C) 2008-2009 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
//#define DEBUG_REGION
-static void MessageCallback( int level, const char *fmt, va_list args, void *data )
-{
- decoder_t *p_dec = (decoder_t *)data;
-
- // translate verbosity level
- if( level > 6 )
- return;
- else if( level > 4 )
- level = VLC_MSG_DBG;
- else if( level > 1 )
- level = VLC_MSG_WARN;
- else
- level = VLC_MSG_ERR;
-
- msg_GenericVa( p_dec, level, MODULE_STRING, fmt, args );
-}
-
/*****************************************************************************
* Create: Open libass decoder.
*****************************************************************************/
return VLC_EGENERIC;
}
- /* Add message callback for logging */
- ass_set_message_cb( p_sys->p_library, MessageCallback, p_dec );
-
/* load attachments */
input_attachment_t **pp_attachments;
int i_attachments;
{
input_attachment_t *p_attach = pp_attachments[k];
+ bool found = false;
+
+ /* Check mimetype*/
if( !strcasecmp( p_attach->psz_mime, "application/x-truetype-font" ) )
+ found = true;
+ /* Then extension */
+ else if( !found && strlen( p_attach->psz_name ) > 4 )
+ {
+ char *ext = p_attach->psz_name + strlen( p_attach->psz_name ) - 4;
+
+ if( !strcasecmp( ext, ".ttf" ) || !strcasecmp( ext, ".otf" ) || !strcasecmp( ext, ".ttc" ) )
+ found = true;
+ }
+
+ if( found )
{
msg_Dbg( p_dec, "adding embedded font %s", p_attach->psz_name );
ass_set_font_scale( p_renderer, 1.0 );
ass_set_line_spacing( p_renderer, 0.0 );
+#if defined( __ANDROID__ )
+ const char *psz_font = "/system/fonts/DroidSans-Bold.ttf";
+ const char *psz_family = "Droid Sans Bold";
+#else
const char *psz_font = NULL; /* We don't ship a default font with VLC */
const char *psz_family = "Arial"; /* Use Arial if we can't find anything more suitable */
+#endif
#ifdef HAVE_FONTCONFIG
#if defined(WIN32)
_("Building font cache"),
_( "Please wait while your font cache is rebuilt.\n"
"This should take less than a minute." ), NULL );
- if( p_dialog )
- dialog_ProgressSet( p_dialog, NULL, 0.2 );
#endif
ass_set_fonts( p_renderer, psz_font, psz_family, true, NULL, 1 ); // setup default font/family
#ifdef WIN32