Sample Usage of utf-8 in OM 2.3 beta

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

3 posts / 0 new
Last post
Sample Usage of utf-8 in OM 2.3 beta

Submitted by Mark on Thu, 12/08/2005 - 16:47.

Hi,

We had a few requests for some suggestions on how to try out utf8 fonts.

The following sample shows how you can use utf8 through render tables.

---
#include
#include
//#include
#include
#include
#include
#include

Pixel ConvertStringToPixel (Widget widget, char *name)
{
XrmValue from_value, to_value; /* For resource conversion */

from_value.addr = name;
from_value.size = strlen( name ) + 1;
to_value.addr = NULL;
XtConvertAndStore (widget, XmRString, &from_value, XmRPixel, &to_value);

if (to_value.addr) {
return (*((Pixel*) to_value.addr)) ;
}

return XmUNSPECIFIED_PIXEL ;
}

int main(int argc, char *argv[])
{
XtAppContext appContext;
Widget toplevel, form, label, text;
XmString s1,s2;
XmRendition rendition;
XmRenderTable rtable;
Arg args[14];
Cardinal n;

String fallback[] = {
"*label.labelString: compound_string(\"?????????_int\")",
"*label1.renderTable: one",
"*label2.renderTable: two",
"*label3.renderTable: three",

"*one.fontType: FONT_IS_FONTSET",
"*one.fontName: -*-*-medium-r-normal-*-14-*-*-*-*-*-*-*:",

"*two.fontType: FONT_IS_XFT",
"*two.fontName: Times",
"*two.fontSize: 10",

"*three.fontType: FONT_IS_FONTSET",
"*three.fontName: -*-*-*-*-*-*-*-*-*-*-*-*-iso10646-*",
NULL
};

XtSetLanguageProc(NULL, NULL, NULL);
toplevel = XtVaAppInitialize(&appContext, "app",
NULL, 0, &argc, argv, fallback,
XmNtitle, "?????????",
NULL);
form = XtVaCreateWidget("form", xmFormWidgetClass, toplevel,
NULL);
XtManageChild(form);

char string1[] = "???? (Japanese)";
label = XtVaCreateManagedWidget("label1",
xmLabelGadgetClass, form,
XmNlabelString,
s1=XmStringCreateSimple(string1),
XmNtopAttachment, XmATTACH_FORM,
NULL);
XmStringFree(s1);

char string2[] = "?????? (Ukrainian)";
label = XtVaCreateManagedWidget("label2",
xmLabelGadgetClass, form,
XmNlabelString,
s1=XmStringCreateSimple(string2),
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, label,
NULL);
XmStringFree(s1);

char string3[] = "Ge?? sa? (Greek)";
label = XtVaCreateManagedWidget("label3",
xmLabelGadgetClass, form,
XmNlabelString,
s1=XmStringCreateSimple(string3),
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, label,
NULL);
XmStringFree(s1);

XtRealizeWidget(toplevel);
XtAppMainLoop(appContext);
return 0;
};//adobe-helvetiva-bold-r-normal--10-100-75-75-*-*-*-*

Thu, 12/08/2005 - 16:49#1

Thu, 12/08/2005 - 16:49#1

Mark

fontlists and utf8

Want to use fontlists instead of render tables? Then change the lines:

*label1.renderTable: one
*one.fontType: FONT_IS_FONTSET
*one.fontName: -*-*-medium-r-normal-*-14-*-*-*-*-*-*-*:

to:

*label1.fontList: -*-*-medium-r-normal-*-14-*-*-*-*-*-*-*:

 

Wed, 02/08/2006 - 21:58#2

Wed, 02/08/2006 - 21:58#2

megan

Sample Usage of utf-8 in OM 2.3 beta

For more information on this topic, see the following whitepaper:
Anti-aliased Fonts and UTF-8 Support in OpenMotif 2.3