* 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.
fi
fi
+HAVE_CAIRO=no
+if test "${HAVE_X11}" = "yes"; then
+ if test "${with_cairo}" != "no"; then
+ CAIRO_REQUIRED=1.12.0
+ CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
+ EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
+ if test $HAVE_CAIRO = yes; then
+ AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
+ else
+ AC_MSG_ERROR([cairo requested but not found.])
+ fi
+
+ CFLAGS="$CFLAGS $CAIRO_CFLAGS"
+ LIBS="$LIBS $CAIRO_LIBS"
+ AC_SUBST(CAIRO_CFLAGS)
+ AC_SUBST(CAIRO_LIBS)
+ fi
+fi
+
### Start of font-backend (under any platform) section.
# (nothing here yet -- this is a placeholder)
### End of font-backend (under any platform) section.
### Start of font-backend (under X11) section.
if test "${HAVE_X11}" = "yes"; then
+ if test $HAVE_CAIRO = yes; then
+ dnl Strict linkers fail with
+ dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
+ dnl if -lfreetype is not specified.
+ dnl The following is needed to set FREETYPE_LIBS.
+ EMACS_CHECK_MODULES([FREETYPE], [freetype2])
+
+ test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(cairo requires libfreetype)
+
+ EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
+
+ test "$HAVE_FONTCONFIG" = "no" && AC_MSG_ERROR(cairo requires libfontconfig)
+ else
## Use -lXft if available, unless '--with-xft=no'.
HAVE_XFT=maybe
if test "x${with_x}" = "xno"; then
test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
fi
+ fi # $HAVE_CAIRO != yes
HAVE_LIBOTF=no
if test "${HAVE_FREETYPE}" = "yes"; then
AC_SUBST(M17N_FLT_CFLAGS)
AC_SUBST(M17N_FLT_LIBS)
-HAVE_CAIRO=no
-if test "${HAVE_X11}" = "yes"; then
- if test "${with_cairo}" != "no"; then
- CAIRO_REQUIRED=1.12.0
- CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
- EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
- if test $HAVE_CAIRO = yes; then
- AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
- else
- AC_MSG_ERROR([cairo requested but not found.])
- fi
-
- CFLAGS="$CFLAGS $CAIRO_CFLAGS"
- LIBS="$LIBS $CAIRO_LIBS"
- AC_SUBST(CAIRO_CFLAGS)
- AC_SUBST(CAIRO_LIBS)
- fi
-fi
-
if test "${HAVE_X11}" = "yes"; then
AC_CHECK_HEADER(X11/Xlib-xcb.h,
AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
#include <X11/Xatom.h>
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
+#ifdef USE_CAIRO
+#include <stdlib.h>
+#include "lwlib-utils.h"
+#else /* HAVE_XFT */
#include <X11/Xft/Xft.h>
+#endif
struct widget_xft_data
{
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
static void
fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font)
{
/* 1.2 gives reasonable line spacing. */
y += data->xft_font->height * 1.2;
}
+#ifdef USE_CAIRO
+ cairo_surface_flush (cairo_get_target (data->xft_draw));
+#endif
}
if (XtIsSubclass (widget, dialogWidgetClass))
{
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (instance->xft_data && instance->xft_data[0].xft_font)
{
set_text (&instance->xft_data[0], instance->parent,
XtSetArg (al[ac], XtNlabel, val->value);ac++;
/* Force centered button text. Se above. */
XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (instance->xft_data && instance->xft_data[0].xft_font)
{
int th;
};
static Boolean actions_initted = False;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
static XtActionsRec button_actions[] =
{
{ "my_reset", command_reset },
Widget dialog;
Widget button;
XtTranslations override;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
XftFont *xft_font = 0;
XtTranslations button_override;
#endif
XtAppContext app = XtWidgetToApplicationContext (parent);
XtAppAddActions (app, xaw_actions,
sizeof (xaw_actions) / sizeof (xaw_actions[0]));
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
XtAppAddActions (app, button_actions,
sizeof (button_actions) / sizeof (button_actions[0]));
#endif
override = XtParseTranslationTable (dialogOverride);
XtOverrideTranslations (dialog, override);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
{
int num;
Widget *ch = NULL;
sprintf (button_name, "button%d", ++bc);
button = XtCreateManagedWidget (button_name, commandWidgetClass,
dialog, av, ac);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (xft_font)
{
fill_xft_data (&instance->xft_data[bc], button, xft_font);
sprintf (button_name, "button%d", ++bc);
button = XtCreateManagedWidget (button_name, commandWidgetClass,
dialog, av, ac);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (xft_font)
{
fill_xft_data (&instance->xft_data[bc], button, xft_font);
Widget widget;
Widget parent;
Boolean pop_up_p;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
struct widget_xft_data *xft_data;
#endif
struct _widget_info* info;
{
return widget->core.being_destroyed;
}
+
+#ifdef USE_CAIRO
+/* Xft emulation on cairo. */
+#include <math.h>
+#include <cairo-ft.h>
+#include <cairo-xlib.h>
+
+XftFont *
+crxft_font_open_name (Display *dpy, int screen, const char *name)
+{
+ XftFont *pub = NULL;
+ FcPattern *pattern = FcNameParse ((FcChar8 *) name);
+ if (pattern)
+ {
+ FcConfigSubstitute (NULL, pattern, FcMatchPattern);
+ double dpi;
+ if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) == FcResultNoMatch)
+ {
+ char *v = XGetDefault (dpy, "Xft", FC_DPI);
+ if (v == NULL || sscanf (v, "%lf", &dpi) != 1)
+ dpi = ((DisplayHeight (dpy, screen) * 25.4)
+ / DisplayHeightMM (dpy, screen));
+ FcPatternAddDouble (pattern, FC_DPI, dpi);
+ }
+ FcDefaultSubstitute (pattern);
+ cairo_font_face_t *font_face
+ = cairo_ft_font_face_create_for_pattern (pattern);
+ if (font_face)
+ {
+ double pixel_size;
+ if ((FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &pixel_size)
+ != FcResultMatch)
+ || pixel_size < 1)
+ pixel_size = 10;
+
+ pub = xmalloc (sizeof (*pub));
+ cairo_matrix_t font_matrix, ctm;
+ cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
+ cairo_matrix_init_identity (&ctm);
+ cairo_font_options_t *options = cairo_font_options_create ();
+ cairo_ft_font_options_substitute (options, pattern);
+ pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix,
+ &ctm, options);
+ cairo_font_face_destroy (font_face);
+ cairo_font_options_destroy (options);
+
+ cairo_font_extents_t extents;
+ cairo_scaled_font_extents (pub->scaled_font, &extents);
+ pub->ascent = lround (extents.ascent);
+ pub->descent = lround (extents.descent);
+ pub->height = lround (extents.height);
+ pub->max_advance_width = lround (extents.max_x_advance);
+ }
+ FcPatternDestroy (pattern);
+ }
+ return pub;
+}
+
+void
+crxft_font_close (XftFont *pub)
+{
+ cairo_scaled_font_destroy (pub->scaled_font);
+ xfree (pub);
+}
+
+cairo_t *
+crxft_draw_create (Display *dpy, Drawable drawable, Visual *visual)
+{
+ cairo_t *cr = NULL;
+ Window root;
+ int x, y;
+ unsigned int width, height, border_width, depth;
+
+ if (!XGetGeometry (dpy, drawable, &root, &x, &y, &width, &height,
+ &border_width, &depth))
+ return NULL;
+
+ cairo_surface_t *surface = cairo_xlib_surface_create (dpy, drawable, visual,
+ width, height);
+ if (surface)
+ {
+ cr = cairo_create (surface);
+ cairo_surface_destroy (surface);
+ }
+
+ return cr;
+}
+
+static void
+crxft_set_source_color (cairo_t *cr, const XftColor *color)
+{
+ cairo_set_source_rgba (cr, color->color.red / 65535.0,
+ color->color.green / 65535.0,
+ color->color.blue / 65535.0,
+ color->color.alpha / 65535.0);
+}
+
+void
+crxft_draw_rect (cairo_t *cr, const XftColor *color, int x, int y,
+ unsigned int width, unsigned int height)
+{
+ crxft_set_source_color (cr, color);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_fill (cr);
+}
+
+void
+crxft_draw_string (cairo_t *cr, const XftColor *color, XftFont *pub,
+ int x, int y, const FcChar8 *string, int len)
+{
+ char *buf = xmalloc (len + 1);
+ memcpy (buf, string, len);
+ buf[len] = '\0';
+ crxft_set_source_color (cr, color);
+ cairo_set_scaled_font (cr, pub->scaled_font);
+ cairo_move_to (cr, x, y);
+ cairo_show_text (cr, buf);
+ xfree (buf);
+}
+
+void
+crxft_text_extents (XftFont *pub, const FcChar8 *string, int len,
+ XGlyphInfo *extents)
+{
+ char *buf = xmalloc (len + 1);
+ memcpy (buf, string, len);
+ buf[len] = '\0';
+ cairo_text_extents_t text_extents;
+ cairo_scaled_font_text_extents (pub->scaled_font, buf, &text_extents);
+ xfree (buf);
+ extents->x = ceil (- text_extents.x_bearing);
+ extents->y = ceil (- text_extents.y_bearing);
+ extents->width = (ceil (text_extents.x_bearing + text_extents.width)
+ + extents->x);
+ extents->height = (ceil (text_extents.y_bearing + text_extents.height)
+ + extents->y);
+ extents->xOff = lround (text_extents.x_advance);
+ extents->yOff = lround (text_extents.y_advance);
+}
+#endif /* USE_CAIRO */
Boolean
XtWidgetBeingDestroyedP (Widget widget);
+#ifdef USE_CAIRO
+
+#include <cairo.h>
+#include <fontconfig/fontconfig.h>
+
+typedef struct {
+ cairo_scaled_font_t *scaled_font;
+ int ascent, descent, height, max_advance_width;
+} XftFont;
+
+typedef cairo_t XftDraw;
+
+typedef struct {
+ unsigned long pixel;
+ struct {unsigned short red, green, blue, alpha;} color;
+} XftColor;
+
+#ifdef HAVE_XRENDER
+#include <X11/extensions/Xrender.h>
+#else
+typedef struct {
+ unsigned short width, height;
+ short x, y, xOff, yOff;
+} XGlyphInfo;
+#endif
+
+#define XftFontOpenName crxft_font_open_name
+extern XftFont *crxft_font_open_name (Display *, int, const char *);
+#define XftFontClose(dpy, pub) crxft_font_close (pub)
+extern void crxft_font_close (XftFont *);
+#define XftDrawCreate(dpy, drawable, visual, colormap) \
+ crxft_draw_create (dpy, drawable, visual)
+extern cairo_t *crxft_draw_create (Display *, Drawable, Visual *);
+#define XftDrawDestroy cairo_destroy
+#define XftDrawRect crxft_draw_rect
+extern void crxft_draw_rect (cairo_t *, const XftColor *, int, int,
+ unsigned int, unsigned int);
+#define XftDrawStringUtf8 crxft_draw_string
+extern void crxft_draw_string (cairo_t *, const XftColor *, XftFont *,
+ int, int, const FcChar8 *, int);
+#define XftTextExtentsUtf8(dpy, pub, string, len, extents) \
+ crxft_text_extents (pub, string, len, extents)
+extern void crxft_text_extents (XftFont *, const FcChar8 *, int, XGlyphInfo *);
+
+#endif /* USE_CAIRO */
#endif /* _LWLIB_UTILS_H_ */
{XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
offset(menu.fontSet), XtRFontSet, NULL},
#endif
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
#define DEFAULT_FONTNAME "Sans-10"
#else
#define DEFAULT_FONTNAME "XtDefaultFont"
{
XCharStruct xcs;
int drop;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (mw->menu.xft_font)
{
XGlyphInfo gi;
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
#define MENU_FONT_HEIGHT(mw) \
((mw)->menu.xft_font != NULL \
? (mw)->menu.xft_font->height \
int width;
enum menu_separator separator;
int separator_p = lw_separator_p (val->name, &separator, 0);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
XftColor *xftfg;
#endif
else
text_gc = mw->menu.disabled_gc;
deco_gc = mw->menu.foreground_gc;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg;
#endif
x_offset += ws->button_width;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (ws->xft_draw)
{
int draw_y = y + v_spacing + shadow;
+#ifdef USE_CAIRO
+ cairo_surface_mark_dirty (cairo_get_target (ws->xft_draw));
+#endif
XftDrawStringUtf8 (ws->xft_draw, xftfg,
mw->menu.xft_font,
x_offset, draw_y + font_ascent,
}
else if (val->key)
{
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (ws->xft_draw)
{
int draw_x = ws->width - ws->max_rest_width
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height,
True, False);
}
+#ifdef USE_CAIRO
+ if (ws->xft_draw)
+ cairo_surface_flush (cairo_get_target (ws->xft_draw));
+#endif
if (highlighted_p)
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False,
XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw);
windows [i].window = XtWindow (windows [i].w);
windows [i].pixmap = None;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
windows [i].xft_draw = 0;
#endif
set_window_type (windows [i].w, mw);
ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window,
ws->width, ws->height,
DefaultDepthOfScreen (XtScreen (ws->w)));
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (ws->xft_draw)
XftDrawDestroy (ws->xft_draw);
if (mw->menu.xft_font)
XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
static XftFont *
getDefaultXftFont (XlwMenuWidget mw)
{
gray_width, gray_height,
(unsigned long)1, (unsigned long)0, 1);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (openXftFont (mw))
;
else
mw->menu.windows [0].height = 0;
mw->menu.windows [0].max_rest_width = 0;
mw->menu.windows [0].pixmap = None;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
mw->menu.windows [0].xft_draw = 0;
#endif
size_menu (mw, 0);
set_window_type (mw->menu.windows [0].w, mw);
create_pixmap_for_menu (&mw->menu.windows [0], mw);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (mw->menu.xft_font)
{
XColor colors[3];
if (mw->menu.font)
XFreeFont (XtDisplay (mw), mw->menu.font);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (mw->menu.windows [0].xft_draw)
XftDrawDestroy (mw->menu.windows [0].xft_draw);
if (mw->menu.xft_font)
{
if (mw->menu.windows [i].pixmap != None)
XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (mw->menu.windows [i].xft_draw)
XftDrawDestroy (mw->menu.windows [i].xft_draw);
#endif
XtFree ((char *) mw->menu.windows);
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
static int
fontname_changed (XlwMenuWidget newmw,
XlwMenuWidget oldmw)
if (newmw->core.background_pixel != oldmw->core.background_pixel
|| newmw->menu.foreground != oldmw->menu.foreground
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
|| fontname_changed (newmw, oldmw)
#endif
#ifdef HAVE_X_I18N
}
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (fontname_changed (newmw, oldmw))
{
int i;
#include "xlwmenu.h"
#include <X11/CoreP.h>
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
+#ifdef USE_CAIRO
+#include "lwlib-utils.h"
+#else /* HAVE_XFT */
#include <X11/Xft/Xft.h>
#endif
+#endif
/* Elements in the stack arrays. */
typedef struct _window_state
/* Width of toggle buttons or radio buttons. */
Dimension button_width;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
XftDraw* xft_draw;
#endif
} window_state;
XFontSet fontSet;
XFontSetExtents *font_extents;
#endif
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
int default_face;
XftFont* xft_font;
XftColor xft_fg, xft_bg, xft_disabled_fg;
ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
}
-#elif defined (USE_LUCID) && defined (HAVE_XFT)
+#elif defined (USE_LUCID) && (defined USE_CAIRO || defined HAVE_XFT)
if (STRINGP (pane_name))
{
pane_name = ENCODE_UTF_8 (pane_name);
{
const char *names[]
= {
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
/* This will find the normal Xft font. */
"monospace-10",
#endif
XrmDatabase db;
char line[256];
-#if defined USE_MOTIF || !defined HAVE_XFT || !defined USE_LUCID
+#if defined USE_MOTIF || !(defined USE_CAIRO || defined HAVE_XFT) || !defined USE_LUCID
const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
#endif
sprintf (line, "Emacs.dialog*.background: grey75");
XrmPutLineResource (&rdb, line);
-#if !defined (HAVE_XFT) || !defined (USE_LUCID)
+#if !(defined USE_CAIRO || defined HAVE_XFT) || !defined (USE_LUCID)
sprintf (line, "Emacs.dialog*.font: %s", helv);
XrmPutLineResource (&rdb, line);
sprintf (line, "*XlwMenu*font: %s", helv);
#include <gconf/gconf-client.h>
#endif
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
+#ifdef USE_CAIRO
+#include <fontconfig/fontconfig.h>
+#else /* HAVE_XFT */
#include <X11/Xft/Xft.h>
#endif
+#endif
static char *current_mono_font;
static char *current_font;
/* Store a monospace font change event if the monospaced font changed. */
-#if defined HAVE_XFT && (defined HAVE_GSETTINGS || defined HAVE_GCONF)
+#if (defined USE_CAIRO || defined HAVE_XFT) && (defined HAVE_GSETTINGS || defined HAVE_GCONF)
static void
store_monospaced_changed (const char *newfont)
{
/* Store a font name change event if the font name changed. */
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
static void
store_font_name_changed (const char *newfont)
{
XCAR (first_dpyinfo->name_list_element));
}
}
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
/* Map TOOL_BAR_STYLE from a string to its corresponding Lisp value.
Return Qnil if TOOL_BAR_STYLE is not known. */
XCAR (dpyinfo->name_list_element));
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
#define XSETTINGS_FONT_NAME "Gtk/FontName"
#endif
#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle"
};
struct xsettings
{
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
FcBool aa, hinting;
int rgba, lcdfilter, hintstyle;
double dpi;
#define GSETTINGS_SCHEMA "org.gnome.desktop.interface"
#define GSETTINGS_TOOL_BAR_STYLE "toolbar-style"
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
#define GSETTINGS_MONO_FONT "monospace-font-name"
#define GSETTINGS_FONT_NAME "font-name"
#endif
g_variant_unref (val);
}
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
else if (strcmp (key, GSETTINGS_MONO_FONT) == 0)
{
val = g_settings_get_value (settings, GSETTINGS_MONO_FONT);
g_variant_unref (val);
}
}
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
}
#endif /* HAVE_GSETTINGS */
#ifdef HAVE_GCONF
#define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style"
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
#define GCONF_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
#define GCONF_FONT_NAME "/desktop/gnome/interface/font_name"
#endif
const char *value = gconf_value_get_string (v);
store_tool_bar_style_changed (value, first_dpyinfo);
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
else if (strcmp (key, GCONF_MONO_FONT) == 0)
{
const char *value = gconf_value_get_string (v);
const char *value = gconf_value_get_string (v);
store_font_name_changed (value);
}
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
}
#endif /* HAVE_GCONF */
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
/* Older fontconfig versions don't have FC_LCD_*. */
#ifndef FC_LCD_NONE
#define FC_LCD_FILTER "lcdfilter"
#endif
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
/* Find the window that contains the XSETTINGS property values. */
if (bytes_parsed > bytes) return settings_seen;
want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0)
|| strcmp (XSETTINGS_FONT_NAME, name) == 0)
want_this = true;
dupstring (&settings->tb_style, sval);
settings->seen |= SEEN_TB_STYLE;
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
{
dupstring (&settings->font, sval);
else
settings->seen &= ~SEEN_LCDFILTER;
}
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
else
want_this = false;
settings_seen += want_this;
apply_xft_settings (struct x_display_info *dpyinfo,
struct xsettings *settings)
{
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
FcPattern *pat;
struct xsettings oldsettings;
bool changed = false;
memset (&oldsettings, 0, sizeof (oldsettings));
pat = FcPatternCreate ();
+#ifdef HAVE_XFT
XftDefaultSubstitute (dpyinfo->display,
XScreenNumberOfScreen (dpyinfo->screen),
pat);
+#endif
FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
#ifdef FC_HINT_STYLE
};
char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
+#ifdef HAVE_XFT
XftDefaultSet (dpyinfo->display, pat);
+#endif
store_config_changed_event (Qfont_render,
XCAR (dpyinfo->name_list_element));
Vxft_settings
}
else
FcPatternDestroy (pat);
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
}
/* Read XSettings from the display for DPYINFO.
current_tool_bar_style = map_tool_bar_style (settings.tb_style);
xfree (settings.tb_style);
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
if (settings.seen & SEEN_FONT)
{
if (send_event_p)
g_variant_unref (val);
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT);
if (val)
{
dupstring (¤t_font, g_variant_get_string (val, NULL));
g_variant_unref (val);
}
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
#endif /* HAVE_GSETTINGS */
}
g_free (s);
}
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
if (s)
{
GCONF_FONT_NAME,
something_changed_gconfCB,
NULL, NULL, NULL);
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
#endif /* HAVE_GCONF */
}
doc: /* Font settings applied to Xft. */);
Vxft_settings = empty_unibyte_string;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
Fprovide (intern_c_string ("font-render-setting"), Qnil);
#if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
Fprovide (intern_c_string ("system-font-setting"), Qnil);
dpyinfo->supports_xdbe = true;
#endif
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
{
/* If we are using Xft, the following precautions should be made: