[Feature request] svg picture format support

I use inkscape to prepare graphics. It would be nice if I don’t need to convert my svg to eps before inserting it TeXmacs.

This should have been supported in TeXmacs 1.99.13, although I did not test. In my computer, when I open the dialog to load an image, the listed “Files of type” includes *.svg.

What OS are you on? I am using official windows 1.99.13 binary and my type does not include svg.

I tried to improve the SVG image handling in TeXmacs several months ago.

Here is the commit:

If there is an inkscape command available, TeXmacs will first convert svg to png using inkscape and then render the PNG image.

From the commit, you may learn about other svg to png options. And inkscape does better svg2png than rsvg-convert. If you want to always use inkscape for svg2png, you should toggle the option in the tab: Edit -> Preferences… -> Convert -> Image

  1. Are you saying that even without inkscape I should be able to insert svg files?

  2. Can you tell me whether you did this on windows? On windows the executable is inkscape.exe and inkscape.com. Do I need to do something like alias?

Yes

I have not tested it on Windows. Let me test it now. Just wait several minutes.

I’m installing Inkscape from the Microsoft Store. It is very slow in China.

On windows, inkscape.exe can be used without .exe in the command line. But you have to add the path first.

Thank you.

After adding Inkscape to PATH and reinstall TeXmacs I can now insert svg file. Unfortunately it does not look good. Maybe the best way to explain is an example svg here:

https://drive.google.com/file/d/1MY52-xArECKPsWHffgJY9ZMDHq-Rggqw/view?usp=sharing

and in TeXmacs it looks like:

Here is the code

(converter svg-file postscript-file
  (:require (url-exists-in-path? "inkscape"))
  (:shell "inkscape" "-z" "-f" from "-P" to))

(converter svg-file pdf-file
  (:require (url-exists-in-path? "inkscape"))
  (:shell "inkscape" "-z" "-f" from "-A" to))

(converter svg-file png-file
  (:require (url-exists-in-path? "inkscape"))
  (:shell "inkscape" "z" "-d" "600" from "--export-png" to))

You may test the conversion command by yourself.

Sorry, but where do I put this code?

I read the documentation and put the code in TEXMACS_HOME_PATH/progs/my-init-texmacs.scm. I don’t see any difference when I inserted the svg file. It’s automatically set to 35x35pt and does not discard the white surroundings.

The command used to be:

inkscape -z -d 600 /path/to/input.svg --export-png /path/to/output.png

Here is the working command for Windows and Inkscape 1.0.0:

inkscape -d 600 --export-type=png --export-filename=/path/to/output.png  /path/to/input.svg

That’s why TeXmacs on Windows does not support inkscape.

I will update the command to convert svg to png using inkscape later for the next release. And also make sure that it works for Windows.

This is not the code to add in any init files. This is the official converter inside TeXmacs.

And it is a good idea to let user override the conversion command.

How are the svg images handled? By conversion to png, seemingly the images are rasterized? I wonder whether it is rasterized when exporting to other formats?