From afe4cbf26df8882b913091aba28f20d0ec0fc7e8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 10 Jan 2024 22:15:14 -0500 Subject: [PATCH] tests: Change the way custom fonts are handled Instead of setting FONTCONFIG_FILE to a custom font configuration, pass the directory containing the fonts as TEST_FONTS and use FcConfigAppFontAddDir to add them to the default font configuration. --- testsuite/gsk/compare-render.c | 24 ++++++++++++++++++++++++ testsuite/gsk/fonts/fonts.conf | 7 ------- testsuite/gsk/meson.build | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) delete mode 100644 testsuite/gsk/fonts/fonts.conf diff --git a/testsuite/gsk/compare-render.c b/testsuite/gsk/compare-render.c index 814b7ec5e8..ec57f9b6bc 100644 --- a/testsuite/gsk/compare-render.c +++ b/testsuite/gsk/compare-render.c @@ -1,9 +1,15 @@ +#include "config.h" #include #include #include #include #include "../reftests/reftest-compare.h" +#ifdef HAVE_PANGOFT +#include +#endif + + static char *arg_output_dir = NULL; static gboolean flip = FALSE; static gboolean rotate = FALSE; @@ -232,6 +238,22 @@ apply_mask_to_pixbuf (GdkPixbuf *pixbuf) return copy; } +static void +maybe_add_test_fonts (void) +{ +#ifdef HAVE_PANGOFT + const char *dir; + + dir = g_getenv ("TEST_FONT_DIR"); + + if (dir && g_file_test (dir, G_FILE_TEST_EXISTS)) + { + FcConfig *config = FcConfigGetCurrent (); + FcConfigAppFontAddDir (config, (const FcChar8 *) dir); + } +#endif +} + /* * Non-option arguments: * 1) .node file to compare @@ -252,6 +274,8 @@ main (int argc, char **argv) GOptionContext *context; GdkTexture *diff_texture; + maybe_add_test_fonts (); + (g_test_init) (&argc, &argv, NULL); context = g_option_context_new ("NODE REF - run GSK node tests"); diff --git a/testsuite/gsk/fonts/fonts.conf b/testsuite/gsk/fonts/fonts.conf deleted file mode 100644 index 26d218edd9..0000000000 --- a/testsuite/gsk/fonts/fonts.conf +++ /dev/null @@ -1,7 +0,0 @@ - - - - /tmp/cache - . - /etc/fonts/fonts.conf - diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 71433c9362..ab842a96f1 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -204,7 +204,7 @@ foreach renderer : renderers 'GTK_A11Y=test', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'FONTCONFIG_FILE=@0@/fonts/fonts.conf'.format(meson.current_source_dir()) + 'TEST_FONT_DIR=@0@/fonts'.format(meson.current_source_dir()) ] if ((not testname.contains(exclude_term)) and