aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-04-24 12:31:37 +0900
committerYAMAMOTO Mitsuharu2019-04-24 12:31:37 +0900
commit5f4e8e2e088de9fb76cb631077c6eddd3219f594 (patch)
treeabb80bc8ec36c28d4eef08b92db90a142f641be6
parent1828e9a9b7481572448284a8e5925bf97f2145f7 (diff)
downloademacs-5f4e8e2e088de9fb76cb631077c6eddd3219f594.tar.gz
emacs-5f4e8e2e088de9fb76cb631077c6eddd3219f594.zip
Don't link libXft when using cairo
* configure.ac: Check cairo early. Don't try Xft if cairo is used. * lwlib/lwlib-utils.h [USE_CAIRO]: Include cairo.h and fontconfig.h. (XftFont, XftDraw, XftColor, XGlyphInfo) [USE_CAIRO]: New typedefs. (XftFontOpenName, XftFontClose, XftDrawCreate, XftDrawDestroy) (XftDrawRect, XftDrawStringUtf8, XftTextExtentsUtf8) [USE_CAIRO]: New macros. (crxft_font_open_name, crxft_font_close, crxft_draw_create) (crxft_draw_rect, crxft_draw_string, crxft_text_extents) [USE_CAIRO]: New externs. * lwlib/lwlib-utils.c [USE_CAIRO]: Include math.h, cairo-ft.h, and cairo-xlib.h. (crxft_font_open_name, crxft_font_close, crxft_draw_create) (crxft_set_source_color, crxft_draw_rect, crxft_draw_string) (crxft_text_extents) [USE_CAIRO]: New Xft compatibility functions. * lwlib/xlwmenuP.h [USE_CAIRO]: Include lwlib-utils.h. * lwlib/xlwmenu.c (display_menu_item) [USE_CAIRO]: Call cairo_surface_mark_dirty and cairo_surface_flush. * lwlib/lwlib-Xaw.c [USE_CAIRO]: Include stdlib.h and lwlib-utils.h. (draw_text) [USE_CAIRO]: Call cairo_surface_flush. * src/xsettings.c [USE_CAIRO]: Include fontconfig.h (apply_xft_settings) [!HAVE_XFT]: Don't call XftDefaultSubstitute or XftDefaultSet. * lwlib/lwlib-Xaw.c: * lwlib/lwlib-int.h: * lwlib/xlwmenu.c: * lwlib/xlwmenuP.h: * src/xrdb.c: * src/xsettings.c: * src/xterm.c: Replace all #ifdef HAVE_XFT with #if defined USE_CAIRO || defined HAVE_XFT. * src/xfns.c (x_default_font_parameter): Replace #ifdef HAVE_XFT with #if defined USE_CAIRO || defined HAVE_XFT.
-rw-r--r--configure.ac52
-rw-r--r--lwlib/lwlib-Xaw.c28
-rw-r--r--lwlib/lwlib-int.h2
-rw-r--r--lwlib/lwlib-utils.c140
-rw-r--r--lwlib/lwlib-utils.h45
-rw-r--r--lwlib/xlwmenu.c43
-rw-r--r--lwlib/xlwmenuP.h10
-rw-r--r--src/menu.c2
-rw-r--r--src/xfns.c2
-rw-r--r--src/xrdb.c4
-rw-r--r--src/xsettings.c58
-rw-r--r--src/xterm.c2
12 files changed, 307 insertions, 81 deletions
diff --git a/configure.ac b/configure.ac
index 8b363c7fca6..810c3219e4f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3312,12 +3312,44 @@ if test "${HAVE_X11}" = "yes"; then
3312 fi 3312 fi
3313fi 3313fi
3314 3314
3315HAVE_CAIRO=no
3316if test "${HAVE_X11}" = "yes"; then
3317 if test "${with_cairo}" != "no"; then
3318 CAIRO_REQUIRED=1.12.0
3319 CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
3320 EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
3321 if test $HAVE_CAIRO = yes; then
3322 AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
3323 else
3324 AC_MSG_ERROR([cairo requested but not found.])
3325 fi
3326
3327 CFLAGS="$CFLAGS $CAIRO_CFLAGS"
3328 LIBS="$LIBS $CAIRO_LIBS"
3329 AC_SUBST(CAIRO_CFLAGS)
3330 AC_SUBST(CAIRO_LIBS)
3331 fi
3332fi
3333
3315### Start of font-backend (under any platform) section. 3334### Start of font-backend (under any platform) section.
3316# (nothing here yet -- this is a placeholder) 3335# (nothing here yet -- this is a placeholder)
3317### End of font-backend (under any platform) section. 3336### End of font-backend (under any platform) section.
3318 3337
3319### Start of font-backend (under X11) section. 3338### Start of font-backend (under X11) section.
3320if test "${HAVE_X11}" = "yes"; then 3339if test "${HAVE_X11}" = "yes"; then
3340 if test $HAVE_CAIRO = yes; then
3341 dnl Strict linkers fail with
3342 dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
3343 dnl if -lfreetype is not specified.
3344 dnl The following is needed to set FREETYPE_LIBS.
3345 EMACS_CHECK_MODULES([FREETYPE], [freetype2])
3346
3347 test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(cairo requires libfreetype)
3348
3349 EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
3350
3351 test "$HAVE_FONTCONFIG" = "no" && AC_MSG_ERROR(cairo requires libfontconfig)
3352 else
3321 ## Use -lXft if available, unless '--with-xft=no'. 3353 ## Use -lXft if available, unless '--with-xft=no'.
3322 HAVE_XFT=maybe 3354 HAVE_XFT=maybe
3323 if test "x${with_x}" = "xno"; then 3355 if test "x${with_x}" = "xno"; then
@@ -3374,6 +3406,7 @@ if test "${HAVE_X11}" = "yes"; then
3374 3406
3375 test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype) 3407 test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
3376 fi 3408 fi
3409 fi # $HAVE_CAIRO != yes
3377 3410
3378 HAVE_LIBOTF=no 3411 HAVE_LIBOTF=no
3379 if test "${HAVE_FREETYPE}" = "yes"; then 3412 if test "${HAVE_FREETYPE}" = "yes"; then
@@ -3427,25 +3460,6 @@ AC_SUBST(LIBOTF_LIBS)
3427AC_SUBST(M17N_FLT_CFLAGS) 3460AC_SUBST(M17N_FLT_CFLAGS)
3428AC_SUBST(M17N_FLT_LIBS) 3461AC_SUBST(M17N_FLT_LIBS)
3429 3462
3430HAVE_CAIRO=no
3431if test "${HAVE_X11}" = "yes"; then
3432 if test "${with_cairo}" != "no"; then
3433 CAIRO_REQUIRED=1.12.0
3434 CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
3435 EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
3436 if test $HAVE_CAIRO = yes; then
3437 AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
3438 else
3439 AC_MSG_ERROR([cairo requested but not found.])
3440 fi
3441
3442 CFLAGS="$CFLAGS $CAIRO_CFLAGS"
3443 LIBS="$LIBS $CAIRO_LIBS"
3444 AC_SUBST(CAIRO_CFLAGS)
3445 AC_SUBST(CAIRO_LIBS)
3446 fi
3447fi
3448
3449if test "${HAVE_X11}" = "yes"; then 3463if test "${HAVE_X11}" = "yes"; then
3450 AC_CHECK_HEADER(X11/Xlib-xcb.h, 3464 AC_CHECK_HEADER(X11/Xlib-xcb.h,
3451 AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes)) 3465 AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
diff --git a/lwlib/lwlib-Xaw.c b/lwlib/lwlib-Xaw.c
index a00f8aa73f9..0801c944008 100644
--- a/lwlib/lwlib-Xaw.c
+++ b/lwlib/lwlib-Xaw.c
@@ -50,8 +50,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
50 50
51#include <X11/Xatom.h> 51#include <X11/Xatom.h>
52 52
53#ifdef HAVE_XFT 53#if defined USE_CAIRO || defined HAVE_XFT
54#ifdef USE_CAIRO
55#include <stdlib.h>
56#include "lwlib-utils.h"
57#else /* HAVE_XFT */
54#include <X11/Xft/Xft.h> 58#include <X11/Xft/Xft.h>
59#endif
55 60
56struct widget_xft_data 61struct widget_xft_data
57{ 62{
@@ -79,7 +84,7 @@ lw_xaw_widget_p (Widget widget)
79} 84}
80 85
81 86
82#ifdef HAVE_XFT 87#if defined USE_CAIRO || defined HAVE_XFT
83static void 88static void
84fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font) 89fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font)
85{ 90{
@@ -210,6 +215,9 @@ draw_text (struct widget_xft_data *data, char *lbl, int inverse)
210 /* 1.2 gives reasonable line spacing. */ 215 /* 1.2 gives reasonable line spacing. */
211 y += data->xft_font->height * 1.2; 216 y += data->xft_font->height * 1.2;
212 } 217 }
218#ifdef USE_CAIRO
219 cairo_surface_flush (cairo_get_target (data->xft_draw));
220#endif
213 221
214} 222}
215 223
@@ -307,7 +315,7 @@ xaw_update_one_widget (widget_instance *instance,
307 if (XtIsSubclass (widget, dialogWidgetClass)) 315 if (XtIsSubclass (widget, dialogWidgetClass))
308 { 316 {
309 317
310#ifdef HAVE_XFT 318#if defined USE_CAIRO || defined HAVE_XFT
311 if (instance->xft_data && instance->xft_data[0].xft_font) 319 if (instance->xft_data && instance->xft_data[0].xft_font)
312 { 320 {
313 set_text (&instance->xft_data[0], instance->parent, 321 set_text (&instance->xft_data[0], instance->parent,
@@ -339,7 +347,7 @@ xaw_update_one_widget (widget_instance *instance,
339 XtSetArg (al[ac], XtNlabel, val->value);ac++; 347 XtSetArg (al[ac], XtNlabel, val->value);ac++;
340 /* Force centered button text. Se above. */ 348 /* Force centered button text. Se above. */
341 XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++; 349 XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++;
342#ifdef HAVE_XFT 350#if defined USE_CAIRO || defined HAVE_XFT
343 if (instance->xft_data && instance->xft_data[0].xft_font) 351 if (instance->xft_data && instance->xft_data[0].xft_font)
344 { 352 {
345 int th; 353 int th;
@@ -473,7 +481,7 @@ static XtActionsRec xaw_actions [] = {
473}; 481};
474static Boolean actions_initted = False; 482static Boolean actions_initted = False;
475 483
476#ifdef HAVE_XFT 484#if defined USE_CAIRO || defined HAVE_XFT
477static XtActionsRec button_actions[] = 485static XtActionsRec button_actions[] =
478 { 486 {
479 { "my_reset", command_reset }, 487 { "my_reset", command_reset },
@@ -506,7 +514,7 @@ make_dialog (char* name,
506 Widget dialog; 514 Widget dialog;
507 Widget button; 515 Widget button;
508 XtTranslations override; 516 XtTranslations override;
509#ifdef HAVE_XFT 517#if defined USE_CAIRO || defined HAVE_XFT
510 XftFont *xft_font = 0; 518 XftFont *xft_font = 0;
511 XtTranslations button_override; 519 XtTranslations button_override;
512#endif 520#endif
@@ -521,7 +529,7 @@ make_dialog (char* name,
521 XtAppContext app = XtWidgetToApplicationContext (parent); 529 XtAppContext app = XtWidgetToApplicationContext (parent);
522 XtAppAddActions (app, xaw_actions, 530 XtAppAddActions (app, xaw_actions,
523 sizeof (xaw_actions) / sizeof (xaw_actions[0])); 531 sizeof (xaw_actions) / sizeof (xaw_actions[0]));
524#ifdef HAVE_XFT 532#if defined USE_CAIRO || defined HAVE_XFT
525 XtAppAddActions (app, button_actions, 533 XtAppAddActions (app, button_actions,
526 sizeof (button_actions) / sizeof (button_actions[0])); 534 sizeof (button_actions) / sizeof (button_actions[0]));
527#endif 535#endif
@@ -546,7 +554,7 @@ make_dialog (char* name,
546 override = XtParseTranslationTable (dialogOverride); 554 override = XtParseTranslationTable (dialogOverride);
547 XtOverrideTranslations (dialog, override); 555 XtOverrideTranslations (dialog, override);
548 556
549#ifdef HAVE_XFT 557#if defined USE_CAIRO || defined HAVE_XFT
550 { 558 {
551 int num; 559 int num;
552 Widget *ch = NULL; 560 Widget *ch = NULL;
@@ -618,7 +626,7 @@ make_dialog (char* name,
618 sprintf (button_name, "button%d", ++bc); 626 sprintf (button_name, "button%d", ++bc);
619 button = XtCreateManagedWidget (button_name, commandWidgetClass, 627 button = XtCreateManagedWidget (button_name, commandWidgetClass,
620 dialog, av, ac); 628 dialog, av, ac);
621#ifdef HAVE_XFT 629#if defined USE_CAIRO || defined HAVE_XFT
622 if (xft_font) 630 if (xft_font)
623 { 631 {
624 fill_xft_data (&instance->xft_data[bc], button, xft_font); 632 fill_xft_data (&instance->xft_data[bc], button, xft_font);
@@ -651,7 +659,7 @@ make_dialog (char* name,
651 sprintf (button_name, "button%d", ++bc); 659 sprintf (button_name, "button%d", ++bc);
652 button = XtCreateManagedWidget (button_name, commandWidgetClass, 660 button = XtCreateManagedWidget (button_name, commandWidgetClass,
653 dialog, av, ac); 661 dialog, av, ac);
654#ifdef HAVE_XFT 662#if defined USE_CAIRO || defined HAVE_XFT
655 if (xft_font) 663 if (xft_font)
656 { 664 {
657 fill_xft_data (&instance->xft_data[bc], button, xft_font); 665 fill_xft_data (&instance->xft_data[bc], button, xft_font);
diff --git a/lwlib/lwlib-int.h b/lwlib/lwlib-int.h
index 28b1fb9508d..9f788e7c0c2 100644
--- a/lwlib/lwlib-int.h
+++ b/lwlib/lwlib-int.h
@@ -30,7 +30,7 @@ typedef struct _widget_instance
30 Widget widget; 30 Widget widget;
31 Widget parent; 31 Widget parent;
32 Boolean pop_up_p; 32 Boolean pop_up_p;
33#ifdef HAVE_XFT 33#if defined USE_CAIRO || defined HAVE_XFT
34 struct widget_xft_data *xft_data; 34 struct widget_xft_data *xft_data;
35#endif 35#endif
36 struct _widget_info* info; 36 struct _widget_info* info;
diff --git a/lwlib/lwlib-utils.c b/lwlib/lwlib-utils.c
index 7c60bdb056d..2c0a931f9cb 100644
--- a/lwlib/lwlib-utils.c
+++ b/lwlib/lwlib-utils.c
@@ -137,3 +137,143 @@ XtWidgetBeingDestroyedP (Widget widget)
137{ 137{
138 return widget->core.being_destroyed; 138 return widget->core.being_destroyed;
139} 139}
140
141#ifdef USE_CAIRO
142/* Xft emulation on cairo. */
143#include <math.h>
144#include <cairo-ft.h>
145#include <cairo-xlib.h>
146
147XftFont *
148crxft_font_open_name (Display *dpy, int screen, const char *name)
149{
150 XftFont *pub = NULL;
151 FcPattern *pattern = FcNameParse ((FcChar8 *) name);
152 if (pattern)
153 {
154 FcConfigSubstitute (NULL, pattern, FcMatchPattern);
155 double dpi;
156 if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) == FcResultNoMatch)
157 {
158 char *v = XGetDefault (dpy, "Xft", FC_DPI);
159 if (v == NULL || sscanf (v, "%lf", &dpi) != 1)
160 dpi = ((DisplayHeight (dpy, screen) * 25.4)
161 / DisplayHeightMM (dpy, screen));
162 FcPatternAddDouble (pattern, FC_DPI, dpi);
163 }
164 FcDefaultSubstitute (pattern);
165 cairo_font_face_t *font_face
166 = cairo_ft_font_face_create_for_pattern (pattern);
167 if (font_face)
168 {
169 double pixel_size;
170 if ((FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &pixel_size)
171 != FcResultMatch)
172 || pixel_size < 1)
173 pixel_size = 10;
174
175 pub = xmalloc (sizeof (*pub));
176 cairo_matrix_t font_matrix, ctm;
177 cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
178 cairo_matrix_init_identity (&ctm);
179 cairo_font_options_t *options = cairo_font_options_create ();
180 cairo_ft_font_options_substitute (options, pattern);
181 pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix,
182 &ctm, options);
183 cairo_font_face_destroy (font_face);
184 cairo_font_options_destroy (options);
185
186 cairo_font_extents_t extents;
187 cairo_scaled_font_extents (pub->scaled_font, &extents);
188 pub->ascent = lround (extents.ascent);
189 pub->descent = lround (extents.descent);
190 pub->height = lround (extents.height);
191 pub->max_advance_width = lround (extents.max_x_advance);
192 }
193 FcPatternDestroy (pattern);
194 }
195 return pub;
196}
197
198void
199crxft_font_close (XftFont *pub)
200{
201 cairo_scaled_font_destroy (pub->scaled_font);
202 xfree (pub);
203}
204
205cairo_t *
206crxft_draw_create (Display *dpy, Drawable drawable, Visual *visual)
207{
208 cairo_t *cr = NULL;
209 Window root;
210 int x, y;
211 unsigned int width, height, border_width, depth;
212
213 if (!XGetGeometry (dpy, drawable, &root, &x, &y, &width, &height,
214 &border_width, &depth))
215 return NULL;
216
217 cairo_surface_t *surface = cairo_xlib_surface_create (dpy, drawable, visual,
218 width, height);
219 if (surface)
220 {
221 cr = cairo_create (surface);
222 cairo_surface_destroy (surface);
223 }
224
225 return cr;
226}
227
228static void
229crxft_set_source_color (cairo_t *cr, const XftColor *color)
230{
231 cairo_set_source_rgba (cr, color->color.red / 65535.0,
232 color->color.green / 65535.0,
233 color->color.blue / 65535.0,
234 color->color.alpha / 65535.0);
235}
236
237void
238crxft_draw_rect (cairo_t *cr, const XftColor *color, int x, int y,
239 unsigned int width, unsigned int height)
240{
241 crxft_set_source_color (cr, color);
242 cairo_rectangle (cr, x, y, width, height);
243 cairo_fill (cr);
244}
245
246void
247crxft_draw_string (cairo_t *cr, const XftColor *color, XftFont *pub,
248 int x, int y, const FcChar8 *string, int len)
249{
250 char *buf = xmalloc (len + 1);
251 memcpy (buf, string, len);
252 buf[len] = '\0';
253 crxft_set_source_color (cr, color);
254 cairo_set_scaled_font (cr, pub->scaled_font);
255 cairo_move_to (cr, x, y);
256 cairo_show_text (cr, buf);
257 xfree (buf);
258}
259
260void
261crxft_text_extents (XftFont *pub, const FcChar8 *string, int len,
262 XGlyphInfo *extents)
263{
264 char *buf = xmalloc (len + 1);
265 memcpy (buf, string, len);
266 buf[len] = '\0';
267 cairo_text_extents_t text_extents;
268 cairo_scaled_font_text_extents (pub->scaled_font, buf, &text_extents);
269 xfree (buf);
270 extents->x = ceil (- text_extents.x_bearing);
271 extents->y = ceil (- text_extents.y_bearing);
272 extents->width = (ceil (text_extents.x_bearing + text_extents.width)
273 + extents->x);
274 extents->height = (ceil (text_extents.y_bearing + text_extents.height)
275 + extents->y);
276 extents->xOff = lround (text_extents.x_advance);
277 extents->yOff = lround (text_extents.y_advance);
278}
279#endif /* USE_CAIRO */
diff --git a/lwlib/lwlib-utils.h b/lwlib/lwlib-utils.h
index ec3daab94ef..64372f19ad2 100644
--- a/lwlib/lwlib-utils.h
+++ b/lwlib/lwlib-utils.h
@@ -15,4 +15,49 @@ Widget *XtCompositeChildren (Widget, unsigned int *);
15Boolean 15Boolean
16XtWidgetBeingDestroyedP (Widget widget); 16XtWidgetBeingDestroyedP (Widget widget);
17 17
18#ifdef USE_CAIRO
19
20#include <cairo.h>
21#include <fontconfig/fontconfig.h>
22
23typedef struct {
24 cairo_scaled_font_t *scaled_font;
25 int ascent, descent, height, max_advance_width;
26} XftFont;
27
28typedef cairo_t XftDraw;
29
30typedef struct {
31 unsigned long pixel;
32 struct {unsigned short red, green, blue, alpha;} color;
33} XftColor;
34
35#ifdef HAVE_XRENDER
36#include <X11/extensions/Xrender.h>
37#else
38typedef struct {
39 unsigned short width, height;
40 short x, y, xOff, yOff;
41} XGlyphInfo;
42#endif
43
44#define XftFontOpenName crxft_font_open_name
45extern XftFont *crxft_font_open_name (Display *, int, const char *);
46#define XftFontClose(dpy, pub) crxft_font_close (pub)
47extern void crxft_font_close (XftFont *);
48#define XftDrawCreate(dpy, drawable, visual, colormap) \
49 crxft_draw_create (dpy, drawable, visual)
50extern cairo_t *crxft_draw_create (Display *, Drawable, Visual *);
51#define XftDrawDestroy cairo_destroy
52#define XftDrawRect crxft_draw_rect
53extern void crxft_draw_rect (cairo_t *, const XftColor *, int, int,
54 unsigned int, unsigned int);
55#define XftDrawStringUtf8 crxft_draw_string
56extern void crxft_draw_string (cairo_t *, const XftColor *, XftFont *,
57 int, int, const FcChar8 *, int);
58#define XftTextExtentsUtf8(dpy, pub, string, len, extents) \
59 crxft_text_extents (pub, string, len, extents)
60extern void crxft_text_extents (XftFont *, const FcChar8 *, int, XGlyphInfo *);
61
62#endif /* USE_CAIRO */
18#endif /* _LWLIB_UTILS_H_ */ 63#endif /* _LWLIB_UTILS_H_ */
diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c
index a5704cbfb53..6292c840f5d 100644
--- a/lwlib/xlwmenu.c
+++ b/lwlib/xlwmenu.c
@@ -107,7 +107,7 @@ xlwMenuResources[] =
107 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet), 107 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
108 offset(menu.fontSet), XtRFontSet, NULL}, 108 offset(menu.fontSet), XtRFontSet, NULL},
109#endif 109#endif
110#ifdef HAVE_XFT 110#if defined USE_CAIRO || defined HAVE_XFT
111#define DEFAULT_FONTNAME "Sans-10" 111#define DEFAULT_FONTNAME "Sans-10"
112#else 112#else
113#define DEFAULT_FONTNAME "XtDefaultFont" 113#define DEFAULT_FONTNAME "XtDefaultFont"
@@ -325,7 +325,7 @@ string_width (XlwMenuWidget mw, char *s)
325{ 325{
326 XCharStruct xcs; 326 XCharStruct xcs;
327 int drop; 327 int drop;
328#ifdef HAVE_XFT 328#if defined USE_CAIRO || defined HAVE_XFT
329 if (mw->menu.xft_font) 329 if (mw->menu.xft_font)
330 { 330 {
331 XGlyphInfo gi; 331 XGlyphInfo gi;
@@ -349,7 +349,7 @@ string_width (XlwMenuWidget mw, char *s)
349 349
350} 350}
351 351
352#ifdef HAVE_XFT 352#if defined USE_CAIRO || defined HAVE_XFT
353#define MENU_FONT_HEIGHT(mw) \ 353#define MENU_FONT_HEIGHT(mw) \
354 ((mw)->menu.xft_font != NULL \ 354 ((mw)->menu.xft_font != NULL \
355 ? (mw)->menu.xft_font->height \ 355 ? (mw)->menu.xft_font->height \
@@ -965,7 +965,7 @@ display_menu_item (XlwMenuWidget mw,
965 int width; 965 int width;
966 enum menu_separator separator; 966 enum menu_separator separator;
967 int separator_p = lw_separator_p (val->name, &separator, 0); 967 int separator_p = lw_separator_p (val->name, &separator, 0);
968#ifdef HAVE_XFT 968#if defined USE_CAIRO || defined HAVE_XFT
969 XftColor *xftfg; 969 XftColor *xftfg;
970#endif 970#endif
971 971
@@ -1005,7 +1005,7 @@ display_menu_item (XlwMenuWidget mw,
1005 else 1005 else
1006 text_gc = mw->menu.disabled_gc; 1006 text_gc = mw->menu.disabled_gc;
1007 deco_gc = mw->menu.foreground_gc; 1007 deco_gc = mw->menu.foreground_gc;
1008#ifdef HAVE_XFT 1008#if defined USE_CAIRO || defined HAVE_XFT
1009 xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg; 1009 xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg;
1010#endif 1010#endif
1011 1011
@@ -1032,10 +1032,13 @@ display_menu_item (XlwMenuWidget mw,
1032 x_offset += ws->button_width; 1032 x_offset += ws->button_width;
1033 1033
1034 1034
1035#ifdef HAVE_XFT 1035#if defined USE_CAIRO || defined HAVE_XFT
1036 if (ws->xft_draw) 1036 if (ws->xft_draw)
1037 { 1037 {
1038 int draw_y = y + v_spacing + shadow; 1038 int draw_y = y + v_spacing + shadow;
1039#ifdef USE_CAIRO
1040 cairo_surface_mark_dirty (cairo_get_target (ws->xft_draw));
1041#endif
1039 XftDrawStringUtf8 (ws->xft_draw, xftfg, 1042 XftDrawStringUtf8 (ws->xft_draw, xftfg,
1040 mw->menu.xft_font, 1043 mw->menu.xft_font,
1041 x_offset, draw_y + font_ascent, 1044 x_offset, draw_y + font_ascent,
@@ -1078,7 +1081,7 @@ display_menu_item (XlwMenuWidget mw,
1078 } 1081 }
1079 else if (val->key) 1082 else if (val->key)
1080 { 1083 {
1081#ifdef HAVE_XFT 1084#if defined USE_CAIRO || defined HAVE_XFT
1082 if (ws->xft_draw) 1085 if (ws->xft_draw)
1083 { 1086 {
1084 int draw_x = ws->width - ws->max_rest_width 1087 int draw_x = ws->width - ws->max_rest_width
@@ -1119,6 +1122,10 @@ display_menu_item (XlwMenuWidget mw,
1119 draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, 1122 draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height,
1120 True, False); 1123 True, False);
1121 } 1124 }
1125#ifdef USE_CAIRO
1126 if (ws->xft_draw)
1127 cairo_surface_flush (cairo_get_target (ws->xft_draw));
1128#endif
1122 1129
1123 if (highlighted_p) 1130 if (highlighted_p)
1124 draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False, 1131 draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False,
@@ -1320,7 +1327,7 @@ make_windows_if_needed (XlwMenuWidget mw, int n)
1320 XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw); 1327 XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw);
1321 windows [i].window = XtWindow (windows [i].w); 1328 windows [i].window = XtWindow (windows [i].w);
1322 windows [i].pixmap = None; 1329 windows [i].pixmap = None;
1323#ifdef HAVE_XFT 1330#if defined USE_CAIRO || defined HAVE_XFT
1324 windows [i].xft_draw = 0; 1331 windows [i].xft_draw = 0;
1325#endif 1332#endif
1326 set_window_type (windows [i].w, mw); 1333 set_window_type (windows [i].w, mw);
@@ -1411,7 +1418,7 @@ create_pixmap_for_menu (window_state* ws, XlwMenuWidget mw)
1411 ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window, 1418 ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window,
1412 ws->width, ws->height, 1419 ws->width, ws->height,
1413 DefaultDepthOfScreen (XtScreen (ws->w))); 1420 DefaultDepthOfScreen (XtScreen (ws->w)));
1414#ifdef HAVE_XFT 1421#if defined USE_CAIRO || defined HAVE_XFT
1415 if (ws->xft_draw) 1422 if (ws->xft_draw)
1416 XftDrawDestroy (ws->xft_draw); 1423 XftDrawDestroy (ws->xft_draw);
1417 if (mw->menu.xft_font) 1424 if (mw->menu.xft_font)
@@ -1831,7 +1838,7 @@ release_shadow_gcs (XlwMenuWidget mw)
1831 XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc); 1838 XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
1832} 1839}
1833 1840
1834#ifdef HAVE_XFT 1841#if defined USE_CAIRO || defined HAVE_XFT
1835static XftFont * 1842static XftFont *
1836getDefaultXftFont (XlwMenuWidget mw) 1843getDefaultXftFont (XlwMenuWidget mw)
1837{ 1844{
@@ -1887,7 +1894,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
1887 gray_width, gray_height, 1894 gray_width, gray_height,
1888 (unsigned long)1, (unsigned long)0, 1); 1895 (unsigned long)1, (unsigned long)0, 1);
1889 1896
1890#ifdef HAVE_XFT 1897#if defined USE_CAIRO || defined HAVE_XFT
1891 if (openXftFont (mw)) 1898 if (openXftFont (mw))
1892 ; 1899 ;
1893 else 1900 else
@@ -1933,7 +1940,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
1933 mw->menu.windows [0].height = 0; 1940 mw->menu.windows [0].height = 0;
1934 mw->menu.windows [0].max_rest_width = 0; 1941 mw->menu.windows [0].max_rest_width = 0;
1935 mw->menu.windows [0].pixmap = None; 1942 mw->menu.windows [0].pixmap = None;
1936#ifdef HAVE_XFT 1943#if defined USE_CAIRO || defined HAVE_XFT
1937 mw->menu.windows [0].xft_draw = 0; 1944 mw->menu.windows [0].xft_draw = 0;
1938#endif 1945#endif
1939 size_menu (mw, 0); 1946 size_menu (mw, 0);
@@ -1981,7 +1988,7 @@ XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
1981 set_window_type (mw->menu.windows [0].w, mw); 1988 set_window_type (mw->menu.windows [0].w, mw);
1982 create_pixmap_for_menu (&mw->menu.windows [0], mw); 1989 create_pixmap_for_menu (&mw->menu.windows [0], mw);
1983 1990
1984#ifdef HAVE_XFT 1991#if defined USE_CAIRO || defined HAVE_XFT
1985 if (mw->menu.xft_font) 1992 if (mw->menu.xft_font)
1986 { 1993 {
1987 XColor colors[3]; 1994 XColor colors[3];
@@ -2078,7 +2085,7 @@ XlwMenuDestroy (Widget w)
2078 if (mw->menu.font) 2085 if (mw->menu.font)
2079 XFreeFont (XtDisplay (mw), mw->menu.font); 2086 XFreeFont (XtDisplay (mw), mw->menu.font);
2080 2087
2081#ifdef HAVE_XFT 2088#if defined USE_CAIRO || defined HAVE_XFT
2082 if (mw->menu.windows [0].xft_draw) 2089 if (mw->menu.windows [0].xft_draw)
2083 XftDrawDestroy (mw->menu.windows [0].xft_draw); 2090 XftDrawDestroy (mw->menu.windows [0].xft_draw);
2084 if (mw->menu.xft_font) 2091 if (mw->menu.xft_font)
@@ -2092,7 +2099,7 @@ XlwMenuDestroy (Widget w)
2092 { 2099 {
2093 if (mw->menu.windows [i].pixmap != None) 2100 if (mw->menu.windows [i].pixmap != None)
2094 XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap); 2101 XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap);
2095#ifdef HAVE_XFT 2102#if defined USE_CAIRO || defined HAVE_XFT
2096 if (mw->menu.windows [i].xft_draw) 2103 if (mw->menu.windows [i].xft_draw)
2097 XftDrawDestroy (mw->menu.windows [i].xft_draw); 2104 XftDrawDestroy (mw->menu.windows [i].xft_draw);
2098#endif 2105#endif
@@ -2102,7 +2109,7 @@ XlwMenuDestroy (Widget w)
2102 XtFree ((char *) mw->menu.windows); 2109 XtFree ((char *) mw->menu.windows);
2103} 2110}
2104 2111
2105#ifdef HAVE_XFT 2112#if defined USE_CAIRO || defined HAVE_XFT
2106static int 2113static int
2107fontname_changed (XlwMenuWidget newmw, 2114fontname_changed (XlwMenuWidget newmw,
2108 XlwMenuWidget oldmw) 2115 XlwMenuWidget oldmw)
@@ -2134,7 +2141,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
2134 2141
2135 if (newmw->core.background_pixel != oldmw->core.background_pixel 2142 if (newmw->core.background_pixel != oldmw->core.background_pixel
2136 || newmw->menu.foreground != oldmw->menu.foreground 2143 || newmw->menu.foreground != oldmw->menu.foreground
2137#ifdef HAVE_XFT 2144#if defined USE_CAIRO || defined HAVE_XFT
2138 || fontname_changed (newmw, oldmw) 2145 || fontname_changed (newmw, oldmw)
2139#endif 2146#endif
2140#ifdef HAVE_X_I18N 2147#ifdef HAVE_X_I18N
@@ -2170,7 +2177,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
2170 } 2177 }
2171 } 2178 }
2172 2179
2173#ifdef HAVE_XFT 2180#if defined USE_CAIRO || defined HAVE_XFT
2174 if (fontname_changed (newmw, oldmw)) 2181 if (fontname_changed (newmw, oldmw))
2175 { 2182 {
2176 int i; 2183 int i;
diff --git a/lwlib/xlwmenuP.h b/lwlib/xlwmenuP.h
index 610f83afe45..2a05d993541 100644
--- a/lwlib/xlwmenuP.h
+++ b/lwlib/xlwmenuP.h
@@ -23,9 +23,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
23 23
24#include "xlwmenu.h" 24#include "xlwmenu.h"
25#include <X11/CoreP.h> 25#include <X11/CoreP.h>
26#ifdef HAVE_XFT 26#if defined USE_CAIRO || defined HAVE_XFT
27#ifdef USE_CAIRO
28#include "lwlib-utils.h"
29#else /* HAVE_XFT */
27#include <X11/Xft/Xft.h> 30#include <X11/Xft/Xft.h>
28#endif 31#endif
32#endif
29 33
30/* Elements in the stack arrays. */ 34/* Elements in the stack arrays. */
31typedef struct _window_state 35typedef struct _window_state
@@ -42,7 +46,7 @@ typedef struct _window_state
42 46
43 /* Width of toggle buttons or radio buttons. */ 47 /* Width of toggle buttons or radio buttons. */
44 Dimension button_width; 48 Dimension button_width;
45#ifdef HAVE_XFT 49#if defined USE_CAIRO || defined HAVE_XFT
46 XftDraw* xft_draw; 50 XftDraw* xft_draw;
47#endif 51#endif
48} window_state; 52} window_state;
@@ -56,7 +60,7 @@ typedef struct _XlwMenu_part
56 XFontSet fontSet; 60 XFontSet fontSet;
57 XFontSetExtents *font_extents; 61 XFontSetExtents *font_extents;
58#endif 62#endif
59#ifdef HAVE_XFT 63#if defined USE_CAIRO || defined HAVE_XFT
60 int default_face; 64 int default_face;
61 XftFont* xft_font; 65 XftFont* xft_font;
62 XftColor xft_fg, xft_bg, xft_disabled_fg; 66 XftColor xft_fg, xft_bg, xft_disabled_fg;
diff --git a/src/menu.c b/src/menu.c
index 7f46e68e73e..e82c8570595 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -687,7 +687,7 @@ digest_single_submenu (int start, int end, bool top_level_items)
687 687
688 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name); 688 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
689 } 689 }
690#elif defined (USE_LUCID) && defined (HAVE_XFT) 690#elif defined (USE_LUCID) && (defined USE_CAIRO || defined HAVE_XFT)
691 if (STRINGP (pane_name)) 691 if (STRINGP (pane_name))
692 { 692 {
693 pane_name = ENCODE_UTF_8 (pane_name); 693 pane_name = ENCODE_UTF_8 (pane_name);
diff --git a/src/xfns.c b/src/xfns.c
index dbc5e10c415..9075491e978 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3487,7 +3487,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms)
3487 { 3487 {
3488 const char *names[] 3488 const char *names[]
3489 = { 3489 = {
3490#ifdef HAVE_XFT 3490#if defined USE_CAIRO || defined HAVE_XFT
3491 /* This will find the normal Xft font. */ 3491 /* This will find the normal Xft font. */
3492 "monospace-10", 3492 "monospace-10",
3493#endif 3493#endif
diff --git a/src/xrdb.c b/src/xrdb.c
index 35de446cb7a..0950b706699 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -383,7 +383,7 @@ x_load_resources (Display *display, const char *xrm_string,
383 XrmDatabase db; 383 XrmDatabase db;
384 char line[256]; 384 char line[256];
385 385
386#if defined USE_MOTIF || !defined HAVE_XFT || !defined USE_LUCID 386#if defined USE_MOTIF || !(defined USE_CAIRO || defined HAVE_XFT) || !defined USE_LUCID
387 const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1"; 387 const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
388#endif 388#endif
389 389
@@ -456,7 +456,7 @@ x_load_resources (Display *display, const char *xrm_string,
456 456
457 sprintf (line, "Emacs.dialog*.background: grey75"); 457 sprintf (line, "Emacs.dialog*.background: grey75");
458 XrmPutLineResource (&rdb, line); 458 XrmPutLineResource (&rdb, line);
459#if !defined (HAVE_XFT) || !defined (USE_LUCID) 459#if !(defined USE_CAIRO || defined HAVE_XFT) || !defined (USE_LUCID)
460 sprintf (line, "Emacs.dialog*.font: %s", helv); 460 sprintf (line, "Emacs.dialog*.font: %s", helv);
461 XrmPutLineResource (&rdb, line); 461 XrmPutLineResource (&rdb, line);
462 sprintf (line, "*XlwMenu*font: %s", helv); 462 sprintf (line, "*XlwMenu*font: %s", helv);
diff --git a/src/xsettings.c b/src/xsettings.c
index 947d5cfb7b6..3e9012e3ab1 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -45,9 +45,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
45#include <gconf/gconf-client.h> 45#include <gconf/gconf-client.h>
46#endif 46#endif
47 47
48#ifdef HAVE_XFT 48#if defined USE_CAIRO || defined HAVE_XFT
49#ifdef USE_CAIRO
50#include <fontconfig/fontconfig.h>
51#else /* HAVE_XFT */
49#include <X11/Xft/Xft.h> 52#include <X11/Xft/Xft.h>
50#endif 53#endif
54#endif
51 55
52static char *current_mono_font; 56static char *current_mono_font;
53static char *current_font; 57static char *current_font;
@@ -83,7 +87,7 @@ dpyinfo_valid (struct x_display_info *dpyinfo)
83 87
84/* Store a monospace font change event if the monospaced font changed. */ 88/* Store a monospace font change event if the monospaced font changed. */
85 89
86#if defined HAVE_XFT && (defined HAVE_GSETTINGS || defined HAVE_GCONF) 90#if (defined USE_CAIRO || defined HAVE_XFT) && (defined HAVE_GSETTINGS || defined HAVE_GCONF)
87static void 91static void
88store_monospaced_changed (const char *newfont) 92store_monospaced_changed (const char *newfont)
89{ 93{
@@ -102,7 +106,7 @@ store_monospaced_changed (const char *newfont)
102 106
103/* Store a font name change event if the font name changed. */ 107/* Store a font name change event if the font name changed. */
104 108
105#ifdef HAVE_XFT 109#if defined USE_CAIRO || defined HAVE_XFT
106static void 110static void
107store_font_name_changed (const char *newfont) 111store_font_name_changed (const char *newfont)
108{ 112{
@@ -117,7 +121,7 @@ store_font_name_changed (const char *newfont)
117 XCAR (first_dpyinfo->name_list_element)); 121 XCAR (first_dpyinfo->name_list_element));
118 } 122 }
119} 123}
120#endif /* HAVE_XFT */ 124#endif /* USE_CAIRO || HAVE_XFT */
121 125
122/* Map TOOL_BAR_STYLE from a string to its corresponding Lisp value. 126/* Map TOOL_BAR_STYLE from a string to its corresponding Lisp value.
123 Return Qnil if TOOL_BAR_STYLE is not known. */ 127 Return Qnil if TOOL_BAR_STYLE is not known. */
@@ -157,7 +161,7 @@ store_tool_bar_style_changed (const char *newstyle,
157 XCAR (dpyinfo->name_list_element)); 161 XCAR (dpyinfo->name_list_element));
158} 162}
159 163
160#ifdef HAVE_XFT 164#if defined USE_CAIRO || defined HAVE_XFT
161#define XSETTINGS_FONT_NAME "Gtk/FontName" 165#define XSETTINGS_FONT_NAME "Gtk/FontName"
162#endif 166#endif
163#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle" 167#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle"
@@ -174,7 +178,7 @@ enum {
174}; 178};
175struct xsettings 179struct xsettings
176{ 180{
177#ifdef HAVE_XFT 181#if defined USE_CAIRO || defined HAVE_XFT
178 FcBool aa, hinting; 182 FcBool aa, hinting;
179 int rgba, lcdfilter, hintstyle; 183 int rgba, lcdfilter, hintstyle;
180 double dpi; 184 double dpi;
@@ -191,7 +195,7 @@ struct xsettings
191#define GSETTINGS_SCHEMA "org.gnome.desktop.interface" 195#define GSETTINGS_SCHEMA "org.gnome.desktop.interface"
192#define GSETTINGS_TOOL_BAR_STYLE "toolbar-style" 196#define GSETTINGS_TOOL_BAR_STYLE "toolbar-style"
193 197
194#ifdef HAVE_XFT 198#if defined USE_CAIRO || defined HAVE_XFT
195#define GSETTINGS_MONO_FONT "monospace-font-name" 199#define GSETTINGS_MONO_FONT "monospace-font-name"
196#define GSETTINGS_FONT_NAME "font-name" 200#define GSETTINGS_FONT_NAME "font-name"
197#endif 201#endif
@@ -224,7 +228,7 @@ something_changed_gsettingsCB (GSettings *settings,
224 g_variant_unref (val); 228 g_variant_unref (val);
225 } 229 }
226 } 230 }
227#ifdef HAVE_XFT 231#if defined USE_CAIRO || defined HAVE_XFT
228 else if (strcmp (key, GSETTINGS_MONO_FONT) == 0) 232 else if (strcmp (key, GSETTINGS_MONO_FONT) == 0)
229 { 233 {
230 val = g_settings_get_value (settings, GSETTINGS_MONO_FONT); 234 val = g_settings_get_value (settings, GSETTINGS_MONO_FONT);
@@ -253,14 +257,14 @@ something_changed_gsettingsCB (GSettings *settings,
253 g_variant_unref (val); 257 g_variant_unref (val);
254 } 258 }
255 } 259 }
256#endif /* HAVE_XFT */ 260#endif /* USE_CAIRO || HAVE_XFT */
257} 261}
258 262
259#endif /* HAVE_GSETTINGS */ 263#endif /* HAVE_GSETTINGS */
260 264
261#ifdef HAVE_GCONF 265#ifdef HAVE_GCONF
262#define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style" 266#define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style"
263#ifdef HAVE_XFT 267#if defined USE_CAIRO || defined HAVE_XFT
264#define GCONF_MONO_FONT "/desktop/gnome/interface/monospace_font_name" 268#define GCONF_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
265#define GCONF_FONT_NAME "/desktop/gnome/interface/font_name" 269#define GCONF_FONT_NAME "/desktop/gnome/interface/font_name"
266#endif 270#endif
@@ -286,7 +290,7 @@ something_changed_gconfCB (GConfClient *client,
286 const char *value = gconf_value_get_string (v); 290 const char *value = gconf_value_get_string (v);
287 store_tool_bar_style_changed (value, first_dpyinfo); 291 store_tool_bar_style_changed (value, first_dpyinfo);
288 } 292 }
289#ifdef HAVE_XFT 293#if defined USE_CAIRO || defined HAVE_XFT
290 else if (strcmp (key, GCONF_MONO_FONT) == 0) 294 else if (strcmp (key, GCONF_MONO_FONT) == 0)
291 { 295 {
292 const char *value = gconf_value_get_string (v); 296 const char *value = gconf_value_get_string (v);
@@ -297,12 +301,12 @@ something_changed_gconfCB (GConfClient *client,
297 const char *value = gconf_value_get_string (v); 301 const char *value = gconf_value_get_string (v);
298 store_font_name_changed (value); 302 store_font_name_changed (value);
299 } 303 }
300#endif /* HAVE_XFT */ 304#endif /* USE_CAIRO || HAVE_XFT */
301} 305}
302 306
303#endif /* HAVE_GCONF */ 307#endif /* HAVE_GCONF */
304 308
305#ifdef HAVE_XFT 309#if defined USE_CAIRO || defined HAVE_XFT
306 310
307/* Older fontconfig versions don't have FC_LCD_*. */ 311/* Older fontconfig versions don't have FC_LCD_*. */
308#ifndef FC_LCD_NONE 312#ifndef FC_LCD_NONE
@@ -315,7 +319,7 @@ something_changed_gconfCB (GConfClient *client,
315#define FC_LCD_FILTER "lcdfilter" 319#define FC_LCD_FILTER "lcdfilter"
316#endif 320#endif
317 321
318#endif /* HAVE_XFT */ 322#endif /* USE_CAIRO || HAVE_XFT */
319 323
320/* Find the window that contains the XSETTINGS property values. */ 324/* Find the window that contains the XSETTINGS property values. */
321 325
@@ -440,7 +444,7 @@ parse_settings (unsigned char *prop,
440 if (bytes_parsed > bytes) return settings_seen; 444 if (bytes_parsed > bytes) return settings_seen;
441 445
442 want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0; 446 want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0;
443#ifdef HAVE_XFT 447#if defined USE_CAIRO || defined HAVE_XFT
444 if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0) 448 if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0)
445 || strcmp (XSETTINGS_FONT_NAME, name) == 0) 449 || strcmp (XSETTINGS_FONT_NAME, name) == 0)
446 want_this = true; 450 want_this = true;
@@ -490,7 +494,7 @@ parse_settings (unsigned char *prop,
490 dupstring (&settings->tb_style, sval); 494 dupstring (&settings->tb_style, sval);
491 settings->seen |= SEEN_TB_STYLE; 495 settings->seen |= SEEN_TB_STYLE;
492 } 496 }
493#ifdef HAVE_XFT 497#if defined USE_CAIRO || defined HAVE_XFT
494 else if (strcmp (name, XSETTINGS_FONT_NAME) == 0) 498 else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
495 { 499 {
496 dupstring (&settings->font, sval); 500 dupstring (&settings->font, sval);
@@ -553,7 +557,7 @@ parse_settings (unsigned char *prop,
553 else 557 else
554 settings->seen &= ~SEEN_LCDFILTER; 558 settings->seen &= ~SEEN_LCDFILTER;
555 } 559 }
556#endif /* HAVE_XFT */ 560#endif /* USE_CAIRO || HAVE_XFT */
557 else 561 else
558 want_this = false; 562 want_this = false;
559 settings_seen += want_this; 563 settings_seen += want_this;
@@ -604,16 +608,18 @@ static void
604apply_xft_settings (struct x_display_info *dpyinfo, 608apply_xft_settings (struct x_display_info *dpyinfo,
605 struct xsettings *settings) 609 struct xsettings *settings)
606{ 610{
607#ifdef HAVE_XFT 611#if defined USE_CAIRO || defined HAVE_XFT
608 FcPattern *pat; 612 FcPattern *pat;
609 struct xsettings oldsettings; 613 struct xsettings oldsettings;
610 bool changed = false; 614 bool changed = false;
611 615
612 memset (&oldsettings, 0, sizeof (oldsettings)); 616 memset (&oldsettings, 0, sizeof (oldsettings));
613 pat = FcPatternCreate (); 617 pat = FcPatternCreate ();
618#ifdef HAVE_XFT
614 XftDefaultSubstitute (dpyinfo->display, 619 XftDefaultSubstitute (dpyinfo->display,
615 XScreenNumberOfScreen (dpyinfo->screen), 620 XScreenNumberOfScreen (dpyinfo->screen),
616 pat); 621 pat);
622#endif
617 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa); 623 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
618 FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting); 624 FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
619#ifdef FC_HINT_STYLE 625#ifdef FC_HINT_STYLE
@@ -713,7 +719,9 @@ apply_xft_settings (struct x_display_info *dpyinfo,
713 }; 719 };
714 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth]; 720 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
715 721
722#ifdef HAVE_XFT
716 XftDefaultSet (dpyinfo->display, pat); 723 XftDefaultSet (dpyinfo->display, pat);
724#endif
717 store_config_changed_event (Qfont_render, 725 store_config_changed_event (Qfont_render,
718 XCAR (dpyinfo->name_list_element)); 726 XCAR (dpyinfo->name_list_element));
719 Vxft_settings 727 Vxft_settings
@@ -725,7 +733,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
725 } 733 }
726 else 734 else
727 FcPatternDestroy (pat); 735 FcPatternDestroy (pat);
728#endif /* HAVE_XFT */ 736#endif /* USE_CAIRO || HAVE_XFT */
729} 737}
730 738
731/* Read XSettings from the display for DPYINFO. 739/* Read XSettings from the display for DPYINFO.
@@ -748,7 +756,7 @@ read_and_apply_settings (struct x_display_info *dpyinfo, bool send_event_p)
748 current_tool_bar_style = map_tool_bar_style (settings.tb_style); 756 current_tool_bar_style = map_tool_bar_style (settings.tb_style);
749 xfree (settings.tb_style); 757 xfree (settings.tb_style);
750 } 758 }
751#ifdef HAVE_XFT 759#if defined USE_CAIRO || defined HAVE_XFT
752 if (settings.seen & SEEN_FONT) 760 if (settings.seen & SEEN_FONT)
753 { 761 {
754 if (send_event_p) 762 if (send_event_p)
@@ -850,7 +858,7 @@ init_gsettings (void)
850 g_variant_unref (val); 858 g_variant_unref (val);
851 } 859 }
852 860
853#ifdef HAVE_XFT 861#if defined USE_CAIRO || defined HAVE_XFT
854 val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT); 862 val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT);
855 if (val) 863 if (val)
856 { 864 {
@@ -868,7 +876,7 @@ init_gsettings (void)
868 dupstring (&current_font, g_variant_get_string (val, NULL)); 876 dupstring (&current_font, g_variant_get_string (val, NULL));
869 g_variant_unref (val); 877 g_variant_unref (val);
870 } 878 }
871#endif /* HAVE_XFT */ 879#endif /* USE_CAIRO || HAVE_XFT */
872 880
873#endif /* HAVE_GSETTINGS */ 881#endif /* HAVE_GSETTINGS */
874} 882}
@@ -903,7 +911,7 @@ init_gconf (void)
903 g_free (s); 911 g_free (s);
904 } 912 }
905 913
906#ifdef HAVE_XFT 914#if defined USE_CAIRO || defined HAVE_XFT
907 s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL); 915 s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
908 if (s) 916 if (s)
909 { 917 {
@@ -932,7 +940,7 @@ init_gconf (void)
932 GCONF_FONT_NAME, 940 GCONF_FONT_NAME,
933 something_changed_gconfCB, 941 something_changed_gconfCB,
934 NULL, NULL, NULL); 942 NULL, NULL, NULL);
935#endif /* HAVE_XFT */ 943#endif /* USE_CAIRO || HAVE_XFT */
936#endif /* HAVE_GCONF */ 944#endif /* HAVE_GCONF */
937} 945}
938 946
@@ -1055,7 +1063,7 @@ If this variable is nil, Emacs ignores system font changes. */);
1055 doc: /* Font settings applied to Xft. */); 1063 doc: /* Font settings applied to Xft. */);
1056 Vxft_settings = empty_unibyte_string; 1064 Vxft_settings = empty_unibyte_string;
1057 1065
1058#ifdef HAVE_XFT 1066#if defined USE_CAIRO || defined HAVE_XFT
1059 Fprovide (intern_c_string ("font-render-setting"), Qnil); 1067 Fprovide (intern_c_string ("font-render-setting"), Qnil);
1060#if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) 1068#if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
1061 Fprovide (intern_c_string ("system-font-setting"), Qnil); 1069 Fprovide (intern_c_string ("system-font-setting"), Qnil);
diff --git a/src/xterm.c b/src/xterm.c
index 0b83263a0e6..e85e8e35d44 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12733,7 +12733,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
12733 dpyinfo->supports_xdbe = true; 12733 dpyinfo->supports_xdbe = true;
12734#endif 12734#endif
12735 12735
12736#ifdef HAVE_XFT 12736#if defined USE_CAIRO || defined HAVE_XFT
12737 { 12737 {
12738 /* If we are using Xft, the following precautions should be made: 12738 /* If we are using Xft, the following precautions should be made:
12739 12739