summaryrefslogtreecommitdiff
path: root/src/fl_font_x.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2011-02-18 13:39:48 +0000
committerManolo Gouy <Manolo>2011-02-18 13:39:48 +0000
commit199b32d9213584e232aee11d2a4d16a26f1d508d (patch)
treeff04fbca414c4ab7a497283f082bcf5f12b9a6de /src/fl_font_x.cxx
parent2c129b4833f45157fde8f90451240d4c00bbc96d (diff)
Added virtual width(), height(), descent() and text_extents() functions to the Fl_Graphics_Driver
class to prepare for the future definition of graphics drivers that fully deal with text measurement. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8442 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_font_x.cxx')
-rw-r--r--src/fl_font_x.cxx25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/fl_font_x.cxx b/src/fl_font_x.cxx
index 8b09af235..46f7eeefd 100644
--- a/src/fl_font_x.cxx
+++ b/src/fl_font_x.cxx
@@ -278,36 +278,35 @@ void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
}
}
-#define current_font (fl_graphics_driver->font_descriptor()->font)
-int fl_height() {
- if (fl_graphics_driver->font_descriptor()) return current_font->ascent + current_font->descent;
+int Fl_Xlib_Graphics_Driver::height() {
+ if (font_descriptor()) return font_descriptor()->font->ascent + font_descriptor()->font->descent;
else return -1;
}
-int fl_descent() {
- if (fl_graphics_driver->font_descriptor()) return current_font->descent;
+int Fl_Xlib_Graphics_Driver::descent() {
+ if (font_descriptor()) return font_descriptor()->font->descent;
else return -1;
}
-double fl_width(const char* c, int n) {
- if (fl_graphics_driver->font_descriptor()) return (double) XUtf8TextWidth(current_font, c, n);
+double Fl_Xlib_Graphics_Driver::width(const char* c, int n) {
+ if (font_descriptor()) return (double) XUtf8TextWidth(font_descriptor()->font, c, n);
else return -1;
}
-double fl_width(unsigned int c) {
- if (fl_graphics_driver->font_descriptor()) return (double) XUtf8UcsWidth(current_font, c);
+double Fl_Xlib_Graphics_Driver::width(unsigned int c) {
+ if (font_descriptor()) return (double) XUtf8UcsWidth(font_descriptor()->font, c);
else return -1;
}
-void fl_text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) {
+void Fl_Xlib_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) {
if (font_gc != fl_gc) {
- if (!fl_graphics_driver->font_descriptor()) fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
+ if (!font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE);
font_gc = fl_gc;
- XSetFont(fl_display, fl_gc, current_font->fid);
+ XSetFont(fl_display, fl_gc, font_descriptor()->font->fid);
}
int xx, yy, ww, hh;
xx = yy = ww = hh = 0;
- if (fl_gc) XUtf8_measure_extents(fl_display, fl_window, current_font, fl_gc, &xx, &yy, &ww, &hh, c, n);
+ if (fl_gc) XUtf8_measure_extents(fl_display, fl_window, font_descriptor()->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...