#include #include #include #include FT_FREETYPE_H #include FT_TRIGONOMETRY_H #define USAGE "%s angle fontfile character\n" void print_bitmap ( const FT_Bitmap* bitmap ) { int r, p, b; unsigned char* ptr = bitmap->buffer; for ( r = 0; r < bitmap->rows; r++ ) { for ( p = 0; p < bitmap->pitch; p++ ) { for ( b = 7; b >= 0; b-- ) { unsigned char mask = 1 << b; if ( *ptr & mask ) printf( "*" ); else printf( "-" ); } ptr++; } printf( "\n" ); } } int main ( int argc, char* argv[] ) { FT_Error error; FT_Library library; FT_Face face; double angle; FT_Vector sinus; FT_Matrix rotation_matrix; FT_UInt glyph_index; if ( argc != 4 ) { fprintf( stderr, USAGE, argv[0] ); return 1; } angle = atof( argv[1] ); error = FT_Init_FreeType( &library ); error = FT_New_Face( library, argv[2], 0, &face ); error = FT_Set_Char_Size( face, 0, 12*64, 100, 100 ); FT_Vector_Unit( &sinus, (FT_Angle)( angle * 0x10000L ) ); rotation_matrix.xx = sinus.x; rotation_matrix.xy = -sinus.y; rotation_matrix.yx = sinus.y; rotation_matrix.yy = sinus.x; FT_Set_Transform( face, &rotation_matrix, 0 ); glyph_index = FT_Get_Char_Index( face, *argv[3] ); error = FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT ); error = FT_Render_Glyph( face->glyph, ft_render_mode_mono ); print_bitmap( &face->glyph->bitmap ); return 0; }