mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
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.
This commit is contained in:
parent
1828e9a9b7
commit
5f4e8e2e08
12 changed files with 307 additions and 81 deletions
52
configure.ac
52
configure.ac
|
|
@ -3312,12 +3312,44 @@ if test "${HAVE_X11}" = "yes"; then
|
||||||
fi
|
fi
|
||||||
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.
|
### Start of font-backend (under any platform) section.
|
||||||
# (nothing here yet -- this is a placeholder)
|
# (nothing here yet -- this is a placeholder)
|
||||||
### End of font-backend (under any platform) section.
|
### End of font-backend (under any platform) section.
|
||||||
|
|
||||||
### Start of font-backend (under X11) section.
|
### Start of font-backend (under X11) section.
|
||||||
if test "${HAVE_X11}" = "yes"; then
|
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'.
|
## Use -lXft if available, unless '--with-xft=no'.
|
||||||
HAVE_XFT=maybe
|
HAVE_XFT=maybe
|
||||||
if test "x${with_x}" = "xno"; then
|
if test "x${with_x}" = "xno"; then
|
||||||
|
|
@ -3374,6 +3406,7 @@ if test "${HAVE_X11}" = "yes"; then
|
||||||
|
|
||||||
test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
|
test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
|
||||||
fi
|
fi
|
||||||
|
fi # $HAVE_CAIRO != yes
|
||||||
|
|
||||||
HAVE_LIBOTF=no
|
HAVE_LIBOTF=no
|
||||||
if test "${HAVE_FREETYPE}" = "yes"; then
|
if test "${HAVE_FREETYPE}" = "yes"; then
|
||||||
|
|
@ -3427,25 +3460,6 @@ AC_SUBST(LIBOTF_LIBS)
|
||||||
AC_SUBST(M17N_FLT_CFLAGS)
|
AC_SUBST(M17N_FLT_CFLAGS)
|
||||||
AC_SUBST(M17N_FLT_LIBS)
|
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
|
if test "${HAVE_X11}" = "yes"; then
|
||||||
AC_CHECK_HEADER(X11/Xlib-xcb.h,
|
AC_CHECK_HEADER(X11/Xlib-xcb.h,
|
||||||
AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
|
AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <X11/Xatom.h>
|
#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>
|
#include <X11/Xft/Xft.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct widget_xft_data
|
struct widget_xft_data
|
||||||
{
|
{
|
||||||
|
|
@ -79,7 +84,7 @@ lw_xaw_widget_p (Widget widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
static void
|
static void
|
||||||
fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font)
|
fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font)
|
||||||
{
|
{
|
||||||
|
|
@ -210,6 +215,9 @@ draw_text (struct widget_xft_data *data, char *lbl, int inverse)
|
||||||
/* 1.2 gives reasonable line spacing. */
|
/* 1.2 gives reasonable line spacing. */
|
||||||
y += data->xft_font->height * 1.2;
|
y += data->xft_font->height * 1.2;
|
||||||
}
|
}
|
||||||
|
#ifdef USE_CAIRO
|
||||||
|
cairo_surface_flush (cairo_get_target (data->xft_draw));
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -307,7 +315,7 @@ xaw_update_one_widget (widget_instance *instance,
|
||||||
if (XtIsSubclass (widget, dialogWidgetClass))
|
if (XtIsSubclass (widget, dialogWidgetClass))
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (instance->xft_data && instance->xft_data[0].xft_font)
|
if (instance->xft_data && instance->xft_data[0].xft_font)
|
||||||
{
|
{
|
||||||
set_text (&instance->xft_data[0], instance->parent,
|
set_text (&instance->xft_data[0], instance->parent,
|
||||||
|
|
@ -339,7 +347,7 @@ xaw_update_one_widget (widget_instance *instance,
|
||||||
XtSetArg (al[ac], XtNlabel, val->value);ac++;
|
XtSetArg (al[ac], XtNlabel, val->value);ac++;
|
||||||
/* Force centered button text. Se above. */
|
/* Force centered button text. Se above. */
|
||||||
XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++;
|
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)
|
if (instance->xft_data && instance->xft_data[0].xft_font)
|
||||||
{
|
{
|
||||||
int th;
|
int th;
|
||||||
|
|
@ -473,7 +481,7 @@ static XtActionsRec xaw_actions [] = {
|
||||||
};
|
};
|
||||||
static Boolean actions_initted = False;
|
static Boolean actions_initted = False;
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
static XtActionsRec button_actions[] =
|
static XtActionsRec button_actions[] =
|
||||||
{
|
{
|
||||||
{ "my_reset", command_reset },
|
{ "my_reset", command_reset },
|
||||||
|
|
@ -506,7 +514,7 @@ make_dialog (char* name,
|
||||||
Widget dialog;
|
Widget dialog;
|
||||||
Widget button;
|
Widget button;
|
||||||
XtTranslations override;
|
XtTranslations override;
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
XftFont *xft_font = 0;
|
XftFont *xft_font = 0;
|
||||||
XtTranslations button_override;
|
XtTranslations button_override;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -521,7 +529,7 @@ make_dialog (char* name,
|
||||||
XtAppContext app = XtWidgetToApplicationContext (parent);
|
XtAppContext app = XtWidgetToApplicationContext (parent);
|
||||||
XtAppAddActions (app, xaw_actions,
|
XtAppAddActions (app, xaw_actions,
|
||||||
sizeof (xaw_actions) / sizeof (xaw_actions[0]));
|
sizeof (xaw_actions) / sizeof (xaw_actions[0]));
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
XtAppAddActions (app, button_actions,
|
XtAppAddActions (app, button_actions,
|
||||||
sizeof (button_actions) / sizeof (button_actions[0]));
|
sizeof (button_actions) / sizeof (button_actions[0]));
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -546,7 +554,7 @@ make_dialog (char* name,
|
||||||
override = XtParseTranslationTable (dialogOverride);
|
override = XtParseTranslationTable (dialogOverride);
|
||||||
XtOverrideTranslations (dialog, override);
|
XtOverrideTranslations (dialog, override);
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
Widget *ch = NULL;
|
Widget *ch = NULL;
|
||||||
|
|
@ -618,7 +626,7 @@ make_dialog (char* name,
|
||||||
sprintf (button_name, "button%d", ++bc);
|
sprintf (button_name, "button%d", ++bc);
|
||||||
button = XtCreateManagedWidget (button_name, commandWidgetClass,
|
button = XtCreateManagedWidget (button_name, commandWidgetClass,
|
||||||
dialog, av, ac);
|
dialog, av, ac);
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (xft_font)
|
if (xft_font)
|
||||||
{
|
{
|
||||||
fill_xft_data (&instance->xft_data[bc], button, xft_font);
|
fill_xft_data (&instance->xft_data[bc], button, xft_font);
|
||||||
|
|
@ -651,7 +659,7 @@ make_dialog (char* name,
|
||||||
sprintf (button_name, "button%d", ++bc);
|
sprintf (button_name, "button%d", ++bc);
|
||||||
button = XtCreateManagedWidget (button_name, commandWidgetClass,
|
button = XtCreateManagedWidget (button_name, commandWidgetClass,
|
||||||
dialog, av, ac);
|
dialog, av, ac);
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (xft_font)
|
if (xft_font)
|
||||||
{
|
{
|
||||||
fill_xft_data (&instance->xft_data[bc], button, xft_font);
|
fill_xft_data (&instance->xft_data[bc], button, xft_font);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ typedef struct _widget_instance
|
||||||
Widget widget;
|
Widget widget;
|
||||||
Widget parent;
|
Widget parent;
|
||||||
Boolean pop_up_p;
|
Boolean pop_up_p;
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
struct widget_xft_data *xft_data;
|
struct widget_xft_data *xft_data;
|
||||||
#endif
|
#endif
|
||||||
struct _widget_info* info;
|
struct _widget_info* info;
|
||||||
|
|
|
||||||
|
|
@ -137,3 +137,143 @@ XtWidgetBeingDestroyedP (Widget widget)
|
||||||
{
|
{
|
||||||
return widget->core.being_destroyed;
|
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 */
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,49 @@ Widget *XtCompositeChildren (Widget, unsigned int *);
|
||||||
Boolean
|
Boolean
|
||||||
XtWidgetBeingDestroyedP (Widget widget);
|
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_ */
|
#endif /* _LWLIB_UTILS_H_ */
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ xlwMenuResources[] =
|
||||||
{XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
|
{XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
|
||||||
offset(menu.fontSet), XtRFontSet, NULL},
|
offset(menu.fontSet), XtRFontSet, NULL},
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
#define DEFAULT_FONTNAME "Sans-10"
|
#define DEFAULT_FONTNAME "Sans-10"
|
||||||
#else
|
#else
|
||||||
#define DEFAULT_FONTNAME "XtDefaultFont"
|
#define DEFAULT_FONTNAME "XtDefaultFont"
|
||||||
|
|
@ -325,7 +325,7 @@ string_width (XlwMenuWidget mw, char *s)
|
||||||
{
|
{
|
||||||
XCharStruct xcs;
|
XCharStruct xcs;
|
||||||
int drop;
|
int drop;
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (mw->menu.xft_font)
|
if (mw->menu.xft_font)
|
||||||
{
|
{
|
||||||
XGlyphInfo gi;
|
XGlyphInfo gi;
|
||||||
|
|
@ -349,7 +349,7 @@ string_width (XlwMenuWidget mw, char *s)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
#define MENU_FONT_HEIGHT(mw) \
|
#define MENU_FONT_HEIGHT(mw) \
|
||||||
((mw)->menu.xft_font != NULL \
|
((mw)->menu.xft_font != NULL \
|
||||||
? (mw)->menu.xft_font->height \
|
? (mw)->menu.xft_font->height \
|
||||||
|
|
@ -965,7 +965,7 @@ display_menu_item (XlwMenuWidget mw,
|
||||||
int width;
|
int width;
|
||||||
enum menu_separator separator;
|
enum menu_separator separator;
|
||||||
int separator_p = lw_separator_p (val->name, &separator, 0);
|
int separator_p = lw_separator_p (val->name, &separator, 0);
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
XftColor *xftfg;
|
XftColor *xftfg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -1005,7 +1005,7 @@ display_menu_item (XlwMenuWidget mw,
|
||||||
else
|
else
|
||||||
text_gc = mw->menu.disabled_gc;
|
text_gc = mw->menu.disabled_gc;
|
||||||
deco_gc = mw->menu.foreground_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;
|
xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -1032,10 +1032,13 @@ display_menu_item (XlwMenuWidget mw,
|
||||||
x_offset += ws->button_width;
|
x_offset += ws->button_width;
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (ws->xft_draw)
|
if (ws->xft_draw)
|
||||||
{
|
{
|
||||||
int draw_y = y + v_spacing + shadow;
|
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,
|
XftDrawStringUtf8 (ws->xft_draw, xftfg,
|
||||||
mw->menu.xft_font,
|
mw->menu.xft_font,
|
||||||
x_offset, draw_y + font_ascent,
|
x_offset, draw_y + font_ascent,
|
||||||
|
|
@ -1078,7 +1081,7 @@ display_menu_item (XlwMenuWidget mw,
|
||||||
}
|
}
|
||||||
else if (val->key)
|
else if (val->key)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (ws->xft_draw)
|
if (ws->xft_draw)
|
||||||
{
|
{
|
||||||
int draw_x = ws->width - ws->max_rest_width
|
int draw_x = ws->width - ws->max_rest_width
|
||||||
|
|
@ -1119,6 +1122,10 @@ display_menu_item (XlwMenuWidget mw,
|
||||||
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height,
|
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height,
|
||||||
True, False);
|
True, False);
|
||||||
}
|
}
|
||||||
|
#ifdef USE_CAIRO
|
||||||
|
if (ws->xft_draw)
|
||||||
|
cairo_surface_flush (cairo_get_target (ws->xft_draw));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (highlighted_p)
|
if (highlighted_p)
|
||||||
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False,
|
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False,
|
||||||
|
|
@ -1320,7 +1327,7 @@ make_windows_if_needed (XlwMenuWidget mw, int n)
|
||||||
XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw);
|
XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw);
|
||||||
windows [i].window = XtWindow (windows [i].w);
|
windows [i].window = XtWindow (windows [i].w);
|
||||||
windows [i].pixmap = None;
|
windows [i].pixmap = None;
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
windows [i].xft_draw = 0;
|
windows [i].xft_draw = 0;
|
||||||
#endif
|
#endif
|
||||||
set_window_type (windows [i].w, mw);
|
set_window_type (windows [i].w, mw);
|
||||||
|
|
@ -1411,7 +1418,7 @@ create_pixmap_for_menu (window_state* ws, XlwMenuWidget mw)
|
||||||
ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window,
|
ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window,
|
||||||
ws->width, ws->height,
|
ws->width, ws->height,
|
||||||
DefaultDepthOfScreen (XtScreen (ws->w)));
|
DefaultDepthOfScreen (XtScreen (ws->w)));
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (ws->xft_draw)
|
if (ws->xft_draw)
|
||||||
XftDrawDestroy (ws->xft_draw);
|
XftDrawDestroy (ws->xft_draw);
|
||||||
if (mw->menu.xft_font)
|
if (mw->menu.xft_font)
|
||||||
|
|
@ -1831,7 +1838,7 @@ release_shadow_gcs (XlwMenuWidget mw)
|
||||||
XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
|
XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
static XftFont *
|
static XftFont *
|
||||||
getDefaultXftFont (XlwMenuWidget mw)
|
getDefaultXftFont (XlwMenuWidget mw)
|
||||||
{
|
{
|
||||||
|
|
@ -1887,7 +1894,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
|
||||||
gray_width, gray_height,
|
gray_width, gray_height,
|
||||||
(unsigned long)1, (unsigned long)0, 1);
|
(unsigned long)1, (unsigned long)0, 1);
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (openXftFont (mw))
|
if (openXftFont (mw))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
|
|
@ -1933,7 +1940,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
|
||||||
mw->menu.windows [0].height = 0;
|
mw->menu.windows [0].height = 0;
|
||||||
mw->menu.windows [0].max_rest_width = 0;
|
mw->menu.windows [0].max_rest_width = 0;
|
||||||
mw->menu.windows [0].pixmap = None;
|
mw->menu.windows [0].pixmap = None;
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
mw->menu.windows [0].xft_draw = 0;
|
mw->menu.windows [0].xft_draw = 0;
|
||||||
#endif
|
#endif
|
||||||
size_menu (mw, 0);
|
size_menu (mw, 0);
|
||||||
|
|
@ -1981,7 +1988,7 @@ XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
|
||||||
set_window_type (mw->menu.windows [0].w, mw);
|
set_window_type (mw->menu.windows [0].w, mw);
|
||||||
create_pixmap_for_menu (&mw->menu.windows [0], 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)
|
if (mw->menu.xft_font)
|
||||||
{
|
{
|
||||||
XColor colors[3];
|
XColor colors[3];
|
||||||
|
|
@ -2078,7 +2085,7 @@ XlwMenuDestroy (Widget w)
|
||||||
if (mw->menu.font)
|
if (mw->menu.font)
|
||||||
XFreeFont (XtDisplay (mw), 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)
|
if (mw->menu.windows [0].xft_draw)
|
||||||
XftDrawDestroy (mw->menu.windows [0].xft_draw);
|
XftDrawDestroy (mw->menu.windows [0].xft_draw);
|
||||||
if (mw->menu.xft_font)
|
if (mw->menu.xft_font)
|
||||||
|
|
@ -2092,7 +2099,7 @@ XlwMenuDestroy (Widget w)
|
||||||
{
|
{
|
||||||
if (mw->menu.windows [i].pixmap != None)
|
if (mw->menu.windows [i].pixmap != None)
|
||||||
XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap);
|
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)
|
if (mw->menu.windows [i].xft_draw)
|
||||||
XftDrawDestroy (mw->menu.windows [i].xft_draw);
|
XftDrawDestroy (mw->menu.windows [i].xft_draw);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2102,7 +2109,7 @@ XlwMenuDestroy (Widget w)
|
||||||
XtFree ((char *) mw->menu.windows);
|
XtFree ((char *) mw->menu.windows);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
static int
|
static int
|
||||||
fontname_changed (XlwMenuWidget newmw,
|
fontname_changed (XlwMenuWidget newmw,
|
||||||
XlwMenuWidget oldmw)
|
XlwMenuWidget oldmw)
|
||||||
|
|
@ -2134,7 +2141,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
|
||||||
|
|
||||||
if (newmw->core.background_pixel != oldmw->core.background_pixel
|
if (newmw->core.background_pixel != oldmw->core.background_pixel
|
||||||
|| newmw->menu.foreground != oldmw->menu.foreground
|
|| newmw->menu.foreground != oldmw->menu.foreground
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
|| fontname_changed (newmw, oldmw)
|
|| fontname_changed (newmw, oldmw)
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_X_I18N
|
#ifdef HAVE_X_I18N
|
||||||
|
|
@ -2170,7 +2177,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (fontname_changed (newmw, oldmw))
|
if (fontname_changed (newmw, oldmw))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include "xlwmenu.h"
|
#include "xlwmenu.h"
|
||||||
#include <X11/CoreP.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>
|
#include <X11/Xft/Xft.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Elements in the stack arrays. */
|
/* Elements in the stack arrays. */
|
||||||
typedef struct _window_state
|
typedef struct _window_state
|
||||||
|
|
@ -42,7 +46,7 @@ typedef struct _window_state
|
||||||
|
|
||||||
/* Width of toggle buttons or radio buttons. */
|
/* Width of toggle buttons or radio buttons. */
|
||||||
Dimension button_width;
|
Dimension button_width;
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
XftDraw* xft_draw;
|
XftDraw* xft_draw;
|
||||||
#endif
|
#endif
|
||||||
} window_state;
|
} window_state;
|
||||||
|
|
@ -56,7 +60,7 @@ typedef struct _XlwMenu_part
|
||||||
XFontSet fontSet;
|
XFontSet fontSet;
|
||||||
XFontSetExtents *font_extents;
|
XFontSetExtents *font_extents;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
int default_face;
|
int default_face;
|
||||||
XftFont* xft_font;
|
XftFont* xft_font;
|
||||||
XftColor xft_fg, xft_bg, xft_disabled_fg;
|
XftColor xft_fg, xft_bg, xft_disabled_fg;
|
||||||
|
|
|
||||||
|
|
@ -687,7 +687,7 @@ digest_single_submenu (int start, int end, bool top_level_items)
|
||||||
|
|
||||||
ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
|
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))
|
if (STRINGP (pane_name))
|
||||||
{
|
{
|
||||||
pane_name = ENCODE_UTF_8 (pane_name);
|
pane_name = ENCODE_UTF_8 (pane_name);
|
||||||
|
|
|
||||||
|
|
@ -3487,7 +3487,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms)
|
||||||
{
|
{
|
||||||
const char *names[]
|
const char *names[]
|
||||||
= {
|
= {
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
/* This will find the normal Xft font. */
|
/* This will find the normal Xft font. */
|
||||||
"monospace-10",
|
"monospace-10",
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,7 @@ x_load_resources (Display *display, const char *xrm_string,
|
||||||
XrmDatabase db;
|
XrmDatabase db;
|
||||||
char line[256];
|
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";
|
const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -456,7 +456,7 @@ x_load_resources (Display *display, const char *xrm_string,
|
||||||
|
|
||||||
sprintf (line, "Emacs.dialog*.background: grey75");
|
sprintf (line, "Emacs.dialog*.background: grey75");
|
||||||
XrmPutLineResource (&rdb, line);
|
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);
|
sprintf (line, "Emacs.dialog*.font: %s", helv);
|
||||||
XrmPutLineResource (&rdb, line);
|
XrmPutLineResource (&rdb, line);
|
||||||
sprintf (line, "*XlwMenu*font: %s", helv);
|
sprintf (line, "*XlwMenu*font: %s", helv);
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
#include <gconf/gconf-client.h>
|
#include <gconf/gconf-client.h>
|
||||||
#endif
|
#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>
|
#include <X11/Xft/Xft.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static char *current_mono_font;
|
static char *current_mono_font;
|
||||||
static char *current_font;
|
static char *current_font;
|
||||||
|
|
@ -83,7 +87,7 @@ dpyinfo_valid (struct x_display_info *dpyinfo)
|
||||||
|
|
||||||
/* Store a monospace font change event if the monospaced font changed. */
|
/* 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
|
static void
|
||||||
store_monospaced_changed (const char *newfont)
|
store_monospaced_changed (const char *newfont)
|
||||||
{
|
{
|
||||||
|
|
@ -102,7 +106,7 @@ store_monospaced_changed (const char *newfont)
|
||||||
|
|
||||||
/* Store a font name change event if the font name changed. */
|
/* Store a font name change event if the font name changed. */
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
static void
|
static void
|
||||||
store_font_name_changed (const char *newfont)
|
store_font_name_changed (const char *newfont)
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +121,7 @@ store_font_name_changed (const char *newfont)
|
||||||
XCAR (first_dpyinfo->name_list_element));
|
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.
|
/* Map TOOL_BAR_STYLE from a string to its corresponding Lisp value.
|
||||||
Return Qnil if TOOL_BAR_STYLE is not known. */
|
Return Qnil if TOOL_BAR_STYLE is not known. */
|
||||||
|
|
@ -157,7 +161,7 @@ store_tool_bar_style_changed (const char *newstyle,
|
||||||
XCAR (dpyinfo->name_list_element));
|
XCAR (dpyinfo->name_list_element));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
#define XSETTINGS_FONT_NAME "Gtk/FontName"
|
#define XSETTINGS_FONT_NAME "Gtk/FontName"
|
||||||
#endif
|
#endif
|
||||||
#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle"
|
#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle"
|
||||||
|
|
@ -174,7 +178,7 @@ enum {
|
||||||
};
|
};
|
||||||
struct xsettings
|
struct xsettings
|
||||||
{
|
{
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
FcBool aa, hinting;
|
FcBool aa, hinting;
|
||||||
int rgba, lcdfilter, hintstyle;
|
int rgba, lcdfilter, hintstyle;
|
||||||
double dpi;
|
double dpi;
|
||||||
|
|
@ -191,7 +195,7 @@ struct xsettings
|
||||||
#define GSETTINGS_SCHEMA "org.gnome.desktop.interface"
|
#define GSETTINGS_SCHEMA "org.gnome.desktop.interface"
|
||||||
#define GSETTINGS_TOOL_BAR_STYLE "toolbar-style"
|
#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_MONO_FONT "monospace-font-name"
|
||||||
#define GSETTINGS_FONT_NAME "font-name"
|
#define GSETTINGS_FONT_NAME "font-name"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -224,7 +228,7 @@ something_changed_gsettingsCB (GSettings *settings,
|
||||||
g_variant_unref (val);
|
g_variant_unref (val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
else if (strcmp (key, GSETTINGS_MONO_FONT) == 0)
|
else if (strcmp (key, GSETTINGS_MONO_FONT) == 0)
|
||||||
{
|
{
|
||||||
val = g_settings_get_value (settings, GSETTINGS_MONO_FONT);
|
val = g_settings_get_value (settings, GSETTINGS_MONO_FONT);
|
||||||
|
|
@ -253,14 +257,14 @@ something_changed_gsettingsCB (GSettings *settings,
|
||||||
g_variant_unref (val);
|
g_variant_unref (val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XFT */
|
#endif /* USE_CAIRO || HAVE_XFT */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_GSETTINGS */
|
#endif /* HAVE_GSETTINGS */
|
||||||
|
|
||||||
#ifdef HAVE_GCONF
|
#ifdef HAVE_GCONF
|
||||||
#define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style"
|
#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_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
|
||||||
#define GCONF_FONT_NAME "/desktop/gnome/interface/font_name"
|
#define GCONF_FONT_NAME "/desktop/gnome/interface/font_name"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -286,7 +290,7 @@ something_changed_gconfCB (GConfClient *client,
|
||||||
const char *value = gconf_value_get_string (v);
|
const char *value = gconf_value_get_string (v);
|
||||||
store_tool_bar_style_changed (value, first_dpyinfo);
|
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)
|
else if (strcmp (key, GCONF_MONO_FONT) == 0)
|
||||||
{
|
{
|
||||||
const char *value = gconf_value_get_string (v);
|
const char *value = gconf_value_get_string (v);
|
||||||
|
|
@ -297,12 +301,12 @@ something_changed_gconfCB (GConfClient *client,
|
||||||
const char *value = gconf_value_get_string (v);
|
const char *value = gconf_value_get_string (v);
|
||||||
store_font_name_changed (value);
|
store_font_name_changed (value);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XFT */
|
#endif /* USE_CAIRO || HAVE_XFT */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_GCONF */
|
#endif /* HAVE_GCONF */
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
|
|
||||||
/* Older fontconfig versions don't have FC_LCD_*. */
|
/* Older fontconfig versions don't have FC_LCD_*. */
|
||||||
#ifndef FC_LCD_NONE
|
#ifndef FC_LCD_NONE
|
||||||
|
|
@ -315,7 +319,7 @@ something_changed_gconfCB (GConfClient *client,
|
||||||
#define FC_LCD_FILTER "lcdfilter"
|
#define FC_LCD_FILTER "lcdfilter"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* HAVE_XFT */
|
#endif /* USE_CAIRO || HAVE_XFT */
|
||||||
|
|
||||||
/* Find the window that contains the XSETTINGS property values. */
|
/* Find the window that contains the XSETTINGS property values. */
|
||||||
|
|
||||||
|
|
@ -440,7 +444,7 @@ parse_settings (unsigned char *prop,
|
||||||
if (bytes_parsed > bytes) return settings_seen;
|
if (bytes_parsed > bytes) return settings_seen;
|
||||||
|
|
||||||
want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0;
|
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)
|
if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0)
|
||||||
|| strcmp (XSETTINGS_FONT_NAME, name) == 0)
|
|| strcmp (XSETTINGS_FONT_NAME, name) == 0)
|
||||||
want_this = true;
|
want_this = true;
|
||||||
|
|
@ -490,7 +494,7 @@ parse_settings (unsigned char *prop,
|
||||||
dupstring (&settings->tb_style, sval);
|
dupstring (&settings->tb_style, sval);
|
||||||
settings->seen |= SEEN_TB_STYLE;
|
settings->seen |= SEEN_TB_STYLE;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
|
else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
|
||||||
{
|
{
|
||||||
dupstring (&settings->font, sval);
|
dupstring (&settings->font, sval);
|
||||||
|
|
@ -553,7 +557,7 @@ parse_settings (unsigned char *prop,
|
||||||
else
|
else
|
||||||
settings->seen &= ~SEEN_LCDFILTER;
|
settings->seen &= ~SEEN_LCDFILTER;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XFT */
|
#endif /* USE_CAIRO || HAVE_XFT */
|
||||||
else
|
else
|
||||||
want_this = false;
|
want_this = false;
|
||||||
settings_seen += want_this;
|
settings_seen += want_this;
|
||||||
|
|
@ -604,16 +608,18 @@ static void
|
||||||
apply_xft_settings (struct x_display_info *dpyinfo,
|
apply_xft_settings (struct x_display_info *dpyinfo,
|
||||||
struct xsettings *settings)
|
struct xsettings *settings)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
FcPattern *pat;
|
FcPattern *pat;
|
||||||
struct xsettings oldsettings;
|
struct xsettings oldsettings;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
memset (&oldsettings, 0, sizeof (oldsettings));
|
memset (&oldsettings, 0, sizeof (oldsettings));
|
||||||
pat = FcPatternCreate ();
|
pat = FcPatternCreate ();
|
||||||
|
#ifdef HAVE_XFT
|
||||||
XftDefaultSubstitute (dpyinfo->display,
|
XftDefaultSubstitute (dpyinfo->display,
|
||||||
XScreenNumberOfScreen (dpyinfo->screen),
|
XScreenNumberOfScreen (dpyinfo->screen),
|
||||||
pat);
|
pat);
|
||||||
|
#endif
|
||||||
FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
|
FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
|
||||||
FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
|
FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
|
||||||
#ifdef FC_HINT_STYLE
|
#ifdef FC_HINT_STYLE
|
||||||
|
|
@ -713,7 +719,9 @@ apply_xft_settings (struct x_display_info *dpyinfo,
|
||||||
};
|
};
|
||||||
char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
|
char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
|
||||||
|
|
||||||
|
#ifdef HAVE_XFT
|
||||||
XftDefaultSet (dpyinfo->display, pat);
|
XftDefaultSet (dpyinfo->display, pat);
|
||||||
|
#endif
|
||||||
store_config_changed_event (Qfont_render,
|
store_config_changed_event (Qfont_render,
|
||||||
XCAR (dpyinfo->name_list_element));
|
XCAR (dpyinfo->name_list_element));
|
||||||
Vxft_settings
|
Vxft_settings
|
||||||
|
|
@ -725,7 +733,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
FcPatternDestroy (pat);
|
FcPatternDestroy (pat);
|
||||||
#endif /* HAVE_XFT */
|
#endif /* USE_CAIRO || HAVE_XFT */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read XSettings from the display for DPYINFO.
|
/* Read XSettings from the display for DPYINFO.
|
||||||
|
|
@ -748,7 +756,7 @@ read_and_apply_settings (struct x_display_info *dpyinfo, bool send_event_p)
|
||||||
current_tool_bar_style = map_tool_bar_style (settings.tb_style);
|
current_tool_bar_style = map_tool_bar_style (settings.tb_style);
|
||||||
xfree (settings.tb_style);
|
xfree (settings.tb_style);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
if (settings.seen & SEEN_FONT)
|
if (settings.seen & SEEN_FONT)
|
||||||
{
|
{
|
||||||
if (send_event_p)
|
if (send_event_p)
|
||||||
|
|
@ -850,7 +858,7 @@ init_gsettings (void)
|
||||||
g_variant_unref (val);
|
g_variant_unref (val);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT);
|
val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT);
|
||||||
if (val)
|
if (val)
|
||||||
{
|
{
|
||||||
|
|
@ -868,7 +876,7 @@ init_gsettings (void)
|
||||||
dupstring (¤t_font, g_variant_get_string (val, NULL));
|
dupstring (¤t_font, g_variant_get_string (val, NULL));
|
||||||
g_variant_unref (val);
|
g_variant_unref (val);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XFT */
|
#endif /* USE_CAIRO || HAVE_XFT */
|
||||||
|
|
||||||
#endif /* HAVE_GSETTINGS */
|
#endif /* HAVE_GSETTINGS */
|
||||||
}
|
}
|
||||||
|
|
@ -903,7 +911,7 @@ init_gconf (void)
|
||||||
g_free (s);
|
g_free (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
|
s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
|
|
@ -932,7 +940,7 @@ init_gconf (void)
|
||||||
GCONF_FONT_NAME,
|
GCONF_FONT_NAME,
|
||||||
something_changed_gconfCB,
|
something_changed_gconfCB,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
#endif /* HAVE_XFT */
|
#endif /* USE_CAIRO || HAVE_XFT */
|
||||||
#endif /* HAVE_GCONF */
|
#endif /* HAVE_GCONF */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1055,7 +1063,7 @@ If this variable is nil, Emacs ignores system font changes. */);
|
||||||
doc: /* Font settings applied to Xft. */);
|
doc: /* Font settings applied to Xft. */);
|
||||||
Vxft_settings = empty_unibyte_string;
|
Vxft_settings = empty_unibyte_string;
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
Fprovide (intern_c_string ("font-render-setting"), Qnil);
|
Fprovide (intern_c_string ("font-render-setting"), Qnil);
|
||||||
#if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
|
#if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
|
||||||
Fprovide (intern_c_string ("system-font-setting"), Qnil);
|
Fprovide (intern_c_string ("system-font-setting"), Qnil);
|
||||||
|
|
|
||||||
|
|
@ -12733,7 +12733,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
|
||||||
dpyinfo->supports_xdbe = true;
|
dpyinfo->supports_xdbe = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#if defined USE_CAIRO || defined HAVE_XFT
|
||||||
{
|
{
|
||||||
/* If we are using Xft, the following precautions should be made:
|
/* If we are using Xft, the following precautions should be made:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue