changeset 36679:36cbede21428

Fix bug with unicode font loading for font.desc files. Unicode glyphs might not get loaded even if they are requested and available. Fix it by checking the font encoding rather than the subtitle encoding when loading the font.
author ib
date Sat, 01 Feb 2014 16:57:50 +0000
parents 61a9df2e25d0
children cc70b0fb8d36
files sub/font_load.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sub/font_load.c	Sat Feb 01 15:13:00 2014 +0000
+++ b/sub/font_load.c	Sat Feb 01 16:57:50 2014 +0000
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -75,6 +76,7 @@
 int chardb=0;
 int fontdb=-1;
 int first=1;
+int unicode;
 
 font_desc_t *desc=calloc(1, sizeof(*desc));
 if(!desc) goto fail_out;
@@ -103,6 +105,8 @@
 
 section[0]=0;
 
+unicode = !subtitle_font_encoding || strcasecmp(subtitle_font_encoding, "unicode") == 0;
+
 while(fgets(sor,1020,f)){
   unsigned char* p[8];
   int pdb=0;
@@ -255,7 +259,7 @@
           int chr=p[0][0];
           int start=atoi(p[1]);
           int end=atoi(p[2]);
-          if(sub_unicode && (chr>=0x80)) chr=(chr<<8)+p[0][1];
+          if(unicode && (chr>=0x80)) chr=(chr<<8)+p[0][1];
           else if(strlen(p[0])!=1) chr=strtol(p[0],NULL,0);
           if(end<start) {
               mp_msg(MSGT_OSD, MSGL_WARN, "error in font desc: end<start for char '%c'\n",chr);