¸®´ª½º ±âŸ ÀÚ·á |
---|
Á¦¸ñ | X-Windows¿¡¼ ÇѱÛ/¿µ¹® È¥ÇÕ Ãâ·Â ÇÔ¼ö ¿¹Á¦ 1998/07/07 (16:06) |
À̸§ | ±èÈ¿¿ø |
¹øÈ£ | 53 |
Á¶È¸ | 342 |
º»¹® |
#include <X11/Xlib.h> #include <stdio.h> int main() { Display *dpy; int screen; Window w; XFontStruct *hanFont, *engFont; GC gc; int n; char *str="¾È³çÇϼ¼¿ä Linux¿Í ÇѱÛÀÇ Á¶ÇÕÀÔ´Ï´Ù."; dpy=XOpenDisplay(NULL); screen=DefaultScreen(dpy); w=XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,400,300,2, BlackPixel(dpy,screen),WhitePixel(dpy,screen)); XMapWindow(dpy,w); XFlush(dpy); gc=XCreateGC(dpy,w,0L,(XGCValues *) NULL); hanFont=XLoadQueryFont(dpy,"-daewoo-mincho-*-normal--16-*-*-*-c-*-*-*"); engFont=XLoadQueryFont(dpy,"fixed"); HanXDrawString(dpy,w,gc,hanFont, engFont, 30,100,100,str, strlen(str)); int HanXDrawString(Display *d, Drawable w, GC gc, XFontStruct *hfont, XFontStruct *efont, int x, int hy, int ey, char *str, int len) { int n; char *p; XChar2b buf[256]; while(len>0){ if(*str & 0x80){ for(p=str; len>0 && (*p & 0x80); p+=2, len-=2) ; n=HanXCharConvert(str,buf,p-str); XSetFont(d,gc,hfont->fid); XDrawString16(d,w,gc,x,hy,buf,n); x+=XTextWidth16(hfont,buf,n); } else{ for(p=str;len>0 && !(*p & 0x80); p++,len--) ; XSetFont(d,gc,efont->fid); XDrawString(d,w,gc,x,ey,str,p-str); x+=XTextWidth(efont,str,p-str); } str=p; } XSetFont(d,gc,efont->fid); return 1; } /* 98.7.7 ¿ÀÈÄ 4½Ã¿¡ swindler°¡ Á¦ÀÛÇÑ ¼Ò½ºÀÓ. Makefile. all : ex1.c cc -o ex1 ex1.c -L/usr/X11R6/lib -lX11 |