- (list font current-prefix-arg)))
- (let (fht fwd)
- (if keep-size
- (setq fht (* (frame-parameter nil 'height) (frame-char-height))
- fwd (* (frame-parameter nil 'width) (frame-char-width))))
- (modify-frame-parameters (selected-frame)
- (list (cons 'font font-name)))
- (if keep-size
- (modify-frame-parameters
- (selected-frame)
- (list (cons 'height (round fht (frame-char-height)))
- (cons 'width (round fwd (frame-char-width)))))))
- (run-hooks 'after-setting-font-hook 'after-setting-font-hooks))
+ (list font current-prefix-arg nil)))
+ (when (or (stringp font) (fontp font))
+ (let* ((this-frame (selected-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 frame-list)
+ (when (display-multi-font-p f)
+ (if keep-size
+ (setq height (* (frame-parameter f 'height)
+ (frame-char-height f))
+ width (* (frame-parameter f 'width)
+ (frame-char-width f))))
+ ;; When set-face-attribute is called for :font, Emacs
+ ;; guesses the best font according to other face attributes
+ ;; (:width, :weight, etc.) so reset them too (Bug#2476).
+ (set-face-attribute 'default f
+ :width 'normal :weight 'normal
+ :slant 'normal :font font)
+ (if keep-size
+ (modify-frame-parameters
+ f
+ (list (cons 'height (round height (frame-char-height f)))
+ (cons 'width (round width (frame-char-width f))))))))
+ (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))))
+ (attrs '(:family :foundry :slant :weight :height :width))
+ (new-specs nil))
+ (if (null specs) (setq specs '((t nil))))
+ (dolist (spec specs)
+ ;; Each SPEC has the form (DISPLAY ATTRIBUTE-PLIST)
+ (let ((display (nth 0 spec))
+ (plist (copy-tree (nth 1 spec))))
+ ;; Alter only DISPLAY conditions matching this frame.
+ (when (or (memq display '(t default))
+ (face-spec-set-match-display display this-frame))
+ (dolist (attr attrs)
+ (setq plist (plist-put plist attr
+ (face-attribute 'default attr)))))
+ (push (list display plist) new-specs)))
+ (setq new-specs (nreverse new-specs))
+ (put 'default 'customized-face new-specs)
+ (custom-push-theme 'theme-face 'default 'user 'set new-specs)
+ (put 'default 'face-modified nil))))
+ (run-hooks 'after-setting-font-hook 'after-setting-font-hooks)))