195 lines
2.2 KiB
C
195 lines
2.2 KiB
C
/*
|
|
* This file is automaticaly generated, Please dont edit this file!
|
|
*/
|
|
#include <engine/fontRenderer.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
texture2D * fontRenderer_loadFont( fontRenderer * this, char character ) {
|
|
|
|
FT_Library ft;
|
|
|
|
if ( FT_Init_FreeType( &ft ) )
|
|
{
|
|
|
|
printf("ERROR::FREETYPE: Could not init FreeType Library");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_Face face;
|
|
|
|
if ( FT_New_Face( ft, "assets/fonts/WorkSans/WorkSans-Regular.ttf", 0, &face ) )
|
|
{
|
|
|
|
printf("ERROR::FREETYPE: Failed to load font\n\n");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
int fontSize = 118;
|
|
|
|
if ( FT_Set_Pixel_Sizes( face, 0, fontSize ) ) {
|
|
|
|
printf("ERROR::FREETYPE: Failed to set font size\n\n");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_Matrix matrix;
|
|
|
|
FT_UInt glyph_index;
|
|
|
|
FT_Vector pen;
|
|
|
|
int n;
|
|
|
|
FT_GlyphSlot slot = face->glyph;
|
|
|
|
|
|
pen.x = 0;
|
|
|
|
pen.y = 0;
|
|
|
|
if( FT_Load_Char( face, character, FT_LOAD_RENDER ) ) {
|
|
|
|
printf("ERROR error loading char.");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_Bitmap * bitmap = &slot->bitmap;
|
|
|
|
texture2D * texture = texture2D_newPointer();
|
|
|
|
texture->width = bitmap->width;
|
|
|
|
texture->height = bitmap->rows;
|
|
|
|
texture->hasAlpha = 1;
|
|
|
|
texture->offset = vector2_newPointer( ( float ) slot->bitmap_left, ( float ) slot->bitmap_top );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
texture->data = bitmap->buffer;
|
|
|
|
for (int x = 0; x < texture->width; ++x)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return texture;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void fontRenderer_draw_bitmap( fontRenderer * this, FT_Bitmap * bitmap, FT_Int x, FT_Int y ) {
|
|
|
|
FT_Int i, j, p, q;
|
|
|
|
FT_Int x_max = x + bitmap->width;
|
|
FT_Int y_max = y + bitmap->rows;
|
|
|
|
int WIDTH = 512;
|
|
|
|
int HEIGHT = 512;
|
|
|
|
printf("x_max: %i\n", x_max);
|
|
|
|
printf("y_max: %i\n", y_max);
|
|
|
|
|
|
for ( i = x, p = 0; i < x_max; i++, p++ )
|
|
{
|
|
for ( j = y, q = 0; j < y_max; j++, q++ )
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void fontRenderer_show_image( fontRenderer * this, void ) {
|
|
}
|
|
|
|
fontRenderer fontRenderer_new() {
|
|
|
|
fontRenderer instance;
|
|
|
|
instance.data = malloc( 512 * 512 * 4 );
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
fontRenderer * fontRenderer_newPointer() {
|
|
|
|
struct fontRenderer * pointer = malloc( sizeof ( struct fontRenderer ) );
|
|
|
|
pointer->data = malloc( 512 * 512 * 4 );
|
|
|
|
return pointer;
|
|
|
|
}
|
|
|