Commit db9af103 authored by Paul Eggert's avatar Paul Eggert

For SVG, 8192 is the new 256

Prefer librsvg for display of splash.svg
When both librsvg and Imagemagick are available, Emacs should
prefer librsvg to render SVG images.  However, Emacs was using
Imagemagick to render its own splash.svg file because
image-type-from-file-header returned nil for that file.
* lisp/image.el (image-type-from-buffer)
(image-type-from-file-header): Look at the first 8192 bytes of
the image, not just the first 256.  For Emacs’s own splash.svg
file, image-type-header-regexps needs to look at 939 bytes.
8192 bytes is a reasonable number nowadays given typical file
system design.
* test/lisp/image-tests.el (image-tests--emacs-images-directory):
New contant.
(image-type-from-file-header-test): New test.
parent 5b8be580
Pipeline #1721 failed with stage
in 55 minutes and 38 seconds
......@@ -315,7 +315,7 @@ be determined."
(min (point-max)
(+ (point-min) 256))))))
(+ (point-min) 8192))))))
(setq image-type (cdr image-type))))
(setq type image-type
types nil)
......@@ -339,7 +339,7 @@ be determined."
(file-readable-p file)
(set-buffer-multibyte nil)
(insert-file-contents-literally file nil 0 256)
(insert-file-contents-literally file nil 0 8192)
......@@ -22,6 +22,10 @@
(require 'ert)
(require 'image)
(defconst image-tests--emacs-images-directory
(expand-file-name "../etc/images" (getenv "EMACS_TEST_DIRECTORY"))
"Directory containing Emacs images.")
(ert-deftest image--set-property ()
"Test `image--set-property' behavior."
(let ((image (list 'image)))
......@@ -42,4 +46,11 @@
(setf (image-property image :width) nil)
(should (equal image '(image)))))
(ert-deftest image-type-from-file-header-test ()
"Test image-type-from-file-header."
(should (eq 'svg
(expand-file-name "splash.svg"
;;; image-tests.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment