[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] avoid hard-coded assumptions in image scaling
From: |
James N. V. Cash |
Subject: |
[PATCH] avoid hard-coded assumptions in image scaling |
Date: |
Sun, 02 May 2021 16:18:30 -0400 |
In image-compute-scaling-factor in images.el, it currently hard-codes
the assumption that the average character width is 10 pixels. Since
`frame-char-width` gives this information though, it seems like it's less
error-prone to use that function instead of assuming.
---
lisp/image.el | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lisp/image.el b/lisp/image.el
index 610d020aab..8a9cfec841 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -561,12 +561,11 @@ image-compute-scaling-factor
((numberp scaling) scaling)
((eq scaling 'auto)
(let ((width (/ (float (window-width nil t)) (window-width))))
- ;; If we assume that a typical character is 10 pixels in width,
- ;; then we should scale all images according to how wide they
- ;; are. But don't scale images down.
- (if (< width 10)
+ ;; We should scale all images according to how wide they are.
+ ;; But don't scale images down.
+ (if (< width (frame-char-width))
1
- (/ (float width) 10))))
+ (/ (float width) (frame-char-width)))))
(t
(error "Invalid scaling factor %s" scaling))))
--
2.25.1
- [PATCH] avoid hard-coded assumptions in image scaling,
James N. V. Cash <=