1 --- libass-0.13.4/libass/ass_fontselect.c.orig 2016-07-11 23:29:00.000000000 +0200
2 +++ libass-0.13.4/libass/ass_fontselect.c 2016-10-11 11:14:24.387661958 +0200
5 #include "ass_string.h"
10 #define ABS(x) ((x) < 0 ? -(x) : (x))
11 #define MAX_FULLNAME 100
14 .destroy_font = destroy_font_ft,
18 +static inline char *FromWide (const wchar_t *wide)
20 + size_t len = WideCharToMultiByte (CP_UTF8, 0, wide, -1, NULL, 0, NULL, NULL);
24 + char *out = (char *)malloc (len);
27 + WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
31 +static inline wchar_t *ToWide (const char *utf8)
33 + int len = MultiByteToWideChar (CP_UTF8, 0, utf8, -1, NULL, 0);
37 + wchar_t *out = (wchar_t *)malloc (len * sizeof (wchar_t));
40 + MultiByteToWideChar (CP_UTF8, 0, utf8, -1, out, len);
45 static void load_fonts_from_dir(ASS_Library *library, const char *dir)
47 - DIR *d = opendir(dir);
48 + wchar_t *dirw = ToWide(dir);
49 + _TDIR *d = _topendir(dirw);
54 - struct dirent *entry = readdir(d);
55 + struct _tdirent *entry = _treaddir(d);
58 + char* d_name = FromWide(entry->d_name);
59 if (entry->d_name[0] == '.')
65 - snprintf(fullname, sizeof(fullname), "%s/%s", dir, entry->d_name);
66 + _snprintf(fullname, sizeof(fullname), "%s/%s", dir, d_name);
68 ass_msg(library, MSGL_INFO, "Loading font file '%s'", fullname);
69 void *data = read_file(library, fullname, &bufsize);
71 - ass_add_font(library, entry->d_name, data, bufsize);
72 + ass_add_font(library, d_name, data, bufsize);