Re: painting SVGs like text
Quote:
Originally Posted by
hartmut
I used to define the symbols in bitmap ressources where I used only three colors: black, white and gray (to create a basic anti aliasing) and I manually converted these three colors pixel by pixel to the current pen, backgrould and average color.
If you can code drawing the symbols then you could paint fully anti-aliased versions of them in the correct colours in the paint() method of the delegate. QPixmapCache could also be useful to minimise reconstruction. You could also look into how you might use a monochrome mask with the image composition operations in Qt to produce your coloured foreground image.
That is how SVG specifies colours, so that is how you change them. It need not be difficult:
- Create the SVG.
- Edit the file and replace the colour codes with markers, e.g. {{bg}} (or entities).
- Ship this file with your project.
- Load the SVG file once into a QByteArray at program start.
When you need the SVG,
- Copy the array
- Use QByteArray::replace() to put your desired colours into the SVG
- Feed the result to QSvgRenderer.
Caching the results would be a good idea.
Quote:
I also thought of creating a font instead of SVG graphics. Is it possible to use a "private" font, which is not installed on the system? It should work under Windows and on a Mac.
Yes. QFontDatabase::addApplicationFont(). The font file can come from a local file or Qt resource system.
Re: painting SVGs like text
Thanks a lot. I tried the font option and it works very well. That's a really elegant solution.