[q-lang-cvs] q/modules/ggi/examples font_test.q,NONE,1.1
Brought to you by:
agraef
From: <ag...@us...> - 2003-12-19 21:37:20
|
Update of /cvsroot/q-lang/q/modules/ggi/examples In directory sc8-pr-cvs1:/tmp/cvs-serv11589 Added Files: font_test.q Log Message: Added font test example --- NEW FILE: font_test.q --- /* $Id: font_test.q,v 1.1 2003/12/19 21:37:17 agraef Exp $ */ /* font_test.q: Little test script showing how to render text using Q-GGI's font interface. NOTE: This requires FreeType2 to work. */ import ggi; def FONT = "/usr/X11R6/lib/X11/fonts/truetype/times.ttf", FONT_METRIC = (), INDEX = 0, SIZE = 50, RES = 100, RED = (0xffff,0,0), GREEN = (0,0xffff,0), BLUE = (0,0,0xffff), BLACK = (0,0,0), WHITE = (0xffff,0xffff,0xffff); def VIS = ggi_open (), _ = ggi_set_mode VIS "640x480" || ggi_set_foreground VIS WHITE || ggi_set_font VIS FONT INDEX || ggi_set_font_metric VIS FONT_METRIC || ggi_set_char_size VIS SIZE RES; // set the font size size SIZE = ggi_set_char_size VIS SIZE RES; // set antialiasing mode antialias FLAG = ggi_set_antialias VIS FLAG; // set transform vector and matrix transform VECT MATRIX = ggi_set_transform VIS VECT MATRIX; // print a sample of the current font test P MSG = ggi_puts VIS P MSG || // draw bounding box ggi_draw_hline VIS (0,Y) 640 || ggi_draw_hline VIS (0,Y+H-1) 640 || ggi_draw_vline VIS (X,0) 480 || ggi_draw_vline VIS (X+W-1,0) 480 where (X,Y) = P, (W,H) = ggi_get_string_size VIS MSG; // set foreground and background color fg COL = ggi_set_foreground VIS COL; bg COL = ggi_set_background VIS COL; // clear the display clr = ggi_clear VIS; |