diff options
| author | Illia Ostapyshyn <ilya.ostapyshyn@gmail.com> | 2021-05-13 19:34:36 +0200 |
|---|---|---|
| committer | Vedang Manerikar <ved.manerikar@gmail.com> | 2021-05-29 12:44:19 +0530 |
| commit | f771c93781b3135200cae6dbc8e45dbb887f77b1 (patch) | |
| tree | 55145baaa8e76170a3a7c56c3e3d85033f2e32be /lisp/pdf-util.el | |
| parent | d06acb9aaa0cf74b2db79eef69b293a7476524ea (diff) | |
Support HiDPI displays on vanilla emacs
Fixes the long-standing issue of displaying pdf contents
in proper resolution on retina Macs using vanilla (not a fork) emacs
[1], [2]
This commit squashes changes contributed by @iostapyshyn. It
introduces the following changes:
- Use `frame-scale-factor` to detect HiDPI displays in preference to
other methods. `frame-scale-factor` is a new function introduced in
Vanilla Emacs to return the scale factor of the backing store.
- Allow scaling for `png` type images as well (if
`pdf-view-use-scaling` is `t`), since this works well and I'm not
sure why it was originally disabled.
1: politza/pdf-tools#51
2: hlissner/doom-emacs#4989
Closes #13
Diffstat (limited to 'lisp/pdf-util.el')
| -rw-r--r-- | lisp/pdf-util.el | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lisp/pdf-util.el b/lisp/pdf-util.el index 3c4d77b..c57f6ec 100644 --- a/lisp/pdf-util.el +++ b/lisp/pdf-util.el @@ -945,15 +945,14 @@ See also `regexp-quote'." (defun pdf-util-frame-scale-factor () "Return the frame scale factor depending on the image type used for display. -When `pdf-view-use-scaling' is non-nil and imagemagick or -image-io are used as the image type for display, return the -backing-scale-factor of the frame if available. If a -backing-scale-factor attribute isn't available, return 2 if the +When `pdf-view-use-scaling' is non-nil, return the scale factor of the frame +if available. If the scale factor isn't available, return 2 if the frame's PPI is larger than 180. Otherwise, return 1." - (if (and pdf-view-use-scaling - (memq (pdf-view-image-type) '(imagemagick image-io)) - (fboundp 'frame-monitor-attributes)) - (or (cdr (assq 'backing-scale-factor (frame-monitor-attributes))) + (if pdf-view-use-scaling + (or (and (fboundp 'frame-scale-factor) + (truncate (frame-scale-factor))) + (and (fboundp 'frame-monitor-attributes) + (cdr (assq 'backing-scale-factor (frame-monitor-attributes)))) (if (>= (pdf-util-frame-ppi) 180) 2 1)) |
