1. find a chinese font.
2. download libiconv, make && make install.
3. write convert function, like this:

int code_convert(char *from_chrset, char *to_chrset, char *inbuf, int
in_len, char *outbuf, int out_len)
{
    iconv_t cd;
    char **pin = &inbuf;
    char **pout = &outbuf;
    int errno, result;
    const int set = 0;

    cd = iconv_open(to_chrset, from_chrset);
    if (cd==0) {
        printf("can't open charset %s !\n", to_chrset);
        return -1;
    }
    iconvctl(cd, ICONV_SET_TRANSLITERATE, (void*)&set);
    iconvctl(cd, ICONV_GET_TRANSLITERATE, &result);
    printf("ICONV_GET_TRANSLITERATE=%d\n", result);
    memset(outbuf, 0, out_len);
    if (iconv(cd, pin, &in_len, pout, &out_len )== -1) {
        printf("can't iconv charset from %s to %s!\n", from_chrset,
to_chrset);
        printf("error=%s\n", strerror(errno));
       return -1;
    }
    iconv_close(cd);
    return 0;
}

call fun : code_convert("GB2312", "UTF-8", text, strlen(text), conv_text,
100); (please link libiconv lib for your program)

4. display previous outbuf use directfb surface DrawString function :
surface->SetFont(surface, gfx_font);
surface->DrawString(surface, conv_text, (int)strlen(conv_text), x, y,
DSTF_LEFT);


2008/11/3 pvanand <[EMAIL PROTECTED]>

>
> Hi,
>
> I'm trying to display chinese text using directfb. I've set the font
> attribute as unicode and using HDZB_35.ttf font. CreateFont is succeeded.
> But no output is observed while plotting the chinese unicode string using
> DrawGlyph api.
>
> If anyone could help me to resolve this issue. If any sample code is
> provided, it would be greatly helpful.
>
> Thanks and Regards,
> Vijay
> --
> View this message in context:
> http://www.nabble.com/How-to-support-chinese-font-and-text-display-using-directfb-tp20304682p20304682.html
> Sent from the DirectFB Users mailing list archive at Nabble.com.
>
> _______________________________________________
> directfb-users mailing list
> directfb-users@directfb.org
> http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users
>
_______________________________________________
directfb-users mailing list
directfb-users@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to