ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
In my programming,I write below:
n=0;
XtSetArg(args[n],XmNwidth,250);n++;
XtSetArg(args[n],XmNheight,150);n++;
XtSetArg(args[n],XmNfontList,"-adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1");n++;
mybutton=XmCreatePushButton(parent_f,"parent_f",args,n);
when I compile my programming,there is an error,below:
X Error of failed request: BadFont (invalid Font parameter)
Major opcode of failed request: 55 (X_CreateGC)
Resource id in failed request: 0x1200017
Serial number of failed request: 153
Current serial number in output stream: 160
Help!!!!
i know there is an error in :XtSetArg(args[n],XmNfontList,"-adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1").
How do I correct it?
Help !!!!!!!
thanks.
Did you do an "xlsfonts|grep 'adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1' to verify that you actually have that font on your system?
OK!paulsm4,thanks!
now the master question is resolved.but there is still a question.My programming is below:
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/PushB.h>
void main(argc,argv)
unsigned int argc;
unsigned **argv;
{
Widget toplevel;
Widget mybutton;
XtAppContext app_context;
Arg args[10];
int n;
toplevel=XtAppInitialize(&app_context,"XMdemos",NULL,0,&argc,argv,NULL,NULL,0);
btn_text=XmStringCreateLtoR("中国北京",XmSTRING_DEFAULT_CHARSET); /*中国北京 is a Chinese string.*/
XFontStruct *font=NULL;
XmFontList fontlist=NULL;
char *namestring=NULL;
namestring="-adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1"; /* this is a Chinese font */
font=XLoadQueryFont(XtDisplay(mybutton),namestring);
fontlist=XmFontListCreate(font,XmSTRING_DEFAULT_CHARSET);
When i run my programming,what the "mybutton"display is not "中国北京".
How can I do whit it? thanks!!!!!
I come from China.
Can you tell me another Chinese_font's name?
I do as you said.
"btn_text=XmStringCreateLtoR("中国北京",XmSTRING_DEFAULT_CHARSET);" is be changed as "btn_text = XmStringCreateLocalized("中国北京", XmFONTLIST_DEFAULT_TAG);"
When I compile my programming,the result is below:
[cring@localhost cring]$ cc -o xmbutton xmbutton.c -L/usr/X11R6/lib -lXm -lXt -lX11
xmbutton.c: In function `main':
xmbutton.c:19: warning: passing arg 6 of `XtAppInitialize' from incompatible pointer type
xmbutton.c:20: too many arguments to function `XmStringCreateLocalized'
xmbutton.c:12: warning: return type of `main' is not `int'
[cring@localhost cring]$
when I "man XmStringCreateLocalized",I know XmStringCreateLocalized has only one parameter which is "char *name".
keefaz:I do as you said,and I also run the version that you compiles fine.but the result is no right,the character displayed on "mybutton" is"涓????含",this is not right.the character displayed on mybutton should be "中国北京".
Is there something wrong with my Linux system.My system is Red Hat Linux 9.0.
the font "-adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1" is not on my RHL9.0 system,later I install it on my OS.The font-file I get is from Tru64 UNIX system.
The font_file of "-adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1" is:adecw_screen_gb2312_16_18_75.pcf which I get from Tru64 Unix system.I install it on Red Hat Linux9.0.
When I run command below:
-----------------------
[cring@localhost cring]$ xlsfonts | grep screen
adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1
[cring@localhost cring]$
-----------------------
the font is indeed in my RHL9.0 system.
I guess the problem is as you said.
In my RHL9.0 system,the context of /etc/sysconfig/i18n is below:
LANG="zh_CN.GB18030"
LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en:ja_JP.eucJP:ja_JP:ja"
SYSFONT="lat0-sun16"
SYSFONTACM="8859-15"
Is the problem in here?How can I add my fontname of ""-adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1" to my system LANG?
Setting the environment variable "$LANG" sets the "locale". The locale helps determine which character set will be used in your Xt/Motif application (it does sound like you're using Motif, aren't you?)
Thanks a lot.I will try my best to understand what you said.
I believe I must be understand this about font problems.
I will see you give me the materials in above link.
Thanks a lot!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.