diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index 5e371509..ac1cfd48 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -370,7 +370,10 @@ if(BUILD_X11) message(FATAL_ERROR "Unable to find Xft library") endif(NOT X11_Xft_FOUND) - set(conky_libs ${conky_libs} ${X11_Xft_LIB}) + find_package(Fontconfig REQUIRED) + + set(conky_libs ${conky_libs} ${X11_Xft_LIB} ${Fontconfig_LIBRARIES}) + set(conky_includes ${conky_includes} ${FREETYPE_INCLUDE_DIR_freetype2} ${Fontconfig_INCLUDE_DIRS}) endif(BUILD_XFT) # check for Xdbe diff --git a/src/display-x11.cc b/src/display-x11.cc index 61759be8..fb6fa9ec 100644 --- a/src/display-x11.cc +++ b/src/display-x11.cc @@ -603,6 +603,9 @@ void display_output_x11::cleanup() { XDestroyRegion(x11_stuff.region); x11_stuff.region = nullptr; } +#ifdef BUILD_XFT + FcFini(); +#endif /* BUILD_XFT */ } void display_output_x11::set_foreground_color(Colour c) { @@ -824,13 +827,8 @@ void display_output_x11::free_fonts(bool utf8) { for (auto &font : x_fonts) { #ifdef BUILD_XFT if (use_xft.get(*state)) { - /* - * Do we not need to close fonts with Xft? Unsure. Not freeing the - * fonts seems to incur a slight memory leak, but it also prevents - * a crash. - * - * XftFontClose(display, x_fonts[i].xftfont); - */ + /* Close each font if it has been initialized */ + if (font.xftfont) { XftFontClose(display, font.xftfont); } } else #endif /* BUILD_XFT */ {