From 3a277b9756499a392b70b74324e4e746b0ae066d Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Sun, 13 Nov 2022 09:14:03 +0000 Subject: [PATCH] Fix global face scaling bug due to rounding. * lisp/face-remap.el (global-text-scale-adjust): Try again if the face height should have changed but did not actually change. (global-text-scale-adjust--increment-factor): New internal variable. Fixes bug#59122. --- lisp/face-remap.el | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 432385587b..33ffb41ec9 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -461,6 +461,8 @@ global-text-scale-adjust-limits (defvar global-text-scale-adjust--default-height nil) +(defvar global-text-scale-adjust--increment-factor 5) + ;;;###autoload (define-key ctl-x-map [(control meta ?+)] 'global-text-scale-adjust) ;;;###autoload (define-key ctl-x-map [(control meta ?=)] 'global-text-scale-adjust) ;;;###autoload (define-key ctl-x-map [(control meta ?-)] 'global-text-scale-adjust) @@ -499,16 +501,24 @@ global-text-scale-adjust (cur (face-attribute 'default :height)) (inc (pcase key - (?- (* (- increment) 5)) + (?- (* (- increment) + global-text-scale-adjust--increment-factor)) (?0 (- global-text-scale-adjust--default-height cur)) - (_ (* increment 5)))) + (_ (* increment + global-text-scale-adjust--increment-factor)))) (new (+ cur inc))) (when (< (car global-text-scale-adjust-limits) new (cdr global-text-scale-adjust-limits)) (let ((frame-inhibit-implied-resize (not global-text-scale-adjust-resizes-frames))) - (set-face-attribute 'default nil :height new))) + (set-face-attribute 'default nil :height new) + (redisplay 'force) + (when (and (not (= key ?0)) + (= cur (face-attribute 'default :height))) + (setq global-text-scale-adjust--increment-factor + (1+ global-text-scale-adjust--increment-factor)) + (global-text-scale-adjust increment)))) (when (characterp key) (set-transient-map (let ((map (make-sparse-keymap))) -- 2.35.1