]> git.sesse.net Git - vlc/blobdiff - modules/codec/libass.c
macosx: save 19 l10n strings by replacing them with already present strings from...
[vlc] / modules / codec / libass.c
index 829e1fe9e3e502af0f7979d78e7e241b50b73e1f..b32791c9781901ab12f1291a8e50993a1039dc6a 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * 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.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -120,23 +120,6 @@ static void RegionDraw( subpicture_region_t *p_region, ASS_Image *p_img );
 
 //#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.
  *****************************************************************************/
@@ -172,9 +155,6 @@ static int Create( vlc_object_t *p_this )
         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;
@@ -187,7 +167,21 @@ static int Create( vlc_object_t *p_this )
     {
         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 );
 
@@ -216,8 +210,13 @@ static int Create( vlc_object_t *p_this )
     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)
@@ -226,8 +225,6 @@ static int Create( vlc_object_t *p_this )
                                _("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