tksvg

tksvg features SVG image for tcl8.6

With TIP507 , svg-support was added to tk8.7+.

To get the same support on tk 8.6, use package tksvg by Auriocus.

ChangeLog

VersionDateText
0.1Initial Version by Christian Werner
0.2Ported to TCL 8.6 by Ariocous
0.32019-09-16TIP545 : Added options "-scaletoheight" and "-scaletowidth". Added binary distribution

Download

The download is contained in the release area: [1 ].

It contains currently the source and binaries for Linux (64 bit), Mac and Windows (32 and 64 bit).

Note: Windows binaries contained a bug (function fabsf was mapped to abs, not fabs), which was corrected shortly after the release. The released binaries contain the fixed version.

Distributions

The following distributions contain TkSVG:

Packages using tksvg

The following packages use tksvg to scale images:

Compilation

Windows x86 (32 bit)

tksvg 0.3 compilation succeeded using ms-vc6 with the following commands:

vcvars.bat
setenv /RETAIL
cd win
nmake -f makefile.vc install TCLDIR=c:\test\tcl8.6.9 INSTALLDIR=c:\test\tknano

Windows x64 (64 bit)

tksvg 0.3 compilation succeeded using SDK2003SP1 with the following commands:

setenv /XP64 /RETAIL
cd win
nmake -f makefile.vc TCLDIR=c:\test\tcl_x64_build\tcl8.6.9 TKDIR=c:\test\tcl_x64_build\tk8.6.9
nmake -f makefile.vc install TCLDIR=c:\test\tcl_x64_build\tcl8.6.9 TKDIR=c:\test\tcl_x64_build\tk8.6.9 INSTALLDIR=c:\test\tcl_x64_build\tksvg_64

Linux (32 and 64 bit)

./configure --with-tcl=/home/oehhar/test/tcl8.6.9 --with-tk=/home/oehhar/test/tk8.6.9 --exec-prefix=/home/oehhar/test/tksvg0.3
make

Usage for buttons

Create an image with an svg image with the given height of 16 pixels:

% image create photo i1 -file c:/myimage/test.svg -format {svg -scaletoheight 16}
% pack [button .b1 -image i1]

Now the button is scaled to 20 pixels in runtime:

% i1 configure -format {svg -scaletoheight 20}

The button image is scaled.

Attention: the image file must be available, as it is read from disk again. So, if you remove the file c:/myimage/test.svg, the command will fail.

If this is an issue, load the image first into a variable and pass the data with the "-data" option to the image creation command.

Text items in svg

The used svg implementation "svgnano" does not support text items. I paint my icons using InkScape as follows: To display text, first use the text tool to print the text. Then go to the path menu and select "transform object to path" with the shortcut "Shift-Control-C". After save, the text is visible within tclnano.