summaryrefslogtreecommitdiffstats
path: root/example.c
diff options
context:
space:
mode:
authordscho <dscho>2001-10-05 20:19:35 +0000
committerdscho <dscho>2001-10-05 20:19:35 +0000
commit8f407f8a1ab2adf08c438f40cd797fef8a810dae (patch)
tree999aab5a3f788f5c6e43621525fdf6515f6bb974 /example.c
parent48eb9b22c7097c4af61760ce3fdc7f5135e657bc (diff)
downloadlibtdevnc-8f407f8a1ab2adf08c438f40cd797fef8a810dae.tar.gz
libtdevnc-8f407f8a1ab2adf08c438f40cd797fef8a810dae.zip
extracted font routines from example
Diffstat (limited to 'example.c')
-rw-r--r--example.c61
1 files changed, 3 insertions, 58 deletions
diff --git a/example.c b/example.c
index da01d7a..64e4d6c 100644
--- a/example.c
+++ b/example.c
@@ -139,59 +139,6 @@ void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
/* aux function to draw a character to x, y */
#include "radon.h"
-int drawchar(unsigned char* buffer,int rowstride,int bpp,int x,int y,char c)
-{
- int i,j,k,width,height;
- unsigned char d;
- unsigned char* data=bdffontdata+bdffontmetadata[c*5];
- width=bdffontmetadata[c*5+1];
- height=bdffontmetadata[c*5+2];
- x+=bdffontmetadata[c*5+3];
- y+=bdffontmetadata[c*5+4]-height+1;
-
- for(j=0;j<height;j++) {
- for(i=0;i<width;i++) {
- if((i&7)==0) {
- d=*data;
- data++;
- }
- if(d&0x80) {
- for(k=0;k<bpp;k++)
- buffer[(y+j)*rowstride+(x+i)*bpp+k]=0xff;
- }
- d<<=1;
- }
- if((i&7)==0)
- data++;
- }
- return(width);
-}
-
-void drawstring(unsigned char* buffer,int rowstride,int bpp,int x,int y,char* string)
-{
- while(*string) {
- x+=drawchar(buffer,rowstride,bpp,x,y,*string);
- string++;
- }
-}
-
-int bdflength(char* string)
-{
- int i;
- while(*string) {
- i+=bdffontmetadata[*string*5+1];
- string++;
- }
- return(i);
-}
-
-void bdfbbox(char c,int* x1,int* y1,int* x2,int* y2)
-{
- *x1+=bdffontmetadata[c*5+3];
- *y1+=bdffontmetadata[c*5+4]-bdffontmetadata[c*5+2]+1;
- *x2=*x1+bdffontmetadata[c*5+1];
- *y2=*y1+bdffontmetadata[c*5+2];
-}
/* Here the key events are handled */
@@ -210,10 +157,8 @@ void dokey(Bool down,KeySym key,rfbClientPtr cl)
int x1=cd->oldx,y1=cd->oldy,x2,y2;
if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl);
- cd->oldx+=drawchar(cl->screen->frameBuffer,
- cl->screen->paddedWidthInBytes,bpp,cd->oldx,cd->oldy,
- key);
- bdfbbox(key,&x1,&y1,&x2,&y2);
+ cd->oldx+=rfbDrawChar(cl->screen,&radonFont,cd->oldx,cd->oldy,key,0xffffff);
+ rfbFontBBox(&radonFont,key,&x1,&y1,&x2,&y2);
rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1);
}
}
@@ -299,7 +244,7 @@ int main(int argc,char** argv)
rfbScreen->httpDir = "./classes";
initBuffer(rfbScreen->frameBuffer);
- drawstring(rfbScreen->frameBuffer,maxx*bpp,bpp,20,100,"Hello, World!");
+ rfbDrawString(rfbScreen,&radonFont,20,100,"Hello, World!",0xffffff);
/* This call creates a mask and then a cursor: */
/* rfbScreen->defaultCursor =