QSvgGenerator can embed specific fonts ?
-
Hello
My request here is an help, regarding the generation of SVG file.
This is the context : I have a QGraphicsScene, filled with drawable elements, some of them are QGraphicsTextItem
In this scene, almost all QGraphicsTextItem elements are a text, with a very specific font (they are scientific or artistic symbols).
The rendering in the scene is correct. Also, I tested an export to PDF file format, and it also works well.But I wanted to test an export to SVG file, with the class QSvgGenerator
Unfortunately, the texts are badly rendered : in the file, the items are set with an « arial » font. And of course, the hexa code of the text in the original font, makes an irrelevant drawing in « arial ».Finally, my question is : does anyone know how generating a SVG file, taking into account specific fonts ?
This is my extract of code below :QSvgGenerator generator; generator.setFileName(filename); generator.setSize(this->sceneRect().size().toSize()); QPainter painter; painter.begin(&generator); painter.setRenderHint(QPainter::Antialiasing); this->render(&painter); painter.end();For the QGraphicsTextItem, I have many.
Basic code for them is like this :QGraphicsTextItem* textItem = scene->addText("A"); textItem->setFont(QFont("MySpecificFont", 12));When exported to SVG, I see a "A" drawn because the SVG considers it is an Arial font. In reality, the "A" with "MySpecificFont" is a very different symbol.
Thanks a lot for your help.