[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Re: [ft] Monochrome Bitmap Trouble
From: |
Paresh Deshmukh |
Subject: |
RE: Re: [ft] Monochrome Bitmap Trouble |
Date: |
Fri, 16 Sep 2005 10:39:35 UT |
I think my comment cause more trouble then bitmap trouble ;).. Well those
comments are for myself Im a beginner and don't want to miss out anything.
Sorry for the trouble.
I cannot send you the real program. But this is based on the tutorial step-1.
The addition is only that...image buffer is copied to print buffer.
I also tried similar code as of
John Churchill
Subject: [Freetype] Distorted characters
Date: Fri, 23 Aug 2002 02:24:20 -0700 (PDT)
void InitFont() {
FT_UInt index;
FT_GlyphSlot slot;
int pitch, start;
unsigned char *bitmap, i;
if ( FT_Init_FreeType(&Library) ) {
printf("Failed to init freetype.\n");
exit(1);
}
if ( FT_New_Face(Library, "/arial.ttf", 0, &face) )
printf("Unable to load font.\n");
if ( FT_Set_Char_Size(face, 0, 22*64, 300,300) )
printf("Unable to set character size.\n");
for (i = 'A'; i < 'A' + 4; i++) {
index = FT_Get_Char_Index(face, i);
if ( FT_Load_Glyph(face, index, FT_LOAD_DEFAULT) )
printf("Unable to load glyph face.\n");
if ( FT_Render_Glyph(face->glyph, ft_render_mode_mono) )
printf("Unable to render glyph\n");
slot = face->glyph;
pitch = slot->bitmap.pitch;
bitmap = (unsigned char *) malloc(slot->bitmap.rows * pitch);
if (bitmap == NULL) {
printf("Out of memory.\n");
free(bitmap);
FT_Done_FreeType(Library);
exit(1);
}
memset(bitmap, 0, slot->bitmap.rows * pitch);
for (start=0; start < slot->bitmap.rows; start++)
memcpy(bitmap + pitch * start,slot->bitmap.buffer +
start * pitch, pitch);
}
/*Cpying bitmap to print buffer*/
free(bitmap);
}
FT_Done_FreeType(Library);
}
This code works for me and giving me proper and all characters without any
garbage. Please comment where Im wrong in first code.