From 288401146162e67efa8f4a23c790fadeb1b92d6a Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Wed, 9 Nov 2022 16:16:22 +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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 432385587b..2d83d804c6 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,22 @@ 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) + (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