Function: ghostel--detect-cell-pixel-scale

ghostel--detect-cell-pixel-scale is a natively compiled function defined in ghostel.el.

Signature

(ghostel--detect-cell-pixel-scale)

Documentation

Compute cell pixel-size scale from display DPI, or nil if unknown.

Returns a positive number: ratio of the display's DPI to the 96 DPI reference, kept as a float so non-integer scales (1.5x displays) flow through correctly. Returns nil when the display's physical size isn't reported (some multi-monitor setups), letting the caller fall back.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--detect-cell-pixel-scale ()
  "Compute cell pixel-size scale from display DPI, or nil if unknown.
Returns a positive number: ratio of the display's DPI to the 96 DPI
reference, kept as a float so non-integer scales (1.5x displays) flow
through correctly.  Returns nil when the display's physical size isn't
reported (some multi-monitor setups), letting the caller fall back."
  (when (display-graphic-p)
    ;; Pass the selected frame so multi-monitor setups resolve to the
    ;; display actually showing the ghostel buffer rather than the
    ;; primary display.
    (let* ((frame (selected-frame))
           (mm-w (display-mm-width frame))
           (px-w (display-pixel-width frame))
           (mm-per-inch 25.4)
           (reference-dpi 96.0))
      (when (and (numberp mm-w) (> mm-w 0)
                 (numberp px-w) (> px-w 0))
        (let ((dpi (/ (* px-w mm-per-inch) mm-w)))
          (max 1.0 (/ dpi reference-dpi)))))))