Subject: bug#50440: Emacs does not rescale fonts when display changes DPI

From: Radon Rosborough <[email-masked]>
Date: Tue, 7 Sep 2021 13:47:08 -0700

> potentially make-frame-on-display could call it

I haven't tried it yet, but I suspect this may not work: the reason is that
DISPLAY is actually the same before and after; it's ":1" in both cases,
despite the DPI being different between the two displays. (Is this the root
cause of the bug?)

> Does any of the above allow you to solve the issue?

After my previous email, I found a workaround which is clearly a hack but
works well enough to satisfy me: changing the size of the default font
appears to be able to cancel out the wrong DPI more or less visually
identically. The code looks like this:

(defun radian-local-make-it-bigger ()
  (interactive)
  (set-face-attribute 'default nil :height (* (face-attribute 'default
:height) 2)))

(defun radian-local-make-it-smaller ()
  (interactive)
  (set-face-attribute 'default nil :height (/ (face-attribute 'default
:height) 2)))

(bind-key "s--" #'radian-local-make-it-smaller)
(bind-key "s-=" #'radian-local-make-it-bigger)

There are some issues with rounding errors, but it's a lot better than
nothing. I just use those keybindings whenever plugging in or unplugging my
external monitor.