[Top][All Lists]

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

[Emacs-diffs] master 2d8c895: Further fix-ups for SVG wrapping in shr

From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 2d8c895: Further fix-ups for SVG wrapping in shr
Date: Thu, 19 Sep 2019 09:58:43 -0400 (EDT)

branch: master
commit 2d8c8950b921e6fa97c04f72253d4c5349b2d5d4
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Further fix-ups for SVG wrapping in shr
    * lisp/net/shr.el (svg--wrap-svg): Add the size to the wrapper to
    avoid having the SVG images shrink (bug#37159).
 lisp/net/shr.el | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index e73c7cd..d8a01cb 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1188,15 +1188,15 @@ Return a string with image data."
 (defun svg--wrap-svg (data)
   "Add a default foreground colour to SVG images."
-  (with-temp-buffer
-    (insert "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\"; "
-            "xmlns:xi=\"http://www.w3.org/2001/XInclude\"; "
-            "style=\"color: "
-            (face-foreground 'default) ";\">"
-            "<xi:include href=\"data:image/svg+xml;base64,"
-            (base64-encode-string data t)
-            "\"></xi:include></svg>")
-    (buffer-string)))
+  (let ((size (image-size (create-image data nil t :scaling 1) t)))
+    (with-temp-buffer
+      (insert
+       (format
+        "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\"; 
xmlns:xi=\"http://www.w3.org/2001/XInclude\"; style=\"color: %s;\" viewBox=\"0 0 
%d %d\"> <xi:include href=\"data:image/svg+xml;base64,%s \"></xi:include></svg>"
+        (face-foreground 'default)
+        (car size) (cdr size)
+        (base64-encode-string data t)))
+      (buffer-string))))
 (defun shr-image-displayer (content-function)
   "Return a function to display an image.

reply via email to

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