mirror of https://github.com/mpv-player/mpv
get rid of -menu-utf8 and -menu-unicode once for all, patch by Guillaume Lecerf
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23355 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
29362964bb
commit
b0615f0024
|
@ -71,8 +71,6 @@ extern int WinID;
|
|||
#ifdef HAVE_MENU
|
||||
extern int menu_startup;
|
||||
extern int menu_keepdir;
|
||||
extern int menu_utf8;
|
||||
extern int menu_unicode;
|
||||
#ifdef USE_FRIBIDI
|
||||
extern char *menu_fribidi_charset;
|
||||
extern int menu_flip_hebrew;
|
||||
|
@ -300,8 +298,6 @@ m_option_t mplayer_opts[]={
|
|||
{"menu-cfg", &menu_cfg, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
|
||||
{"menu-startup", &menu_startup, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
|
||||
{"menu-keepdir", &menu_keepdir, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
|
||||
{"menu-utf8", &menu_utf8, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
{"menu-unicode", &menu_unicode, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
#ifdef USE_FRIBIDI
|
||||
{"menu-fribidi-charset", &menu_fribidi_charset, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
{"menu-flip-hebrew", &menu_flip_hebrew, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
|
|
|
@ -297,27 +297,10 @@ static inline int get_height(int c,int h){
|
|||
return h;
|
||||
}
|
||||
|
||||
int menu_utf8 = 0;
|
||||
int menu_unicode = 0;
|
||||
|
||||
static int get_next_char(char **txt)
|
||||
{
|
||||
int c;
|
||||
c = (unsigned char)*(*txt)++;
|
||||
if (c >= 0x80) {
|
||||
if (menu_utf8)
|
||||
c = utf8_get_char((const char**)txt);
|
||||
else if (menu_unicode)
|
||||
c = (c<<8) + (unsigned char)*(*txt)++;
|
||||
}
|
||||
if (!c) c++; // avoid UCS 0
|
||||
return c;
|
||||
}
|
||||
|
||||
static void render_txt(char *txt)
|
||||
{
|
||||
while (*txt) {
|
||||
int c = get_next_char(&txt);
|
||||
int c = utf8_get_char(&txt);
|
||||
render_one_glyph(vo_font, c);
|
||||
}
|
||||
}
|
||||
|
@ -345,11 +328,7 @@ static char *menu_fribidi(char *txt)
|
|||
if (char_set_num == -1) {
|
||||
fribidi_set_mirroring (1);
|
||||
fribidi_set_reorder_nsm (0);
|
||||
if (menu_utf8 == 0) {
|
||||
char_set_num = fribidi_parse_charset(menu_fribidi_charset ? menu_fribidi_charset : "ISO8859-8");
|
||||
} else {
|
||||
char_set_num = fribidi_parse_charset("UTF-8");
|
||||
}
|
||||
char_set_num = fribidi_parse_charset("UTF-8");
|
||||
buffer_size = FFMAX(1024,len+1);
|
||||
logical = malloc(buffer_size);
|
||||
visual = malloc(buffer_size);
|
||||
|
@ -388,7 +367,7 @@ void menu_draw_text(mp_image_t* mpi,char* txt, int x, int y) {
|
|||
render_txt(txt);
|
||||
|
||||
while (*txt) {
|
||||
int c=get_next_char(&txt);
|
||||
int c=utf8_get_char(&txt);
|
||||
if ((font=vo_font->font[c])>=0 && (x + vo_font->width[c] <= mpi->w) && (y + vo_font->pic_a[font]->h <= mpi->h))
|
||||
draw_alpha(vo_font->width[c], vo_font->pic_a[font]->h,
|
||||
vo_font->pic_b[font]->bmp+vo_font->start[c],
|
||||
|
@ -481,7 +460,7 @@ void menu_draw_text_full(mp_image_t* mpi,char* txt,
|
|||
|
||||
// Jump some the beginnig text if needed
|
||||
while(sy < ymin && *txt) {
|
||||
int c=get_next_char(&txt);
|
||||
int c=utf8_get_char(&txt);
|
||||
if(c == '\n' || (warp && ll + vo_font->width[c] > w)) {
|
||||
ll = 0;
|
||||
sy += vo_font->height + vspace;
|
||||
|
@ -555,7 +534,7 @@ void menu_draw_text_full(mp_image_t* mpi,char* txt,
|
|||
}
|
||||
|
||||
while(sx < xmax && txt != line_end) {
|
||||
int c=get_next_char(&txt);
|
||||
int c=utf8_get_char(&txt);
|
||||
font = vo_font->font[c];
|
||||
if(font >= 0) {
|
||||
int cs = (vo_font->pic_a[font]->h - vo_font->height) / 2;
|
||||
|
@ -583,7 +562,7 @@ int menu_text_length(char* txt) {
|
|||
int l = 0;
|
||||
render_txt(txt);
|
||||
while (*txt) {
|
||||
int c=get_next_char(&txt);
|
||||
int c=utf8_get_char(&txt);
|
||||
l += vo_font->width[c]+vo_font->charspace;
|
||||
}
|
||||
return l - vo_font->charspace;
|
||||
|
@ -595,7 +574,7 @@ void menu_text_size(char* txt,int max_width, int vspace, int warp, int* _w, int*
|
|||
|
||||
render_txt(txt);
|
||||
while (*txt) {
|
||||
int c=get_next_char(&txt);
|
||||
int c=utf8_get_char(&txt);
|
||||
if(c == '\n' || (warp && i + vo_font->width[c] >= max_width)) {
|
||||
if(*txt)
|
||||
l++;
|
||||
|
@ -615,7 +594,7 @@ int menu_text_num_lines(char* txt, int max_width) {
|
|||
int l = 1, i = 0;
|
||||
render_txt(txt);
|
||||
while (*txt) {
|
||||
int c=get_next_char(&txt);
|
||||
int c=utf8_get_char(&txt);
|
||||
if(c == '\n' || i + vo_font->width[c] > max_width) {
|
||||
l++;
|
||||
i = 0;
|
||||
|
@ -630,7 +609,7 @@ char* menu_text_get_next_line(char* txt, int max_width) {
|
|||
int i = 0;
|
||||
render_txt(txt);
|
||||
while (*txt) {
|
||||
int c=get_next_char(&txt);
|
||||
int c=utf8_get_char(&txt);
|
||||
if(c == '\n') {
|
||||
txt++;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue