[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

1235.0. "XLoadQueryFont bug??" by SOJU::FRANCUS (Mets in '89) Fri Aug 04 1989 15:38

    The documentation for XLoadQueryFont says that if a font is not found
    the function returns NULL.
    
    Below is a program that loads font in from a file called font_name.
    
    Non of the lines in font_name are legal font_names yet XLoadQueryFont
    does not return a NULL? Am I doing something wrong or should this/has
    this been SPR'ed??
    
#include <stdio.h>
#include <X11/Xlib.h>
#define LENGTH 40

static char fn[LENGTH];

main(argc,argv)
int argc;
char *argv[];
{
	Display *disp;
        GC gcontext;
        XGCValues graphval;
	int screen;
	FILE *fp;
	char *dis_name = NULL;
	Window windowid;
	XFontStruct *finfo;
	int ypos; 	/* text y position */

	if ( (disp = XOpenDisplay(dis_name)) == NULL)
	{
		printf("Display %s is not available\n",XDisplayName(dis_name));
		exit(4);
	}

	if((fp = fopen("./font_name", "r")) == NULL)
		perror("Open font name data base"), exit(1);
	
        screen = DefaultScreen(disp);
        if ((windowid = XCreateSimpleWindow(disp,RootWindow(disp,screen),
                  0,0,400,800,2, BlackPixel(disp,screen),
                  WhitePixel(disp,screen))) == 0)
        {
                printf("No window today!!\n");
                exit(8);
        }
	XMapWindow(disp, windowid);
        XFlush(disp);
	sleep(2);
	while(fscanf(fp, "%s", fn) != EOF)
	{
	if ((finfo = XLoadQueryFont(disp,fn))==NULL)
	{
		printf("font %s could not be found ** Bye Bye **\n",fn);
		continue;
	}
	ypos += 5 + finfo->max_bounds.descent + finfo->max_bounds.ascent;
	graphval.font = finfo->fid;
        gcontext=XCreateGC(disp,windowid,GCFont,&graphval);
	XUnloadFont(disp,finfo->fid);
	XDrawString(disp,windowid,gcontext,
			10,ypos,fn,sizeof(fn));
        XFlush(disp);
	}
	sleep(80);

	XCloseDisplay(disp);
}

    ----------------------------------------------------------------------------
font_name
----------
    
abcd
xxxxx
ASDADASd
    
    

T.RTitleUserPersonal
Name
DateLines
1235.1similar problem has been QAR'dRANCHO::KIMBALLYou&#039;re soaking in it...Tue Aug 15 1989 23:573
    I had similar issue with XLoadFont and just QAR'd it in the UWS_QAR
    file.

1235.2another LoadQueryFont problem?TRNSAM::HOLTRobert Holt ISV Atelier WestTue Jan 16 1990 15:13121
/*
    If I attempt to specify a font such as "8x13", no text is written
    into the window.

    I however I change it to "fixed", text appears. This appears to
    be a feature of UWS2.2.....2.1 handled either case.

    Bug? or feature?
*/




#include <stdio.h>

#include <X11/DECwDwtWidgetProg.h>

#define GW_XORG     0
#define GW_YORG     0
#define GW_WIDTH  800
#define GW_HEIGHT 650
#define TW_XORG   GW_XORG
#define TW_YORG   GW_YORG
#define TW_WIDTH  GW_WIDTH
#define TW_HEIGHT GW_HEIGHT

/* Global Variables */
static char    text_title[]  =  "Text Window";

/* Text buffers */
#define MAXTEXTBUF 2048
struct text_info {
    DwtFontList tx_font_list;	      /* current text font */
    char *tx_buffer;		      /* display text for text screen */
    int buf_size;                     /* rows * cols chars */
    int tx_cur_len;		      /* length of text buffer */
    int tx_new_line;		      /* inserting new line flag */
    int tx_start_line;		      /* address of start of current line */
    int tx_ins_pos;		      /* next output character position */
    int tx_cur_line;		      /* start of current line */
    int tx_char_wdt, tx_char_hgt;     /* character height and width */
    int tx_cols, tx_rows;             /* cols & rows in text widget */
};
static struct text_info *text;
static void create_text_window();

Widget  text_frame, text_main, text_window;
XFontStruct *graph_font;
Display *display;
Visual *visual;
Screen *screen;
XtAppContext context;

main(argc, argv)
int argc;
char **argv;
{
    Arg arglist[30];
    int count, i, fdr;

    /* Init toolkit, open root window */
    XtToolkitInitialize();
    context = XtCreateApplicationContext();
    display = XtOpenDisplay(context,NULL,"Test","Test",NULL,0,&argc,argv);    

    /* this works */
    /*graph_font = XLoadQueryFont(display,"fixed");*/

    /* this doesn't */
    graph_font = XLoadQueryFont(display,"8x13");

    /* Create text window */
    create_text_window();

    /* manage, realize widgets */
    XtManageChild(text_window);
    XtManageChild(text_main);
    XtRealizeWidget(text_frame);

    /* Handoff to event handlers */
    XtAppMainLoop(context);
}

static void create_text_window()
{
    Arg arglist[20];
    int count;

    text_frame = XtAppCreateShell(text_title,"AutoCad",
	applicationShellWidgetClass,display,NULL,0);
    text_main = DwtMainWindow(text_frame,"TextMainWindow",0, 0,
	TW_WIDTH, TW_HEIGHT, NULL);

    /* allocate text buffer for text window */
    text = (struct text_info *) XtMalloc(sizeof(struct text_info));
    text->tx_buffer = (char *) XtMalloc(MAXTEXTBUF);
    text->tx_buffer[0] = '\0';
    text->tx_ins_pos = 0;
    text->tx_cur_len = 0;
    text->tx_cur_line = 0;

    strcpy(text->tx_buffer,"this is a test message....this is a test message....this is a test message");

    /* specify the ISO Latin1 charset */
    text->tx_font_list = DwtCreateFontList(graph_font, 1);

    /* build the text widget */
    count = 0;
    XtSetArg(arglist[count],DwtNscrollVertical,TRUE); count++;
    XtSetArg(arglist[count],DwtNresizeWidth,FALSE);count++;
    XtSetArg(arglist[count],DwtNresizeHeight,FALSE);count++;
    XtSetArg(arglist[count],DwtNeditable,FALSE); count++;
    XtSetArg(arglist[count],DwtNautoShowInsertPoint,TRUE);count++; 
    XtSetArg(arglist[count],DwtNinsertionPointVisible,TRUE);count++; 
    XtSetArg(arglist[count],DwtNwordWrap,TRUE); count++; 
    XtSetArg(arglist[count],DwtNfont,text->tx_font_list);count++;
    XtSetArg(arglist[count],DwtNvalue,text->tx_buffer);count++;
    text_window=DwtSTextCreate(text_main,/*MSG0*/"TextWindow",arglist,count);
}

1235.3Did you load UWSUNMIT022?MIPSBX::thomasThe Code WarriorTue Jan 16 1990 22:511
The MIT fonts aren't loaded by default in UWS2.2 or UWS4.0.
1235.4why, goodness no...TRNSAM::HOLTRobert Holt ISV Atelier WestWed Jan 17 1990 12:471
    
1235.5look in the unsupported subsetsSMURF::HOFFMANanywhere in the universeFri Jan 26 1990 15:4419
to amplify on .3

The MIT fonts, including 8x13 and about 120 others, are in the 
Unsupported X11 Components subset in UWS V2.2 and UWS V4.0.
For many of you out there, that means that they are on a 
separate piece of media (along with unspported components
of the ULTRIX base operating system) which is clearly labelled
"Unsupported".  For those doing RIS (aka Remote Installations),
the Unsupported subsets are in a separate Product that cannot
be installed until after the supported installation is complete.

Many users, especially those who fail to carefully examine the
rather thick release notes, are unaware of this.  It is probably
the single most common source of serious run-time problem reports
from people familiar with previous versions of ULTRIX Worksystem Software.

Of course, this wasn't my idea.

John
1235.6"Not invented Here" = "Unsupported"?SUBWAY::GRAHAMif ya want home cookin, stay homeSun Feb 04 1990 14:1017
    
    RE.5
    
    >..look in the unsupported subsets
    >The MIT fonts, including 8x13 and about 120 others, are in the
    >Unsupported X11 Components....
    
    John,
    
    I know this was not your idea.  It is amazing how this company
    touts "open systems", but continue to do evil things like these.
    Kind of like the proprietary phone jacks/cables used for 'DEC'
    modems ;-)
    Another opportunity for our competition to claim that our systems
    are not standard!
    
    Kris...