From 47288ad1203c7fe3b58e8bdab46c4932d37150dc Mon Sep 17 00:00:00 2001 From: Zajcev Evgeny Date: Thu, 17 Dec 2020 01:04:09 +0300 Subject: [PATCH] Improvements for `:base-uri' svg image property * src/image.c (svg_load): Use ENCODE_FILE for `:base-uri' * doc/lispref/display.texi: Add more documentation for `:base-uri' --- doc/lispref/display.texi | 8 +++++++- src/image.c | 8 +++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 2b3119ea59..2ecd14fed9 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -5904,7 +5904,13 @@ SVG Images To @var{svg} add an embedded (raster) image placed at @var{relative-filename}. @var{relative-filename} is searched inside @code{file-name-directory} of the @code{:base-uri} svg image property. -This improves the performance of embedding large images. +@code{:base-uri} specifies a (possible non-existing) filename name of +the svg image to be created, thus all the embedded files are searched +relatively to the @code{:base-uri} filename's directory. If +@code{:base-uri} is ommited, then filename from where svg image is +loaded is used. Using @code{:base-uri} improves the performance of +embedding large images, comparing to @code{svg-embed}, because all the +work is done directly by librsvg. @lisp ;; Embeding /tmp/subdir/rms.jpg and /tmp/another/rms.jpg diff --git a/src/image.c b/src/image.c index dc06e9ce20..ba39fdc785 100644 --- a/src/image.c +++ b/src/image.c @@ -9779,8 +9779,9 @@ svg_load (struct frame *f, struct image *img) } /* If the file was slurped into memory properly, parse it. */ if (!STRINGP (base_uri)) - base_uri = ENCODE_FILE (file); - success_p = svg_load_image (f, img, contents, size, SSDATA (base_uri)); + base_uri = file; + success_p = svg_load_image (f, img, contents, size, + SSDATA (ENCODE_FILE (base_uri))); xfree (contents); } /* Else it's not a file, it's a Lisp object. Load the image from a @@ -9798,7 +9799,8 @@ svg_load (struct frame *f, struct image *img) if (!STRINGP (base_uri)) base_uri = BVAR (current_buffer, filename); success_p = svg_load_image (f, img, SSDATA (data), SBYTES (data), - (NILP (base_uri) ? NULL : SSDATA (base_uri))); + (STRINGP (base_uri) ? + SSDATA (ENCODE_FILE (base_uri)) : NULL)); } return success_p; -- 2.25.1