Hi,

I have a simple piece of code that returns a character from a TTF file to the 
caller for rendering text labels. The caller of getCharacter() uses the buffer 
to merge to the frame buffer. The output looks like characters and numbers, but 
is certainly corrupted. I was hoping that maybe you could find something 
obviously wrong, and/or provide an example that is better than what's on 
FreeType's website. Any help would be greatly appreciated. In summary, I am 
doing the following:

typedef struct {
                unsigned char *image;
                ...
} CHAR_STRUCT;

CHAR_STRUCT* CharStruct;

FT_Library library;
FT_Face face;

Initfunction()
{
                CharStruct = (CHAR_STRUCT *)malloc(sizeof(CHAR_STRUCT));
error = FT_Init_FreeType(& library);
error = FT_New_Face(library, fontName, 0, &face);
error = FT_Set_Char_Size(face, 14 * 64, 0, 190, 190);
}

getCharacter(unsigned char character)
{
                FT_Bitmap bitMap = face->glyph->bitmap;
                error = FT_Load_Char(face, character, FT_LOAD_RENDER);
                error = FT_Render_Glyph(slot, FT_RENDER_MODE_MONO);
                CharStruct->image = (unsigned char*) malloc(size(unsigned char) 
* bitMap.width * bitMap.rows);
                memcpy(charStruct->image, bitMap.buffer, bitMap.width * 
bitMap.rows);
                return CharStruct;
}
________________________________

Please be advised that this email may contain confidential information. If you 
are not the intended recipient, please notify us by email by replying to the 
sender and delete this message. The sender disclaims that the content of this 
email constitutes an offer to enter into, or the acceptance of, any agreement; 
provided that the foregoing does not invalidate the binding effect of any 
digital or other electronic reproduction of a manual signature that is included 
in any attachment.
_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to