TSkSvg....TrySetAttribute not working

I require to set SVG attributes at runtime. The sample project Skia4Delphi_VCL does exactly what I require by setting the eyes of a lamb red as expected. The problem is, I cannot get this to work in my own project even when using the exact same sample svg file duplicating the exact lines of code as below.

  SkSvg2.Svg.Source := TFile.ReadAllText('C:\Users\Public\Documents\Embarcadero\Studio\23.0\Samples\Assets\lamb.svg');
  SkSvg2.Svg.DOM.FindNodeById('eyes').TrySetAttribute('fill', 'red');

I have checked that FindNodeById(‘eyes’) is assigned and all is well. However, TrySetAttribute(‘fill’, ‘red’) does not work.
Delphi 12, Windows 10, Win32 and Win64. Skia is enabled for the project.
Any clues would be appreciated.

Add the line


after the code you specified and it should work.

Thanks Geoff. That works as expected. I see major benefit in using SVG everywhere and Skia is a good option after using some other tools. I’m experimenting with making my own button class based on TSkSvg which looks very promising.

Recent versions of DevExpress VCL have SVG support for all components that have glyph or image properties (Including buttons). The library comes with an extensive catalog of SVG images in various styles.

I went down the svg path (pun intended) a while back, converting all our tooolbar/menu images to svg - but sadly that didn’t turn out well. Whilst it might seem attractive as svgs are scalable - they don’t work well at smaller sizes - the details are lost and you end up with indistinct blobs. The reality is there is an art (another pun) to drawing small icons so that they actually resemble something. I ended up switching back to pngs.

If you are still keen to go down that path, take a look at

You don’t need to create your own buttons - this library allows you to use regular buttons.

Thanks Vincent. I am already using your library but I do agree with your concern comment about small icon detail. I am investigating new strategies whilst being careful not to go down the wrong rabbit hole. Again!!! I’ll communicate any observations as I go.