XFontStruct *
GetFontOrFixed (Display *disp, char *fontname)
{
	XFontStruct	*fnt;

	if ((fnt = XLoadQueryFont (disp, fontname)) == NULL)
	{
		msg
		(	"Fonte \"%s\" não localizada; tentando \"fixed\"",
			fontname
		);

		if ((fnt = XLoadQueryFont (disp, "fixed")) == NULL) 
			msg ("Fonte \"fixed\" não localizada!");
	}

	return (fnt);

}	/* end GetFontOrFixed */
Beispiel #2
0
/*
 * Load a font
 */
static XFontStruct *getFont(AngbandWidget widget,
                            String font, Boolean fallback)
{
  Display *dpy = XtDisplay((Widget) widget);
  char buf[256];
  XFontStruct *fnt = NULL;
  
  if (!(fnt = XLoadQueryFont(dpy, font)) && fallback)
    {
      sprintf(buf, "Can't find the font \"%s\", trying fixed\n", font);
      XtWarning(buf);
      if (!(fnt = XLoadQueryFont(dpy, "fixed")))
	{
	  XtError("Can't fint the font \"fixed\"!, bailing out\n");
	}
    }
  
  return fnt;
}
Beispiel #3
0
XmFontList CommonGetFontListWithCharset(char *fontstr, char *charset)

{

#ifdef MOTIF1_1
    XFontStruct   *newfont;
#else
    static XmFontListEntry fixed_font = NULL;
    XmFontListEntry fontlistEntry;
#endif
    XmFontList    fontlist;

#ifdef MOTIF1_1

    if (!(newfont = XLoadQueryFont (display, fontstr)))
    	newfont = XLoadQueryFont (display, default_font);
    fontlist = XmFontListCreate (newfont, charset);


#else

    if (!fixed_font) {
        fixed_font = XmFontListEntryLoad(display, "fixed", XmFONT_IS_FONT,
                                         charset);
    }

    if ((fontlistEntry = XmFontListEntryLoad(display, fontstr, XmFONT_IS_FONT,
                                        charset)) == NULL)
      {
	fontlist = XmFontListAppendEntry(NULL, fixed_font);
      }
    else
      {
	fontlist = XmFontListAppendEntry(NULL, fontlistEntry);
	XmFontListEntryFree(&fontlistEntry);
      }

#endif

	return(fontlist);

}
Beispiel #4
0
static ImotFont* motFindFont(const char* foundry, const char *standardfont)
{
  char xlfd[1024];
  XFontStruct* fontstruct;
  int i, count = iupArrayCount(mot_fonts);
  int is_underline = 0, is_strikeout = 0;

  ImotFont* fonts = (ImotFont*)iupArrayGetData(mot_fonts);

  /* Check if the standardfont already exists in cache */
  for (i = 0; i < count; i++)
  {
    if (iupStrEqualNoCase(standardfont, fonts[i].standardfont))
      return &fonts[i];
  }

  /* not found, create a new one */
  if (standardfont[0] == '-')
  {
    fontstruct = XLoadQueryFont(iupmot_display, standardfont);
    if (!fontstruct) return NULL;
    strcpy(xlfd, standardfont);
  }
  else
  {
    int size,
        is_bold = 0,
        is_italic = 0;
    char typeface[1024];
    const char* mapped_name;

    if (!iupFontParsePango(standardfont, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
      return NULL;

    mapped_name = iupFontGetXName(typeface);
    if (mapped_name)
      strcpy(typeface, mapped_name);

    fontstruct = motLoadFont(foundry, typeface, size, is_bold, is_italic, xlfd);
    if (!fontstruct) return NULL;
  }

  /* create room in the array */
  fonts = (ImotFont*)iupArrayInc(mot_fonts);

  strcpy(fonts[i].standardfont, standardfont);
  strcpy(fonts[i].xlfd, xlfd);
  fonts[i].fontstruct = fontstruct;
  fonts[i].fontlist = motFontCreateRenderTable(fontstruct, is_underline, is_strikeout);
  fonts[i].charwidth = motFontCalcCharWidth(fontstruct);
  fonts[i].charheight = fontstruct->ascent + fontstruct->descent;

  return &fonts[i];
}
Beispiel #5
0
// chargement des parametre commun a toutes les fenetres
void init_graphique(void){
	XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), "grey", &color_fond, &color_fond);
	XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), "DimGrey", &color_focus, &color_focus);
	XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), "WhiteSmoke", &color_fond_de_fen , &color_fond_de_fen );

	if ((font=XLoadQueryFont(dpy,"-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1"))==NULL){
	 	fprintf(stderr," Sorry, having font problems.\n");
	    exit(-1);
	}
	cursor= XCreateFontCursor(dpy, CODE_CURS_XC_draft_large);
}
Beispiel #6
0
static
void get_list(char *pattern)
{
    int           available = nnames+1,
                  i;
    char        **fonts;
    XFontStruct  *info;

    /* Get list of fonts matching pattern */
    for (;;) {
        if (open_instead_of_list) {
            info = XLoadQueryFont (dpy, pattern);

            if (info) {
                fonts = &pattern;
                available = 1;
                XUnloadFont (dpy, info->fid);
            } else {
                fonts = NULL;
            }
            break;
        }
            
        if (long_list == L_MEDIUM)
            fonts = XListFontsWithInfo(dpy, pattern, nnames, &available, &info);
        else
            fonts = XListFonts(dpy, pattern, nnames, &available);
        if (fonts == NULL || available < nnames)
            break;
        if (long_list == L_MEDIUM)
            XFreeFontInfo(fonts, info, available);
        else
            XFreeFontNames(fonts);
        nnames = available * 2;
    }

    if (fonts == NULL) {
        fprintf(stderr, "%s: pattern \"%s\" unmatched\n",
                program_name, pattern);
        return;
    }

    font_list = (FontList *)Realloc((char *)font_list,
            (font_cnt + available) * sizeof(FontList));
    for (i=0; i<available; i++) {
        font_list[font_cnt].name = fonts[i];
        if (long_list == L_MEDIUM)
            font_list[font_cnt].info = info + i;
        else
            font_list[font_cnt].info = NULL;
        
        font_cnt++;
    }
}
Beispiel #7
0
void set_value_font(Display *display, char *fontname)
{
  original_font_struct = Xcil_font_struct;
  value_font_struct = XLoadQueryFont(display, fontname);
  if (value_font_struct == 0)
    {
      fprintf(stderr,"フォント(%s)がロードできませんでした。\n", fontname);
      value_font_struct = Xcil_font_struct;
      return;
    }
}
Beispiel #8
0
/* Xlib font utils define */
static XFontStruct *LoadQueryScalableFont (Display * dpy, int screen, char *name, int size)
{
    int i, j, field;
    char newname[500];          /* big enough for a long font name */
    int res_x, res_y;           /* resolution values for this screen */
    /* catch obvious errors */
    if ((name == NULL) || (name[0] != '-'))
        return NULL;
    /* calculate our screen resolution in dots per inch. 25.4mm = 1 inch */
    res_x = DisplayWidth (dpy, screen) / (DisplayWidthMM (dpy, screen) / 25.4);
    res_y = DisplayHeight (dpy, screen) / (DisplayHeightMM (dpy, screen) / 25.4);
    /* copy the font name, changing the scalable fields as we do so */
    for (i = j = field = 0; name[i] != '\0' && field <= 14; i++)
    {
        newname[j++] = name[i];
        if (name[i] == '-')
        {
            field++;
            switch (field)
            {
            case 7:            /* pixel size */
            case 12:           /* average width */
                /* change from "-0-" to "-*-" */
                newname[j] = '*';
                j++;
                if (name[i + 1] != '\0')
                    i++;
                break;
            case 8:            /* point size */
                /* change from "-0-" to "-<size>-" */
                sprintf (&newname[j], "%d", size);
                while (newname[j] != '\0')
                    j++;
                if (name[i + 1] != '\0')
                    i++;
                break;
            case 9:            /* x-resolution */
            case 10:           /* y-resolution */
                /* change from an unspecified resolution to res_x or res_y */
                sprintf (&newname[j], "%d", (field == 9) ? res_x : res_y);
                while (newname[j] != '\0')
                    j++;
                while ((name[i + 1] != '-') && (name[i + 1] != '\0'))
                    i++;
                break;
            }
        }
    }
    newname[j] = '\0';
    /* if there aren't 14 hyphens, it isn't a well formed name */
    if (field != 14)
        return NULL;
    return XLoadQueryFont (dpy, newname);
}
Beispiel #9
0
static Bool
load_pointer_font( void)
{
	if ( !guts.pointer_font)
		guts.pointer_font = XLoadQueryFont( DISP, "cursor");
	if ( !guts.pointer_font) {
		warn( "Cannot load cursor font");
		return false;
	}
	return true;
}
Beispiel #10
0
static XFontStruct *XLQF(FILE *err, Display *disp, const char *name)
{
    XFontStruct *font = XLoadQueryFont(disp, name);
#ifdef DEBUG
    if (font != NULL)
    {
        fprintf(err, "Loaded font %s\n", name);
    }
#endif
    return font;
}
Beispiel #11
0
// load up a font
XFontStruct *
LoadFont(Display *display, char *font_name, char *fallback_font_name)
{
	// load up a font
	XFontStruct *font_struct = XLoadQueryFont(display, font_name);
	if (font_struct == NULL)
	{
		font_struct = XLoadQueryFont(display, fallback_font_name);
		if (font_struct == NULL)
		{
			fprintf(stderr, "unable to load font.", 
				font_name);
			fprintf(stderr, "unable to load font.", 
				fallback_font_name);
			return(NULL);
		}
	}

	// all done
	return(font_struct);
}
void Init_Help()
	{
	XGCValues gcv;
	unsigned long gcvm;

	gcvm=(GCFont | GCGraphicsExposures | GCForeground | GCBackground);

	gcv.graphics_exposures=False;
	gcv.foreground=white;
	gcv.background=black;

	if ( (SymbolFont=XLoadQueryFont(xw_display,SYMBOL_FONT)) == NULL)
		{ xw_fatal("Cannot load SYMBOL font.\n",__LINE__,__FILE__); }
	gcv.font=SymbolFont->fid;
	SymbolGC=XCreateGC(xw_display, xw_window, gcvm, &gcv);

	if ( (HeaderFont=XLoadQueryFont(xw_display,HEADER_FONT)) == NULL)
		{ xw_fatal("Cannot load HEADER font.\n",__LINE__,__FILE__); }
	gcv.font=HeaderFont->fid;
	HeaderGC=XCreateGC(xw_display, xw_window, gcvm, &gcv);
	}
Beispiel #13
0
Datei: draw.c Projekt: dylex/dzen
void
setfont(const char *fontstr) {
#ifndef DZEN_XFT
	char *def, **missing;
	int i, n;

	missing = NULL;
	if(dzen.font.set)
		XFreeFontSet(dzen.dpy, dzen.font.set);

	dzen.font.set = XCreateFontSet(dzen.dpy, fontstr, &missing, &n, &def);
	if(missing)
		XFreeStringList(missing);

	if(dzen.font.set) {
		XFontSetExtents *font_extents;
		XFontStruct **xfonts;
		char **font_names;
		dzen.font.ascent = dzen.font.descent = 0;
		font_extents = XExtentsOfFontSet(dzen.font.set);
		n = XFontsOfFontSet(dzen.font.set, &xfonts, &font_names);
		for(i = 0, dzen.font.ascent = 0, dzen.font.descent = 0; i < n; i++) {
			if(dzen.font.ascent < (*xfonts)->ascent)
				dzen.font.ascent = (*xfonts)->ascent;
			if(dzen.font.descent < (*xfonts)->descent)
				dzen.font.descent = (*xfonts)->descent;
			xfonts++;
		}
	}
	else {
		if(dzen.font.xfont)
			XFreeFont(dzen.dpy, dzen.font.xfont);
		dzen.font.xfont = NULL;
		if(!(dzen.font.xfont = XLoadQueryFont(dzen.dpy, fontstr)))
			eprint("dzen: error, cannot load font: '%s'\n", fontstr);
		dzen.font.ascent = dzen.font.xfont->ascent;
		dzen.font.descent = dzen.font.xfont->descent;
	}
	dzen.font.height = dzen.font.ascent + dzen.font.descent;
#else
        if(dzen.font.xftfont)
           XftFontClose(dzen.dpy, dzen.font.xftfont);
	dzen.font.xftfont = XftFontOpenXlfd(dzen.dpy, dzen.screen, fontstr);
	if(!dzen.font.xftfont)
	   dzen.font.xftfont = XftFontOpenName(dzen.dpy, dzen.screen, fontstr);
	if(!dzen.font.xftfont)
	   eprint("error, cannot load font: '%s'\n", fontstr);
	dzen.font.extents = malloc(sizeof(XGlyphInfo));
	XftTextExtentsUtf8(dzen.dpy, dzen.font.xftfont, (unsigned const char *) fontstr, strlen(fontstr), dzen.font.extents);
	dzen.font.height = dzen.font.xftfont->ascent + dzen.font.xftfont->descent;
	dzen.font.width = (dzen.font.extents->width)/strlen(fontstr);
#endif
}
Beispiel #14
0
void
initfont(const char *fontstr)
{
    char *def, **missing;
    int i, n;

    missing = NULL;
    if(dc.font.set)
        XFreeFontSet(dpy, dc.font.set);
    dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
    if(missing) {
        while(n--) {
            fprintf(stderr, "thingmenu: missing fontset: %s\n",
                    missing[n]);
        }
        XFreeStringList(missing);
    }
    if(dc.font.set) {
        XFontStruct **xfonts;
        char **font_names;
        dc.font.ascent = dc.font.descent = 0;
        n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
        for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
            dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
            dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent);
            xfonts++;
        }
    }
    else {
        if(dc.font.xfont)
            XFreeFont(dpy, dc.font.xfont);
        dc.font.xfont = NULL;
        if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
                && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
            die("error, cannot load font: '%s'\n", fontstr);
        dc.font.ascent = dc.font.xfont->ascent;
        dc.font.descent = dc.font.xfont->descent;
    }
    dc.font.height = dc.font.ascent + dc.font.descent;
}
Beispiel #15
0
XFontStruct *xLoadFont(Display *display, const char *fontname)

{

  XFontStruct *font;
  
  if((font = XLoadQueryFont(display, fontname)) == 0) {
    if((font = XLoadQueryFont(display, "fixed")) == 0) {
      fprintf(stderr, "ERROR - xLoadFont\n");
      fprintf(stderr, "Cannot find  font '%s'\n", fontname);
      fprintf(stderr, "Cannot find fixed font.\n");
      exit(1);
    } else {
      fprintf(stderr, "WARNING - xLoadFont\n");
      fprintf(stderr, "Cannot find  font '%s'\n", fontname);
      fprintf(stderr, "Using fixed font.\n");
    }
  }

  return font;

}
int XMessageBox::loadFont()
{
  // load the font
   mFS = XLoadQueryFont(mDisplay, 
      "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*");
   
   if (mFS == NULL)
      mFS = XLoadQueryFont(mDisplay, "fixed");

   if (mFS == NULL)
      return -1;

   // dummy call to XTextExtents to get the font specs
   XCharStruct strInfo;
   
   XTextExtents(mFS, "foo", 1, 
      &mFontDirection, &mFontAscent, &mFontDescent,
      &strInfo);

   mFontHeight = mFontAscent + mFontDescent;
   return 0;
}
Beispiel #17
0
XFontStruct*
#endif
JXFontManager::GetNewFont
	(
	const JCharacter*	name,
	const JCharacter*	charSet,
	const JSize			size,
	const JFontStyle&	style
	)
	const
{
#ifdef _J_USE_XFT
	double raw_size = size;
	XftFont* font = XftFontOpen(*itsDisplay, DefaultScreen((Display*)*itsDisplay),
									XFT_FAMILY, XftTypeString, name,
									XFT_SIZE, XftTypeDouble, raw_size,
									XFT_WEIGHT, XftTypeInteger, style.bold ? XFT_WEIGHT_BOLD : XFT_WEIGHT_MEDIUM,
									XFT_SLANT, XftTypeInteger, style.italic ? XFT_SLANT_ITALIC : XFT_SLANT_ROMAN, 0);
	return font;
#else
	const JCharacter* italicStr = kObliqueStr;	// try oblique before italic
	JBoolean iso                = JStringEmpty(charSet);

	XFontStruct* xfont = NULL;
	while (1)
		{
		JString xFontStr = BuildFontName(name, charSet, size, style, italicStr, iso);
		xfont            = XLoadQueryFont(*itsDisplay, xFontStr);
		if (xfont != NULL)
			{
			break;
			}

		if (strcmp(italicStr, kObliqueStr) == 0 && style.italic)
			{
			italicStr = kItalicStr;
			}
		else if (iso)
			{
			iso       = kJFalse;
			italicStr = kObliqueStr;
			}
		else
			{
			break;	// give up and return NULL
			}
		}

	return xfont;
#endif
}
Beispiel #18
0
void
gui_init (void)
{
	XGCValues gcv;
	XColor xcl;
	unsigned int i;
#ifndef XFT
	char *fontname;
#endif

	i = 0;
	do
	{
		xcl.red = cols[i].red;
		xcl.green = cols[i].green;
		xcl.blue = cols[i].blue;
		XAllocColor (dd, DefaultColormap (dd, scr_screen), &xcl);
		palette[i] = xcl.pixel;
		i++;
	}
	while (i < PALETTE_COUNT);

#ifdef XFT
	xfs = XftFontOpenName (dd, scr_screen, XFT_FONT);
#else
	fontname = FONT_NAME;
	do
	{
		xfs = XLoadQueryFont (dd, fontname);
		fontname = "fixed";
	}
	while (!xfs);
#endif

	gcv.graphics_exposures = False;
#ifdef XFT
	text_y = xfs->ascent + ((WINHEIGHT - (xfs->ascent + xfs->descent)) / 2);
	fore_gc = XCreateGC (dd, root_win, GCGraphicsExposures, &gcv);
#else
	text_y = xfs->ascent + ((WINHEIGHT - xfs->ascent) / 2);
	gcv.font = xfs->fid;
	fore_gc = XCreateGC (dd, root_win, GCFont | GCGraphicsExposures, &gcv);
#endif

#ifdef HAVE_XPM
	XpmCreatePixmapFromData (dd, root_win, icon_xpm, &generic_icon,
									 &generic_mask, NULL);
#else
	generic_icon = 0;
#endif
}
Beispiel #19
0
void InitHScrollBar(struct XObj *xobj)
{
 unsigned long mask;
 XSetWindowAttributes Attr;
 int i;
 int asc,desc,dir;
 XCharStruct struc;
 char str[20];

 /* Enregistrement des couleurs et de la police */
 MyAllocNamedColor(xobj->display,*xobj->colormap,xobj->forecolor,&xobj->TabColor[fore]); 
 MyAllocNamedColor(xobj->display,*xobj->colormap,xobj->backcolor,&xobj->TabColor[back]);
 MyAllocNamedColor(xobj->display,*xobj->colormap,xobj->licolor,&xobj->TabColor[li]); 
 MyAllocNamedColor(xobj->display,*xobj->colormap,xobj->shadcolor,&xobj->TabColor[shad]);
 MyAllocNamedColor(xobj->display,*xobj->colormap,"#000000",&xobj->TabColor[black]);
 MyAllocNamedColor(xobj->display,*xobj->colormap,"#FFFFFF",&xobj->TabColor[white]);

 mask=0;
 Attr.background_pixel=xobj->TabColor[back].pixel;
 mask|=CWBackPixel;
 Attr.cursor=XCreateFontCursor(xobj->display,XC_hand2); 
 mask|=CWCursor;		/* Curseur pour la fenetre */

 xobj->win=XCreateWindow(xobj->display,*xobj->ParentWin,
		xobj->x,xobj->y,xobj->width,xobj->height,0,
		CopyFromParent,InputOutput,CopyFromParent,
		mask,&Attr);
 xobj->gc=XCreateGC(xobj->display,xobj->win,0,NULL);
 XSetForeground(xobj->display,xobj->gc,xobj->TabColor[fore].pixel);
 XSetBackground(xobj->display,xobj->gc,xobj->TabColor[back].pixel);
 if ((xobj->xfont=XLoadQueryFont(xobj->display,xobj->font))==NULL)
   fprintf(stderr,"Can't load font %s\n",xobj->font);
 else
  XSetFont(xobj->display,xobj->gc,xobj->xfont->fid);

 XSetLineAttributes(xobj->display,xobj->gc,1,LineSolid,CapRound,JoinMiter);
 
 if ((xobj->value3-xobj->value2)<=0)
  xobj->value3=xobj->value2+10;
 if (!((xobj->value>=xobj->value2)&&(xobj->value<=xobj->value3)))
  xobj->value=xobj->value2;
 XTextExtents(xobj->xfont,"lp",strlen("lp"),&dir,&asc,&desc,&struc);
 xobj->height=(asc+desc)*2+30;
 sprintf(str,"%d",xobj->value2);
 i=XTextWidth(xobj->xfont,str,strlen(str));
 sprintf(str,"%d",xobj->value3);
 i=XTextWidth(xobj->xfont,str,strlen(str))+i+20;
 if (xobj->width<i)
  xobj->width=i;
 XResizeWindow(xobj->display,xobj->win,xobj->width,xobj->height);
}
Beispiel #20
0
/* Writes the string "Loading..." in the middle of the screen.
   This will presumably get blown away when the image finally loads,
   minutes or hours later...

   This is called by load_image_async_simple() but not by load_image_async(),
   since it is assumed that hacks that are loading more than one image
   *at one time* will be doing something more clever than just blocking
   with a blank screen.
 */
static void
print_loading_msg (Screen *screen, Window window)
{
  Display *dpy = DisplayOfScreen (screen);
  XWindowAttributes xgwa;
  XGCValues gcv;
  XFontStruct *f = 0;
  GC gc;
  char *fn = get_string_resource (dpy, "labelFont", "Font");
  const char *text = "Loading...";
  int w;

  if (!fn) fn = get_string_resource (dpy, "titleFont", "Font");
  if (!fn) fn = get_string_resource (dpy, "font", "Font");
  if (!fn) fn = strdup ("-*-times-bold-r-normal-*-180-*");
  f = XLoadQueryFont (dpy, fn);
  if (!f) f = XLoadQueryFont (dpy, "fixed");
  if (!f) abort();
  free (fn);
  fn = 0;

  XGetWindowAttributes (dpy, window, &xgwa);
  w = XTextWidth (f, text, (int) strlen(text));

  gcv.foreground = get_pixel_resource (dpy, xgwa.colormap,
                                       "foreground", "Foreground");
  gcv.background = get_pixel_resource (dpy, xgwa.colormap,
                                       "background", "Background");
  gcv.font = f->fid;
  gc = XCreateGC (dpy, window, GCFont | GCForeground | GCBackground, &gcv);
  XDrawImageString (dpy, window, gc,
                    (xgwa.width - w) / 2,
                    (xgwa.height - (f->ascent + f->descent)) / 2 + f->ascent,
                    text, (int) strlen(text));
  XFreeFont (dpy, f);
  XFreeGC (dpy, gc);
  XSync (dpy, False);
}
Beispiel #21
0
static Widget text_create(uschar *name, int height)
{
Widget textshell, form, text, button;

/* Create a popup shell widget to display as an additional
toplevel window. */

textshell = XtCreatePopupShell("textshell", topLevelShellWidgetClass,
  toplevel_widget, NULL, 0);
xs_SetValues(textshell, 4,
  "title",     name,
  "iconName",  name,
  "minWidth",  100,
  "minHeight", 100);

/* Create a form widget, containing the text widget and the
dismiss button widget. */

form = XtCreateManagedWidget("textform", formWidgetClass,
  textshell, NULL, 0);
xs_SetValues(form, 1, "defaultDistance", 8);

text = XtCreateManagedWidget("texttext", asciiTextWidgetClass,
  form, text_arg, XtNumber(text_arg));
xs_SetValues(text, 4,
  "editType",        XawtextAppend,
  "width",           700,
  "height",          height,
  "translations",    text_trans);
XawTextDisplayCaret(text, TRUE);

/* Use the same font as for the queue display */

if (queue_font != NULL)
  {
  XFontStruct *f = XLoadQueryFont(X_display, CS queue_font);
  if (f != NULL) xs_SetValues(text, 1, "font", f);
  }

button_arg[0].value = (XtArgVal)text;
button = XtCreateManagedWidget("dismiss", commandWidgetClass,
  form, button_arg, XtNumber(button_arg));
XtAddCallback(button, "callback",  dismissAction, (XtPointer)textshell);

/* Get the toplevel popup displayed, and yield the text widget so
that text can be put into it. */

XtPopup(textshell, XtGrabNone);
return text;
}
Beispiel #22
0
static XFontStruct *XLoadQueryFontX(Display *display, char *name)
{
    XFontStruct *result = NULL;
    result = XLoadQueryFont(display, name);
#if FONT_DEBUG < 2
    if (result == NULL)
#endif
        fprintf(stderr, "XLoadQueryFont(\"%s\") -> 0x%x.\n", name, result);
#if FONT_DEBUG >= 3
    if (result == NULL)
        exit(-1);
#endif
    return result;
}
Beispiel #23
0
static Bool
load_font (ModeInfo *mi, char *res, XFontStruct **fontP, GLuint *dlistP)
{
#ifdef STANDALONE
  const char *font = get_string_resource (res, "Font");
#else
  const char *font = res;
#endif
  XFontStruct *f;
  Font id;
  int first, last;

  if (!font) font = "-*-times-bold-r-normal-*-180-*";

  f = XLoadQueryFont(MI_DISPLAY(mi), font);
  if (!f) f = XLoadQueryFont(MI_DISPLAY(mi), "fixed");

  id = f->fid;
  first = f->min_char_or_byte2;
  last = f->max_char_or_byte2;

  clear_gl_error ();
  *dlistP = glGenLists ((GLuint) last+1);
  if (check_gl_error ("glGenLists"))
	return False;
  /*-
   * PURIFY reports a cumulative memory leak on the next line with Mesa 3.4.1
   * on Solaris 2.X and SunOS 4.1.X. This can be fixed with a patch to Mesa
   * 3.4.1. OpenGL on Solaris does not have the memory leak.
   */
  glXUseXFont(id, first, last-first+1, *dlistP + first);
  if (check_gl_error ("glXUseXFont"))
	return False;

  *fontP = f;
  return True;
}
Beispiel #24
0
/* function to build our font list */
GLvoid buildFont( GLvoid )
{
    Display *dpy;          /* Our current X display */
    XFontStruct *fontInfo; /* Our font info */

    /* Sotrage for 96 characters */
    base = glGenLists( 96 );

    /* Get our current display long enough to get the fonts */
    dpy = XOpenDisplay( NULL );

    /* Get the font information */
    fontInfo = XLoadQueryFont( dpy, "-adobe-helvetica-medium-r-normal--18-*-*-*-p-*-iso8859-1" );

    /* If the above font didn't exist try one that should */
    if ( fontInfo == NULL )
    {
        fontInfo = XLoadQueryFont( dpy, "fixed" );
        /* If that font doesn't exist, something is wrong */
        if ( fontInfo == NULL )
        {
            fprintf( stderr, "no X font available?\n" );
            Quit( 1 );
        }
    }

    /* generate the list */
    glXUseXFont( fontInfo->fid, 32, 96, base );

    /* Recover some memory */
    XFreeFont( dpy, fontInfo );

    /* close the display now that we're done with it */
    XCloseDisplay( dpy );

    return;
}
Beispiel #25
0
Fnt *
draw_font_create(Draw *draw, const char *fontname) {
	Fnt *font;
	char *def, **missing;
	int n;

	if(!draw)
		return NULL;
	font = (Fnt *)calloc(1, sizeof(Fnt));
	font->set = XCreateFontSet(draw->dpy, fontname, &missing, &n, &def);
	if(missing) {
		while(n--)
			fprintf(stderr, "draw: missing fontset: %s\n", missing[n]);
		XFreeStringList(missing);
	}
	if(font->set) {
		XFontStruct **xfonts;
		char **font_names;

		XExtentsOfFontSet(font->set);
		n = XFontsOfFontSet(font->set, &xfonts, &font_names);
		while(n--) {
			font->ascent = MAX(font->ascent, (*xfonts)->ascent);
			font->descent = MAX(font->descent,(*xfonts)->descent);
			xfonts++;
		}
	}
	else {
		if(!(font->xfont = XLoadQueryFont(draw->dpy, fontname))
		&& !(font->xfont = XLoadQueryFont(draw->dpy, "fixed")))
			die("error, cannot load font: '%s'\n", fontname);
		font->ascent = font->xfont->ascent;
		font->descent = font->xfont->descent;
	}
	font->h = font->ascent + font->descent;
	return font;
}
int
main(int argc, char *argv[])
{
  int c;
  TexGlyphInfo tgi;
  int usageError = 0;
  char *varname, *fontname;
  XFontStruct *xfont;
  int i;

  if (argc == 3) {
     varname  = argv[1];
     fontname = argv[2];
     }
  else
     usageError = 1;

  if (usageError) {
    fprintf(stderr, "\n");
    fprintf(stderr, "usage: genfontfile variable_name X_font_name\n");
    fprintf(stderr, "\n");
    exit(1);
  }

  dpy = XOpenDisplay(NULL);
  if (!dpy) {
    fprintf(stderr, "could not open display\n");
    exit(1);
  }
  /* find an OpenGL-capable RGB visual with depth buffer */
  xfont = XLoadQueryFont(dpy, fontname);
  if (!xfont) {
    fprintf(stderr, "could not get load X font: %s\n", fontname);
    exit(1);
  }
  fontinfo = SuckGlyphsFromServer(dpy, xfont->fid);
  if (!fontinfo) {
    fprintf(stderr, "could not get font glyphs\n");
    exit(1);
  }

  printf("static const %s[][%d] = {\n", varname, fontinfo->max_ascent + fontinfo->max_descent + 2);
  for (c = 32; c < 256; c++) {
      getMetric(fontinfo, c, &tgi);
      printGlyph(fontinfo, c);
      }
  printf("  };\n");
  return 0;
}
Beispiel #27
0
void Initialize()
{

    disp = XOpenDisplay(NULL); // open $DISPLAY
    win = XCreateSimpleWindow(disp,						// ディスプレイ
				DefaultRootWindow(disp),			// 親ウィンドウ
				0, 0,						// (x, y)
				640, 480,					// 幅・高さ
				0,						// border width
				0,						// border color
				WhitePixel(disp, DefaultScreen(disp)));		// background color
    XMapWindow(disp, win);

    /* ウィンドウに関連付けられたグラフィックコンテキストを作る */
    gc = XCreateGC(disp, win, 0, NULL);
    XSetForeground(disp, gc,
		   BlackPixel(disp, DefaultScreen(disp)));

    // 暴露イベントとキー押下イベントを受け取る。
    XSelectInput(disp, win, ExposureMask | KeyPressMask);

    font = XLoadQueryFont(disp, FONT);
    XSetFont(disp, gc, (font)->fid);

    Colormap colormap;
    colormap = DefaultColormap(disp, 0);

    XParseColor(disp, colormap, "#00AA00", &Color.green);
    XAllocColor(disp, colormap, &Color.green);

    XParseColor(disp, colormap, "gray50", &Color.gray50);
    XAllocColor(disp, colormap, &Color.gray50);

    XParseColor(disp, colormap, "gray80", &Color.gray80);
    XAllocColor(disp, colormap, &Color.gray80);

    XParseColor(disp, colormap, "cyan3", &Color.skyblue);
    XAllocColor(disp, colormap, &Color.skyblue);

    control_gc = XCreateGC(disp, win, 0, NULL);
    XSetFont(disp, control_gc, (font)->fid);
    XSetForeground(disp, control_gc, Color.skyblue.pixel);

    margin_gc = XCreateGC(disp, win, 0, NULL);
    XSetForeground(disp, margin_gc, Color.gray80.pixel);

    cursor_gc = XCreateGC(disp, win, 0, NULL);
    XSetForeground(disp, cursor_gc, Color.green.pixel);
}
Beispiel #28
0
int
main(int argc, char **argv)
{
    XtAppContext app;
    XmFontList fontlist;
    XmString xmstr1 = XmStringCreateLtoR("Here\nIs\nA\nLabel", "MY_FONT");
    Atom XA_MWM_MESSAGES, PUNT;
    char buf[256];

    XtSetLanguageProc(NULL, NULL, NULL);

    toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, FallBack, NULL);

    fontlist = XmFontListAppendEntry(NULL,
                                     XmFontListEntryCreate("MY_FONT",
                                             XmFONT_IS_FONT,
                                             XLoadQueryFont(XtDisplay(toplevel),
                                                     "-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1")));

    one = XtVaCreateManagedWidget("One",
                                  xmPushButtonWidgetClass,
                                  toplevel, XmNfontList, fontlist,
                                  XmNlabelString, xmstr1,
                                  XtNborderWidth, 20,
                                  NULL);
    XtAddCallback(one, XmNactivateCallback, cb, NULL);


    XA_MWM_MESSAGES = XmInternAtom(XtDisplay(toplevel), _XA_MWM_MESSAGES, False);
    XmAddWMProtocols(toplevel, &XA_MWM_MESSAGES, 1);
    PUNT = XmInternAtom(XtDisplay(toplevel), "PUNT", False);
    XmAddProtocolCallback(toplevel, XA_MWM_MESSAGES, PUNT, punt, NULL);

    sprintf(buf, MENU, PUNT);
    XtVaSetValues(toplevel, XmNmwmMenu, buf, NULL);

    XtRealizeWidget(toplevel);


    {
        static XtWidgetGeometry Expected[] = {
            CWWidth | CWHeight            ,   50,   50,   57,   84, 0,0,0, /* One */
        };
        PrintDetails(  toplevel ,Expected);
    };
    LessTifTestMainLoop(  toplevel );

    exit(0);
}
Beispiel #29
0
/*
 * Set specified font for that GC.
 * Return font that is used for this GC, even if setting a new
 * font failed (return default font in that case).
 */
static XFontStruct* Set_font(Display* display, GC gc,
			     const char* fontName,
			     const char *resName)
{
    XFontStruct*	font;

    if ((font = XLoadQueryFont(display, fontName)) == NULL) {
	error("Couldn't find font '%s' for %s, using default font",
	      fontName, resName);
	font = XQueryFont(display, XGContextFromGC(gc));
    } else
	XSetFont(display, gc, font->fid);

    return font;
}
Beispiel #30
0
static void
load_font(XFontStruct **font_info, char *fontname)
{
   if ((*font_info = XLoadQueryFont(gXDisplay, fontname)) == NULL) {
        fprintf(stderr, "(HyperDoc) Cannot load font %s ; using default.\n",
            fontname);

        if ((*font_info = XQueryFont(gXDisplay,
               XGContextFromGC(DefaultGC(gXDisplay, gXScreenNumber)))) == NULL)
        {
            fprintf(stderr, "(HyperDoc) Cannot get default font ; exiting.\n");
            exit(-1);
        }
   }
}