[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 5a0ab88: Add default foreground colours to SVG imag
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 5a0ab88: Add default foreground colours to SVG images |
Date: |
Sat, 14 Sep 2019 10:48:30 -0400 (EDT) |
branch: master
commit 5a0ab88cc984e8a5e66f85cb5acfa362fc66bdb6
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Add default foreground colours to SVG images
* lisp/net/shr.el (svg--wrap-svg): Add a default foreground colour
to SVG images (bug#37159). This helps with images like the ones
in https://en.wikipedia.org/wiki/Banach_fixed-point_theorem that
specify no foreground or background colours.
(shr-parse-image-data): Use it.
---
lisp/net/shr.el | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 81c3fb4..1dff129 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1180,8 +1180,24 @@ Return a string with image data."
;; so glitches may occur during this transformation.
(shr-dom-to-xml
(libxml-parse-xml-region (point) (point-max)))))
+ ;; SVG images often do not have a specified foreground/background
+ ;; color, so wrap them in styles.
+ (when (eq content-type 'image/svg+xml)
+ (setq data (svg--wrap-svg data)))
(list data content-type)))
+(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)))
+
(defun shr-image-displayer (content-function)
"Return a function to display an image.
CONTENT-FUNCTION is a function to retrieve an image for a cid url that
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 5a0ab88: Add default foreground colours to SVG images,
Lars Ingebrigtsen <=