diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-05-30 15:28:08 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-05-30 15:28:08 +0200 |
| commit | e6bccc081f651a87bba58235e8c28c3fdfae5607 (patch) | |
| tree | 17457740d8b4c53959565f9f2a011fab89dc2388 /src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx | |
| parent | 7c4239915f818ff26309ed6a638871ea284a82e9 (diff) | |
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.
Diffstat (limited to 'src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx')
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx | 16 |
1 files changed, 11 insertions, 5 deletions
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$". // |
