tags:

views:

123

answers:

0

What should I do to to render sample string with specified font to the QPixmap? QT still cannot working with Type1 font, but it is required.

My code: int e; e = FT_Init_FreeType(&library); e = FT_New_Face( library, "arial.ttf", 0, &face ); e = FT_Set_Char_Size( face, size << 6, size << 6, 96, 96 ); e = FT_Set_Pixel_Sizes( face, size, size );

for(int i = 0; i < str.length(); ++i)
{
    e = FT_Load_Char(face, str[i].toAscii(), FT_LOAD_DEFAULT);
    if( e )
        continue;

    e = FT_Render_Glyph( face->glyph,  FT_RENDER_MODE_NORMAL );
    if( e )
        continue;

    QPixmap pix(slot->bitmap.rows, slot->bitmap.width);
    pix.fill(Qt::yellow);
    bool b = pix.loadFromData((const char*)slot->bitmap.buffer);
    pix.save("qweqwe.png", "PNG", 100);
}

And saved PNG containg only yellow backgroud, not rendered font (also b == false, so loadFromData call fails) Coul anyone give to me working sample? May be for win32 HDC, I'll translate it for QT.