Game Development Reference
In-Depth Information
8.
Read the value v from the bitmap and copy each of the four RGBA components into
the output:
unsigned char v = bitmap->buffer[q * bitmap->width + p];
for(int k = 0 ; k < 4 ; k++) image[j][i][k] = v;
}
}
9.
The main() function of the application goes as follows:
int main()
{
10. Clear the bitmap to black color:
memset( &image[0][0][0], 0, sizeof(image) );
11. Initialize the FreeType library:
FT_Library library;
FT_Init_FreeType( &library );
12. Create the face object:
FT_Face face;
FT_New_Face( library, “font.ttf”, 0, &face );
13. Set the character size. We declared CHAR_SIZE to denote the number of pixels for a
single char in our bitmap. The multiplier 64 is used, because FreeType units are equal
to 1/64th of a point. The value 100 corresponds to the horizontal resolution of 100
dots per inch:
FT_Set_Char_Size( face, CHAR_SIZE * 64, 0, 100, 0 );
FT_GlyphSlot slot = face->glyph;
14. Render each character of the ASCII table:
for ( int n = 0; n < 256; n++ )
{
15. Load the next glyph image into the slot, overwriting the previous one, and ignore
errors:
if( FT_Load_Char( face, n, FT_LOAD_RENDER ) )
{ continue; }
16. Calculate the non-transformed origin of the glyph in the resulting bitmap:
FT_Vector pen;
pen.x = (n % 16) * SLOT_SIZE * 64;
pen.y = ( HEIGHT - (n / 16) * SLOT_SIZE) * 64;
 
Search WWH ::




Custom Search