diff sub/font_load_ft.c @ 36602:5964549c821f

Fix handling of option 'subfont-encoding'. prepare_charset_unicode() is supposed to work without iconv which it does indeed. So, move the function definition out of the '#ifdef CONFIG_ICONV' block. As a result, charset_size can be uninitialized and charmap may be unused. Fix them both.
author ib
date Wed, 22 Jan 2014 19:26:30 +0000
parents 63661fc7b53b
children 19e0fc815a0e
line wrap: on
line diff
--- a/sub/font_load_ft.c	Wed Jan 22 19:22:08 2014 +0000
+++ b/sub/font_load_ft.c	Wed Jan 22 19:26:30 2014 +0000
@@ -795,6 +795,7 @@
 
     return charset_size;
 }
+#endif
 
 static int prepare_charset_unicode(FT_Face face, FT_ULong *charset, FT_ULong *charcodes) {
 #ifdef HAVE_FREETYPE21
@@ -836,7 +837,6 @@
 
     return i;
 }
-#endif
 
 static font_desc_t* init_font_desc(void)
 {
@@ -948,9 +948,8 @@
     FT_ULong *my_charset = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* characters we want to render; Unicode */
     FT_ULong *my_charcodes = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* character codes in 'encoding' */
 
-    char *charmap = "ucs-4";
     int err;
-    int charset_size;
+    int charset_size = -1;
     int i, j;
     int unicode;
 
@@ -1003,19 +1002,17 @@
     }
     desc->face_cnt++;
 
-#ifdef CONFIG_ICONV
     if (unicode)
 	charset_size = prepare_charset_unicode(face, my_charset, my_charcodes);
+#ifdef CONFIG_ICONV
     else
-	charset_size = prepare_charset(charmap, subtitle_font_encoding, my_charset, my_charcodes);
+	charset_size = prepare_charset("ucs-4", subtitle_font_encoding, my_charset, my_charcodes);
+#endif
 
     if (charset_size < 0) {
 	mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_SubFontCharsetFailed);
 	goto err_out;
     }
-#else
-    goto err_out;
-#endif
 
 //    fprintf(stderr, "fg: prepare t = %f\n", GetTimer()-t);