LibVNCServer/LibVNCClient
fontsel.c
Go to the documentation of this file.
1 
8 #include <rfb/rfb.h>
9 
10 #define FONTDIR "/usr/lib/kbd/consolefonts/"
11 #define DEFAULTFONT FONTDIR "default8x16"
12 
13 static char *fontlist[50]={
14 "8x16alt", "b.fnt", "c.fnt", "default8x16", "m.fnt", "ml.fnt", "mod_d.fnt",
15 "mod_s.fnt", "mr.fnt", "mu.fnt", "r.fnt", "rl.fnt", "ro.fnt", "s.fnt",
16 "sc.fnt", "scrawl_s.fnt", "scrawl_w.fnt", "sd.fnt", "t.fnt",
17  NULL
18 };
19 
20 static rfbScreenInfoPtr rfbScreen = NULL;
21 static rfbFontDataPtr curFont = NULL;
22 static void showFont(int index)
23 {
24  char buffer[1024];
25 
26  if(!rfbScreen) return;
27 
28  if(curFont)
29  rfbFreeFont(curFont);
30 
31  strcpy(buffer,FONTDIR);
32  strcat(buffer,fontlist[index]);
33  curFont = rfbLoadConsoleFont(buffer);
34 
35  rfbFillRect(rfbScreen,210,30-20,210+10*16,30-20+256*20/16,0xb77797);
36  if(curFont) {
37  int i,j;
38  for(j=0;j<256;j+=16)
39  for(i=0;i<16;i++)
40  rfbDrawCharWithClip(rfbScreen,curFont,210+10*i,30+j*20/16,j+i,
41  0,0,640,480,0xffffff,0x000000);
42  }
43 }
44 
45 int main(int argc,char** argv)
46 {
47  rfbFontDataPtr font;
48  rfbScreenInfoPtr s=rfbGetScreen(&argc,argv,640,480,8,3,3);
49  int i,j;
50 
51  if(!s)
52  return 1;
53 
54  s->frameBuffer=(char*)malloc(640*480*3);
55  if(!s->frameBuffer)
56  return 1;
57 
58  rfbInitServer(s);
59 
60  for(j=0;j<480;j++)
61  for(i=0;i<640;i++) {
62  s->frameBuffer[(j*640+i)*3+0]=j*256/480;
63  s->frameBuffer[(j*640+i)*3+1]=i*256/640;
64  s->frameBuffer[(j*640+i)*3+2]=(i+j)*256/(480+640);
65  }
66 
67  rfbScreen = s;
69  if(!font) {
70  rfbErr("Couldn't find %s\n",DEFAULTFONT);
71  exit(1);
72  }
73 
74  for(j=0;j<10 && rfbIsActive(s);j++)
75  rfbProcessEvents(s,900000);
76 
77  i = rfbSelectBox(s,font,fontlist,10,20,200,300,0xffdfdf,0x602040,2,showFont);
78  rfbLog("Selection: %d: %s\n",i,(i>=0)?fontlist[i]:"cancelled");
79 
80  rfbFreeFont(font);
81  free(s->frameBuffer);
83 
84  return(0);
85 }
86 
#define DEFAULTFONT
Definition: fontsel.c:11
int main(int argc, char **argv)
Definition: fontsel.c:45
#define FONTDIR
Definition: fontsel.c:10
rfbLogProc rfbErr
Definition: rfb.h:1020
void rfbFreeFont(rfbFontDataPtr font)
free a dynamically loaded font
void rfbInitServer(rfbScreenInfoPtr rfbScreen)
int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, int x, int y, unsigned char c, int x1, int y1, int x2, int y2, rfbPixel colour, rfbPixel backColour)
if colour==backColour, background is transparent
rfbFontDataPtr rfbLoadConsoleFont(char *filename)
dynamically load a linux console font (4096 bytes, 256 glyphs a 8x16
int rfbSelectBox(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, char **list, int x1, int y1, int x2, int y2, rfbPixel foreColour, rfbPixel backColour, int border, SelectionChangedHookPtr selChangedHook)
void rfbFillRect(rfbScreenInfoPtr s, int x1, int y1, int x2, int y2, rfbPixel col)
void rfbScreenCleanup(rfbScreenInfoPtr screenInfo)
rfbScreenInfoPtr rfbGetScreen(int *argc, char **argv, int width, int height, int bitsPerSample, int samplesPerPixel, int bytesPerPixel)
rfbLogProc rfbLog
rfbBool rfbIsActive(rfbScreenInfoPtr screenInfo)
rfbBool rfbProcessEvents(rfbScreenInfoPtr screenInfo, long usec)