svg options for krita

Jos van den Oever jos at vandenoever.info
Fri Aug 26 08:45:20 UTC 2016


Hi all,

This is a follow up of sprint discussions about how to support SVG in Krita.

SVG is a rather large specification. Implementing it from scratch is a large 
task. Just implementing reading and writing is a lot of work. So it's 
important to be clever.

For reading and writing, it's best to generate the code from a schema or reuse 
an existing library that can read and write SVG.

There are Relax NG schemas for SVG Tiny 1.2 and SVG Basic 1.1.

http://www.w3.org/TR/SVGTiny12/relaxng/
http://yupotan.sppd.ne.jp/relax-ng/svg11/

The schema for SVG Tiny 1.2 is normative. But it is not a complete solution. 
Thee schema does not go into all details, for example the color type is not 
defined but just a string in the schema, even though the specification has a 
detailed explanation for the type which could be expressed in Relax NG.

These can be starting points for generating code. A number of projects take 
input and generate code from that. My favorite one is Blasien, because it has 
the most beautiful C++ code and avoids most programming errors. Yet, all these 
generators are either tailored to one Relax NG schema or just a proof of 
concept.

Blasien
https://github.com/vandenoever/blasien
http://www.vandenoever.info/blog/2015/07/05/literal-xml-in-c++.html
 - does not currently handle multi-file relax-ng
 - only generates serializer
 - most compiletime checks
 - beautiful syntax

rng2cpp from Calligra
https://quickgit.kde.org/?p=calligra.git&a=tree&f=libs%2Fodf%2Fwriteodf
https://quickgit.kde.org/?p=calligra.git&a=tree&f=devtools%2Frng2cpp
 - predecessor to Blasien
 - used in production for OpenDocument in Calligra
 - does not currently handle multi-file relax-ng
 - only generates serializer

https://gitlab.com/odfplugfest/xmlmirror/commits/krita-svg
 - handles multi-file relax ng
 - generates json (see attach), not c++, so all c++ generation has to be added

These options would help to write high quality conversions between ODF and 
SVG.

That leaves rendering and editing. Krita has great code for editing vectors 
that can be adapted to read and write SVG with the generated code.

Another option is to use SVG-Edit. This is an SVG editor written in 
JavaScript.
https://svg-edit.github.io/svgedit/releases/svg-edit-2.8.1/svg-editor.html
The SVG is never converted to a runtime model. Just get the element with id 
'svgcontent' and save it. The browser takes care of loading the svg and 
rendering it.

This code can be used via QtWebKit. PhantomJS from Krita alumnus Ariya Hidayat 
shows that QtWebKit is still very much alive.
https://github.com/ariya/phantomjs/issues/14366

Another option is http://svgpp.org/. This library uses RapidXMLNS to provide a 
runtime SVG DOM. This DOM can be modified and re-rendered. The render must 
be provided by the application. This DOM is not typed, so care must be taken 
to not create invalid SVG.

I'll close this long mail with an inspirational link to a talk about 
WebRender.
https://air.mozilla.org/bay-area-rust-meetup-february-2016/

Cheers,
Jos






-------------- next part --------------
A non-text attachment was scrubbed...
Name: svgtiny.json.bz2
Type: application/x-bzip
Size: 4462 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20160826/2e88e341/attachment.bin>


More information about the kimageshop mailing list