On Wed, Jun 13, 2007 at 04:28:16PM -0500, Ben Combee wrote:
> On 6/13/07, M. Dietrich <[EMAIL PROTECTED]> wrote:
> >i encounter a strange effect with GetStringBreak. it cuts the string
> >nicely at blank-delimiters to fit the width but words that are too
> >long are not split. instead ret_next_line is the same as before and
> >ret_str_length is a smaller value than expected (more chars could be
> >put on that line - blanks ignored).
> >
> >is this correct behavior? or a bug? how should a program react here?
>
> This sounds like a bug to me. Looking at the code, there's no check
> to see if the word is the only word on a line
>
i found two other problems with GetStringBreak:
- GetStringBreak returns number of chars while DrawString expects
number of bytes. because it works on utf8 this may be different.
- the last line is cut by one char.
here is my sample code:
const char* p = "u-umlaut \xc3\xbc bla this is a short test text to
show... and a veryveryveryveryveryverylongword bla bla";
while (p != NULL && *p != '\0')
{
int ret_width = 0;
int ret_str_length = 0;
const char* ret_next_line = NULL;
DFBCHECK(font->GetStringBreak(font, p, -1, 100, &ret_width,
&ret_str_length, &ret_next_line));
printf("'%.*s' %d '%s'\n", ret_str_length, p, ret_str_length,
ret_next_line);
p = ret_next_line;
}
i put those lines directly after GetStringBreak and everything works as
expected:
if (ret_next_line == p) p += ret_str_length;
else if (p == NULL) ret_str_length = -1;
else ret_str_length = ret_next_line - p;
can someone tell me what the expected behavior of GetStringBreak is? is
GetStringBreak wrong or DrawString?
best regards,
michael
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users