--- old/fl_font_xft.cxx	2007-10-11 21:05:06.000000000 +0100
+++ v1/fl_font_xft.cxx	2007-10-12 16:15:01.000000000 +0100
@@ -3,7 +3,7 @@
 //
 // Xft font code for the Fast Light Tool Kit (FLTK).
 //
-// Copyright 2001-2005 Bill Spitzak and others.
+// Copyright 2001-2007 Bill Spitzak and others.
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Library General Public
@@ -184,18 +184,92 @@
 }
 
 #if HAVE_GL
-// This call is used by opengl to get a bitmapped font.
+/* This code is used by opengl to get a bitmapped font. The original XFT-1 code
+ * used XFT's "core" fonts methods to load an XFT font that was actually a
+ * X-bitmap font, that could then be readily used with GL.
+ * But XFT-2 does not provide that ability, and there is no easy method to use
+ * an XFT font directly with GL. So...
+*/
+
+#  if XFT_MAJOR > 1
+// This function attempts, on XFT2 systems, to find a suitable "core" Xfont
+// for GL to use, since we dont have an XglUseXftFont(...) function.
+// There's probably a better way to do this. I can't believe it is this hard...
+// Anyway... This code attempts to make an XLFD out of the fltk-style font
+// name it is passed, then tries to load that font. Surprisingly, this quite
+// often works - boxes that have XFT generally also have a fontserver that
+// can serve TTF and other fonts to X, and so the font name that fltk makes
+// from the XFT name often also "exists" as an "core" X font...
+// If this code fails to load the requested font, it falls back through a
+// series of tried 'n tested alternatives, ultimately resorting to what the
+// original fltk code did.
+// NOTE:
+// On my test boxes (FC6, FC7) this works well for the fltk "built-in" font names.
+static XFontStruct* load_xfont_for_xft2(void) {
+  XFontStruct* xgl_font = 0;
+  int size = fl_size_;
+  char *weight = "medium"; // no specifc weight requested - accept any
+  char slant = 'r';   // regular non-italic by default
+  char xlfd[128];     // we will put our synthetic XLFD in here
+  char *pc = strdup(fl_fonts[fl_font_].name); // what font were we asked for?
+  char *name = pc;    // keep a handle to the original name for freeing later
+  // Parse the "fltk-name" of the font
+  switch (*name++) {
+  case 'I': slant = 'i'; break;     // italic
+  case 'P': slant = 'i';            // bold-italic (falls-through)
+  case 'B': weight = "bold"; break; // bold
+  case ' ': break;                  // regular
+  default: name--;                  // no prefix, restore name
+  }
+
+  // first, we do a query with no prefered size, to see if the font exists at all
+  snprintf(xlfd, 128, "-*-*%s*-%s-%c-*--*-*-*-*-*-*-*-*", name, weight, slant); // make up xlfd style name
+  xgl_font = XLoadQueryFont(fl_display, xlfd);
+  if(xgl_font) { // the face exists, but can we get it in a suitable size?
+    XFreeFont(fl_display, xgl_font); // release the non-sized version
+    snprintf(xlfd, 128, "-*-*%s*-%s-%c-*--*-%d-*-*-*-*-*-*", name, weight, slant, (size*10));
+    xgl_font = XLoadQueryFont(fl_display, xlfd); // attempt to load the font at the right size
+  }
+  free(pc); // release our copy of the font name
+
+  // if we have nothing loaded, try a generic proportional font
+  if(!xgl_font) {
+    snprintf(xlfd, 128, "-*-helvetica-*-%c-*--*-%d-*-*-*-*-*-*", slant, (size*10));
+    xgl_font = XLoadQueryFont(fl_display, xlfd);
+  }
+  // If that still didn't work, try this instead
+  if(!xgl_font) {
+    snprintf(xlfd, 128, "-*-courier-medium-%c-*--*-%d-*-*-*-*-*-*", slant, (size*10));
+    xgl_font = XLoadQueryFont(fl_display, xlfd);
+  }
+  // Last chance fallback - this usually loads something...
+  if (!xgl_font) xgl_font = XLoadQueryFont(fl_display, "fixed");
+
+  return xgl_font;
+} // end of load_xfont_for_xft2
+#  endif
+
 XFontStruct* fl_xxfont() {
 #  if XFT_MAJOR > 1
-  // kludge!
-  static XFontStruct* fixed = 0;
-  if (!fixed) fixed = XLoadQueryFont(fl_display, "fixed");
-  return fixed;
-#  else
-  if (current_font->core) return current_font->u.core.font;
+  // kludge! XFT 2 and later does not provide core fonts for us to use with GL
+  // try to load a bitmap X font instead
+  static XFontStruct* xgl_font = 0;
+  static int glsize = 0;
+  static int glfont = -1;
+  // Do we need to load a new font?
+  if ((!xgl_font) || (glsize != fl_size_) || (glfont != fl_font_)) {
+    if (xgl_font) XFreeFont(fl_display, xgl_font); // font already loaded, free it
+    glsize = fl_size_; // record current font size
+    glfont = fl_font_; // and face
+    // create a dummy XLFD for some font of the appropriate size...
+    xgl_font = load_xfont_for_xft2();
+  }
+  return xgl_font;
+#  else // XFT-1 provides a means to load a "core" font directly
+  if (current_font->core) return current_font->u.core.font; // is the current font a "core" font? If so, use it.
   static XftFont* xftfont;
   if (xftfont) XftFontClose (fl_display, xftfont);
-  xftfont = fontopen(fl_fonts[fl_font_].name, true);
+  xftfont = fontopen(fl_fonts[fl_font_].name, true); // else request XFT to load a suitable "core" font instead.
   return xftfont->u.core.font;
 #  endif // XFT_MAJOR > 1
 }
@@ -233,7 +307,7 @@
 #if USE_OVERLAY
   XftDraw*& draw = fl_overlay ? draw_overlay : ::draw;
   if (fl_overlay) {
-    if (!draw) 
+    if (!draw)
       draw = XftDrawCreate(fl_display, draw_overlay_window = fl_window,
 			   fl_overlay_visual->visual, fl_overlay_colormap);
     else //if (draw_overlay_window != fl_window)
