|
I don't think so.. QueryFont gives me a fat nada when I use GC,
This may require accessing the FONT property for the application
root window, then a LoadQuery using the newly-obtained value
for the FONT name.
I'll work on this tomorrow and post a solution.
So many Xlib calls to get font charateristics, yet none will simply
tell me the name of the current font.... why is that?
|
| Ha...that's right. Since XLIB does not know whether you are giving it a font
or a GC, it does not know whether to take the number directly (for a font) or
use it as a pointer to its local GC structure to get the GCID which the server
really wants.
I'm glad that DEC is not the only place that the right and left hands don't
communicate. (Well, actually, XLib was designed at DEC and the server protocol
was designed at MIT, so it was only half DEC).
Burns
|
|
Thanks, Burns..
It just seems reasonable that after going to the trouble to
get a GContextID, that QueryFont would give me
a useful fid instead of the selfsame GContextID I already
know about.
I think that the best alternative will turn out to use XGetWindowProperty
and extract the value of the FONT_NAME property of a window with the
desired font.
|
| #include <X11/DECwDwtWidgetProg.h>
#include <stdio.h>
/*-------------------------------------------------------------+
| get_font_name - Search default resource files for a font |
| for this application name/class. |
| |
| First, the user's .Xdefaults is searched |
| for "app-name.Font" or "app-name.font" |
| |
| If no font is found, the default resource |
| file "/usr/lib/X11/app-defaults/"app-name" |
| is searched. |
| |
| If this is unsuccessful, the font "fixed" |
| is returned. |
| |
| DEC ISVG/West - rah 3/90 |
+-------------------------------------------------------------*/
char *get_font_name(app_name)
char *app_name;
{
char str_ret[40],
*font_name,
class_str[40],
name_str[40],
app_def_str[40],
home_dir_str[40],
*get_home_dir();
XrmDatabase database;
XrmValue value_ret;
static char default_font_name[]="fixed";
strcpy(home_dir_str,get_home_dir());
strcat(home_dir_str,"/.Xdefaults");
strcpy(class_str,app_name);
strcat(class_str,".Font");
strcpy(name_str,app_name);
strcat(name_str,".font");
strcpy(app_def_str,"/usr/lib/X11/app-defaults");
strcat(app_def_str,"/");
strcat(app_def_str,app_name);
/* checking .Xdefaults */
if ((database = XrmGetFileDatabase(home_dir_str)) != NULL) {
strcpy(name_str,".font");
strcpy(class_str,".Font");
XrmGetResource(database,name_str,class_str,str_ret,&value_ret);
}
/* see if there is a name here */
if (value_ret.size)
font_name = value_ret.addr;
/* else check apps-default */
else if ((database = XrmGetFileDatabase(app_def_str)) != NULL) {
XrmGetResource(database,name_str,class_str,str_ret,&value_ret);
}
/* see if there is a name here */
if (value_ret.size)
font_name = value_ret.addr;
else {
/* no name found, so punt with "fixed" */
font_name = default_font_name;
}
return(font_name);
}
|