Display wide character text - Motif

This is a discussion on Display wide character text - Motif ; Hi, you can see below a partially working test program. What works: - some widechar text (Western European, Arabic, Cyrillic, Japanese in an older version) is displayed What does not work: - some widechar text (Japanese and Hebrew) is not ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Display wide character text

  1. Display wide character text

    Hi,
    you can see below a partially working test program. What works:

    - some widechar text (Western European, Arabic, Cyrillic, Japanese
    in an older version) is displayed

    What does not work:

    - some widechar text (Japanese and Hebrew) is not displayed
    - Arabic text is displayed left-to-right and without ligatures
    - the text is only displayed under ja_JP.UTF-8 locale; funnily enough
    japanese text is not displayed; I tried ja_JP.eucJP and it_IT.UTF-8
    to
    see if either Japanese locale or UTF-8 encoding made a diffeence.
    They did
    not.

    Could somebody kindly point my in the right direction/provide some
    example
    code (small and self-contained would be wonderful, but I am not
    choosy...).
    I am not interested in XmText yet.

    Thanks in advance!
    Mattia

    #include
    #include
    #include
    #include
    #include
    #include
    #include

    static char line[1024];

    struct pair {
    const char* reg;
    const char* enc;
    };

    static struct pair encodingsx[] = {
    { "jisx*", "*" }
    };

    static struct pair encodings[] = {
    { "iso8859", "1" },
    { "iso8859", "2" },
    { "iso8859", "3" },
    { "iso8859", "4" },
    { "iso8859", "5" },
    { "iso8859", "7" },
    { "iso8859", "8" },
    { "iso8859", "9" },
    { "iso8859", "10" },
    { "iso8859", "11" },
    { "iso8859", "13" },
    { "iso8859", "14" },
    { "iso8859", "15" },
    { "iso8859", "16" },
    { "gb2312.1980", "0" },
    { "jisx0201.1976", "0" },
    { "jisx0208.1983", "0" },
    { "koi8", "r" },
    { "ksc5601.1987", "0" },
    { "iso10646", "1" },
    // { "*", "*" }
    };

    main( Cardinal argc, char **argv )
    {
    XtAppContext actx;
    Widget wlist[3];
    Arg al[5];
    Cardinal ac = 0;
    short i=999;
    int j;
    XmString label;
    XmRendition rendition;
    XmRendition renditions[20];
    XmRenderTable renderTable;
    Arg args[5];
    int count = 0;
    char buffer[1024];

    FILE* in = fopen(argv[1], "r");

    memset(line, 0, sizeof(line));
    printf("read %d bytes\n", fread(line, 1, 254, in));
    XtSetLanguageProc(NULL, NULL, NULL);

    wlist[0] = XtAppInitialize(&actx, "TestI18N",
    (XrmOptionDescList) NULL, 0, &argc, argv, NULL,
    (ArgList) NULL, 0);

    label = XmStringGenerate(line, NULL,
    XmWIDECHAR_TEXT,
    (XmStringTag)"");

    wlist[2] = XtVaCreateManagedWidget("pushme",
    xmLabelWidgetClass, wlist[0],
    XmNlabelString, label,
    NULL);

    for( j = 0; j < sizeof(encodings)/sizeof(encodings[0]); ++j ) {
    char *re = malloc(100);

    sprintf(buffer, "-*-*-*-*-*-*-*-*-*-*-*-*-%s-%s",
    encodings[j].reg, encodings[j].enc);
    sprintf(re, "%s-%s", encodings[j].reg, encodings[j].enc);

    count = 0;
    XtSetArg( args[count], XmNfontName, buffer ); ++count;
    XtSetArg( args[count], XmNfontType, XmFONT_IS_FONTSET );
    ++count;
    renditions[j] = XmRenditionCreate( wlist[2],
    (XmStringTag) "",
    args, count );
    }

    renderTable = XmRenderTableAddRenditions( NULL, renditions, j,
    XmMERGE_REPLACE );

    XtVaSetValues( wlist[2],
    XmNrenderTable, renderTable,
    NULL );

    XtVaSetValues( wlist[0], XmNx, 200, XmNy, 200, NULL );

    XtManageChild( wlist[2] );
    XtRealizeWidget( wlist[0] );

    XtAppMainLoop( actx );
    }


  2. Re: Display wide character text

    utf-8 support is not yet supported by Motif. OpenMotif 2.3 includes
    this feature and I believe it is implemented in the HEAD. See
    cvs.openmotif.org.

    Mark


  3. Re: Display wide character text

    Thanks! Too bad I did not find a definitive answer on it before.
    It would have been nicer if Motif at least signaled it could not
    possibly display the characters.

    Best regards
    Mattia


+ Reply to Thread