From fa0825822c3ef344a3c18d3466fc4ac1820f91f6 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Thu, 10 Nov 2022 16:58:06 +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 did not actually change. (global-text-scale-adjust--increment-factor): New internal variable. Fixes bug#59122. --- lisp/face-remap.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 432385587b..3c14085a63 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,23 @@ 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 (= 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