Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSvgGenerator can embed specific fonts ?
Forum Updated to NodeBB v4.3 + New Features

QSvgGenerator can embed specific fonts ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 258 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mathieu33
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved