emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 1556b43764: docview: Use svg images when using mupdf for conversi


From: Lars Ingebrigtsen
Subject: master 1556b43764: docview: Use svg images when using mupdf for conversion
Date: Sat, 24 Sep 2022 08:10:30 -0400 (EDT)

branch: master
commit 1556b4376457db409a0a15765e89b2a209007d7b
Author: Visuwesh <visuweshm@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    docview: Use svg images when using mupdf for conversion
    
    * lisp/doc-view.el (doc-view-mupdf-use-svg, doc-view-svg-background)
    (doc-view-svg-foreground): New user options.
    (doc-view-insert-image): Add :background and :foreground image
    attributes when display svg images.
    (doc-view-set-up-single-converter): Produce svg images when using
    mupdf (bug#58041).
---
 lisp/doc-view.el | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index aa0f9fd383..fbd1427946 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -209,6 +209,23 @@ are available (see Info node `(emacs)Document View')."
           function)
   :version "24.4")
 
+(defcustom doc-view-mupdf-use-svg (image-type-available-p 'svg)
+  "Whether to use svg images for PDF files."
+  :type 'boolean
+  :version "29.1")
+
+(defcustom doc-view-svg-background "white"
+  "Background color for svg images.
+See `doc-view-mupdf-use-svg'."
+  :type 'color
+  :version "29.1")
+
+(defcustom doc-view-svg-foreground "black"
+  "Foreground color for svg images.
+See `doc-view-mupdf-use-svg'."
+  :type 'color
+  :version "29.1")
+
 (defcustom doc-view-ghostscript-options
   '("-dSAFER" ;; Avoid security problems when rendering files from untrusted
     ;; sources.
@@ -1562,6 +1579,9 @@ ARGS is a list of image descriptors."
                            (setq args `(,@args :width ,doc-view-image-width)))
                           (unless (member :transform-smoothing args)
                             (setq args `(,@args :transform-smoothing t)))
+                          (when (eq doc-view--image-type 'svg)
+                            (setq args `(,@args :background 
,doc-view-svg-background
+                                               :foreground 
,doc-view-svg-foreground)))
                          (apply #'create-image file doc-view--image-type nil 
args))))
             (slice (doc-view-current-slice))
             (img-width (and image (car (image-size image))))
@@ -1983,7 +2003,11 @@ If BACKWARD is non-nil, jump to the previous match."
   (pcase-let ((`(,conv-function ,type ,extension)
                (pcase doc-view-doc-type
                  ('djvu (list #'doc-view-djvu->tiff-converter-ddjvu 'tiff 
"tif"))
-                 (_     (list doc-view-pdf->png-converter-function  'png  
"png")))))
+                 (_ (if (and (eq doc-view-pdf->png-converter-function
+                                 #'doc-view-pdf->png-converter-mupdf)
+                             doc-view-mupdf-use-svg)
+                        (list doc-view-pdf->png-converter-function 'svg "svg")
+                      (list doc-view-pdf->png-converter-function 'png 
"png"))))))
     (setq-local doc-view-single-page-converter-function conv-function)
     (setq-local doc-view--image-type type)
     (setq-local doc-view--image-file-pattern (concat "page-%s." extension))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]