Vector screenshots for the manuals: better quality and more visually attractive

Hossein Noorikhah hossein.ir at gmail.com
Mon May 31 20:49:48 UTC 2021


Hello,

You may already know that with Gtk 3, it is possible to take vector
screenshots
from a GUI. The utility created by Joachim Breitner (nomeata) takes care of
the
job:
https://github.com/nomeata/gtk-vector-screenshot

But, this does not work out of the box. I have tried to take vector
screenshots
from LibreOffice gtk3 gui, and it led to an immediate crash. I have
debugged the
soffice binary, and I came across several assertions that are checked and
some
aborts in case of specific threading situations. I have temporarily disabled
these assertions and aborts, and by further disabling the autosave,
everything
was fine, and I could take vector screenshots. The tiny patch is attached.

I have created a proof of concept document from "LibreOffice Writer Guide",
section titled “20. Customizing Writer”, and created vector screenshots in
SVG
format for almost all of the previously raster screenshots. The quality of
the
PDF output is much better, the file is more visually attractive and it is
better
for print and display.

Vector ODT:
https://wiki.documentfoundation.org/images/7/79/WG7120-CustomizingWriter-vector.odt

Vector PDF:
https://wiki.documentfoundation.org/images/4/4b/WG7120-CustomizingWriter-vector.pdf

There are few remaining things:

1. Vector screenshot does not add window decorations, so some workaround is
needed. For example, some toplevel Gtk widgets contain decorations in the
screenshots, so these can be used for containing the window contents.

2. Trying to take screenshots closes menus, etc, and this can be handled by
creating a delay in taking screenshots.

3. Not everything is vector. For example, document contents in LibreOffice
and
also toolbar and status bar icons are not vectors. This is because of the
way
text and images are rendered in LibreOffice. If you take screenshots from
other
applications, the output is different. Try Glade and Gedit for the
comparison.

On the development side, I doubt that having these aborts will be useful at
runtime. There are hundreds of aborts and thousands of asserts in the code
in which I
think should be revised. Crashing the application in case of some problem is
usually a bad idea.

Assertions in C++, and Why Not to Use assert()
https://web.archive.org/web/20191110223903/https://www.softwariness.com/articles/assertions-in-cpp/

Regards,
Hossein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20210601/b1ee2ec1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vector.diff
Type: text/x-patch
Size: 1809 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20210601/b1ee2ec1/attachment.bin>


More information about the LibreOffice mailing list