diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index ad31bd0ee..ad7b60309 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -470,8 +470,11 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) { /** Recalculate the display's visible lines and scrollbar sizes. */ +#include void Fl_Text_Display::recalc_display() { if (!buffer()) return; +struct timeval now, after_calc; +gettimeofday(&now, NULL); // did we have scrollbars initially? unsigned int hscrollbarvisible = mHScrollBar->visible(); @@ -693,6 +696,12 @@ void Fl_Text_Display::recalc_display() { update_v_scrollbar(); update_h_scrollbar(); + +gettimeofday(&after_calc, NULL); +double duration = (after_calc.tv_sec - now.tv_sec) + + (after_calc.tv_usec >= now.tv_usec ? (after_calc.tv_usec - now.tv_usec)/1000000. : + (1000000 - now.tv_usec + after_calc.tv_usec)/1000000.); +fprintf(stderr, "recalc_display:%g\n", duration); } diff --git a/src/drivers/Xlib/Fl_Font.H b/src/drivers/Xlib/Fl_Font.H index 49917b6d3..d0277886e 100644 --- a/src/drivers/Xlib/Fl_Font.H +++ b/src/drivers/Xlib/Fl_Font.H @@ -38,6 +38,7 @@ public: # if USE_PANGO int descent_; int height_; + int width[0x590]; # else XftFont* font; # endif diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx index ee36e1cf6..20f528ae6 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx @@ -1352,11 +1352,22 @@ void Fl_Xlib_Graphics_Driver::do_draw(int from_right, const char *str, int n, in double Fl_Xlib_Graphics_Driver::width_unscaled(const char* str, int n) { if (!n) return 0; if (!fl_display || size_ == 0) return -1; + int len; + unsigned utf32 = fl_utf8decode(str, str+n, &len); + bool in_mem = (len == n && utf32 < 0x590); + if (in_mem) { + int w = ((Fl_Xlib_Font_Descriptor*)font_descriptor())->width[utf32]; + if (w >= 0) return w; + } + if (!playout_) context(); int width, height; pango_layout_set_font_description(playout_, pfd_array[font_]); pango_layout_set_text(playout_, str, n); pango_layout_get_pixel_size(playout_, &width, &height); + if (in_mem) { + ((Fl_Xlib_Font_Descriptor*)font_descriptor())->width[utf32] = width; + } return (double)width; } @@ -1460,6 +1471,7 @@ Fl_Xlib_Font_Descriptor::Fl_Xlib_Font_Descriptor(const char* name, Fl_Fontsize f angle = fangle; height_ = 0; descent_ = 0; +for(int i = 0; i < 0x590; i++) width[i] = -1; } #endif // USE_PANGO