Subject: bug#505: 23.0.60; Font for fixed-pitch not resolved

From: Chong Yidong <[email-masked]>
Date: Wed, 15 Oct 2008 21:04:16 -0400

Interesting.  Okay, let's try something else (thanks for bearing with
me).

Could you save the following program in a file called, say, foo.c, then
compile it, run it, and show me the output (if any)?

cyd: ~ $ gcc foo.c -lX11 -o foo
cyd: ~ $ ./foo

Here's the program:

#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <string.h>

int main ()
{
  int i, limit, num_fonts;
  char **names;
  Display *display = XOpenDisplay (NULL);
  char *pattern = "-unknown-Monospace-*-*-*-*-*-*-*-*-*-*-iso8859-1";

  for (limit = 512; ; limit *= 2)
    {
      names = XListFonts (display, pattern, limit, &num_fonts);
      if (num_fonts < limit)
	break;
      XFreeFontNames (names);
    }

  for (i = 0; i < num_fonts; i++)
    {
      XFontStruct *font;
      unsigned long value;

      printf ("%s\n", names[i]);
      font = XLoadQueryFont (display, names[i]);
      if (! font)
	continue;
      if (XGetFontProperty (font, XA_FONT, &value))
	{
	  char *name = (char *) XGetAtomName (display, (Atom) value);
	  int len = strlen (name);
	  if (len > 0)
	    printf("  %s\n", name);
	}
    }

  return 0;
}