---
 Makefile   |   11 ++++--
 boglinfo.c |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 111 insertions(+), 4 deletions(-)

--- /dev/null
+++ b/boglinfo.c
@@ -0,0 +1,104 @@
+/* BGF file information
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+   USA. */
+
+#define _XOPEN_SOURCE 500
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "bogl.h"
+#include "bogl-bgf.h"
+
+int
+bogl_cloexec(int fd)
+{
+  /* We don't care */
+  return 0;
+}
+
+int main(int argc, char *argv[])
+{
+  struct bogl_font *font;
+  int mask;
+  wchar_t wchi, wclo;
+  int w, h;
+  unsigned count;
+
+  if (argc < 2) {
+    fprintf (stderr, "Usage: %s font.bgf\n", argv[0]);
+    return 1;
+  }
+
+  if ((font = bogl_mmap_font(argv[1], 1)) == NULL) {
+    fprintf(stderr, "Bad font\n");
+    return 1;
+  }
+
+  h = font->height;
+  mask = font->index_mask;
+
+  printf("Name: %s\n", font->name);
+  printf("Height: %d\n", font->height);
+  printf("Default char: U+%04X\n", font->default_char);
+  printf("Index mask: %04x\n", mask);
+
+  count = 0;
+  for (wchi = 0; wchi < 0x10000; wchi += mask+1)
+  {
+    for (wclo = 0; wclo < mask; wclo++)
+    {
+      int i;
+      for (i = font->offset[wclo]; font->index[i]; i+= 2)
+      {
+	int x, y;
+	u_int32_t *character;
+
+	if ((font->index[i] & ~mask) != wchi)
+	  continue;
+
+	printf("\n");
+	count++;
+
+	w = font->index[i] & mask;
+	printf("Char U+%04X\n", wclo | wchi);
+	printf("Width %d:\n", w);
+
+	character = &font->content[font->index[i+1]];
+	for (y = 0; y < h; y++)
+	  {
+	    u_int32_t c = *character++;
+	    putchar(' ');
+	    for (x = 0; x < w; x++)
+	      {
+		if (c & 0x80000000)
+		  putchar('X');
+		else
+		  putchar(' ');
+		c <<= 1;
+	      }
+	    putchar('\n');
+	  }
+	break;
+      }
+    }
+  }
+
+  printf("Glyphs: %u\n", count);
+
+  bogl_munmap_font(font);
+  return 0;
+}
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ LIBRSRCOBJECTS = helvB10.o helvB12.o hel
 SOURCES_DEP = arrow.c bdftobogl.c bogl-cfb.c bogl-cfb.h bogl-cfb8.c	\
 bogl-cfb8.h bogl-font.c bogl-font.h \
 bogl-test.c bogl.h boglP.h boml.c	\
-boml.h bowl.c bowl.h
+boml.h bowl.c bowl.h boglinfo.c
 
 ifeq ($(os),linux)
 	SOURCES_DEP += pngtobogl.c bogl-pcfb.c bogl-pcfb.h bogl-tcfb.c bogl-tcfb.h bowl-boxes.c bogl.c
@@ -45,7 +45,7 @@ GENERATED = helvB10.c helvB12.c helvR10.
 #		 libutf8/libutf8_plug.so unifont-reduced.bgf
 all:    depend
 ifeq ($(os),linux)
-all: $(SHARED_LIB) $(LIB) bterm bdftobogl pngtobogl
+all: $(SHARED_LIB) $(LIB) bterm bdftobogl pngtobogl boglinfo
 endif
 all: reduce-font
 
@@ -99,12 +99,15 @@ pngtobogl: pngtobogl.o
 %.c: %.png pngtobogl
 	./pngtobogl $< > $@
 
+boglinfo: boglinfo.o bogl-bgf.o
+	$(CC) $(ALLCFLAGS) -o boglinfo boglinfo.o bogl-bgf.o -lgd $(LDFLAGS)
+
 depend: .depend
 .depend: $(SOURCES_DEP)
 	$(CPP) $(ALLCFLAGS) -M $(SOURCES_DEP) > .depend
 
 clean: 
-	rm -rf reduce-font bterm bdftobogl pngtobogl *.o $(GENERATED) *-test lang.h tmp.*.c bowl-boxes $(LIB) unifont-reduced.bgf unifont-reduced.bdf
+	rm -rf reduce-font bterm bdftobogl pngtobogl *.o $(GENERATED) *-test lang.h tmp.*.c bowl-boxes $(LIB) unifont-reduced.bgf unifont-reduced.bdf boglinfo
 	rm -f $(OBJECTS:%.o=%.lo) $(SHARED_LIB)
 	rm -f .depend
 
@@ -126,7 +129,7 @@ ifeq ($(os),linux)
 	ln -s $(SHARED_LIB) $(DESTDIR)/usr/lib/$(SONAME)
 	install -m644 $(LIB) $(DESTDIR)/usr/lib/$(LIB)
 	install -m644 *.h $(DESTDIR)/usr/include/bogl
-	install -m755 bdftobogl bterm pngtobogl $(DESTDIR)/usr/bin
+	install -m755 bdftobogl bterm pngtobogl boglinfo $(DESTDIR)/usr/bin
 	install -d $(DESTDIR)/usr/share/terminfo
 	tic -o$(DESTDIR)/usr/share/terminfo bterm.ti
 endif
