]> git.eshelyaron.com Git - emacs.git/commitdiff
Improvements for `:base-uri' svg image property
authorZajcev Evgeny <zevlg@yandex.ru>
Wed, 16 Dec 2020 22:04:09 +0000 (01:04 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 26 Dec 2020 09:18:49 +0000 (11:18 +0200)
* src/image.c (svg_load): Use ENCODE_FILE for `:base-uri'

* doc/lispref/display.texi (SVG Images): Add more documentation for
  `:base-uri'

doc/lispref/display.texi
src/image.c

index 2b3119ea5903c63c0d88dea077804e11f7b05b69..949fd8987c245de44c360cf9988190e5d28eab2f 100644 (file)
@@ -5904,7 +5904,13 @@ string containing the image data as raw bytes.  @var{image-type} should be a
 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 (possibly non-existing) file 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
index 29cd189f177b4a4d1c7840154f4ae8d6d676c68b..e99ba09f515c3dad133671df0b887f0e94b44941 100644 (file)
@@ -9803,8 +9803,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
@@ -9822,7 +9823,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;