forked from mirrors/org-mode
org-latex-preview: Robustify DPI calculation
* lisp/org-latex-preview.el (org-latex-preview--get-display-dpi): It was reported that on a WSLg system using pgtk that `org-latex-preview--get-display-dpi' produced an arithmetic overflow error. Inspecting the calculation performed and docstrings of functions involved, it seems we need to be more careful of the `display-mm-height' output. We now guard against it being zero or nil, which should make the DPI calculation more robust. Simply falling back to a guessed DPI of 140 is non-ideal, but probably the best we can reasonably do here.
This commit is contained in:
parent
c20bf88205
commit
5e7af27352
|
@ -2405,8 +2405,11 @@ color information for this run."
|
|||
The function assumes that the display has the same pixel width in
|
||||
the horizontal and vertical directions."
|
||||
(if (display-graphic-p)
|
||||
(round (/ (display-pixel-height)
|
||||
(/ (display-mm-height) 25.4)))
|
||||
(let ((mm-height (or (display-mm-height) 0))
|
||||
(mm-per-inch 25.4))
|
||||
(if (= 0 mm-height)
|
||||
140 ; Fallback reasonable DPI
|
||||
(round (/ (display-pixel-height) (/ mm-height mm-per-inch)))))
|
||||
(error "Attempt to calculate the dpi of a non-graphic display")))
|
||||
|
||||
(defun org-latex-preview--attr-color (attr)
|
||||
|
|
Loading…
Reference in New Issue