summaryrefslogtreecommitdiff
path: root/src/fl_font_x.cxx
diff options
context:
space:
mode:
authorIan MacArthur <imacarthur@gmail.com>2011-02-07 22:22:16 +0000
committerIan MacArthur <imacarthur@gmail.com>2011-02-07 22:22:16 +0000
commit33af4e4ba5cec3f0fe757ca9889b23b2ba0f3b76 (patch)
tree198b2daea575779dac3dd942934e66e15a59e38b /src/fl_font_x.cxx
parentd140f4f3be96f7002c6d8a50d72f11baa92509d1 (diff)
Attempt to fix STR #2550 to make fl_text_extents work in Xlib-only
(i.e. non-XFT) X11 builds. This appears to be working now, though I can not test it fully, so we need more feedback. In particular the setting of the dx param is certainly wrong, but works fine in general cases. I think. Also, I suspect it may behave badly in the face of RtoL text rendering but I think we have other problems in that area anyway... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8399 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_font_x.cxx')
-rw-r--r--src/fl_font_x.cxx23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/fl_font_x.cxx b/src/fl_font_x.cxx
index c55b97734..de5a2ab8f 100644
--- a/src/fl_font_x.cxx
+++ b/src/fl_font_x.cxx
@@ -302,15 +302,20 @@ double fl_width(unsigned int c) {
void fl_text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) {
-
-#if defined(__GNUC__)
-#warning fl_text_extents is only a test stub in Xlib build at present
-#endif /*__GNUC__*/
-
- W = 0; H = 0;
- fl_measure(c, W, H, 0);
- dx = 0;
- dy = fl_descent() - H;
+ if (font_gc != fl_gc) {
+ if (!current_font) fl_font(FL_HELVETICA, 14);
+ font_gc = fl_gc;
+ XSetFont(fl_display, fl_gc, current_font->fid);
+ }
+ int xx, yy, ww, hh;
+ XUtf8_measure_extents(fl_display, fl_window, current_font, fl_gc, &xx, &yy, &ww, &hh, c, n);
+
+ W = ww; H = hh; dx = xx; dy = yy;
+// This is the safe but mostly wrong thing we used to do...
+// W = 0; H = 0;
+// fl_measure(c, W, H, 0);
+// dx = 0;
+// dy = fl_descent() - H;
} // fl_text_extents