comparison 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
comparison
equal deleted inserted replaced
36601:63661fc7b53b 36602:5964549c821f
793 return -1; 793 return -1;
794 } 794 }
795 795
796 return charset_size; 796 return charset_size;
797 } 797 }
798 #endif
798 799
799 static int prepare_charset_unicode(FT_Face face, FT_ULong *charset, FT_ULong *charcodes) { 800 static int prepare_charset_unicode(FT_Face face, FT_ULong *charset, FT_ULong *charcodes) {
800 #ifdef HAVE_FREETYPE21 801 #ifdef HAVE_FREETYPE21
801 FT_ULong charcode; 802 FT_ULong charcode;
802 #else 803 #else
834 #endif 835 #endif
835 mp_msg(MSGT_OSD, MSGL_V, "Unicode font: %d glyphs.\n", i); 836 mp_msg(MSGT_OSD, MSGL_V, "Unicode font: %d glyphs.\n", i);
836 837
837 return i; 838 return i;
838 } 839 }
839 #endif
840 840
841 static font_desc_t* init_font_desc(void) 841 static font_desc_t* init_font_desc(void)
842 { 842 {
843 font_desc_t *desc = calloc(1, sizeof(*desc)); 843 font_desc_t *desc = calloc(1, sizeof(*desc));
844 if(!desc) return NULL; 844 if(!desc) return NULL;
946 FT_Face face; 946 FT_Face face;
947 947
948 FT_ULong *my_charset = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* characters we want to render; Unicode */ 948 FT_ULong *my_charset = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* characters we want to render; Unicode */
949 FT_ULong *my_charcodes = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* character codes in 'encoding' */ 949 FT_ULong *my_charcodes = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* character codes in 'encoding' */
950 950
951 char *charmap = "ucs-4";
952 int err; 951 int err;
953 int charset_size; 952 int charset_size = -1;
954 int i, j; 953 int i, j;
955 int unicode; 954 int unicode;
956 955
957 float movie_size; 956 float movie_size;
958 957
1001 mp_msg(MSGT_OSD, MSGL_WARN, MSGTR_LIBVO_FONT_LOAD_FT_SubFaceFailed); 1000 mp_msg(MSGT_OSD, MSGL_WARN, MSGTR_LIBVO_FONT_LOAD_FT_SubFaceFailed);
1002 goto gen_osd; 1001 goto gen_osd;
1003 } 1002 }
1004 desc->face_cnt++; 1003 desc->face_cnt++;
1005 1004
1006 #ifdef CONFIG_ICONV
1007 if (unicode) 1005 if (unicode)
1008 charset_size = prepare_charset_unicode(face, my_charset, my_charcodes); 1006 charset_size = prepare_charset_unicode(face, my_charset, my_charcodes);
1007 #ifdef CONFIG_ICONV
1009 else 1008 else
1010 charset_size = prepare_charset(charmap, subtitle_font_encoding, my_charset, my_charcodes); 1009 charset_size = prepare_charset("ucs-4", subtitle_font_encoding, my_charset, my_charcodes);
1010 #endif
1011 1011
1012 if (charset_size < 0) { 1012 if (charset_size < 0) {
1013 mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_SubFontCharsetFailed); 1013 mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_SubFontCharsetFailed);
1014 goto err_out; 1014 goto err_out;
1015 } 1015 }
1016 #else
1017 goto err_out;
1018 #endif
1019 1016
1020 // fprintf(stderr, "fg: prepare t = %f\n", GetTimer()-t); 1017 // fprintf(stderr, "fg: prepare t = %f\n", GetTimer()-t);
1021 1018
1022 err = prepare_font(desc, face, subtitle_font_ppem, desc->face_cnt-1, 1019 err = prepare_font(desc, face, subtitle_font_ppem, desc->face_cnt-1,
1023 charset_size, my_charset, my_charcodes, unicode, 1020 charset_size, my_charset, my_charcodes, unicode,