diff --git a/README.org b/README.org
index 9cf1937..98eae02 100644
--- a/README.org
+++ b/README.org
@@ -21,9 +21,10 @@
qrencode RET=.
QR Codes are rendered as Unicode text, but there is an option to
- export them as bitmap (NetPBM format) by pressing =e= in the QR Code
- buffer. There are also some public elisp library functions to
- generate QR Codes for use in other elisp code.
+ export them as bitmap (NetPBM format) or vector graphics (SVG) by
+ pressing =e= in the QR Code buffer. There are also some public
+ elisp library functions to generate QR Codes for use in other elisp
+ code.
Currently two NetPBM formats are supported: P1 and P4. The latter
is much smaller and the exporter much faster, so highly recommended.
@@ -32,6 +33,10 @@
format can be changed. In the next major version release P1 support
is likely to get dropped in favour of P4.
+ SVG export is available if =svg.el= (Emacs 26.1 or newer) is
+ available. This can be selected by customizing
+ =qrencode-export-format= to ='svg=.
+
*** Converting different bitmaps
This package only supports exporting to NetPBM format due to the
@@ -60,7 +65,7 @@
[[file:https://github.com/ruediger/qrencode-el/actions/workflows/test.yml/badge.svg]]
- The code is written in pure Emacs Lisp on GNU Emacs 27. It should
+ The code is written in pure Emacs Lisp on GNU Emacs 31. It should
be backwards compatible to GNU Emacs 25.1 and potentially even
earlier with =seq= and =cl-lib= compat libraries.
diff --git a/qr-self.svg b/qr-self.svg
new file mode 100644
index 0000000..0d52712
--- /dev/null
+++ b/qr-self.svg
@@ -0,0 +1 @@
+
diff --git a/qrencode-tests.el b/qrencode-tests.el
index 973a973..a26aa5c 100644
--- a/qrencode-tests.el
+++ b/qrencode-tests.el
@@ -536,6 +536,13 @@ The expected word for version 7 is the literal from section 7.10 of the
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
")))
+(ert-deftest qrencode-svg-path-test ()
+ "Test SVG path."
+ (skip-unless (featurep 'svg))
+ (should (string= (qrencode--svg-path [[0 0] [0 0]] 0) ""))
+ (should (string= (qrencode--svg-path [[1 1] [1 1]] 0) "M0 0h2v1h-2zM0 1h2v1h-2z"))
+ (should (string= (qrencode--svg-path [[0 0 1] [0 1 1] [0 0 0]] 0) "M2 0h1v1h-1zM1 1h2v1h-2z")))
+
(defun qrencode-tests--get-file (filename)
"Helper function returning contents of FILENAME."
(with-temp-buffer
@@ -553,7 +560,8 @@ The expected word for version 7 is the literal from section 7.10 of the
(should (not (null qrencode--raw-qr)))
(let ((tmpfile-p1 (make-temp-file "qr-p1" nil ".pbm"))
(tmpfile-p4 (make-temp-file "qr-p4" nil ".pbm"))
- p1 p4)
+ (tmpfile-svg (make-temp-file "qr-svg" nil ".svg"))
+ p1 p4 svg)
(unwind-protect
(progn
(let ((qrencode-export-format 'p1))
@@ -564,18 +572,26 @@ The expected word for version 7 is the literal from section 7.10 of the
(qrencode-export-buffer-to-file tmpfile-p4))
(setq p4 (qrencode-tests--get-file tmpfile-p4))
(should (string-prefix-p "P4\n" p4))
+ (when (featurep 'svg)
+ (let ((qrencode-export-format 'svg))
+ (qrencode-export-buffer-to-file tmpfile-svg))
+ (setq svg (qrencode-tests--get-file tmpfile-svg))
+ (should (string-prefix-p "