diff options
author | Jan Djärv <jan.h.d@swipnet.se> | 2009-11-17 08:21:23 +0000 |
---|---|---|
committer | Jan Djärv <jan.h.d@swipnet.se> | 2009-11-17 08:21:23 +0000 |
commit | 637fa9880877f485842b7aca18146a1f12c05b96 (patch) | |
tree | f4994cdadaad980b7b28827eba6cd50421a7f892 /src/xterm.c | |
parent | 77fd3e0c13b345cd4ff5c9ef5c89bd6b29054bc3 (diff) | |
download | emacs-637fa9880877f485842b7aca18146a1f12c05b96.tar.gz |
Handle system default font and changing font parameters.
* xterm.h (struct x_display_info): Add atoms and Window for xsettings.
* xterm.c (handle_one_xevent): Call xft_settings_event for
ClientMessage, PropertyNotify and DestroyNotify.
(x_term_init): If we have XFT, get DPI from Xft.dpi.
Call xsettings_initialize.
* xftfont.c (xftfont_fix_match): New function.
(xftfont_open): Call XftDefaultSubstitute before XftFontMatch.
Call xftfont_fix_match after XftFontMatch.
* xfont.c (xfont_driver): Initialize all members.
* xfns.c (x_default_font_parameter): Try font from Ffont_get_system_font.
Do not get font from x_default_parameter if we got one from
Ffont_get_system_font.
(Fx_select_font): Get the defaut font name from :name of FRAME_FONT (f).
* w32font.c (w32font_driver): Initialize all members.
* termhooks.h (enum event_kind): CONFIG_CHANGED_EVENT is new.
* lisp.h: Declare syms_of_xsettings.
* keyboard.c (kbd_buffer_get_event, make_lispy_event): Handle
CONFIG_CHANGED_EVENT.
* ftfont.c (ftfont_filter_properties): New function.
* frame.c (x_set_font): Remove unused variable lval.
* font.h (struct font_driver): filter_properties is new.
* font.c (font_put_extra): Don't return if val is nil, it means
boolean option is off.
(font_parse_fcname): Collect all extra properties in extra_props
and call filter_properties for all drivers with extra_props and
font as parameter.
(font_open_entity): Do not use cache, it does not pick up new fontconfig
settings like hinting.
(font_load_for_lface): If spec had a name in it, store it in entity.
* emacs.c (main): Call syms_of_xsettings
* config.in: HAVE_GCONF is new.
* Makefile.in (GCONF_CFLAGS, GCONF_LIBS): New variables for HAVE_GCONF.
xsettings.o is new.
* menu-bar.el: Put "Use system font" in Option-menu.
* loadup.el: If feature system-font-setting or font-render-setting is
there, load font-setting.
* Makefile.in (ELCFILES): font-settings.el is new.
* font-setting.el: New file.
* NEWS: Mention dynamic font changes (font-use-system-font).
* configure.in: New option: --with(out)-gconf.
Set HAVE_GCONF if we find gconf.
Diffstat (limited to 'src/xterm.c')
-rw-r--r-- | src/xterm.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/src/xterm.c b/src/xterm.c index 9936e98b1ed..3349dc05b95 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -86,6 +86,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "keymap.h" #include "font.h" #include "fontset.h" +#include "xsettings.h" #include "sysselect.h" #ifdef USE_X_TOOLKIT @@ -6026,6 +6027,8 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) goto done; } + xft_settings_event (dpyinfo, &event); + f = x_any_window_to_frame (dpyinfo, event.xclient.window); if (!f) goto OTHER; @@ -6088,6 +6091,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) x_handle_net_wm_state (f, &event.xproperty); x_handle_property_notify (&event.xproperty); + xft_settings_event (dpyinfo, &event); goto OTHER; case ReparentNotify: @@ -6991,6 +6995,10 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) } goto OTHER; + case DestroyNotify: + xft_settings_event (dpyinfo, &event); + break; + default: OTHER: #ifdef USE_X_TOOLKIT @@ -10300,17 +10308,33 @@ x_term_init (display_name, xrm_option, resource_name) dpyinfo->cmap = XCreateColormap (dpyinfo->display, dpyinfo->root_window, dpyinfo->visual, AllocNone); +#ifdef HAVE_XFT { - int screen_number = XScreenNumberOfScreen (dpyinfo->screen); - double pixels = DisplayHeight (dpyinfo->display, screen_number); - double mm = DisplayHeightMM (dpyinfo->display, screen_number); - /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ - dpyinfo->resy = (mm < 1) ? 100 : pixels * 25.4 / mm; - pixels = DisplayWidth (dpyinfo->display, screen_number); - mm = DisplayWidthMM (dpyinfo->display, screen_number); - /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ - dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm; + /* If we are using Xft, check dpi value in X resources. + It is better we use it as well, since Xft will use it, as will all + Gnome applications. If our real DPI is smaller or larger than the + one Xft uses, our font will look smaller or larger than other + for other applications, even if it is the same font name (monospace-10 + for example). */ + char *v = XGetDefault (dpyinfo->display, "Xft", "dpi"); + double d; + if (v != NULL && sscanf (v, "%lf", &d) == 1) + dpyinfo->resy = dpyinfo->resx = d; } +#endif + + if (dpyinfo->resy < 1) + { + int screen_number = XScreenNumberOfScreen (dpyinfo->screen); + double pixels = DisplayHeight (dpyinfo->display, screen_number); + double mm = DisplayHeightMM (dpyinfo->display, screen_number); + /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ + dpyinfo->resy = (mm < 1) ? 100 : pixels * 25.4 / mm; + pixels = DisplayWidth (dpyinfo->display, screen_number); + mm = DisplayWidthMM (dpyinfo->display, screen_number); + /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ + dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm; + } dpyinfo->Xatom_wm_protocols = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False); @@ -10415,6 +10439,8 @@ x_term_init (display_name, xrm_option, resource_name) xim_initialize (dpyinfo, resource_name); #endif + xsettings_initialize (dpyinfo); + #ifdef subprocesses /* This is only needed for distinguishing keyboard and process input. */ if (connection != 0) |