Tscope5
textio05.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// textio05.c
// - Load a custom font.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <stdio.h>
int main()
{
// open a display
ts5_set_coordinate_system(TS5_DISPLAY_COORDINATES);
ts5_set_text_alignment(TS5_ALIGN_LEFT);
TS5_FONT *oldfont, *newfont1, *newfont2, *newfont3;
// load a font, 20px
newfont1 = ts5_read_font("cmunobi.ttf", 20.0);
oldfont = ts5_set_font(newfont1);
ts5_printf(20.0, 50.0, "custom font: computer modern 20");
ts5_set_font(oldfont);
newfont2 = ts5_read_font ("cmunobi.ttf", 30.0);
ts5_set_font(newfont2);
ts5_printf(20.0, 80.0, "custom font: computer modern 30");
newfont3 = ts5_read_font ("cmunobi.ttf", 80.0);
ts5_set_font(newfont3);
ts5_printf(20.0, 120.0, "custom font: computer modern 80");
ts5_set_font(oldfont);
ts5_printf(20.0, 210, "back to the default font");
// make everything visible
// free the fonts
ts5_free_font(newfont1);
ts5_free_font(newfont2);
ts5_free_font(newfont3);
// wait for a click
ts5_draw_mouse_button(ax(0.9), ay(0.8));
return 0;
}