summaryrefslogtreecommitdiff
path: root/FL/x.H
diff options
context:
space:
mode:
authorIan MacArthur <imacarthur@gmail.com>2010-04-09 16:46:45 +0000
committerIan MacArthur <imacarthur@gmail.com>2010-04-09 16:46:45 +0000
commit52470488ce1e7f7574c3ea77f64b2531b1ba12cc (patch)
tree92a0d5bdfb9f8fef9da598c933acb6270a2ddda0 /FL/x.H
parent74dbd5e017b6ffd2aaf34c5958c053132bbceade (diff)
After testing, I have applied ucko's latest patch for providing access
to "core" fonts when XFT is selected. This allows contexts that need bitmapped fonts (e.g. GL) to access a bitmap core font, even though XFT2 does not generally provide bitmap font access. STR #2214 refers. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7474 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL/x.H')
-rw-r--r--FL/x.H28
1 files changed, 26 insertions, 2 deletions
diff --git a/FL/x.H b/FL/x.H
index 86715423b..6c2bb07c7 100644
--- a/FL/x.H
+++ b/FL/x.H
@@ -65,11 +65,35 @@ extern FL_EXPORT int fl_screen;
extern FL_EXPORT XVisualInfo *fl_visual;
extern FL_EXPORT Colormap fl_colormap;
+// access to core fonts:
+// This class provides a "smart pointer" that returns a pointer to an XFontStruct.
+// The global variable fl_xfont can be called wherever a bitmap "core" font is
+// needed, e.g. when rendering to a GL context under X11.
+// With Xlib / X11 fonts, fl_xfont will return the current selected font.
+// With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most
+// similar to (usually the same as) the current XFT font.
+class Fl_XFont_On_Demand
+{
+public:
+ Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
+ Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
+ { ptr = x.ptr; return *this; }
+ Fl_XFont_On_Demand& operator=(XFontStruct* p)
+ { ptr = p; return *this; }
+ XFontStruct* value();
+ operator XFontStruct*() { return value(); }
+ XFontStruct& operator*() { return *value(); }
+ XFontStruct* operator->() { return value(); }
+ bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
+ bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
+private:
+ XFontStruct *ptr;
+};
+extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
+
// drawing functions:
extern FL_EXPORT GC fl_gc;
extern FL_EXPORT Window fl_window;
-//extern FL_EXPORT XFontStruct* fl_xfont;
-extern FL_EXPORT XUtf8FontStruct* fl_xfont;
extern FL_EXPORT void *fl_xftfont;
FL_EXPORT ulong fl_xpixel(Fl_Color i);
FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);