XP1Dr2SVG Version 1.22
Converts drawfiles to SVG (Scalable Vector Graphics) format, for import into various applications on Mac or PCs (or of course on any computer, if it has an app that handles SVG files). I’ve tested it with Safari, Firefox, LibreOffice, Inkscape and The GIMP on a Mac.
For a few example drawings that I originally drew in !Draw and which are now SVGs, see SVGsamples.
It doesn’t do a perfect job, but it’s not bad and I’ll improve it in time. It does a good job of solid lines and curves, and gets stroke widths, fills and colours correct. Dashed and/or dotted lines are also correct, as are chains and railway tracks and other fancy lines you can produce using !XP1ReDraw (as of v1.13, 30th December 2018).
View Boxes! You can make a “view box” so that only what’s inside the box will be rendered by SVG rendering apps. To do this, make a rectangle corresponding to the area you want to be visible, with no fill, and a “thin” line outline in the darkest shade of grey (not black) of !Draw’s default palette. !XP1Dr2SVG will convert this into an SVG View Box. Don’t use thin line outlines in this shade of grey, with no fill, for anything else – they won’t appear in the SVG file, and you’ll end up with a view box equal to the bounding box of whichever such path is on top.
Thin Lines !Draw renders lines of zero width (“thin” lines) as the thinnest lines the current medium can display. !X1P1Dr2SVG converts them to single pixel width at the scale you specify on the save box - 90dpi by default - because otherwise SVG doesn't render them at all. If you want a different line thickness, you can specify it in !Draw.
!Draw has a peculiarity that arrowheads on lines are applied to the ends of dots and dashes in dotted and dashed lines.
This isn’t usually what you really want anyway (although I have made use of it in “show windings” in !XP1PathEd).
This is NOT reproduced by !XP1Dr2SVG: it just puts arrowheads (as of August 9th 2021, correctly sized and coloured) on the ends of whole lines.
SVG doesn’t allow different endcaps on the ends of lines (apart from arrowheads). There’s a way around this (now implemented) for solid lines, but not exactly for dashed lines.
Text !XP1Dr2SVG converts Trinity to Times, Homerton to Arial, Corpus to Courier – and everything else to Arial. These three fonts can be rotated to any angle, OR have different height and width (that is, condensed or expanded) - but NOT both at once. If you want other fonts, or rotated extended or rotated condensed text, or any kind of skewed text, converted faithfully, convert them to path in !Draw first. It’s unlikely I’ll do anything more than this with text. This is enough to cope with almost everything in my own work. I’ve only done this much to keep file sizes down and maintain editability after conversion.
!XP1Dr2SVG assumes that the alphabet is set to Default, Latin1, or UTF8 - and that it was set the same when the Drawfile it’s converting was made. This doesn’t matter if only plain ASCII characters are used, but otherwise you could get wrong characters, or SVG errors.
* I can make other fonts convert where there are clear equivalences between RISC OS fonts and those on other systems – but I don’t want to end up converting to fonts that might not be available on the target systems. I’ll probably do some of this for my own system, and the font table in !RunImage is pretty obvious and easily edited if you want to. The table can be extended to as many fonts as !Draw can handle (255) with no complications.
Sprites !XP1Dr2SVG doesn’t convert Sprites. They are simply ignored. I do not intend to do anything about this. I might make jpegs transfer over, now that !Draw can handle them.
An oddity when importing to LibreOffice Draw worth being aware of: if you open an SVG file in LibreOffice, if there are paths with a “nonzero” winding rule (as distinct from an “evenodd” winding rule), they’ll appear as “evenodd” – but if you open a blank drawing and drag and drop the file onto the draw window, LibreOffice gets it right! (This applies to the version of LibreOffice I updated to yesterday – it may not apply to all versions.)
If you find it useful, contributions to my pension are always welcome, but certainly not required.