[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r107039: Fix dynamic font settings in
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r107039: Fix dynamic font settings interaction with Custom Themes. |
Date: |
Wed, 01 Feb 2012 16:13:02 +0800 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 107039
fixes bug(s): http://debbugs.gnu.org/9982
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Wed 2012-02-01 16:13:02 +0800
message:
Fix dynamic font settings interaction with Custom Themes.
* lisp/dynamic-setting.el (font-setting-change-default-font): Use
set-frame-font.
* lisp/frame.el (set-frame-font): Tweak meaning of third argument.
modified:
lisp/ChangeLog
lisp/dynamic-setting.el
lisp/frame.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-02-01 07:32:21 +0000
+++ b/lisp/ChangeLog 2012-02-01 08:13:02 +0000
@@ -1,3 +1,10 @@
+2012-02-01 Chong Yidong <address@hidden>
+
+ * frame.el (set-frame-font): Tweak meaning of third argument.
+
+ * dynamic-setting.el (font-setting-change-default-font): Use
+ set-frame-font (Bug#9982).
+
2012-02-01 Glenn Morris <address@hidden>
* progmodes/compile.el (compilation-internal-error-properties):
=== modified file 'lisp/dynamic-setting.el'
--- a/lisp/dynamic-setting.el 2012-01-29 13:55:09 +0000
+++ b/lisp/dynamic-setting.el 2012-02-01 08:13:02 +0000
@@ -42,45 +42,28 @@
If SET-FONT is non-nil, change the font for frames. Otherwise re-apply the
current form for the frame (i.e. hinting or somesuch changed)."
-
(let ((new-font (and (fboundp 'font-get-system-font)
- (font-get-system-font))))
- (when new-font
- ;; Be careful here: when set-face-attribute is called for the
- ;; :font attribute, Emacs tries to guess the best matching font
- ;; by examining the other face attributes (Bug#2476).
-
+ (font-get-system-font)))
+ (frame-list (frames-on-display-list display-or-frame)))
+ (when (and new-font (display-graphic-p display-or-frame))
(clear-font-cache)
- ;; Set for current frames. Only change font for those that have
- ;; the old font now. If they don't have the old font, the user
- ;; probably changed it.
- (dolist (f (frames-on-display-list display-or-frame))
- (if (display-graphic-p f)
- (let* ((frame-font
- (or (font-get (face-attribute 'default :font f
- 'default) :user-spec)
- (frame-parameter f 'font-parameter)))
- (font-to-set
- (if set-font new-font
- ;; else set font again, hinting etc. may have changed.
- frame-font)))
- (if font-to-set
- (progn
- (set-frame-parameter f 'font-parameter font-to-set)
- (set-face-attribute 'default f
- :width 'normal
- :weight 'normal
- :slant 'normal
- :font font-to-set))))))
-
- ;; Set for future frames.
- (when set-font
- ;; FIXME: this is not going to play well with Custom themes.
- (set-face-attribute 'default t :font new-font)
- (let ((spec (list (list t (face-attr-construct 'default)))))
- (put 'default 'customized-face spec)
- (custom-push-theme 'theme-face 'default 'user 'set spec)
- (put 'default 'face-modified nil))))))
+ (if set-font
+ ;; Set the font on all current and future frames, as though
+ ;; the `default' face had been "set for this session":
+ (set-frame-font new-font nil frame-list)
+ ;; Just redraw the existing fonts on all frames:
+ (dolist (f frame-list)
+ (let ((frame-font
+ (or (font-get (face-attribute 'default :font f 'default)
+ :user-spec)
+ (frame-parameter f 'font-parameter))))
+ (when frame-font
+ (set-frame-parameter f 'font-parameter frame-font)
+ (set-face-attribute 'default f
+ :width 'normal
+ :weight 'normal
+ :slant 'normal
+ :font frame-font))))))))
(defun dynamic-setting-handle-config-changed-event (event)
"Handle config-changed-event on the display in EVENT.
=== modified file 'lisp/frame.el'
--- a/lisp/frame.el 2012-01-31 08:38:58 +0000
+++ b/lisp/frame.el 2012-02-01 08:13:02 +0000
@@ -1053,7 +1053,7 @@
(define-obsolete-function-alias 'set-default-font 'set-frame-font "23.1")
-(defun set-frame-font (font-name &optional keep-size all-frames)
+(defun set-frame-font (font-name &optional keep-size frames)
"Set the default font to FONT-NAME.
When called interactively, prompt for the name of a font, and use
that font on the selected frame.
@@ -1063,9 +1063,10 @@
to keep the current frame size fixed (in pixels) by adjusting the
number of lines and columns.
-If ALL-FRAMES is nil, apply the font to the selected frame only.
-If ALL-FRAMES is non-nil, apply the font to all frames; in
-addition, alter the user's Customization settings as though the
+If FRAMES is nil, apply the font to the selected frame only.
+If FRAMES is non-nil, it should be a list of frames to act upon,
+or t meaning all graphical frames. Also, if FRAME is non-nil,
+alter the user's Customization settings as though the
font-related attributes of the `default' face had been \"set in
this session\", so that the font is applied to future frames."
(interactive
@@ -1079,9 +1080,14 @@
(list font current-prefix-arg nil)))
(when (stringp font-name)
(let* ((this-frame (selected-frame))
- (frames (if all-frames (frame-list) (list this-frame)))
+ ;; FRAMES nil means affect the selected frame.
+ (frame-list (cond ((null frames)
+ (list this-frame))
+ ((eq frames t)
+ (frame-list))
+ (t frames)))
height width)
- (dolist (f frames)
+ (dolist (f frame-list)
(when (display-multi-font-p f)
(if keep-size
(setq height (* (frame-parameter f 'height)
@@ -1099,7 +1105,7 @@
f
(list (cons 'height (round height (frame-char-height f)))
(cons 'width (round width (frame-char-width f))))))))
- (when all-frames
+ (when frames
;; Alter the user's Custom setting of the `default' face, but
;; only for font-related attributes.
(let ((specs (cadr (assq 'user (get 'default 'theme-face))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r107039: Fix dynamic font settings interaction with Custom Themes.,
Chong Yidong <=