/* xftfont.c -- XFT font driver.
- Copyright (C) 2006-2013 Free Software Foundation, Inc.
+ Copyright (C) 2006-2014 Free Software Foundation, Inc.
Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H13PRO009
static Lisp_Object QChinting, QCautohint, QChintstyle, QCrgba, QCembolden,
QClcdfilter;
-/* The actual structure for Xft font that can be casted to struct
+/* The actual structure for Xft font that can be cast to struct
font. */
struct xftfont_info
int index;
FT_Matrix matrix;
Display *display;
- int screen;
XftFont *xftfont;
+ unsigned x_display_id;
};
/* Structure pointed by (struct face *)->extra */
XftColor xft_bg; /* color for face->background */
};
-static void xftfont_get_colors (struct frame *, struct face *, GC gc,
- struct xftface_info *,
- XftColor *fg, XftColor *bg);
-
-
/* Setup foreground and background colors of GC into FG and BG. If
XFTFACE_INFO is not NULL, reuse the colors in it if possible. BG
may be NULL. */
block_input ();
- /* Make sure that the Xrender extension is added before the Xft one.
- Otherwise, the close-display hook set by Xft is called after the
- one for Xrender, and the former tries to re-add the latter. This
- results in inconsistency of internal states and leads to X
- protocol error when one reconnects to the same X server.
- (Bug#1696) */
- {
- int event_base, error_base;
- XRenderQueryExtension (display, &event_base, &error_base);
- }
/* Substitute in values from X resources and XftDefaultSet. */
XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat);
xftfont_info = (struct xftfont_info *) font;
xftfont_info->display = display;
- xftfont_info->screen = FRAME_X_SCREEN_NUMBER (f);
xftfont_info->xftfont = xftfont;
+ xftfont_info->x_display_id = FRAME_DISPLAY_INFO (f)->x_id;
/* This means that there's no need of transformation. */
xftfont_info->matrix.xx = 0;
if (FcPatternGetMatrix (xftfont->pattern, FC_MATRIX, 0, &matrix)
}
static void
-xftfont_close (struct frame *f, struct font *font)
+xftfont_close (struct font *font)
{
+ struct x_display_info *xdi;
struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
#ifdef HAVE_LIBOTF
if (xftfont_info->otf)
- OTF_close (xftfont_info->otf);
+ {
+ OTF_close (xftfont_info->otf);
+ xftfont_info->otf = NULL;
+ }
#endif
- block_input ();
- XftUnlockFace (xftfont_info->xftfont);
- XftFontClose (xftfont_info->display, xftfont_info->xftfont);
- unblock_input ();
+
+ /* See comment in xfont_close. */
+ if (xftfont_info->xftfont
+ && ((xdi = x_display_info_for_display (xftfont_info->display))
+ && xftfont_info->x_display_id == xdi->x_id))
+ {
+ block_input ();
+ XftUnlockFace (xftfont_info->xftfont);
+ XftFontClose (xftfont_info->display, xftfont_info->xftfont);
+ unblock_input ();
+ xftfont_info->xftfont = NULL;
+ }
}
-static int
+static void
xftfont_prepare_face (struct frame *f, struct face *face)
{
struct xftface_info *xftface_info;
if (face != face->ascii_face)
{
face->extra = face->ascii_face->extra;
- return 0;
+ return;
}
#endif
- xftface_info = malloc (sizeof *xftface_info);
- if (! xftface_info)
- return -1;
+ xftface_info = xmalloc (sizeof *xftface_info);
xftfont_get_colors (f, face, face->gc, NULL,
&xftface_info->xft_fg, &xftface_info->xft_bg);
face->extra = xftface_info;
- return 0;
}
static void
xftface_info = (struct xftface_info *) face->extra;
if (xftface_info)
{
- free (xftface_info);
+ xfree (xftface_info);
face->extra = NULL;
}
}