15

The gtk-vector-screenshot program can be used to take vector screenshots of Gtk-3 applications. It seems to work by asking the application to redraw itself onto an SVG canvas.

Emacs on GNU/Linux can be built with Gtk+, but trying to use the aforementioned application on an Emacs window results in a screenshot that only contains GUI elements such as the menu bar; buffers are not rendered (I tried with and without Cairo). This is not too surprising, given that Emacs' buffer rendering happens at a pretty low level.

Still, is there a way to take scalable vector screenshots of Emacs?

2

According to the documentation Gtk+ widgets in Emacs are:

  • menus,
  • dialogs,
  • tool bars and
  • scroll bars

Buffers are rendered by Emacs itself. Neither the buffer nor the lines in a buffer are Gtk+ widgets. This means they do not know anything about the export functionality of Gtk+ widgets.

The best thing you can do is to use htmlfontify-buffer in order to embed the generated HTML into your SVG containing the widgets. But this will require some additional work to merge the HTML and SVG. But be aware that htmlfontify-buffer has also some limitations and does not work with every buffer.

| improve this answer | |
  • I'm not sure this answers the question. I did mention take-vector-screenshot as an example, but I also mentioned that it wasn't surprising that it didn't work. htmlfontify-buffer has too many limitations to really qualify (it won't render overlays, display-string, line wraps, font fallback, etc.) – Clément Feb 16 '16 at 14:41
  • 1
    @Clément The short answer is: no way. – ceving Feb 16 '16 at 14:42
  • Is this personal opinion, or do you have evidence to back that claim? Given the number of rendering backends (Cairo, directly through X, Gtk, etc.) that Emacs has, one could imagine that a slight tweak to one of them might be enough. – Clément Feb 16 '16 at 15:18
  • 2
    @Clément Gtk+ can render to SVG, because Gtk+ uses Cairo, which has a backend for SVG. Emacs does not use Cairo for the buffer rendering. But there is a experimental branch for Cairo. Maybe in the near future it might be possible. – ceving Feb 17 '16 at 8:46
1

It's possible in Cairo builds!

(x-export-frames FRAMES TYPE)

Return image data of FRAMES in TYPE format.
FRAMES should be nil (the selected frame), a frame, or a list of
frames (each of which corresponds to one page).  Each frame should be
visible.  Optional arg TYPE should be either `pdf' (default), `png',
`postscript', or `svg'.  Supported types are determined by the
compile-time configuration of cairo.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.