[BUG] [FIX?] wrong osd_show_text behaviour
Hi The current osd_show_text behaviour seems wrong: o The text is positioned strangely (too much on the right) o The last 2 char's are cut I traced the problem down to mplayer.c: MP_CMD_OSD_SHOW_TEXT uses set_osd_msg(OSD_MSG_TEXT,1,osd_duration,"%64s",cmd->args[0].v.s); so the text is saved as a "right alligned char[65]" iirc (or not?). In void set_osd_msg(int id, int level, int time, char* fmt, ...): ... va_start(va,fmt); vsnprintf(msg->msg, 63, fmt, va); va_end(va); So this would explain the 2 char cut. Iirc the fmt takes the "visual" size whereis vsnprintf takes the real length (usually +1), so this should be 65 instead of 63. Or even better: 64 and %63s in set_osd_msg, as the osd message string was declared as char[64] iirc. Anyway, I'm still not happy: To me it seems that this was introduced to right allign the text to a fixed size of 64, but once the text is rendered the char's won't have equal width, so will this work at all? Besides the text would need to be shown right alligned in the sub.c code, not left alligned as it seems to be done in sub.c: initial position x=20 (that doesn't make any sense to me, to right allign a string and then left allign the rendered one). The allignment should be done in the sub.c code only anyway and not by adding spaces to the initial string. So I vote for this change: -set_osd_msg(OSD_MSG_TEXT,1,osd_duration,"%64s",cmd->args[0].v.s); +set_osd_msg(OSD_MSG_TEXT,1,osd_duration,"%s",cmd->args[0].v.s); -vsnprintf(msg->msg, 63, fmt, va); +vsnprintf(msg->msg, 64, fmt, va); (I'm still not 100% sure if this should be 63, 64 or 65 here and what to do with trailing \0, etc ... ;) Maybe there are still problems with this solution, but at least change the ugly solution to a "working" (not bugged) solution. With Best Regards Jonas Jermann
On Thu, 23 Mar 2006 14:05:17 +0100 Jonas Jermann <jjermann@gmx.net> wrote:
Hi
The current osd_show_text behaviour seems wrong:
Thanks for the nice report, cvs is fixed now. Albeu
participants (2)
-
Alban Bedel -
Jonas Jermann