1#include <rfb/rfb.h>
2
3#define FONTDIR "/usr/lib/kbd/consolefonts/"
4#define DEFAULTFONT FONTDIR "default8x16"
5
6static char *fontlist[50]={
7"8x16alt", "b.fnt", "c.fnt", "default8x16", "m.fnt", "ml.fnt", "mod_d.fnt",
8"mod_s.fnt", "mr.fnt", "mu.fnt", "r.fnt", "rl.fnt", "ro.fnt", "s.fnt",
9"sc.fnt", "scrawl_s.fnt", "scrawl_w.fnt", "sd.fnt", "t.fnt",
10  NULL
11};
12
13static rfbScreenInfoPtr rfbScreen = NULL;
14static rfbFontDataPtr curFont = NULL;
15static void showFont(int index)
16{
17  char buffer[1024];
18
19  if(!rfbScreen) return;
20
21  if(curFont)
22    rfbFreeFont(curFont);
23
24  strcpy(buffer,FONTDIR);
25  strcat(buffer,fontlist[index]);
26  curFont = rfbLoadConsoleFont(buffer);
27
28  rfbFillRect(rfbScreen,210,30-20,210+10*16,30-20+256*20/16,0xb77797);
29  if(curFont) {
30    int i,j;
31    for(j=0;j<256;j+=16)
32      for(i=0;i<16;i++)
33	rfbDrawCharWithClip(rfbScreen,curFont,210+10*i,30+j*20/16,j+i,
34			    0,0,640,480,0xffffff,0x000000);
35  }
36}
37
38int main(int argc,char** argv)
39{
40  rfbFontDataPtr font;
41  rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,640,480,8,3,3);
42  int i,j;
43
44  if(!s)
45    return 0;
46
47  s->frameBuffer=(char*)malloc(640*480*3);
48  rfbInitServer(s);
49
50  for(j=0;j<480;j++)
51    for(i=0;i<640;i++) {
52      s->frameBuffer[(j*640+i)*3+0]=j*256/480;
53      s->frameBuffer[(j*640+i)*3+1]=i*256/640;
54      s->frameBuffer[(j*640+i)*3+2]=(i+j)*256/(480+640);
55    }
56
57  rfbScreen = s;
58  font=rfbLoadConsoleFont(DEFAULTFONT);
59  if(!font) {
60    rfbErr("Couldn't find %s\n",DEFAULTFONT);
61    exit(1);
62  }
63
64  for(j=0;j<0 && rfbIsActive(s);j++)
65    rfbProcessEvents(s,900000);
66
67  i = rfbSelectBox(s,font,fontlist,10,20,200,300,0xffdfdf,0x602040,2,showFont);
68  rfbLog("Selection: %d: %s\n",i,(i>=0)?fontlist[i]:"cancelled");
69
70  rfbFreeFont(font);
71  free(s->frameBuffer);
72  rfbScreenCleanup(s);
73
74  return(0);
75}
76
77