Missing characters from a Type1 font

Alexander Gottwald Alexander.Gottwald at s1999.tu-chemnitz.de
Sat Sep 25 10:06:05 PDT 2004


Arthur Norman wrote:

> I install the AMS "computer modern" type1 fonts (as fetched form any big
> TeX archive) and then try to use them. I appear to find that using cygwin
> and its X server that the character with code 0xa1 is not displayed when
> XDrawString is used. The code is a second-mapping of what would otherwise
> be code 0x00, a capital Gamma.
> Running exactly the same code on several 32-bit Linux systems causes the
> character to be visible (specifically SuSE 9.0 + current updates and
> RedHat 6.1). The new fonts were added using "xset fp+" and Delta, Theta
> appear ok from 0xa2, 0xa3, so the font can really be accessed. I have some
> belief that things fail on SuSE 9.x x86_64 too but can not readily check
> that again just now.  As short a demo program I have got is a hack of a
> Hello World program found on the Web. It should display
>     X Gamma Y Delta | Theta Lambda Hello, World
> but as I say on cygwin the Gamma is just missed out.  Have I missed some
> fine print in a manual please anybody?


I could reproduce this with the X11R6.8.1 on linux too. So it's not bound to
Cygwin/X alone.

I'm CCing the xorg at freedesktop.org mailing list.






> unpack cmps-unix.tar.gz to somwhere
> pushd <dir with cm fonts .pfb file>
> type1inst
> xset fp+ `pwd`
> xset fp rehash
> popd
> gcc hello.c -L/usr/X11R6/lib -lX11 -o hello
> ./hello
> ============
> /*
>   * This is basically an X "Hello World" program found in a collection
>   * of Hello Worlds on the web. I have stripped some comments to reduce
>   * bulk
>   */
>
> #include <stdio.h>
> #include <X11/Xlib.h>
> #include <X11/Xutil.h>
>
> #define STRING  "X\x00Y\x01Z\x02\x03Hello, world"
> #define STRING  "X\xa1Y\xa2Z\xa3\xa4Hello,\xa0world"
> #define STRINGlength 19
> #define BORDER  1
> #define FONT    "-unknown-cmr17-medium-r-normal--40-0-0-0-p-0-adobe-fontspecific"
> XWMHints        xwmh = {
>      (InputHint|StateHint),      /* flags */
>      False,                      /* input */
>      NormalState,                /* initial_state */
>      0,                          /* icon pixmap */
>      0,                          /* icon window */
>      0, 0,                       /* icon location */
>      0,                          /* icon mask */
>      0,                          /* Window group */
> };
>
> main(argc,argv)
>      int argc;
>      char **argv;
> {
>      Display    *dpy;            /* X server connection */
>      Window      win;            /* Window ID */
>      GC          gc;             /* GC to draw with */
>      XFontStruct *fontstruct;    /* Font descriptor */
>      unsigned long fth, pad;     /* Font size parameters */
>      unsigned long fg, bg, bd;   /* Pixel values */
>      unsigned long bw;           /* Border width */
>      XGCValues   gcv;            /* Struct for creating GC */
>      XEvent      event;          /* Event received */
>      XSizeHints  xsh;            /* Size hints for window manager */
>      char       *geomSpec;       /* Window geometry string */
>      XSetWindowAttributes xswa;  /* Temporary Set Window Attribute struct */
>
>      if ((dpy = XOpenDisplay(NULL)) == NULL) {
>          fprintf(stderr, "%s: can't open %s\en", argv[0], XDisplayName(NULL));
>          exit(1);
>      }
>
>      if ((fontstruct = XLoadQueryFont(dpy, FONT)) == NULL) {
>          fprintf(stderr, "%s: display %s doesn't know font %s\en",
>                  argv[0], DisplayString(dpy), FONT);
>          exit(1);
>      }
>      fth = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent;
>
>      bd = BlackPixel(dpy, DefaultScreen(dpy));
>      bg = WhitePixel(dpy, DefaultScreen(dpy));
>      fg = BlackPixel(dpy, DefaultScreen(dpy));
>
>      pad = BORDER;
>      bw = 8;
>
>      xsh.flags = (PPosition | PSize);
>      xsh.height = fth + pad * 2;
>      xsh.width = XTextWidth(fontstruct, STRING, STRINGlength) + pad * 2;
>      xsh.x = (DisplayWidth(dpy, DefaultScreen(dpy)) - xsh.width) / 2;
>      xsh.y = (DisplayHeight(dpy, DefaultScreen(dpy)) - xsh.height) / 2;
>
>      win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
>                                xsh.x, xsh.y, xsh.width, xsh.height,
>                                bw, bd, bg);
>
>      XSetStandardProperties(dpy, win, STRING, STRING, None, argv, argc, &xsh);
>      XSetWMHints(dpy, win, &xwmh);
>
>      xswa.colormap = DefaultColormap(dpy, DefaultScreen(dpy));
>      xswa.bit_gravity = CenterGravity;
>      XChangeWindowAttributes(dpy, win, (CWColormap | CWBitGravity), &xswa);
>
>      gcv.font = fontstruct->fid;
>      gcv.foreground = fg;
>      gcv.background = bg;
>      gc = XCreateGC(dpy, win, (GCFont | GCForeground | GCBackground), &gcv);
>
>      XSelectInput(dpy, win, ExposureMask);
>      XMapWindow(dpy, win);
>      while (1) {
>          XNextEvent(dpy, &event);
>          if (event.type == Expose && event.xexpose.count == 0) {
>              XWindowAttributes xwa;      /* Temp Get Window Attribute struct */
>              int         x, y;
>              while (XCheckTypedEvent(dpy, Expose, &event));
>              if (XGetWindowAttributes(dpy, win, &xwa) == 0)
>                  break;
>              x = (xwa.width - XTextWidth(fontstruct, STRING, STRINGlength)) / 2;
>              y = (xwa.height + fontstruct->max_bounds.ascent
>                   - fontstruct->max_bounds.descent) / 2;
>              XClearWindow(dpy, win);
> /* The next line appears to me to behave oddly */
>              XDrawString(dpy, win, gc, x, y, STRING, STRINGlength);
>          }
>      }
>      exit(1);
> }
> ============
>

NP: Fixmer/McCarthy - Freefall (Remix by Covenant)
-- 
 Alexander.Gottwald at informatik.tu-chemnitz.de
 http://www.gotti.org           ICQ: 126018723



More information about the xorg mailing list