Problem
I want to use fontsets to display multibyte characters in Motif Widgets.
Solution
The attached example program creates a Labelwidget, a Textwidget
and a Pushbutton in a Bulletinboard Widget. A Shift-JIS encoded
string called KANJI is to be displayed in all those widgets.Compile this example with:$ cc -b elf -o main main.c -lXm -lXt -lX11 -lsocketand start it with:$ LANG=ja_JP.SJIS ./main -xrm "*fontList : \
-jis-fixed-medium-r-normal--16-110-100-100-c-160-jisx0208.1983-0\;\
-sony-fixed-medium-r-normal--16-120-100-100-c-80-jisx0201.1976-0\;\
-adobe-helvetica-bold-o-normal--17-120-100-100-p-92-iso8859-1\:"Note: This command line specifies a "fontList" which consists of
one fontset. It is only for demonstration purposes that this
resource is loaded from the command line.------------------------ Example program starts here ---------------------------
#include <Xm/Xm.h>
#include <Xm/Text.h>
#include <Xm/Label.h>
#include <Xm/BulletinB.h>
#include <Xm/PushB.h>#define MotifString( A ) ( XmStringLtoRCreate( (A), XmSTRING_DEFAULT_CHARSET ) )/* Shift-JIS encoded - see page 73 of "Japanese Information Processing/Ken Lunde" */
#define KANJI "\202\251\202\310\212\277\216\232\nThis string means kana [and] kanji"main(argc, argv)
int argc;
char *argv[];
{
XtAppContext app_con;
Widget top,text, label, bulletin, button;
XFontSet fontset;XtSetLanguageProc(NULL,NULL,NULL);top=XtVaAppInitialize( &app_con, "Text", NULL, 0, &argc, argv, NULL, NULL );
bulletin=XtVaCreateManagedWidget("bulletin", xmBulletinBoardWidgetClass,
top,
XmNwidth, 500,
XmNheight, 400,
NULL);label=XtVaCreateManagedWidget("label", xmLabelWidgetClass,
bulletin,
XmNx, 0,
XmNy, 0,
XmNlabelString, MotifString(KANJI),
NULL);text=XtVaCreateManagedWidget("text", xmTextWidgetClass,
bulletin,
XmNx, 0,
XmNy, 100,
XmNvalue, KANJI,
XmNrows, 5,
XmNwordWrap, True,
XmNeditMode, XmMULTI_LINE_EDIT,
NULL);button=XtVaCreateManagedWidget("button", xmPushButtonWidgetClass,
bulletin,
XmNx, 0,
XmNy, 250,
XmNlabelString, MotifString(KANJI),
NULL); XtRealizeWidget(top);
XtAppMainLoop(app_con);
}
------------------------ Example program ends here --------------------------- See also
XmFontList(Xm); Ken Lunde's Japanese Information Processing, O'Reilly & Associates Inc.