File: test.c

package info (click to toggle)
fnlib 0.3-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,624 kB
  • ctags: 118
  • sloc: ansic: 2,381; sh: 2,002; makefile: 110
file content (69 lines) | stat: -rw-r--r-- 1,892 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <Imlib.h>
#include <Fnlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include <sys/time.h>
#include <time.h>

int 
main(int argc, char **argv)
{
   Display            *disp;
   ImlibData          *id;
   FnlibData          *fd;
   FnlibFont          *fn;
   FnlibStyle          fs;
   Window              win;
   Pixmap              p;
   Pixmap              m;
   ImlibImage         *im;
   ImlibColorModifier  mod;
   int                 w, h, i, j, k, n, o, sz;
   double              t1, t2, total;
   struct timeval      timev;

   disp = XOpenDisplay(NULL);
   id = Imlib_init(disp);
   fd = Fnlib_init(id);
   if (argc <= 2)
     {
	printf("Usage:\n test font_name pixel_size\n");
	exit(1);
     }
   sz = atoi(argv[2]);
   fn = Fnlib_load_font(fd, argv[1]);
   if (!fn)
     {
	printf("Cannot find font %s\n", argv[1]);
	exit(1);
     }
   win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 640, 480, 0, 0, 0);
   XClearWindow(disp, win);
   XMapWindow(disp, win);
   XSync(disp, False);
   fs.mode = MODE_WRAP_WORD;
   fs.orientation = FONT_TO_RIGHT;
   fs.justification = 0;
   fs.spacing = 0;

   for (i = 0; i < 1; i += 1)
     {
	usleep(100000);
	XClearWindow(disp, win);
	Fnlib_draw(fd, fn, win, 0, 20, 30, 600, 400, i, i / 2, sz, &fs,
		   "T11esting1 1 1   0123456789! \n"
		   "1234567890-=[]\\;',./~!@#$%^&*()_+{}|:\"<>?\n"
		   "My bum is bigger than yours because you are a complete whimp and so there bum you.\n"
		   "Pummel pummel. fuck me DEAD!@#%\n"
		   "Said 4-skin NED NED. So this is a test string to see how well this word and character wrapping works.\n"
		   "Blum\n"
		   "Shubbdhjfbhedfhjewfdwsdkbjnbgdskfvbvhjdshjbsdfdsfhgwerewuygfrhwfewfhewfnwdfhjnfjneygfnjegnfunfgfewuyuxe\n"
		   "Shub Brumby\n"
		   "Nim Nim Nim\n"
		   "Blumfrub\n");
	XSync(disp, False);
     }
   sleep(80);
   return 0;
}