summaryrefslogtreecommitdiff
path: root/src/ftcrfont.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-11-15 19:07:44 +0800
committerPo Lu <luangruo@yahoo.com>2022-11-15 19:48:39 +0800
commit833e60ae1a5dd4301eb556460285414f4fea9fec (patch)
tree9a5288bc252262a470596480f8c3cc49baa6ee13 /src/ftcrfont.c
parent0ac626f1d4eba84bd988a16991178ff25a07ece5 (diff)
downloademacs-833e60ae1a5dd4301eb556460285414f4fea9fec.tar.gz
Fix recent Cairo xsettings changes
* lisp/dynamic-setting.el (font-setting-change-default-font): Instead of setting the font frame parameter, just clear the font and face cache and redraw the display. This will re-open all fonts as well. * src/ftcrfont.c (ftcrfont_get_default_font_options): New function. * src/ftfont.h: Export. * src/xsettings.c (apply_xft_settings): Call that function to obtain the default font settings on Cairo. (bug#58912, bug#59283, bug#59271)
Diffstat (limited to 'src/ftcrfont.c')
-rw-r--r--src/ftcrfont.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index dc765e5aee4..ede8f1323cd 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -737,7 +737,7 @@ struct font_driver const ftcrfont_driver =
.filter_properties = ftfont_filter_properties,
.combining_capability = ftfont_combining_capability,
#ifdef HAVE_PGTK
- .cached_font_ok = ftcrfont_cached_font_ok
+ .cached_font_ok = ftcrfont_cached_font_ok,
#endif
};
#ifdef HAVE_HARFBUZZ
@@ -755,6 +755,42 @@ syms_of_ftcrfont (void)
pdumper_do_now_and_after_load (syms_of_ftcrfont_for_pdumper);
}
+#ifdef HAVE_X_WINDOWS
+
+/* Place the default font options used by Cairo on the given display
+ in OPTIONS. */
+
+void
+ftcrfont_get_default_font_options (struct x_display_info *dpyinfo,
+ cairo_font_options_t *options)
+{
+ Pixmap drawable;
+ cairo_surface_t *surface;
+
+ /* Cairo doesn't allow fetching the default font options for a
+ display, so the only option is to create a drawable, and an Xlib
+ surface for that drawable, and to get the font options from there
+ instead. */
+
+ drawable = XCreatePixmap (dpyinfo->display, dpyinfo->root_window,
+ 1, 1, dpyinfo->n_planes);
+ surface = cairo_xlib_surface_create (dpyinfo->display, drawable,
+ dpyinfo->visual, 1, 1);
+
+ if (!surface)
+ {
+ XFreePixmap (dpyinfo->display, drawable);
+ return;
+ }
+
+ cairo_surface_get_font_options (surface, options);
+ XFreePixmap (dpyinfo->display, drawable);
+ cairo_surface_destroy (surface);
+ return;
+}
+
+#endif
+
static void
syms_of_ftcrfont_for_pdumper (void)
{