text: ensure fontconfig cache of Pango is invalidated (#2847)

See: https://gitlab.gnome.org/GNOME/pango/-/issues/551
This commit is contained in:
Kleis Auke Wolthuizen 2022-06-08 16:20:19 +02:00 committed by GitHub
parent 2d0c6b364c
commit 5106e9b49e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -1241,10 +1241,10 @@ AC_ARG_WITH([fontconfig],
[build without fontconfig (default: test)]))
if test x"$with_pangocairo" != x"no" -a x"$with_fontconfig" != x"no"; then
PKG_CHECK_MODULES(FONTCONFIG, fontconfig,
PKG_CHECK_MODULES(FONTCONFIG, fontconfig pangoft2 >= 1.4,
[AC_DEFINE(HAVE_FONTCONFIG,1,[define if you have fontconfig installed.])
with_fontconfig=yes
PACKAGES_USED="$PACKAGES_USED fontconfig"
PACKAGES_USED="$PACKAGES_USED fontconfig pangoft2"
],
[AC_MSG_WARN([fontconfig not found; disabling fontconfig support])
with_fontconfig=no

View File

@ -86,6 +86,7 @@
#include <pango/pangocairo.h>
#ifdef HAVE_FONTCONFIG
#include <pango/pangofc-fontmap.h>
#include <fontconfig/fontconfig.h>
#endif
@ -389,6 +390,13 @@ vips_text_build( VipsObject *object )
g_hash_table_insert( vips_text_fontfiles,
text->fontfile,
g_strdup( text->fontfile ) );
/* We need to inform that pango should invalidate its
* fontconfig cache whenever any changes are made.
*/
if( PANGO_IS_FC_FONT_MAP( vips_text_fontmap ) )
pango_fc_font_map_cache_clear(
PANGO_FC_FONT_MAP( vips_text_fontmap ) );
}
#else /*!HAVE_FONTCONFIG*/
if( text->fontfile )

View File

@ -338,6 +338,7 @@ endif
fontconfig_dep = dependency('fontconfig', required: get_option('fontconfig'))
if fontconfig_dep.found() and pangocairo_dep.found()
libvips_deps += fontconfig_dep
libvips_deps += dependency('pangoft2', version: '>=1.4')
cfg_var.set('HAVE_FONTCONFIG', '1')
endif