On Fri, Jun 29, 2007 at 02:00:57PM +0200, M. Dietrich wrote:
> 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.
> 
the sample code had a small bug, this one is correct:

        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));
                if (ret_next_line == p) ret_next_line += ret_str_length;
                else if (p == NULL) ret_str_length = -1;
                else ret_str_length = ret_next_line - p;
                printf("'%.*s' %d '%s'\n",  ret_str_length, p, ret_str_length, 
ret_next_line);
                p = ret_next_line;
        }

this works with DirectFB-1.0.0 and DirectFB from git but is a
workaround.

i would like to see another type of GetStringBreak with a callback for
detection of possible break-positions. also the parameter
ret_str_length seems to be redundant because it may be calculated as
above. what do you think?

another thing is hyphenation and i have no clue how to implement that.
the problem for me is the '-' that must be appended if a word was
splitted. any ideas?

best regards,
        michael

_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to