Created
January 3, 2019 15:45
-
-
Save jsks/056a4e950c8bc410aabe3c219fbd4b25 to your computer and use it in GitHub Desktop.
YAMAMOTO Mitsuharu's patch for pdf-tools on MacOS https://lists.gnu.org/archive/html/emacs-devel/2016-04/msg00648.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lisp/pdf-annot.el b/lisp/pdf-annot.el | |
index b0ff3c2..82cf122 100644 | |
--- a/lisp/pdf-annot.el | |
+++ b/lisp/pdf-annot.el | |
@@ -981,6 +981,7 @@ other annotations." | |
(pdf-cache-renderpage-highlight | |
page (car size) | |
`("white" "steel blue" 0.35 ,@edges)) | |
+ :width (car size) | |
:map (pdf-view-apply-hotspot-functions | |
window page size)))) | |
(pdf-util-scroll-to-edges | |
diff --git a/lisp/pdf-info.el b/lisp/pdf-info.el | |
index 3eeacf8..54c07e5 100644 | |
--- a/lisp/pdf-info.el | |
+++ b/lisp/pdf-info.el | |
@@ -1594,7 +1594,15 @@ Return the data of the corresponding PNG image." | |
'renderpage | |
(pdf-info--normalize-file-or-buffer file-or-buffer) | |
page | |
- width | |
+ (* width | |
+ ;; XXX This does not give optimal results when you have both | |
+ ;; Retina and non-Retina displays connected. For true | |
+ ;; high-resolution support, one should use either TIFF, "@2x" | |
+ ;; convention, or resolution-independent formats such as PDF. | |
+ (or (and (memq (pdf-view-image-type) '(imagemagick image-io)) | |
+ (fboundp 'frame-monitor-attributes) | |
+ (cdr (assq 'backing-scale-factor (frame-monitor-attributes)))) | |
+ 1)) | |
(let (transformed) | |
(while (cdr commands) | |
(let ((kw (pop commands)) | |
diff --git a/lisp/pdf-isearch.el b/lisp/pdf-isearch.el | |
index 563e721..5225395 100644 | |
--- a/lisp/pdf-isearch.el | |
+++ b/lisp/pdf-isearch.el | |
@@ -742,7 +742,7 @@ MATCH-BG LAZY-FG LAZY-BG\)." | |
occur-hack-p) | |
(eq page (pdf-view-current-page))) | |
(pdf-view-display-image | |
- (pdf-view-create-image data)))))))) | |
+ (pdf-view-create-image data :width width)))))))) | |
(pdf-info-renderpage-text-regions | |
page width t nil | |
`(,fg1 ,bg1 ,@(pdf-util-scale-pixel-to-relative | |
diff --git a/lisp/pdf-view.el b/lisp/pdf-view.el | |
index 2eecb8e..7e6af5a 100644 | |
--- a/lisp/pdf-view.el | |
+++ b/lisp/pdf-view.el | |
@@ -892,7 +892,7 @@ See also `pdf-view-set-slice-from-bounding-box'." | |
"Return the image type that should be used. | |
The return value is either `imagemagick' (if available and wanted | |
-or if png is not available) or `png'. | |
+or if png is not available), image-io (on the Mac port), or `png'. | |
Signal an error, if neither `imagemagick' nor `png' is available. | |
@@ -900,6 +900,8 @@ See also `pdf-view-use-imagemagick'." | |
(cond ((and pdf-view-use-imagemagick | |
(fboundp 'imagemagick-types)) | |
'imagemagick) | |
+ ((image-type-available-p 'image-io) | |
+ 'image-io) | |
((image-type-available-p 'png) | |
'png) | |
((fboundp 'imagemagick-types) | |
@@ -909,8 +911,8 @@ See also `pdf-view-use-imagemagick'." | |
(defun pdf-view-use-scaling-p () | |
"Return t if scaling should be used." | |
- (and (eq 'imagemagick | |
- (pdf-view-image-type)) | |
+ (and (memq (pdf-view-image-type) | |
+ '(imagemagick image-io)) | |
pdf-view-use-scaling)) | |
(defmacro pdf-view-create-image (data &rest props) | |
@@ -1377,7 +1379,8 @@ This is more useful for commands like | |
`(,(car colors) ,(cdr colors) 0.35 ,@region)) | |
(pdf-info-renderpage-text-regions | |
page width nil nil | |
- `(,(car colors) ,(cdr colors) ,@region))))))) | |
+ `(,(car colors) ,(cdr colors) ,@region))) | |
+ :width width)))) | |
(defun pdf-view-kill-ring-save () | |
"Copy the region to the `kill-ring'." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment