[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

1441.0. "font / pixmap => corrupted font" by MUHWSS::SCHMADERER () Thu Sep 14 1989 12:56

I ran into the following problem with fonts and pixmaps:

I use XloadFont to load a (big) font. Drawing with this font doesn't cause any
problems. Afterwards I create a pixmap (1000 x 800 pixels). No error occurs and
everything works fine with my font until I draw into the pixmap.

The result is that my font gets corrupted.

If I draw a filled rectangle into my pixmap some characters ('j' and '|') are
missing, if I draw a grid into the pixmap some characters ('j' and '|' again)
are xor'd with the grid.

I tried this out on different servers. The firefox and the pmax don't seem to
have that problem but on a GPX and a VS3100 you can see what I mean. This 
problem occurs on VMS and (even !) on Ultrix, no matter whether you write
yor programs in C or Fortran.

So, is it a bug in the server or am I to stupid to write a simple program ?

I posted my program after this note. Please give me any hint you can offer.
The customer who pointed my to this (via outage) and I would be happy to get 
rid of this problem.


#include <stdio.h>
#ifdef VMS
#include <decw$include/Xlib.h>
#else
#include <X11/Xlib.h>
#endif

#define FONT "-bitstream-terminal-bold-r-normal--*-*-*-*-c-22-iso8859-1"

char *string1 = "A B C D E F G H I J K L M";
char *string2 = "N O P Q R S T U V W X Y Z";
char *string3 = "a b c d e f g h i j k l m";
char *string4 = "n o p q r s t u v w x y z";
char *string5 = "{ | } [ ] ! @ # $ % ^ & *";

Display   *display;
Window    window; 
Pixmap    pixmap;
Screen    *screen;
GC        gc;
XEvent    event;
Font      font;


main()
{           
    do_init();
    do_windcreate();
    do_pixmapcreate();
    do_gccreate();
    do_loadfont();
    do_eventsetup();
    do_windmap();
    do_handleevents();
}


do_init()
{
    if ( !(display = XOpenDisplay("")) ) {
        printf("Error: XOpenDisplay\n");
        exit();
    }
    screen = DefaultScreenOfDisplay(display);
#ifdef DEBUG
    XSynchronize(display, 1);
#endif
}


do_windcreate()
{
    window = XCreateSimpleWindow(display, RootWindowOfScreen(screen),
        10, 10, 1000, 800,  
        0, 
        BlackPixelOfScreen(screen),
        WhitePixelOfScreen(screen)
        );
}


do_pixmapcreate()
{
    pixmap = XCreatePixmap(display, window, 1000, 800,
        DefaultDepthOfScreen(screen));
}


do_gccreate()
{
    gc = XCreateGC(display, window, 0L, 0L);
    XSetForeground(display, gc, BlackPixelOfScreen(screen));
    XSetBackground(display, gc, WhitePixelOfScreen(screen));
}


do_loadfont()
{
    font = XLoadFont(display, FONT);
    XSetFont(display, gc, font);
}


do_windmap()
{
    XMapWindow(display, window);
    XFlush(display); 
}


do_eventsetup()
{
    XSelectInput(display, window,
            ExposureMask |
            ButtonPressMask |
			KeyPressMask
            );
}


do_handleevents()
{
    for(;;) {

        XNextEvent(display, &event);

        switch(event.type) {

            case Expose:        test_symbol_font();
                                break;

            case ButtonPress:   do_button();
                                break;

            case KeyPress:      do_exit();
                                break;

            default:    		break;

        }

    }
}


test_symbol_font()
{
    XClearWindow(display, window);

	XDrawString(display, window, gc, 10, 50 ,
		string1, strlen(string1));
	XDrawString(display, window, gc, 10, 100 ,
		string2, strlen(string2));
	XDrawString(display, window, gc, 10, 150 ,
		string3, strlen(string3));
	XDrawString(display, window, gc, 10, 200 ,
		string4, strlen(string4));
	XDrawString(display, window, gc, 10, 250 ,
		string5, strlen(string5));
}


do_button()
{
    if (event.xbutton.button == Button2) {
        copy_pixmap_to_window();
    }
    if (event.xbutton.button == Button1) {
        test_symbol_font();
    }
    if (event.xbutton.button == Button3) {
        fill_pixmap();
    }
}


copy_pixmap_to_window()
{
    XCopyArea(display, pixmap, window, gc, 0, 0, 1000, 800, 0, 0);
}



fill_pixmap()
{
    XFillRectangle(display, pixmap, gc, 0, 0, 1000, 800);
}


do_exit()
{
    XCloseDisplay(display);
}


T.RTitleUserPersonal
Name
DateLines
1441.1STAR::ORGOVANVince OrgovanFri Sep 15 1989 20:112
    Please file a QAR on this problem.