From 73557d011bf165830ebd5e18643d09536c742392 Mon Sep 17 00:00:00 2001 From: Idriss Fekir Date: Tue, 21 May 2024 18:59:09 +0100 Subject: [PATCH] text: keep fonts usable if the current one becomes missing If a font is being used and becomes missing all other fonts become unusable, setting the fontconfig object to the pango fontmap fixes this. --- app/text/gimptext-compat.c | 7 +++++++ app/text/gimptextlayout.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/app/text/gimptext-compat.c b/app/text/gimptext-compat.c index fbf5901902..dfb11164c8 100644 --- a/app/text/gimptext-compat.c +++ b/app/text/gimptext-compat.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include "libgimpcolor/gimpcolor.h" @@ -154,6 +156,11 @@ text_get_extents (Gimp *gimp, g_error ("You are using a Pango that has been built against a cairo " "that lacks the Freetype font backend"); + /* In case a font becomes missing mid-session and is chosen (or is already in use) + * pango substitutes EVERY font for the default font, to avoid this + * the FcConfig has to be set everytime a pango fontmap is created + */ + pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), FcConfigGetCurrent ()); pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), 72.0); /* FIXME: resolution */ context = pango_font_map_create_context (fontmap); diff --git a/app/text/gimptextlayout.c b/app/text/gimptextlayout.c index 9b7c957654..d3b27832ab 100644 --- a/app/text/gimptextlayout.c +++ b/app/text/gimptextlayout.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "libgimpbase/gimpbase.h" #include "libgimpcolor/gimpcolor.h" @@ -856,6 +858,11 @@ gimp_text_get_pango_context (GimpText *text, g_error ("You are using a Pango that has been built against a cairo " "that lacks the Freetype font backend"); + /* In case a font becomes missing mid-session and is chosen (or is already in use) + * pango substitutes EVERY font for the default font, to avoid this + * the FcConfig has to be set everytime a pango fontmap is created + */ + pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), FcConfigGetCurrent ()); pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (fontmap), yres); context = pango_font_map_create_context (fontmap);