From e6bccc081f651a87bba58235e8c28c3fdfae5607 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 30 May 2019 15:28:08 +0200 Subject: X11+Pango: call pango_font_description_from_string() less often Previously, each time fl_font(fnum, fsize) was called, functions pango_font_description_free() and pango_font_description_from_string() would be called. Now, pango_font_description_from_string() is called only once, the first time an Fl_Font is used. --- src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx') diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx index d01d1156b..3a1ff8361 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -54,7 +54,6 @@ Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) { p = NULL; line_delta_ = 0; #if USE_PANGO - pfd_ = pango_font_description_new(); Fl_Graphics_Driver::font(0, 0); #endif offset_x_ = 0; offset_y_ = 0; @@ -64,9 +63,6 @@ Fl_Xlib_Graphics_Driver::Fl_Xlib_Graphics_Driver(void) { Fl_Xlib_Graphics_Driver::~Fl_Xlib_Graphics_Driver() { if (p) free(p); -#if USE_PANGO - pango_font_description_free(pfd_); -#endif } @@ -216,7 +212,11 @@ const char *Fl_Xlib_Graphics_Driver::font_name(int num) { void Fl_Xlib_Graphics_Driver::font_name(int num, const char *name) { #if USE_XFT # if USE_PANGO - init_built_in_fonts(); + init_built_in_fonts(); + if (pfd_array_length > num && pfd_array[num]) { + pango_font_description_free(pfd_array[num]); + pfd_array[num] = NULL; + } # endif Fl_Fontdesc *s = fl_fonts + num; #else @@ -287,6 +287,12 @@ void Fl_Xlib_Graphics_Driver::set_current_() { restore_clip(); } +#if USE_PANGO +int Fl_Xlib_Graphics_Driver::pfd_array_length = FL_FREE_FONT; + +PangoFontDescription **Fl_Xlib_Graphics_Driver::pfd_array = (PangoFontDescription**)calloc(pfd_array_length, sizeof(PangoFontDescription*)); +#endif + // // End of "$Id$". // -- cgit v1.2.3