summaryrefslogtreecommitdiff
path: root/src/fl_font_x.cxx
diff options
context:
space:
mode:
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