Virtuoso (R) and Windowmaker

Discussion in 'Cadence' started by Satya Mishra, Jun 7, 2005.

  1. Satya Mishra

    Satya Mishra Guest

    Hi All

    Here's a pesky problem I am trying to deal with, but have found no
    easy solution.

    With IC5.0 Cadence decided that they must let the engineers who use
    their products know that Virtuoso is a registered trademark. So they
    included in the title the ISO-8859-1 character 0xae. Now I like
    Windowmaker as my window manager. It uses UTF-8 for displaying title
    bar. UTF-8 and ISO-8859-1 have the same characters upto 0x7f. But 0xae
    is not a valid UTF-8 character and Windowmaker chops off the rest of
    the title.

    Does anyone know if there is a way to make the window title encoding
    UTF-8 in Virtuoso?

    Any help would be greatly appreciated.

    Regards
    Satya
     
    Satya Mishra, Jun 7, 2005
    #1
  2. Hm... most of the DFII tools are pretty much locale unaware.

    I can supply a hack, but I must emphasize that this is a very, very
    extreme and unsanctioned hack -- use it only on your own, personal DFII
    install, and only if this is keeping you from getting work done and you
    can't find a way to force WindowMaker to use ISO-8859-1 encoding, and
    don't expect anyone here to provide support...

    (Anyone else who might be reading this from Cadence... you didn't see
    this. :)

    Compile the attached C program (to, say, ~/changetm), and then:
    cd DFIIDirectory/tools/dfII/etc/context
    ~/changetm *.cxt

    This will insert a binary hack to convert every instance of Virtuoso\xae
    to VirtuosoR.

    --
    David Cuthbert dacut at cadence dot com
    Cadence Design Systems +1 (412) 599-1820

    #include <errno.h>
    #include <limits.h>
    #include <stdio.h>
    #include <stdlib.h>

    void translate(FILE *infd, FILE *outfd)
    {
    /* Implementation of a DFA (deterministic finite automaton) for
    * changing any occurrence of Virtuoso\xae to VirtuosoR.
    */

    int c;

    /* State: Nothing of interest seen yet. */
    begin:
    if ((c = fgetc(infd)) != 'V') {
    if (c == EOF) return;
    fputc(c, outfd);
    goto begin;
    }

    /* State: seen "V" */
    state1:
    if ((c = fgetc(infd)) != 'i') {
    fputs("V", outfd);
    goto checkForV;
    }

    /* State: seen "Vi" */
    if ((c = fgetc(infd)) != 'r') {
    fputs("Vi", outfd);
    goto checkForV;
    }

    /* State: seen "Vir" */
    if ((c = fgetc(infd)) != 't') {
    fputs("Vir", outfd);
    goto checkForV;
    }

    /* State: seen "Virt" */
    if ((c = fgetc(infd)) != 'u') {
    fputs("Virt", outfd);
    goto checkForV;
    }

    /* State: seen "Virtu" */
    if ((c = fgetc(infd)) != 'o') {
    fputs("Virtu", outfd);
    goto checkForV;
    }

    /* State: seen "Virtuo" */
    if ((c = fgetc(infd)) != 's') {
    fputs("Virtuo", outfd);
    goto checkForV;
    }

    /* State: seen "Virtuos" */
    if ((c = fgetc(infd)) != 'o') {
    fputs("Virtuos", outfd);
    goto checkForV;
    }

    /* State: seen "Virtuoso" */
    if ((char)(c = fgetc(infd)) != '\xae') {
    fputs("Virtuoso", outfd);
    goto checkForV;
    }

    /* State: seen "Virtuoso\xae" */
    fputs("VirtuosoR", outfd);
    goto begin;

    /* Figure out whether we should transition to the main "idle" state,
    the "seen V" state, or exit. */
    checkForV:
    switch (c) {
    case 'V':
    goto state1;

    case EOF:
    return;

    default:
    fputc(c, outfd);
    goto begin;
    }
    }

    int main(int argc, char *argv[])
    {
    int errors = 0;
    int argp;
    char const *filename;
    char filename_orig[PATH_MAX];
    FILE *infd, *outfd;

    for (argp = 1; argp < argc; ++argp) {
    filename = argv[argp];

    if ((infd = fopen(filename, "rb")) == NULL) {
    fprintf(stderr, "Could not open %s for reading: %s\n",
    filename, strerror(errno));
    errors = 1;
    continue;
    }

    fclose(infd);

    sprintf(filename_orig, "%s.orig", filename);
    if (rename(filename, filename_orig) != 0) {
    fprintf(stderr, "Could not rename %s to %s: %s\n",
    filename, filename_orig, strerror(errno));
    errors = 1;
    continue;
    }

    if ((infd = fopen(filename_orig, "rb")) == NULL) {
    fprintf(stderr, "Could not open %s for reading: %s\n",
    filename_orig, strerror(errno));
    rename(filename_orig, filename); /* ignore errors */
    errors = 1;
    continue;
    }

    if ((outfd = fopen(filename, "wb")) == NULL) {
    fprintf(stderr, "Could not open %s for writing: %s\n",
    filename, strerror(errno));
    fclose(infd);
    rename(filename_orig, filename); /* ignore errors */
    errors = 1;
    continue;
    }

    translate(infd, outfd);
    fclose(infd);
    fclose(outfd);
    }

    return errors;
    }
     
    David Cuthbert, Jun 8, 2005
    #2
  3. Satya Mishra

    Satya Mishra Guest

    "David" == David Cuthbert <"dacut at cadence dot com"> writes:


    David> Hm... most of the DFII tools are pretty much locale
    David> unaware.

    David> I can supply a hack, but I must emphasize that this is a
    David> very, very extreme and unsanctioned hack -- use it only on
    David> your own, personal DFII install, and only if this is
    David> keeping you from getting work done and you can't find a way
    David> to force WindowMaker to use ISO-8859-1 encoding, and don't
    David> expect anyone here to provide support...

    David> (Anyone else who might be reading this from Cadence... you
    David> didn't see this. :)

    David> Compile the attached C program (to, say, ~/changetm), and
    David> then: cd DFIIDirectory/tools/dfII/etc/context ~/changetm
    David> *.cxt

    David> This will insert a binary hack to convert every instance of
    David> Virtuoso\xae to VirtuosoR.
    <snip>

    David

    Thank you very much for your help. However, I, like most engineers,
    are limited by what sys-admins let me do. So, change the cxt files is
    out of question. I am trying to write a script that uses "xprop -spy"
    and "iconv -f iso-8859-1 -t utf-8" to make it work.

    Thank you very much for the C program. But if I am not very much
    mistaken, the same effect can be achieved using "gvim -b" or
    "binary-overwrite-mode" in emacs. I am not too sure of the latter. I
    use the former fairly frequently to edit binary files without changing
    the byt alignment and such stuff.

    Thanks again for the help.

    Satya
     
    Satya Mishra, Jun 10, 2005
    #3
  4. You could also fix WindowMaker. The ICCCM specifies that STRING types
    should be ISO-Latin-1 (i.e., ISO-8859-1) encoding, but WindowMaker
    ignores this and treats all strings as UTF-8.

    If you can compile WindowMaker from scratch -- the source is at:
    ftp://windowmaker.org/pub/source/release/WindowMaker-0.91.0.tar.gz
    apply the attached patch (patch -p1 < wmaker-utf8.patch), configure,
    make, make install, it should work. I can't compile WindowMaker fully
    on this system, though, since it doesn't have a working, up-to-date
    fontconfig (we're still at RHEL 2.1 here).
    Yep... I just wasn't sure which editor(s) you had access to.

    --
    David Cuthbert dacut at cadence dot com
    Cadence Design Systems +1 (412) 599-1820

    diff -r -c WindowMaker-0.91.0.orig/WINGs/WINGs/WINGs.h WindowMaker-0.91.0/WINGs/WINGs/WINGs.h
    *** WindowMaker-0.91.0.orig/WINGs/WINGs/WINGs.h Sun Oct 24 21:48:39 2004
    --- WindowMaker-0.91.0/WINGs/WINGs/WINGs.h Fri Jun 10 14:05:03 2005
    ***************
    *** 850,855 ****
    --- 850,858 ----
    void WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
    int x, int y, char *text, int length);

    + void WMDrawString8(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
    + int x, int y, char *text, int length);
    +
    void WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color,
    WMColor *background, WMFont *font, int x, int y,
    char *text, int length);
    diff -r -c WindowMaker-0.91.0.orig/WINGs/wfont.c WindowMaker-0.91.0/WINGs/wfont.c
    *** WindowMaker-0.91.0.orig/WINGs/wfont.c Mon Oct 25 23:23:19 2004
    --- WindowMaker-0.91.0/WINGs/wfont.c Fri Jun 10 14:05:34 2005
    ***************
    *** 320,325 ****
    --- 320,346 ----


    void
    + WMDrawString8(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
    + int x, int y, char *text, int length)
    + {
    + XftColor xftcolor;
    +
    + wassertr(font!=NULL);
    +
    + xftcolor.color.red = color->color.red;
    + xftcolor.color.green = color->color.green;
    + xftcolor.color.blue = color->color.blue;
    + xftcolor.color.alpha = color->alpha;;
    + xftcolor.pixel = W_PIXEL(color);
    +
    + XftDrawChange(scr->xftdraw, d);
    +
    + XftDrawString8(scr->xftdraw, &xftcolor, font->font,
    + x, y + font->y, (XftChar8*)text, length);
    + }
    +
    +
    + void
    WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background,
    WMFont *font, int x, int y, char *text, int length)
    {
    diff -r -c WindowMaker-0.91.0.orig/src/framewin.c WindowMaker-0.91.0/src/framewin.c
    *** WindowMaker-0.91.0.orig/src/framewin.c Thu Oct 14 18:55:15 2004
    --- WindowMaker-0.91.0/src/framewin.c Fri Jun 10 14:06:43 2005
    ***************
    *** 1101,1108 ****
    }

    /*XDrawRectangle(dpy, buf, WMColorGC(scr->white),1,0,w,h-1);*/
    ! WMDrawString(scr->wmscreen, buf, fwin->title_color[state],
    ! *fwin->font, 1, 0, title, titlelen);

    XCopyArea(dpy, buf, fwin->titlebar->window, scr->copy_gc,
    0, 0, w+2, h, x-1, y);
    --- 1101,1108 ----
    }

    /*XDrawRectangle(dpy, buf, WMColorGC(scr->white),1,0,w,h-1);*/
    ! WMDrawString8(scr->wmscreen, buf, fwin->title_color[state],
    ! *fwin->font, 1, 0, title, titlelen);

    XCopyArea(dpy, buf, fwin->titlebar->window, scr->copy_gc,
    0, 0, w+2, h, x-1, y);
     
    David Cuthbert, Jun 10, 2005
    #4
  5. Satya Mishra

    Satya Mishra Guest

    "David" == David Cuthbert <"dacut at cadence dot com"> writes:
    <snip>
    David> Date: Fri, 10 Jun 2005 14:13:01 -0400

    David> You could also fix WindowMaker. The ICCCM specifies that
    David> STRING types should be ISO-Latin-1 (i.e., ISO-8859-1)
    David> encoding, but WindowMaker ignores this and treats all
    David> strings as UTF-8.

    David> If you can compile WindowMaker from scratch -- the source
    David> is at:
    David> ftp://windowmaker.org/pub/source/release/WindowMaker-0.91.0.tar.gz
    David> apply the attached patch (patch -p1 < wmaker-utf8.patch),
    David> configure, make, make install, it should work. I can't
    David> compile WindowMaker fully on this system, though, since it
    David> doesn't have a working, up-to-date fontconfig (we're still
    David> at RHEL 2.1 here).
    <snip>

    David

    Thanks a lot for the patch. It certainly was more help than I could
    expect. You make it too easy! The code compiled like a charm and I get
    good window titles again.

    I will probably follow up and submit a bug to WindowMaker project,
    unless you have already done so.

    RHEL 2.1. Wow! I used to think that RHEL 3.0 that we use at our
    company was ancient.

    Regards
    Satya
     
    Satya Mishra, Jun 14, 2005
    #5
  6. Satya Mishra

    Satya Mishra Guest

    Satya> <snip>
    David> Date: Fri, 10 Jun 2005 14:13:01 -0400

    David> If you can compile WindowMaker from scratch -- the source
    David> is at:
    David> ftp://windowmaker.org/pub/source/release/WindowMaker-0.91.0.tar.gz
    David> apply the attached patch (patch -p1 < wmaker-utf8.patch),
    David> configure, make, make install, it should work. I can't
    David> compile WindowMaker fully on this system, though, since it
    David> doesn't have a working, up-to-date fontconfig (we're still
    David> at RHEL 2.1 here).

    Satya> Thanks a lot for the patch. It certainly was more help than
    Satya> I could expect. You make it too easy! The code compiled
    Satya> like a charm and I get good window titles again.

    David

    My happiness was short-lived. The patched seemed to work initially (I
    was using IC5033), but then I started IC5141 and the window titles
    were gone again.

    Then I figured out that WindowMaker takes a --locale argument. So
    starting WindowMaker as "wmaker --locale C" seems to fix the
    problem. For some reason the locale was getting set to something
    else.


    Thanks for all the help.

    Satya
     
    Satya Mishra, Jun 14, 2005
    #6
  7. Glad that this and/or the --locale flag worked. Go ahead and ping the
    WindowMaker folks -- they know a lot more about the ICCCM that I do, and
    would be able to say whether my suspicion is correct or I'm off my
    rocker or...
    We have to compile our tools on the oldest version of each platform we
    support. This holds especially true for Linux, which compiles version
    information into our executables and libraries (and will explicitly
    refuse to run on older systems).

    I do run a bleeding-edge Gentoo box at home, though.
     
    David Cuthbert, Jun 14, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.