Author: spitzak
Date: 2007-08-02 07:22:54 -0700 (Thu, 02 Aug 2007)
New Revision: 5940
Log:
Added back-compatabilty with the fltk1 fl_xfont variable.
The function fltk::xfont() returns an XFontStruct* on X. The current
implementation just returns the "variable" font. There were better
versions written for the OpenGL code but I can't find them now.
The function fltk::xftfont() returns an XftFont* on X, which is what
xfont() was doing before.


Modified:
   trunk/OpenGL/gl_draw.cxx
   trunk/fltk/x11.h
   trunk/fluid/factory.cxx
   trunk/src/x11/Font_xft.cxx

Modified: trunk/OpenGL/gl_draw.cxx
===================================================================
--- trunk/OpenGL/gl_draw.cxx    2007-08-02 14:19:28 UTC (rev 5939)
+++ trunk/OpenGL/gl_draw.cxx    2007-08-02 14:22:54 UTC (rev 5940)
@@ -83,9 +83,9 @@
     listbase = glGenLists(256);
     fl_set_font_opengl_id(listbase);
 #if USE_XFT
-    glXUseXftFont((XftFont*)xfont(), listbase);
+    glXUseXftFont(xftfont(), listbase);
 #elif USE_X11
-    HFONT current_xfont = xfont();
+    XFontStruct* current_xfont = xfont();
     int base = current_xfont->min_char_or_byte2;
     int last = current_xfont->max_char_or_byte2;
     if (last > 255) last = 255;

Modified: trunk/fltk/x11.h
===================================================================
--- trunk/fltk/x11.h    2007-08-02 14:19:28 UTC (rev 5939)
+++ trunk/fltk/x11.h    2007-08-02 14:22:54 UTC (rev 5940)
@@ -59,6 +59,7 @@
 #    include <X11/Xft/Xft.h>
 #   else
      typedef struct _XftDraw XftDraw;
+     typedef struct _XftFont XftFont;
 #   endif
 
 #   include <X11/extensions/XInput.h>
@@ -126,8 +127,8 @@
 extern FL_API void     draw_into(XWindow, int w, int h);
 extern FL_API void     stop_drawing(XWindow);
 
-#  define HFONT XFontStruct*
-extern FL_API HFONT    xfont();
+extern FL_API XFontStruct* xfont();
+extern FL_API XftFont*  xftfont();
 
 ////////////////////////////////////////////////////////////////
 // only include this if <fltk/Window.h> was included:

Modified: trunk/fluid/factory.cxx
===================================================================
--- trunk/fluid/factory.cxx     2007-08-02 14:19:28 UTC (rev 5939)
+++ trunk/fluid/factory.cxx     2007-08-02 14:22:54 UTC (rev 5940)
@@ -49,7 +49,7 @@
 
 ////////////////////////////////////////////////////////////////
 const Enumeration buttontype_menu[] = {
-  {"Normal", 0,                (void*)fltk::Button::NORMAL},
+  {"Normal", 0,                (void*)0},
   {"Toggle", "TOGGLE", (void*)fltk::Button::TOGGLE},
   {"Radio",  "RADIO",  (void*)fltk::Button::RADIO},
   {0}};

Modified: trunk/src/x11/Font_xft.cxx
===================================================================
--- trunk/src/x11/Font_xft.cxx  2007-08-02 14:19:28 UTC (rev 5939)
+++ trunk/src/x11/Font_xft.cxx  2007-08-02 14:22:54 UTC (rev 5940)
@@ -177,10 +177,22 @@
 }
 #endif
 
-// This returns the XftFont, not an XFontStruct!
+XftFont* fltk::xftfont() {
+  return current->font;
+}
+
+// This is for back compatability with fltk1 programs, implements the
+// former variable fl_xfont:
 XFontStruct* fltk::xfont() {
-  return (XFontStruct*)(current->font);
-#if 0
+#if XFT_MAJOR > 1
+  // kludge!
+  static XFontStruct* ret = 0;
+  if (!ret) {
+    ret = XLoadQueryFont(xdisplay, "variable");
+    if (!ret) ret = XLoadQueryFont(xdisplay, "fixed");
+  }
+  return ret;
+#else
   // This code only works for XFT 1, which was able to find matching
   // X fonts:
   if (!current->xfont) {
@@ -190,7 +202,10 @@
       static XftFont* xftfont;
       if (xftfont) XftFontClose (xdisplay, xftfont);
       // select the "core" version of the font:
-      xftfont = 
fontopen(current_font_->name_,current_font_->attributes_,current_size_,true);
+      xftfont = fontopen(current_font_->name_,
+                        current_font_->attributes_,
+                        current_size_,
+                        true);
       current->xfont = xftfont->u.core.font;
     }
   }

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to