









| author | Arash Esbati <arash@gnu.org> | 2026-08-19 12:31:29 +0200 |
|---|---|---|
| committer | Arash Esbati <arash@gnu.org> | 2026-08-19 12:31:29 +0200 |
| commit | 34e5496f1205181dfd995066ed599197229bacfa (patch) | |
| tree | 2e249f4a094b7d0121ac5935b53853e8e61cdbc1 | |
| parent | 228e2c7ff54b1d192bc8054bb02a9a31744eece4 (diff) | |
Deal with wrong monitor height and width
* preview.el (preview-get-dpi): Guard against the case where `frame-monitor-attributes' returns a 0-pair for the monitor width and height in millimeters. See below for the original report and further discussion: https://emacs.stackexchange.com/q/85878/12242 https://lists.gnu.org/archive/html/emacs-devel/2026-07/msg00495.html
| -rw-r--r-- | preview.el | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/preview.el b/preview.el
index 37da8f1d0da..962712481b3 100644
--- a/preview.el
+++ b/preview.el
@@ -1,6 +1,6 @@
;;; preview.el --- embed preview LaTeX images in source buffer -*- lexical-binding: t; -*-
-;; Copyright (C) 2001-2025 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2026 Free Software Foundation, Inc.
;; Author: David Kastrup
;; Keywords: tex, text, convenience
@@ -4009,8 +4009,14 @@ name(\\([^)]+\\))\\)\\|\
(defun preview-get-dpi ()
(let* ((monitor-attrs (frame-monitor-attributes))
(mm-dims (cdr (assoc 'mm-size monitor-attrs)))
- (mm-width (or (nth 0 mm-dims) 1))
- (mm-height (or (nth 1 mm-dims) 1))
+ (mm-width (or (and (integerp (nth 0 mm-dims))
+ (> (nth 0 mm-dims) 0)
+ (nth 0 mm-dims))
+ 1))
+ (mm-height (or (and (integerp (nth 1 mm-dims))
+ (> (nth 1 mm-dims) 0)
+ (nth 1 mm-dims))
+ 1))
(pixel-dims (cl-cdddr (assoc 'geometry monitor-attrs)))
(pixel-width (nth 0 pixel-dims))
(pixel-height (nth 1 pixel-dims)))
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。